#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*/ ListDirContents(char *);
int /*<<< orphan*/ MakeDir(char *);
int /*<<< orphan*/ RemoveDir(char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
void TestCase1(void) {
  int i;
  char dirName[(56)];
  printf(" ---- Test Case 1 ----\n");
  MakeDir("/tmp");
  MakeDir("/usr");
  MakeDir("/etc");
  MakeDir("/home");
  for (i = 0; i < 8; i++) {
    memset(dirName, 0, (56));
    sprintf(dirName, "/home/user%d", i);
    MakeDir(dirName);
  }
  for (i = 0; i < 24; i++) {
    memset(dirName, 0, (56));
    sprintf(dirName, "/etc/dev%d", i);
    MakeDir(dirName);
  }
  ListDirContents("/home");
  ListDirContents("/etc");
  for (i = 24; i > 0; i--) {
    memset(dirName, 0, (56));
    sprintf(dirName, "/etc/dev%d", i);
    RemoveDir(dirName);
  }
  ListDirContents("/etc");
}


x86 assembly (clang, -O0):
<TestCase1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
lea    0xe91(%rip),%rdi
call   1040 <printf@plt>
lea    0xe9d(%rip),%rdi
call   1070 <MakeDir@plt>
lea    0xe96(%rip),%rdi
call   1070 <MakeDir@plt>
lea    0xe8f(%rip),%rdi
call   1070 <MakeDir@plt>
lea    0xe88(%rip),%rdi
call   1070 <MakeDir@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0x8,-0x4(%rbp)
jge    11ef <TestCase1+0x8f>
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x38,%edx
call   1050 <memset@plt>
lea    -0x40(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xe5a(%rip),%rsi
call   1080 <sprintf@plt>
lea    -0x40(%rbp),%rdi
call   1070 <MakeDir@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11ab <TestCase1+0x4b>
movl   $0x0,-0x4(%rbp)
cmpl   $0x18,-0x4(%rbp)
jge    123a <TestCase1+0xda>
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x38,%edx
call   1050 <memset@plt>
lea    -0x40(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xe1c(%rip),%rsi
call   1080 <sprintf@plt>
lea    -0x40(%rbp),%rdi
call   1070 <MakeDir@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11f6 <TestCase1+0x96>
lea    0xde6(%rip),%rdi
call   1030 <ListDirContents@plt>
lea    0xdd5(%rip),%rdi
call   1030 <ListDirContents@plt>
movl   $0x18,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jle    129d <TestCase1+0x13d>
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x38,%edx
call   1050 <memset@plt>
lea    -0x40(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xdb9(%rip),%rsi
call   1080 <sprintf@plt>
lea    -0x40(%rbp),%rdi
call   1060 <RemoveDir@plt>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
jmp    1259 <TestCase1+0xf9>
lea    0xd7e(%rip),%rdi
call   1030 <ListDirContents@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TestCase1>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x38,%rsp
lea    0xebc(%rip),%rdi
call   1030 <puts@plt>
lea    0xe83(%rip),%rdi
call   1070 <MakeDir@plt>
lea    0xe7c(%rip),%rdi
call   1070 <MakeDir@plt>
lea    0xe75(%rip),%rdi
call   1070 <MakeDir@plt>
lea    0xe6e(%rip),%rdi
call   1070 <MakeDir@plt>
mov    %rsp,%r15
xor    %ebp,%ebp
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x38,%edx
call   1050 <memset@plt>
lea    0xe54(%rip),%r14
mov    %r15,%rdi
mov    %r14,%rsi
xor    %edx,%edx
call   1080 <sprintf@plt>
mov    %r15,%rdi
call   1070 <MakeDir@plt>
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x38,%edx
call   1050 <memset@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    $0x1,%edx
call   1080 <sprintf@plt>
mov    %r15,%rdi
call   1070 <MakeDir@plt>
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x38,%edx
call   1050 <memset@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    $0x2,%edx
call   1080 <sprintf@plt>
mov    %r15,%rdi
call   1070 <MakeDir@plt>
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x38,%edx
call   1050 <memset@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    $0x3,%edx
call   1080 <sprintf@plt>
mov    %r15,%rdi
call   1070 <MakeDir@plt>
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x38,%edx
call   1050 <memset@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    $0x4,%edx
call   1080 <sprintf@plt>
mov    %r15,%rdi
call   1070 <MakeDir@plt>
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x38,%edx
call   1050 <memset@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    $0x5,%edx
call   1080 <sprintf@plt>
mov    %r15,%rdi
call   1070 <MakeDir@plt>
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x38,%edx
call   1050 <memset@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    $0x6,%edx
call   1080 <sprintf@plt>
mov    %r15,%rdi
call   1070 <MakeDir@plt>
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x38,%edx
call   1050 <memset@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    $0x7,%edx
call   1080 <sprintf@plt>
mov    %r15,%rdi
call   1070 <MakeDir@plt>
lea    0xd34(%rip),%rbx
xchg   %ax,%ax
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x38,%edx
call   1050 <memset@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1080 <sprintf@plt>
mov    %r15,%rdi
call   1070 <MakeDir@plt>
add    $0x1,%ebp
cmp    $0x18,%ebp
jne    12f0 <TestCase1+0x190>
lea    0xcec(%rip),%rdi
call   1040 <ListDirContents@plt>
lea    0xcdb(%rip),%rdi
call   1040 <ListDirContents@plt>
mov    $0x19,%ebx
mov    %rsp,%rbp
lea    0xcdf(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0xffffffff,%ebx
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x38,%edx
call   1050 <memset@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
mov    %ebx,%edx
call   1080 <sprintf@plt>
mov    %rbp,%rdi
call   1060 <RemoveDir@plt>
cmp    $0x1,%ebx
ja     1350 <TestCase1+0x1f0>
lea    0xc87(%rip),%rdi
call   1040 <ListDirContents@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [24 x i8] c" ---- Test Case 1 ----\0A\00"
@.str.1 = [5 x i8] c"/tmp\00"
@.str.2 = [5 x i8] c"/usr\00"
@.str.3 = [5 x i8] c"/etc\00"
@.str.4 = [6 x i8] c"/home\00"
@.str.5 = [13 x i8] c"/home/user%d\00"
@.str.6 = [11 x i8] c"/etc/dev%d\00"
define void @TestCase1() {
%1 = alloca i32
%2 = alloca [56 x i8]
%3 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @MakeDir(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @MakeDir(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%6 = call i32 @MakeDir(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%7 = call i32 @MakeDir(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %1
br label %8
8: ; preds = %19, %0
%9 = load i32, i32* %1
%10 = icmp slt i32 %9, 8
br i1 %10, label %11, label %22
11: ; preds = %8
%12 = getelementptr inbounds [56 x i8], [56 x i8]* %2, i64 0, i64 0
%13 = call i32 @memset(i8* %12, i32 0, i32 56)
%14 = getelementptr inbounds [56 x i8], [56 x i8]* %2, i64 0, i64 0
%15 = load i32, i32* %1
%16 = call i32 @sprintf(i8* %14, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds [56 x i8], [56 x i8]* %2, i64 0, i64 0
%18 = call i32 @MakeDir(i8* %17)
br label %19
19: ; preds = %11
%20 = load i32, i32* %1
%21 = add nsw i32 %20, 1
store i32 %21, i32* %1
br label %8
22: ; preds = %8
store i32 0, i32* %1
br label %23
23: ; preds = %34, %22
%24 = load i32, i32* %1
%25 = icmp slt i32 %24, 24
br i1 %25, label %26, label %37
26: ; preds = %23
%27 = getelementptr inbounds [56 x i8], [56 x i8]* %2, i64 0, i64 0
%28 = call i32 @memset(i8* %27, i32 0, i32 56)
%29 = getelementptr inbounds [56 x i8], [56 x i8]* %2, i64 0, i64 0
%30 = load i32, i32* %1
%31 = call i32 @sprintf(i8* %29, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i32 %30)
%32 = getelementptr inbounds [56 x i8], [56 x i8]* %2, i64 0, i64 0
%33 = call i32 @MakeDir(i8* %32)
br label %34
34: ; preds = %26
%35 = load i32, i32* %1
%36 = add nsw i32 %35, 1
store i32 %36, i32* %1
br label %23
37: ; preds = %23
%38 = call i32 @ListDirContents(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%39 = call i32 @ListDirContents(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
store i32 24, i32* %1
br label %40
40: ; preds = %51, %37
%41 = load i32, i32* %1
%42 = icmp sgt i32 %41, 0
br i1 %42, label %43, label %54
43: ; preds = %40
%44 = getelementptr inbounds [56 x i8], [56 x i8]* %2, i64 0, i64 0
%45 = call i32 @memset(i8* %44, i32 0, i32 56)
%46 = getelementptr inbounds [56 x i8], [56 x i8]* %2, i64 0, i64 0
%47 = load i32, i32* %1
%48 = call i32 @sprintf(i8* %46, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i32 %47)
%49 = getelementptr inbounds [56 x i8], [56 x i8]* %2, i64 0, i64 0
%50 = call i32 @RemoveDir(i8* %49)
br label %51
51: ; preds = %43
%52 = load i32, i32* %1
%53 = add nsw i32 %52, -1
store i32 %53, i32* %1
br label %40
54: ; preds = %40
%55 = call i32 @ListDirContents(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.1 = [5 x i8] c"/tmp\00"
@.str.2 = [5 x i8] c"/usr\00"
@.str.3 = [5 x i8] c"/etc\00"
@.str.4 = [6 x i8] c"/home\00"
@.str.5 = [13 x i8] c"/home/user%d\00"
@.str.6 = [11 x i8] c"/etc/dev%d\00"
@str = [23 x i8] c" ---- Test Case 1 ----\00"
define void @TestCase1() {
%1 = alloca [56 x i8]
%2 = getelementptr inbounds [56 x i8], [56 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @MakeDir(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 @MakeDir(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%6 = tail call i32 @MakeDir(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%7 = tail call i32 @MakeDir(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%8 = call i32 @memset(i8* %2, i32 0, i32 56)
%9 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i32 0)
%10 = call i32 @MakeDir(i8* %2)
%11 = call i32 @memset(i8* %2, i32 0, i32 56)
%12 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i32 1)
%13 = call i32 @MakeDir(i8* %2)
%14 = call i32 @memset(i8* %2, i32 0, i32 56)
%15 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i32 2)
%16 = call i32 @MakeDir(i8* %2)
%17 = call i32 @memset(i8* %2, i32 0, i32 56)
%18 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i32 3)
%19 = call i32 @MakeDir(i8* %2)
%20 = call i32 @memset(i8* %2, i32 0, i32 56)
%21 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i32 4)
%22 = call i32 @MakeDir(i8* %2)
%23 = call i32 @memset(i8* %2, i32 0, i32 56)
%24 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i32 5)
%25 = call i32 @MakeDir(i8* %2)
%26 = call i32 @memset(i8* %2, i32 0, i32 56)
%27 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i32 6)
%28 = call i32 @MakeDir(i8* %2)
%29 = call i32 @memset(i8* %2, i32 0, i32 56)
%30 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i32 7)
%31 = call i32 @MakeDir(i8* %2)
br label %32
32: ; preds = %0, %32
%33 = phi i32 [ %37, %32 ], [ 0, %0 ]
%34 = call i32 @memset(i8* %2, i32 0, i32 56)
%35 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i32 %33)
%36 = call i32 @MakeDir(i8* %2)
%37 = add nuw nsw i32 %33, 1
%38 = icmp eq i32 %37, 24
br i1 %38, label %39, label %32
39: ; preds = %32
%40 = call i32 @ListDirContents(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%41 = call i32 @ListDirContents(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %42
42: ; preds = %39, %42
%43 = phi i32 [ 24, %39 ], [ %47, %42 ]
%44 = call i32 @memset(i8* %2, i32 0, i32 56)
%45 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i32 %43)
%46 = call i32 @RemoveDir(i8* %2)
%47 = add nsw i32 %43, -1
%48 = icmp ugt i32 %43, 1
br i1 %48, label %42, label %49
49: ; preds = %42
%50 = call i32 @ListDirContents(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
ret void
}