#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 */
struct stat {
  int dummy;
};

/* Variables and functions */
int FTW_F;
int errno;
int /*<<< orphan*/ printf(char *, int, char *);
scalar_t__ unlink(char *);
int cleanup_files(char *file, struct stat *statBuff, int flag) {
  int rc = 0;
  if (flag == FTW_F) {
    if (unlink(file)) {
      printf("ERROR:%d removing file %s\n", errno, file);
    }
  }
  return rc;
}


x86 assembly (clang, -O0):
<cleanup_files>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2ea4(%rip),%rcx
cmp    (%rcx),%eax
jne    117d <cleanup_files+0x5d>
mov    -0x8(%rbp),%rdi
call   1030 <unlink@plt>
cmp    $0x0,%rax
je     1178 <cleanup_files+0x58>
mov    0x2e72(%rip),%rax
mov    (%rax),%esi
mov    -0x8(%rbp),%rdx
lea    0xe8d(%rip),%rdi
call   1040 <printf@plt>
jmp    117d <cleanup_files+0x5d>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cleanup_files>:
push   %rbx
mov    0x2ec0(%rip),%rax
cmp    %edx,(%rax)
jne    1151 <cleanup_files+0x31>
mov    %rdi,%rbx
call   1030 <unlink@plt>
test   %rax,%rax
je     1151 <cleanup_files+0x31>
mov    0x2e98(%rip),%rax
mov    (%rax),%esi
lea    0xeb7(%rip),%rdi
mov    %rbx,%rdx
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@FTW_F = global i32 0
@.str = [27 x i8] c"ERROR:%d removing file %s\0A\00"
@errno = global i32 0
define i32 @cleanup_files(i8* %0, %struct.stat* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca %struct.stat*
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store %struct.stat* %1, %struct.stat** %5
store i32 %2, i32* %6
store i32 0, i32* %7
%8 = load i32, i32* %6
%9 = load i32, i32* @FTW_F
%10 = icmp eq i32 %8, %9
br i1 %10, label %11, label %20
11: ; preds = %3
%12 = load i8*, i8** %4
%13 = call i64 @unlink(i8* %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %11
%16 = load i32, i32* @errno
%17 = load i8*, i8** %4
%18 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %16, i8* %17)
br label %19
19: ; preds = %15, %11
br label %20
20: ; preds = %19, %3
%21 = load i32, i32* %7
ret i32 %21
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@FTW_F = global i32 0
@.str = [27 x i8] c"ERROR:%d removing file %s\0A\00"
@errno = global i32 0
define i32 @cleanup_files(i8* %0, %struct.stat* nocapture readnone %1, i32 %2) {
%4 = load i32, i32* @FTW_F
%5 = icmp eq i32 %4, %2
br i1 %5, label %6, label %12
6: ; preds = %3
%7 = tail call i64 @unlink(i8* %0)
%8 = icmp eq i64 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %6
%10 = load i32, i32* @errno
%11 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %10, i8* %0)
br label %12
12: ; preds = %6, %9, %3
ret i32 0
}