#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 get_tai();
int ksft_exit_fail();
int ksft_exit_pass();
int /*<<< orphan*/ printf(char *, ...);
int set_tai(int);
int main(int argc, char **argv) {
  int i, ret;
  ret = get_tai();
  printf("tai offset started at %i\n", ret);
  printf("Checking tai offsets can be properly set: ");
  for (i = 1; i <= 60; i++) {
    ret = set_tai(i);
    ret = get_tai();
    if (ret != i) {
      printf("[FAILED] expected: %i got %i\n", i, ret);
      return ksft_exit_fail();
    }
  }
  printf("[OK]\n");
  return ksft_exit_pass();
}


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    $0x0,%al
call   1070 <get_tai@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x14(%rbp)
cmpl   $0x3c,-0x14(%rbp)
jg     11f7 <main+0xa7>
mov    -0x14(%rbp),%edi
call   1060 <set_tai@plt>
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   1070 <get_tai@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
je     11e4 <main+0x94>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1040 <ksft_exit_fail@plt>
mov    %eax,-0x4(%rbp)
jmp    120f <main+0xbf>
jmp    11e9 <main+0x99>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1196 <main+0x46>
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1030 <ksft_exit_pass@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1080 <get_tai@plt>
lea    0xe91(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe9b(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x1,%ebx
nopl   0x0(%rax,%rax,1)
mov    %ebx,%edi
call   1070 <set_tai@plt>
xor    %eax,%eax
call   1080 <get_tai@plt>
cmp    %eax,%ebx
jne    11be <main+0x5e>
add    $0x1,%ebx
cmp    $0x3d,%ebx
jne    1190 <main+0x30>
lea    0xeb2(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
jmp    1040 <ksft_exit_pass@plt>
lea    0xe80(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
pop    %rbx
jmp    1050 <ksft_exit_fail@plt>

LLVM IR (-O0):
@.str = [26 x i8] c"tai offset started at %i\0A\00"
@.str.1 = [43 x i8] c"Checking tai offsets can be properly set: \00"
@.str.2 = [30 x i8] c"[FAILED] expected: %i got %i\0A\00"
@.str.3 = [6 x i8] c"[OK]\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 = call i32 (...) @get_tai()
store i32 %8, i32* %7
%9 = load i32, i32* %7
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %6
br label %12
12: ; preds = %28, %2
%13 = load i32, i32* %6
%14 = icmp sle i32 %13, 60
br i1 %14, label %15, label %31
15: ; preds = %12
%16 = load i32, i32* %6
%17 = call i32 @set_tai(i32 %16)
store i32 %17, i32* %7
%18 = call i32 (...) @get_tai()
store i32 %18, i32* %7
%19 = load i32, i32* %7
%20 = load i32, i32* %6
%21 = icmp ne i32 %19, %20
br i1 %21, label %22, label %27
22: ; preds = %15
%23 = load i32, i32* %6
%24 = load i32, i32* %7
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i32 %23, i32 %24)
%26 = call i32 (...) @ksft_exit_fail()
store i32 %26, i32* %3
br label %34
27: ; preds = %15
br label %28
28: ; preds = %27
%29 = load i32, i32* %6
%30 = add nsw i32 %29, 1
store i32 %30, i32* %6
br label %12
31: ; preds = %12
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%33 = call i32 (...) @ksft_exit_pass()
store i32 %33, i32* %3
br label %34
34: ; preds = %31, %22
%35 = load i32, i32* %3
ret i32 %35
}

LLVM IR (-O2):
@.str = [26 x i8] c"tai offset started at %i\0A\00"
@.str.1 = [43 x i8] c"Checking tai offsets can be properly set: \00"
@.str.2 = [30 x i8] c"[FAILED] expected: %i got %i\0A\00"
@str = [5 x i8] c"[OK]\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @get_tai()
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
br label %6
6: ; preds = %2, %14
%7 = phi i32 [ 1, %2 ], [ %15, %14 ]
%8 = tail call i32 @set_tai(i32 %7)
%9 = tail call i32 (...) @get_tai()
%10 = icmp eq i32 %9, %7
br i1 %10, label %14, label %11
11: ; preds = %6
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i32 %7, i32 %9)
%13 = tail call i32 (...) @ksft_exit_fail()
br label %20
14: ; preds = %6
%15 = add nuw nsw i32 %7, 1
%16 = icmp eq i32 %15, 61
br i1 %16, label %17, label %6
17: ; preds = %14
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
%19 = tail call i32 (...) @ksft_exit_pass()
br label %20
20: ; preds = %17, %11
%21 = phi i32 [ %13, %11 ], [ %19, %17 ]
ret i32 %21
}