#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*/ ms_sleep(int);
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ setCurrTab(int);
int main() {
  int i;
  int j;
  j = 0;
  i = 0;
  while (1) {
    if (i < 2)
      i++;
    else
      i = 0;
    setCurrTab(i);
    ms_sleep(1000);
    j++;
    if (j > 10)
      return 10;
    printf("i=%d j=%d\n", i, j);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1165 <main+0x35>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    116c <main+0x3c>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1050 <setCurrTab@plt>
mov    $0x3e8,%edi
call   1040 <ms_sleep@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jle    119c <main+0x6c>
mov    $0xa,%eax
add    $0x10,%rsp
pop    %rbp
ret
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe57(%rip),%rdi
call   1030 <printf@plt>
jmp    114d <main+0x1d>

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x1,%edi
call   1050 <setCurrTab@plt>
mov    $0x3e8,%edi
call   1040 <ms_sleep@plt>
lea    0xeb4(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
call   1030 <printf@plt>
mov    $0x2,%edi
call   1050 <setCurrTab@plt>
mov    $0x3e8,%edi
call   1040 <ms_sleep@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x2,%edx
call   1030 <printf@plt>
xor    %edi,%edi
call   1050 <setCurrTab@plt>
mov    $0x3e8,%edi
call   1040 <ms_sleep@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x3,%edx
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <setCurrTab@plt>
mov    $0x3e8,%edi
call   1040 <ms_sleep@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x4,%edx
call   1030 <printf@plt>
mov    $0x2,%edi
call   1050 <setCurrTab@plt>
mov    $0x3e8,%edi
call   1040 <ms_sleep@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x5,%edx
call   1030 <printf@plt>
xor    %edi,%edi
call   1050 <setCurrTab@plt>
mov    $0x3e8,%edi
call   1040 <ms_sleep@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x6,%edx
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <setCurrTab@plt>
mov    $0x3e8,%edi
call   1040 <ms_sleep@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x7,%edx
call   1030 <printf@plt>
mov    $0x2,%edi
call   1050 <setCurrTab@plt>
mov    $0x3e8,%edi
call   1040 <ms_sleep@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x8,%edx
call   1030 <printf@plt>
xor    %edi,%edi
call   1050 <setCurrTab@plt>
mov    $0x3e8,%edi
call   1040 <ms_sleep@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x9,%edx
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <setCurrTab@plt>
mov    $0x3e8,%edi
call   1040 <ms_sleep@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0xa,%edx
call   1030 <printf@plt>
mov    $0x2,%edi
call   1050 <setCurrTab@plt>
mov    $0x3e8,%edi
call   1040 <ms_sleep@plt>
mov    $0xa,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [11 x i8] c"i=%d j=%d\0A\00"
define i32 @main() {
%1 = tail call i32 @setCurrTab(i32 1)
%2 = tail call i32 @ms_sleep(i32 1000)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 1, i32 1)
%4 = tail call i32 @setCurrTab(i32 2)
%5 = tail call i32 @ms_sleep(i32 1000)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 2, i32 2)
%7 = tail call i32 @setCurrTab(i32 0)
%8 = tail call i32 @ms_sleep(i32 1000)
%9 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 0, i32 3)
%10 = tail call i32 @setCurrTab(i32 1)
%11 = tail call i32 @ms_sleep(i32 1000)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 1, i32 4)
%13 = tail call i32 @setCurrTab(i32 2)
%14 = tail call i32 @ms_sleep(i32 1000)
%15 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 2, i32 5)
%16 = tail call i32 @setCurrTab(i32 0)
%17 = tail call i32 @ms_sleep(i32 1000)
%18 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 0, i32 6)
%19 = tail call i32 @setCurrTab(i32 1)
%20 = tail call i32 @ms_sleep(i32 1000)
%21 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 1, i32 7)
%22 = tail call i32 @setCurrTab(i32 2)
%23 = tail call i32 @ms_sleep(i32 1000)
%24 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 2, i32 8)
%25 = tail call i32 @setCurrTab(i32 0)
%26 = tail call i32 @ms_sleep(i32 1000)
%27 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 0, i32 9)
%28 = tail call i32 @setCurrTab(i32 1)
%29 = tail call i32 @ms_sleep(i32 1000)
%30 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 1, i32 10)
%31 = tail call i32 @setCurrTab(i32 2)
%32 = tail call i32 @ms_sleep(i32 1000)
ret i32 10
}