#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 atoi(char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ tickSetup(int);
int /*<<< orphan*/ tickWait();
int main(int argc, char **argv) {
  int f = atoi(argv[1]);
  int i;
  tickSetup(f);
  for (i = 0; i < 10 * f; i++) {
    printf("tick: %d\n", i);
    tickWait();
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1050 <tickSetup@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
imul   $0xa,-0x14(%rbp),%ecx
cmp    %ecx,%eax
jge    11a8 <main+0x68>
mov    -0x18(%rbp),%esi
lea    0xe72(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <tickWait@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1175 <main+0x35>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    0x8(%rsi),%rdi
call   1060 <atoi@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1050 <tickSetup@plt>
test   %ebx,%ebx
jle    1198 <main+0x58>
add    %ebx,%ebx
lea    (%rbx,%rbx,4),%eax
cmp    $0x2,%eax
mov    $0x1,%ebx
cmovge %eax,%ebx
lea    0xe8f(%rip),%r14
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <tickWait@plt>
add    $0x1,%ebp
cmp    %ebp,%ebx
jne    1180 <main+0x40>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"tick: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i8**, i8*** %5
%9 = getelementptr inbounds i8*, i8** %8, i64 1
%10 = load i8*, i8** %9
%11 = call i32 @atoi(i8* %10)
store i32 %11, i32* %6
%12 = load i32, i32* %6
%13 = call i32 @tickSetup(i32 %12)
store i32 0, i32* %7
br label %14
14: ; preds = %23, %2
%15 = load i32, i32* %7
%16 = load i32, i32* %6
%17 = mul nsw i32 10, %16
%18 = icmp slt i32 %15, %17
br i1 %18, label %19, label %26
19: ; preds = %14
%20 = load i32, i32* %7
%21 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %20)
%22 = call i32 (...) @tickWait()
br label %23
23: ; preds = %19
%24 = load i32, i32* %7
%25 = add nsw i32 %24, 1
store i32 %25, i32* %7
br label %14
26: ; preds = %14
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"tick: %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i32 @atoi(i8* %4)
%6 = tail call i32 @tickSetup(i32 %5)
%7 = icmp sgt i32 %5, 0
br i1 %7, label %8, label %17
8: ; preds = %2
%9 = mul i32 %5, 10
%10 = call i32 @llvm.smax.i32(i32 %9, i32 1)
br label %11
11: ; preds = %8, %11
%12 = phi i32 [ %15, %11 ], [ 0, %8 ]
%13 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = tail call i32 (...) @tickWait()
%15 = add nuw nsw i32 %12, 1
%16 = icmp eq i32 %15, %10
br i1 %16, label %17, label %11
17: ; preds = %11, %2
ret i32 0
}