#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*/ close(int);
int /*<<< orphan*/ do_open_rd(char const *, int *);
int /*<<< orphan*/ do_snap_async(int, char const *, unsigned long long *);
int /*<<< orphan*/ do_snap_destroy(int, char const *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ usage_exit(char *);
int main(int argc, char *argv[]) {
  const char *base_dir;
  const char *snap_name;
  int fd;
  int i;
  unsigned long long transid;
  if (argc < 3)
    usage_exit(argv[0]);
  base_dir = argv[1];
  snap_name = argv[2];
  for (i = 0; i < 10; i++) {
    printf("%d\n", i);
    do_open_rd(base_dir, &fd);
    do_snap_async(fd, snap_name, &transid);
    sleep(2);
    do_snap_destroy(fd, snap_name);
    close(fd);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    119c <main+0x2c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1080 <usage_exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x28(%rbp)
cmpl   $0xa,-0x28(%rbp)
jge    121d <main+0xad>
mov    -0x28(%rbp),%esi
lea    0xe31(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
lea    -0x24(%rbp),%rsi
call   1070 <do_open_rd@plt>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%rsi
lea    -0x30(%rbp),%rdx
call   1030 <do_snap_async@plt>
mov    $0x2,%edi
call   1090 <sleep@plt>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1040 <do_snap_destroy@plt>
mov    -0x24(%rbp),%edi
call   1060 <close@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11bb <main+0x4b>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jg     118e <main+0x1e>
mov    (%rbx),%rdi
call   1080 <usage_exit@plt>
mov    0x8(%rbx),%r14
mov    0x10(%rbx),%rbx
xor    %ebp,%ebp
lea    0xe61(%rip),%r15
lea    0xc(%rsp),%r12
lea    0x10(%rsp),%r13
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %ebp,%esi
call   1050 <printf@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1070 <do_open_rd@plt>
mov    0xc(%rsp),%edi
mov    %rbx,%rsi
mov    %r13,%rdx
call   1030 <do_snap_async@plt>
mov    $0x2,%edi
call   1090 <sleep@plt>
mov    0xc(%rsp),%edi
mov    %rbx,%rsi
call   1040 <do_snap_destroy@plt>
mov    0xc(%rsp),%edi
call   1060 <close@plt>
add    $0x1,%ebp
cmp    $0xa,%ebp
jne    11b0 <main+0x40>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 3
br i1 %12, label %13, label %18
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 @usage_exit(i8* %16)
br label %18
18: ; preds = %13, %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
store i8* %21, i8** %6
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 2
%24 = load i8*, i8** %23
store i8* %24, i8** %7
store i32 0, i32* %9
br label %25
25: ; preds = %42, %18
%26 = load i32, i32* %9
%27 = icmp slt i32 %26, 10
br i1 %27, label %28, label %45
28: ; preds = %25
%29 = load i32, i32* %9
%30 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %29)
%31 = load i8*, i8** %6
%32 = call i32 @do_open_rd(i8* %31, i32* %8)
%33 = load i32, i32* %8
%34 = load i8*, i8** %7
%35 = call i32 @do_snap_async(i32 %33, i8* %34, i64* %10)
%36 = call i32 @sleep(i32 2)
%37 = load i32, i32* %8
%38 = load i8*, i8** %7
%39 = call i32 @do_snap_destroy(i32 %37, i8* %38)
%40 = load i32, i32* %8
%41 = call i32 @close(i32 %40)
br label %42
42: ; preds = %28
%43 = load i32, i32* %9
%44 = add nsw i32 %43, 1
store i32 %44, i32* %9
br label %25
45: ; preds = %25
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i64
%5 = bitcast i32* %3 to i8*
%6 = bitcast i64* %4 to i8*
%7 = icmp slt i32 %0, 3
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load i8*, i8** %1
%10 = tail call i32 @usage_exit(i8* %9)
br label %11
11: ; preds = %8, %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = getelementptr inbounds i8*, i8** %1, i64 2
%15 = load i8*, i8** %14
br label %16
16: ; preds = %11, %16
%17 = phi i32 [ 0, %11 ], [ %27, %16 ]
%18 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = call i32 @do_open_rd(i8* %13, i32* %3)
%20 = load i32, i32* %3
%21 = call i32 @do_snap_async(i32 %20, i8* %15, i64* %4)
%22 = call i32 @sleep(i32 2)
%23 = load i32, i32* %3
%24 = call i32 @do_snap_destroy(i32 %23, i8* %15)
%25 = load i32, i32* %3
%26 = call i32 @close(i32 %25)
%27 = add nuw nsw i32 %17, 1
%28 = icmp eq i32 %27, 10
br i1 %28, label %29, label %16
29: ; preds = %16
ret i32 0
}