#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 char cycle_direction = 0;
  unsigned long cycle_position = 0;
  while (1) {
    for (unsigned char i = 0; i < (10) + ((1) * (cycle_direction ? -1 : 1));
         i++) {
      if (i == 0)
        doTick();
      else
        doSleep();
    }
    if (cycle_position++ >= (60L * 60 * 12)) {
      cycle_position = 0;
      cycle_direction = !cycle_direction;
    }
  }
}


x86 assembly (clang, -O0):
<loop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movb   $0x0,-0x1(%rbp)
movq   $0x0,-0x10(%rbp)
movb   $0x0,-0x11(%rbp)
movzbl -0x11(%rbp),%eax
movzbl -0x1(%rbp),%esi
mov    $0x1,%ecx
mov    $0xffffffff,%edx
cmp    $0x0,%esi
cmovne %edx,%ecx
shl    $0x0,%ecx
add    $0xa,%ecx
cmp    %ecx,%eax
jge    1190 <loop+0x70>
movzbl -0x11(%rbp),%eax
cmp    $0x0,%eax
jne    1177 <loop+0x57>
mov    $0x0,%al
call   1030 <doTick@plt>
jmp    117e <loop+0x5e>
mov    $0x0,%al
call   1040 <doSleep@plt>
jmp    1183 <loop+0x63>
mov    -0x11(%rbp),%al
add    $0x1,%al
mov    %al,-0x11(%rbp)
jmp    1138 <loop+0x18>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
cmp    $0xa8c0,%rax
jb     11c4 <loop+0xa4>
movq   $0x0,-0x10(%rbp)
cmpb   $0x0,-0x1(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %al,-0x1(%rbp)
jmp    1134 <loop+0x14>

x86 assembly (clang, -O2):
<loop>:
push   %rbp
push   %r14
push   %rbx
xor    %r14d,%r14d
xor    %ebx,%ebx
nopl   0x0(%rax)
xor    %eax,%eax
test   %r14b,%r14b
sete   %al
lea    (%rax,%rax,1),%ebp
add    $0x8,%ebp
xor    %eax,%eax
call   1030 <doTick@plt>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1040 <doSleep@plt>
add    $0xffffffff,%ebp
jne    1150 <loop+0x30>
xor    %eax,%eax
test   %r14b,%r14b
sete   %al
cmp    $0xa8c0,%rbx
movzbl %r14b,%ecx
cmovb  %ecx,%eax
lea    0x1(%rbx),%rcx
mov    $0x0,%ebx
cmovb  %rcx,%rbx
mov    %eax,%r14d
jmp    1130 <loop+0x10>

LLVM IR (-O0):
define void @loop() {
%1 = alloca i8
%2 = alloca i64
%3 = alloca i8
store i8 0, i8* %1
store i64 0, i64* %2
br label %4
4: ; preds = %0, %38
store i8 0, i8* %3
br label %5
5: ; preds = %25, %4
%6 = load i8, i8* %3
%7 = zext i8 %6 to i32
%8 = load i8, i8* %1
%9 = zext i8 %8 to i32
%10 = icmp ne i32 %9, 0
%11 = zext i1 %10 to i64
%12 = select i1 %10, i32 -1, i32 1
%13 = mul nsw i32 1, %12
%14 = add nsw i32 10, %13
%15 = icmp slt i32 %7, %14
br i1 %15, label %16, label %28
16: ; preds = %5
%17 = load i8, i8* %3
%18 = zext i8 %17 to i32
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = call i32 (...) @doTick()
br label %24
22: ; preds = %16
%23 = call i32 (...) @doSleep()
br label %24
24: ; preds = %22, %20
br label %25
25: ; preds = %24
%26 = load i8, i8* %3
%27 = add i8 %26, 1
store i8 %27, i8* %3
br label %5
28: ; preds = %5
%29 = load i64, i64* %2
%30 = add i64 %29, 1
store i64 %30, i64* %2
%31 = icmp uge i64 %29, 43200
br i1 %31, label %32, label %38
32: ; preds = %28
store i64 0, i64* %2
%33 = load i8, i8* %1
%34 = icmp ne i8 %33, 0
%35 = xor i1 %34, true
%36 = zext i1 %35 to i32
%37 = trunc i32 %36 to i8
store i8 %37, i8* %1
br label %38
38: ; preds = %32, %28
br label %4
}

LLVM IR (-O2):
define void @loop() {
br label %1
1: ; preds = %0, %7
%2 = phi i8 [ 0, %0 ], [ %11, %7 ]
%3 = phi i64 [ 0, %0 ], [ %12, %7 ]
%4 = icmp eq i8 %2, 0
%5 = select i1 %4, i32 11, i32 9
%6 = tail call i32 (...) @doTick()
br label %13
7: ; preds = %13
%8 = add i64 %3, 1
%9 = icmp ugt i64 %3, 43199
%10 = zext i1 %4 to i8
%11 = select i1 %9, i8 %10, i8 %2
%12 = select i1 %9, i64 0, i64 %8
br label %1
13: ; preds = %1, %13
%14 = phi i32 [ 1, %1 ], [ %16, %13 ]
%15 = tail call i32 (...) @doSleep()
%16 = add nuw nsw i32 %14, 1
%17 = icmp eq i32 %16, %5
br i1 %17, label %7, label %13
}