#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*/ perror(char *);
int rmdir(char *);
int unlink(char *);
int cleanup_test_files(void) {
  int ret;
  ret = unlink("testdir/first");
  if (ret == -1) {
    perror("unlink testdir/first");
    return -1;
  }
  ret = unlink("testdir/second");
  if (ret == -1) {
    perror("unlink testdir/second");
    return -1;
  }
  ret = unlink("testdir/third");
  if (ret == -1) {
    perror("unlink testdir/third");
    return -1;
  }
  ret = rmdir("testdir");
  if (ret == -1) {
    perror("unlink testdir");
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<cleanup_test_files>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec8(%rip),%rdi
call   1030 <unlink@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    1169 <cleanup_test_files+0x39>
lea    0xea8(%rip),%rdi
call   1050 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1203 <cleanup_test_files+0xd3>
lea    0xeac(%rip),%rdi
call   1030 <unlink@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    119a <cleanup_test_files+0x6a>
lea    0xe8c(%rip),%rdi
call   1050 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1203 <cleanup_test_files+0xd3>
lea    0xe91(%rip),%rdi
call   1030 <unlink@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    11cb <cleanup_test_files+0x9b>
lea    0xe71(%rip),%rdi
call   1050 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1203 <cleanup_test_files+0xd3>
lea    0xe75(%rip),%rdi
call   1040 <rmdir@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    11fc <cleanup_test_files+0xcc>
lea    0xe55(%rip),%rdi
call   1050 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1203 <cleanup_test_files+0xd3>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cleanup_test_files>:
push   %rax
lea    0xecf(%rip),%rdi
call   1030 <unlink@plt>
cmp    $0xffffffff,%eax
je     117b <cleanup_test_files+0x4b>
lea    0xed3(%rip),%rdi
call   1030 <unlink@plt>
cmp    $0xffffffff,%eax
je     1184 <cleanup_test_files+0x54>
lea    0xed8(%rip),%rdi
call   1030 <unlink@plt>
cmp    $0xffffffff,%eax
je     118d <cleanup_test_files+0x5d>
lea    0xedc(%rip),%rdi
call   1040 <rmdir@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0xffffffff,%ecx
je     1196 <cleanup_test_files+0x66>
pop    %rcx
ret
lea    0xe7e(%rip),%rdi
jmp    119d <cleanup_test_files+0x6d>
lea    0xe8a(%rip),%rdi
jmp    119d <cleanup_test_files+0x6d>
lea    0xe97(%rip),%rdi
jmp    119d <cleanup_test_files+0x6d>
lea    0xea3(%rip),%rdi
call   1050 <perror@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [14 x i8] c"testdir/first\00"
@.str.1 = [21 x i8] c"unlink testdir/first\00"
@.str.2 = [15 x i8] c"testdir/second\00"
@.str.3 = [22 x i8] c"unlink testdir/second\00"
@.str.4 = [14 x i8] c"testdir/third\00"
@.str.5 = [21 x i8] c"unlink testdir/third\00"
@.str.6 = [8 x i8] c"testdir\00"
@.str.7 = [15 x i8] c"unlink testdir\00"
define i32 @cleanup_test_files() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 @unlink(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
store i32 %3, i32* %2
%4 = load i32, i32* %2
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %1
br label %27
8: ; preds = %0
%9 = call i32 @unlink(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
store i32 %9, i32* %2
%10 = load i32, i32* %2
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %1
br label %27
14: ; preds = %8
%15 = call i32 @unlink(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
store i32 %15, i32* %2
%16 = load i32, i32* %2
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
store i32 -1, i32* %1
br label %27
20: ; preds = %14
%21 = call i32 @rmdir(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
store i32 %21, i32* %2
%22 = load i32, i32* %2
%23 = icmp eq i32 %22, -1
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0))
store i32 -1, i32* %1
br label %27
26: ; preds = %20
store i32 0, i32* %1
br label %27
27: ; preds = %26, %24, %18, %12, %6
%28 = load i32, i32* %1
ret i32 %28
}

LLVM IR (-O2):
@.str = [14 x i8] c"testdir/first\00"
@.str.1 = [21 x i8] c"unlink testdir/first\00"
@.str.2 = [15 x i8] c"testdir/second\00"
@.str.3 = [22 x i8] c"unlink testdir/second\00"
@.str.4 = [14 x i8] c"testdir/third\00"
@.str.5 = [21 x i8] c"unlink testdir/third\00"
@.str.6 = [8 x i8] c"testdir\00"
@.str.7 = [15 x i8] c"unlink testdir\00"
define i32 @cleanup_test_files() {
%1 = tail call i32 @unlink(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i32 %1, -1
br i1 %2, label %12, label %3
3: ; preds = %0
%4 = tail call i32 @unlink(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%5 = icmp eq i32 %4, -1
br i1 %5, label %12, label %6
6: ; preds = %3
%7 = tail call i32 @unlink(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%8 = icmp eq i32 %7, -1
br i1 %8, label %12, label %9
9: ; preds = %6
%10 = tail call i32 @rmdir(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %15
12: ; preds = %9, %6, %3, %0
%13 = phi i8* [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), %0 ], [ getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), %3 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), %6 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), %9 ]
%14 = tail call i32 @perror(i8* %13)
br label %15
15: ; preds = %12, %9
%16 = phi i32 [ 0, %9 ], [ -1, %12 ]
ret i32 %16
}