#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 = (366);
    if (outer_counter < (6))
      this_cycle_length++;
    if (++inner_counter >= this_cycle_length) {
      inner_counter = 0;
      if (++outer_counter >= (59)) {
        outer_counter = 0;
      }
      if (tick_counter == 0) {
        doTick();
        tick_counter++;
      }
      continue;
    }
    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   $0x16e,-0x10(%rbp)
cmpl   $0x6,-0x8(%rbp)
jae    1170 <loop+0x50>
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     11c1 <loop+0xa1>
movl   $0x0,-0x4(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
cmp    $0x3b,%eax
jb     11a2 <loop+0x82>
movl   $0x0,-0x8(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    11bc <loop+0x9c>
mov    $0x0,%al
call   1030 <doTick@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    113d <loop+0x1d>
cmpl   $0x0,-0xc(%rbp)
jne    11d7 <loop+0xb7>
mov    $0x0,%al
call   1030 <doTick@plt>
jmp    11de <loop+0xbe>
mov    $0x0,%al
call   1040 <doSleep@plt>
jmp    113d <loop+0x1d>

x86 assembly (clang, -O2):
<loop>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %r15d,%r15d
xor    %r14d,%r14d
xor    %ebp,%ebp
jmp    1150 <loop+0x30>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%r14d
cmp    $0x3b,%r14d
cmovae %r15d,%r14d
test   %ebp,%ebp
je     11a0 <loop+0x80>
xor    %r12d,%r12d
cmp    $0x6,%r14d
setb   %r12b
or     $0x16e,%r12d
mov    $0x1,%ebx
jmp    117a <loop+0x5a>
nopl   0x0(%rax)
xor    %eax,%eax
call   1040 <doSleep@plt>
add    $0x1,%ebx
add    $0x1,%ebp
cmp    $0xa,%ebp
cmovae %r15d,%ebp
cmp    %r12d,%ebx
jae    1140 <loop+0x20>
test   %ebp,%ebp
jne    1170 <loop+0x50>
xor    %ebp,%ebp
xor    %eax,%eax
call   1030 <doTick@plt>
add    $0x1,%ebx
jmp    117a <loop+0x5a>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <doTick@plt>
mov    $0x1,%ebp
jmp    1150 <loop+0x30>

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, %33, %41
%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 366, i32* %4
%11 = load i32, i32* %2
%12 = icmp ult i32 %11, 6
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 %34
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, 59
br i1 %24, label %25, label %26
25: ; preds = %21
store i32 0, i32* %2
br label %26
26: ; preds = %25, %21
%27 = load i32, i32* %3
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %33
29: ; preds = %26
%30 = call i32 (...) @doTick()
%31 = load i32, i32* %3
%32 = add i32 %31, 1
store i32 %32, i32* %3
br label %33
33: ; preds = %29, %26
br label %5
34: ; preds = %16
%35 = load i32, i32* %3
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %34
%38 = call i32 (...) @doTick()
br label %41
39: ; preds = %34
%40 = call i32 (...) @doSleep()
br label %41
41: ; preds = %39, %37
br label %5
}

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