#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 nondet_int();
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();
    }
    {
      int i = 0, loop4 = nondet_int();
      while (i < loop4) {
      while_3_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_3_break;
        } else {
        }
        i++;
      }
    while_3_break:;
    }
    return;
  }
}


x86 assembly (clang, -O0):
<start_simulation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1050 <update_channels@plt>
mov    $0x0,%al
call   1080 <init_threads@plt>
mov    $0x0,%al
call   1060 <fire_delta_events@plt>
mov    $0x0,%al
call   1040 <activate_threads@plt>
mov    $0x0,%al
call   1090 <reset_delta_events@plt>
movl   $0x0,-0x10(%rbp)
mov    $0x0,%al
call   1030 <nondet_int@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    12a2 <start_simulation+0xf2>
jmp    1204 <start_simulation+0x54>
movl   $0x1,-0x4(%rbp)
mov    $0x0,%al
call   10d0 <eval@plt>
movl   $0x2,-0x4(%rbp)
mov    $0x0,%al
call   1050 <update_channels@plt>
movl   $0x3,-0x4(%rbp)
mov    $0x0,%al
call   1060 <fire_delta_events@plt>
mov    $0x0,%al
call   1040 <activate_threads@plt>
mov    $0x0,%al
call   1090 <reset_delta_events@plt>
mov    $0x0,%al
call   10a0 <exists_runnable_thread@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1271 <start_simulation+0xc1>
movl   $0x4,-0x4(%rbp)
mov    $0x0,%al
call   10c0 <fire_time_events@plt>
mov    $0x0,%al
call   1040 <activate_threads@plt>
mov    $0x0,%al
call   10b0 <reset_time_events@plt>
jmp    1276 <start_simulation+0xc6>
jmp    1276 <start_simulation+0xc6>
mov    $0x0,%al
call   1070 <stop_simulation@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     128f <start_simulation+0xdf>
jmp    12a7 <start_simulation+0xf7>
jmp    1294 <start_simulation+0xe4>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11f3 <start_simulation+0x43>
jmp    12a7 <start_simulation+0xf7>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<start_simulation>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <update_channels@plt>
xor    %eax,%eax
call   1080 <init_threads@plt>
xor    %eax,%eax
call   1060 <fire_delta_events@plt>
xor    %eax,%eax
call   1040 <activate_threads@plt>
xor    %eax,%eax
call   1090 <reset_delta_events@plt>
xor    %eax,%eax
call   1030 <nondet_int@plt>
test   %eax,%eax
jle    1247 <start_simulation+0x97>
mov    %eax,%ebp
mov    $0x1,%ebx
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   10d0 <eval@plt>
xor    %eax,%eax
call   1050 <update_channels@plt>
xor    %eax,%eax
call   1060 <fire_delta_events@plt>
xor    %eax,%eax
call   1040 <activate_threads@plt>
xor    %eax,%eax
call   1090 <reset_delta_events@plt>
xor    %eax,%eax
call   10a0 <exists_runnable_thread@plt>
test   %eax,%eax
jne    1233 <start_simulation+0x83>
xor    %eax,%eax
call   10c0 <fire_time_events@plt>
xor    %eax,%eax
call   1040 <activate_threads@plt>
xor    %eax,%eax
call   10b0 <reset_time_events@plt>
xor    %eax,%eax
call   1070 <stop_simulation@plt>
test   %eax,%eax
jne    1247 <start_simulation+0x97>
lea    0x1(%rbx),%eax
cmp    %ebp,%ebx
mov    %eax,%ebx
jl     11f0 <start_simulation+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @start_simulation() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (...) @update_channels()
%7 = call i32 (...) @init_threads()
%8 = call i32 (...) @fire_delta_events()
%9 = call i32 (...) @activate_threads()
%10 = call i32 (...) @reset_delta_events()
store i32 0, i32* %4
%11 = call i32 (...) @nondet_int()
store i32 %11, i32* %5
br label %12
12: ; preds = %37, %0
%13 = load i32, i32* %4
%14 = load i32, i32* %5
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %40
16: ; preds = %12
br label %17
17: ; preds = %16
store i32 1, i32* %1
%18 = call i32 (...) @eval()
store i32 2, i32* %1
%19 = call i32 (...) @update_channels()
store i32 3, i32* %1
%20 = call i32 (...) @fire_delta_events()
%21 = call i32 (...) @activate_threads()
%22 = call i32 (...) @reset_delta_events()
%23 = call i32 (...) @exists_runnable_thread()
store i32 %23, i32* %2
%24 = load i32, i32* %2
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %17
store i32 4, i32* %1
%27 = call i32 (...) @fire_time_events()
%28 = call i32 (...) @activate_threads()
%29 = call i32 (...) @reset_time_events()
br label %31
30: ; preds = %17
br label %31
31: ; preds = %30, %26
%32 = call i32 (...) @stop_simulation()
store i32 %32, i32* %3
%33 = load i32, i32* %3
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %31
br label %41
36: ; preds = %31
br label %37
37: ; preds = %36
%38 = load i32, i32* %4
%39 = add nsw i32 %38, 1
store i32 %39, i32* %4
br label %12
40: ; preds = %12
br label %41
41: ; preds = %40, %35
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()
%6 = tail call i32 (...) @nondet_int()
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %27
8: ; preds = %0, %21
%9 = phi i32 [ %24, %21 ], [ 0, %0 ]
%10 = tail call i32 (...) @eval()
%11 = tail call i32 (...) @update_channels()
%12 = tail call i32 (...) @fire_delta_events()
%13 = tail call i32 (...) @activate_threads()
%14 = tail call i32 (...) @reset_delta_events()
%15 = tail call i32 (...) @exists_runnable_thread()
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %8
%18 = tail call i32 (...) @fire_time_events()
%19 = tail call i32 (...) @activate_threads()
%20 = tail call i32 (...) @reset_time_events()
br label %21
21: ; preds = %8, %17
%22 = tail call i32 (...) @stop_simulation()
%23 = icmp eq i32 %22, 0
%24 = add nuw nsw i32 %9, 1
%25 = icmp slt i32 %24, %6
%26 = select i1 %23, i1 %25, i1 false
br i1 %26, label %8, label %27
27: ; preds = %21, %0
ret void
}