#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*/ doSleep();
int /*<<< orphan*/ doTick();
void loop() {
  unsigned int inner_counter = 0;
  unsigned int outer_counter = 0;
  unsigned int tick_counter = 0;
  while (1) {
    if (++tick_counter >= (10)) {
      tick_counter = 0;
    }
    unsigned int this_cycle_length = (28);
    if (outer_counter < (404))
      this_cycle_length++;
    if (++inner_counter >= this_cycle_length) {
      inner_counter = 0;
      if (++outer_counter >= (757)) {
        outer_counter = 0;
      }
      doSleep();
    }
    if (tick_counter == 0)
      doTick();
    else
      doSleep();
  }
}


x86 assembly (clang, -O0):
<loop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmp    $0xa,%eax
jb     1156 <loop+0x36>
movl   $0x0,-0xc(%rbp)
movl   $0x1c,-0x10(%rbp)
cmpl   $0x194,-0x8(%rbp)
jae    1173 <loop+0x53>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
cmp    -0x10(%rbp),%eax
jb     11ae <loop+0x8e>
movl   $0x0,-0x4(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
cmp    $0x2f5,%eax
jb     11a7 <loop+0x87>
movl   $0x0,-0x8(%rbp)
mov    $0x0,%al
call   1040 <doSleep@plt>
cmpl   $0x0,-0xc(%rbp)
jne    11c4 <loop+0xa4>
mov    $0x0,%al
call   1030 <doTick@plt>
jmp    11cb <loop+0xab>
mov    $0x0,%al
call   1040 <doSleep@plt>
jmp    113d <loop+0x1d>

x86 assembly (clang, -O2):
<loop>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %r14d,%r14d
xor    %ebp,%ebp
xor    %r15d,%r15d
xor    %ebx,%ebx
jmp    1145 <loop+0x25>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
call   1040 <doSleep@plt>
add    $0x1,%ebx
cmp    $0xa,%ebx
cmovae %r14d,%ebx
xor    %eax,%eax
cmp    $0x194,%r15d
setb   %al
or     $0x1c,%eax
add    $0x1,%ebp
cmp    %eax,%ebp
jb     117d <loop+0x5d>
add    $0x1,%r15d
xor    %ebp,%ebp
cmp    $0x2f5,%r15d
cmovae %ebp,%r15d
xor    %eax,%eax
call   1040 <doSleep@plt>
xor    %eax,%eax
test   %ebx,%ebx
jne    1140 <loop+0x20>
call   1030 <doTick@plt>
jmp    1145 <loop+0x25>

LLVM IR (-O0):
define void @loop() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
br label %5
5: ; preds = %0, %35
%6 = load i32, i32* %3
%7 = add i32 %6, 1
store i32 %7, i32* %3
%8 = icmp uge i32 %7, 10
br i1 %8, label %9, label %10
9: ; preds = %5
store i32 0, i32* %3
br label %10
10: ; preds = %9, %5
store i32 28, i32* %4
%11 = load i32, i32* %2
%12 = icmp ult i32 %11, 404
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = load i32, i32* %4
%15 = add i32 %14, 1
store i32 %15, i32* %4
br label %16
16: ; preds = %13, %10
%17 = load i32, i32* %1
%18 = add i32 %17, 1
store i32 %18, i32* %1
%19 = load i32, i32* %4
%20 = icmp uge i32 %18, %19
br i1 %20, label %21, label %28
21: ; preds = %16
store i32 0, i32* %1
%22 = load i32, i32* %2
%23 = add i32 %22, 1
store i32 %23, i32* %2
%24 = icmp uge i32 %23, 757
br i1 %24, label %25, label %26
25: ; preds = %21
store i32 0, i32* %2
br label %26
26: ; preds = %25, %21
%27 = call i32 (...) @doSleep()
br label %28
28: ; preds = %26, %16
%29 = load i32, i32* %3
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %28
%32 = call i32 (...) @doTick()
br label %35
33: ; preds = %28
%34 = call i32 (...) @doSleep()
br label %35
35: ; preds = %33, %31
br label %5
}

LLVM IR (-O2):
define void @loop() {
br label %1
1: ; preds = %25, %0
%2 = phi i32 [ 0, %0 ], [ %18, %25 ]
%3 = phi i32 [ 0, %0 ], [ %19, %25 ]
%4 = phi i32 [ 0, %0 ], [ %7, %25 ]
%5 = add i32 %4, 1
%6 = icmp ugt i32 %5, 9
%7 = select i1 %6, i32 0, i32 %5
%8 = icmp ult i32 %3, 404
%9 = select i1 %8, i32 29, i32 28
%10 = add i32 %2, 1
%11 = icmp ult i32 %10, %9
br i1 %11, label %17, label %12
12: ; preds = %1
%13 = add i32 %3, 1
%14 = icmp ugt i32 %13, 756
%15 = select i1 %14, i32 0, i32 %13
%16 = tail call i32 (...) @doSleep()
br label %17
17: ; preds = %12, %1
%18 = phi i32 [ 0, %12 ], [ %10, %1 ]
%19 = phi i32 [ %15, %12 ], [ %3, %1 ]
%20 = icmp eq i32 %7, 0
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = tail call i32 (...) @doTick()
br label %25
23: ; preds = %17
%24 = tail call i32 (...) @doSleep()
br label %25
25: ; preds = %23, %21
br label %1
}