#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 */
scalar_t__ atoi(char *);
int /*<<< orphan*/ final_bar();
int /*<<< orphan*/ init_bar(int *, int *);
int /*<<< orphan*/ print_bar(int *, int *, int);
int /*<<< orphan*/ usleep(int);
int main(int argc, char *argv[]) {
  int Niter, i, j, n;
  Niter = (int)atoi(argv[1]);
  init_bar(&i, &j);
  for (n = 0; n < Niter; n++) {
    usleep(1000);
    print_bar(&i, &j, Niter);
  }
  final_bar();
  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)
lea    -0x18(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
call   1040 <init_bar@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11be <main+0x6e>
mov    $0x3e8,%edi
call   1070 <usleep@plt>
mov    -0x14(%rbp),%edx
lea    -0x18(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
call   1050 <print_bar@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    118a <main+0x3a>
mov    $0x0,%al
call   1030 <final_bar@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    0x8(%rsi),%rdi
call   1060 <atoi@plt>
mov    %rax,%rbx
lea    0x4(%rsp),%rdi
mov    %rsp,%rsi
call   1040 <init_bar@plt>
test   %ebx,%ebx
jle    119c <main+0x4c>
lea    0x4(%rsp),%r14
mov    %rsp,%r15
mov    %ebx,%ebp
xchg   %ax,%ax
mov    $0x3e8,%edi
call   1070 <usleep@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
call   1050 <print_bar@plt>
add    $0xffffffff,%ebp
jne    1180 <main+0x30>
xor    %eax,%eax
call   1030 <final_bar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i64 @atoi(i8* %12)
%14 = trunc i64 %13 to i32
store i32 %14, i32* %6
%15 = call i32 @init_bar(i32* %7, i32* %8)
store i32 0, i32* %9
br label %16
16: ; preds = %24, %2
%17 = load i32, i32* %9
%18 = load i32, i32* %6
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %27
20: ; preds = %16
%21 = call i32 @usleep(i32 1000)
%22 = load i32, i32* %6
%23 = call i32 @print_bar(i32* %7, i32* %8, i32 %22)
br label %24
24: ; preds = %20
%25 = load i32, i32* %9
%26 = add nsw i32 %25, 1
store i32 %26, i32* %9
br label %16
27: ; preds = %16
%28 = call i32 (...) @final_bar()
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i64 @atoi(i8* %8)
%10 = trunc i64 %9 to i32
%11 = call i32 @init_bar(i32* %3, i32* %4)
%12 = icmp sgt i32 %10, 0
br i1 %12, label %13, label %19
13: ; preds = %2, %13
%14 = phi i32 [ %17, %13 ], [ 0, %2 ]
%15 = call i32 @usleep(i32 1000)
%16 = call i32 @print_bar(i32* %3, i32* %4, i32 %10)
%17 = add nuw nsw i32 %14, 1
%18 = icmp eq i32 %17, %10
br i1 %18, label %19, label %13
19: ; preds = %13, %2
%20 = call i32 (...) @final_bar()
ret i32 0
}