#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() {
  for (int i = 0; i < (30 * 5); i++) {
    doTick();
    doSleep();
  }
  while (1) {
    static unsigned int tick_counter = 0;
    unsigned int limit = 139;
    if (tick_counter++ >= limit) {
      tick_counter = 0;
      doTick();
    } else {
      doSleep();
    }
  }
}


x86 assembly (clang, -O0):
<loop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
cmpl   $0x96,-0x4(%rbp)
jge    1158 <loop+0x38>
mov    $0x0,%al
call   1030 <doTick@plt>
mov    $0x0,%al
call   1040 <doSleep@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    112f <loop+0xf>
jmp    115d <loop+0x3d>
movl   $0x8b,-0x8(%rbp)
mov    0x2eca(%rip),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,0x2ebf(%rip)
cmp    -0x8(%rbp),%eax
jb     1194 <loop+0x74>
movl   $0x0,0x2eac(%rip)
mov    $0x0,%al
call   1030 <doTick@plt>
jmp    119b <loop+0x7b>
mov    $0x0,%al
call   1040 <doSleep@plt>
jmp    115d <loop+0x3d>

x86 assembly (clang, -O2):
<loop>:
push   %rbx
mov    $0x96,%ebx
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <doTick@plt>
xor    %eax,%eax
call   1040 <doSleep@plt>
add    $0xffffffff,%ebx
jne    1130 <loop+0x10>
jmp    1157 <loop+0x37>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1040 <doSleep@plt>
mov    0x2ed7(%rip),%eax
lea    0x1(%rax),%ecx
mov    %ecx,0x2ece(%rip)
cmp    $0x8b,%eax
jb     1150 <loop+0x30>
movl   $0x0,0x2ebd(%rip)
xor    %eax,%eax
call   1030 <doTick@plt>
jmp    1157 <loop+0x37>

LLVM IR (-O0):
@loop.tick_counter = internal global i32 0
define void @loop() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
br label %3
3: ; preds = %9, %0
%4 = load i32, i32* %1
%5 = icmp slt i32 %4, 150
br i1 %5, label %6, label %12
6: ; preds = %3
%7 = call i32 (...) @doTick()
%8 = call i32 (...) @doSleep()
br label %9
9: ; preds = %6
%10 = load i32, i32* %1
%11 = add nsw i32 %10, 1
store i32 %11, i32* %1
br label %3
12: ; preds = %3
br label %13
13: ; preds = %12, %22
store i32 139, i32* %2
%14 = load i32, i32* @loop.tick_counter
%15 = add i32 %14, 1
store i32 %15, i32* @loop.tick_counter
%16 = load i32, i32* %2
%17 = icmp uge i32 %14, %16
br i1 %17, label %18, label %20
18: ; preds = %13
store i32 0, i32* @loop.tick_counter
%19 = call i32 (...) @doTick()
br label %22
20: ; preds = %13
%21 = call i32 (...) @doSleep()
br label %22
22: ; preds = %20, %18
br label %13
}

LLVM IR (-O2):
@loop.tick_counter = internal unnamed_addr global i32 0
define void @loop() {
br label %1
1: ; preds = %0, %1
%2 = phi i32 [ 0, %0 ], [ %5, %1 ]
%3 = tail call i32 (...) @doTick()
%4 = tail call i32 (...) @doSleep()
%5 = add nuw nsw i32 %2, 1
%6 = icmp eq i32 %5, 150
br i1 %6, label %7, label %1
7: ; preds = %1, %15
%8 = load i32, i32* @loop.tick_counter
%9 = add i32 %8, 1
store i32 %9, i32* @loop.tick_counter
%10 = icmp ugt i32 %8, 138
br i1 %10, label %11, label %13
11: ; preds = %7
store i32 0, i32* @loop.tick_counter
%12 = tail call i32 (...) @doTick()
br label %15
13: ; preds = %7
%14 = tail call i32 (...) @doSleep()
br label %15
15: ; preds = %13, %11
br label %7
}