#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ activate_threads();
int /*<<< orphan*/ eval();
int exists_runnable_thread();
int /*<<< orphan*/ fire_delta_events();
int /*<<< orphan*/ fire_time_events();
int /*<<< orphan*/ init_threads();
int /*<<< orphan*/ reset_delta_events();
int /*<<< orphan*/ reset_time_events();
int stop_simulation();
int /*<<< orphan*/ update_channels();
void start_simulation(void) {
  int kernel_st;
  int tmp;
  int tmp___0;
  {
    {
      kernel_st = 0;
      update_channels();
      init_threads();
      fire_delta_events();
      activate_threads();
      reset_delta_events();
    }
    {
      while (1) {
      while_16_continue:;
        {
          kernel_st = 1;
          eval();
        }
        {
          kernel_st = 2;
          update_channels();
        }
        {
          kernel_st = 3;
          fire_delta_events();
          activate_threads();
          reset_delta_events();
        }
        { tmp = exists_runnable_thread(); }
        if (tmp == 0) {
          {
            kernel_st = 4;
            fire_time_events();
            activate_threads();
            reset_time_events();
          }
        } else {
        }
        { tmp___0 = stop_simulation(); }
        if (tmp___0) {
          goto while_16_break;
        } else {
        }
      }
    while_16_break:;
    }
    return;
  }
}


x86 assembly (clang, -O0):
<start_simulation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <update_channels@plt>
mov    $0x0,%al
call   1070 <init_threads@plt>
mov    $0x0,%al
call   1050 <fire_delta_events@plt>
mov    $0x0,%al
call   1030 <activate_threads@plt>
mov    $0x0,%al
call   1080 <reset_delta_events@plt>
jmp    11d7 <start_simulation+0x37>
movl   $0x1,-0x4(%rbp)
mov    $0x0,%al
call   10c0 <eval@plt>
movl   $0x2,-0x4(%rbp)
mov    $0x0,%al
call   1040 <update_channels@plt>
movl   $0x3,-0x4(%rbp)
mov    $0x0,%al
call   1050 <fire_delta_events@plt>
mov    $0x0,%al
call   1030 <activate_threads@plt>
mov    $0x0,%al
call   1080 <reset_delta_events@plt>
mov    $0x0,%al
call   1090 <exists_runnable_thread@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1244 <start_simulation+0xa4>
movl   $0x4,-0x4(%rbp)
mov    $0x0,%al
call   10b0 <fire_time_events@plt>
mov    $0x0,%al
call   1030 <activate_threads@plt>
mov    $0x0,%al
call   10a0 <reset_time_events@plt>
jmp    1249 <start_simulation+0xa9>
jmp    1249 <start_simulation+0xa9>
mov    $0x0,%al
call   1060 <stop_simulation@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1262 <start_simulation+0xc2>
jmp    126c <start_simulation+0xcc>
jmp    1267 <start_simulation+0xc7>
jmp    11d2 <start_simulation+0x32>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<start_simulation>:
push   %rax
xor    %eax,%eax
call   1040 <update_channels@plt>
xor    %eax,%eax
call   1070 <init_threads@plt>
xor    %eax,%eax
call   1050 <fire_delta_events@plt>
xor    %eax,%eax
call   1030 <activate_threads@plt>
xor    %eax,%eax
call   1080 <reset_delta_events@plt>
jmp    11db <start_simulation+0x3b>
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <stop_simulation@plt>
test   %eax,%eax
jne    1220 <start_simulation+0x80>
xor    %eax,%eax
call   10c0 <eval@plt>
xor    %eax,%eax
call   1040 <update_channels@plt>
xor    %eax,%eax
call   1050 <fire_delta_events@plt>
xor    %eax,%eax
call   1030 <activate_threads@plt>
xor    %eax,%eax
call   1080 <reset_delta_events@plt>
xor    %eax,%eax
call   1090 <exists_runnable_thread@plt>
test   %eax,%eax
jne    11d0 <start_simulation+0x30>
xor    %eax,%eax
call   10b0 <fire_time_events@plt>
xor    %eax,%eax
call   1030 <activate_threads@plt>
xor    %eax,%eax
call   10a0 <reset_time_events@plt>
jmp    11d0 <start_simulation+0x30>
pop    %rax
ret

LLVM IR (-O0):
define void @start_simulation() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (...) @update_channels()
%5 = call i32 (...) @init_threads()
%6 = call i32 (...) @fire_delta_events()
%7 = call i32 (...) @activate_threads()
%8 = call i32 (...) @reset_delta_events()
br label %9
9: ; preds = %0, %30
br label %10
10: ; preds = %9
store i32 1, i32* %1
%11 = call i32 (...) @eval()
store i32 2, i32* %1
%12 = call i32 (...) @update_channels()
store i32 3, i32* %1
%13 = call i32 (...) @fire_delta_events()
%14 = call i32 (...) @activate_threads()
%15 = call i32 (...) @reset_delta_events()
%16 = call i32 (...) @exists_runnable_thread()
store i32 %16, i32* %2
%17 = load i32, i32* %2
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %10
store i32 4, i32* %1
%20 = call i32 (...) @fire_time_events()
%21 = call i32 (...) @activate_threads()
%22 = call i32 (...) @reset_time_events()
br label %24
23: ; preds = %10
br label %24
24: ; preds = %23, %19
%25 = call i32 (...) @stop_simulation()
store i32 %25, i32* %3
%26 = load i32, i32* %3
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %24
br label %31
29: ; preds = %24
br label %30
30: ; preds = %29
br label %9
31: ; preds = %28
ret void
}

LLVM IR (-O2):
define void @start_simulation() {
%1 = tail call i32 (...) @update_channels()
%2 = tail call i32 (...) @init_threads()
%3 = tail call i32 (...) @fire_delta_events()
%4 = tail call i32 (...) @activate_threads()
%5 = tail call i32 (...) @reset_delta_events()
br label %6
6: ; preds = %18, %0
%7 = tail call i32 (...) @eval()
%8 = tail call i32 (...) @update_channels()
%9 = tail call i32 (...) @fire_delta_events()
%10 = tail call i32 (...) @activate_threads()
%11 = tail call i32 (...) @reset_delta_events()
%12 = tail call i32 (...) @exists_runnable_thread()
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %6
%15 = tail call i32 (...) @fire_time_events()
%16 = tail call i32 (...) @activate_threads()
%17 = tail call i32 (...) @reset_time_events()
br label %18
18: ; preds = %6, %14
%19 = tail call i32 (...) @stop_simulation()
%20 = icmp eq i32 %19, 0
br i1 %20, label %6, label %21
21: ; preds = %18
ret void
}