#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;
};
struct FTW {
  int dummy;
};

/* Variables and functions */
int FTW_F;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *, char *);
int /*<<< orphan*/ printf(char *, char const *, int);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
scalar_t__ unlink(char const *);
int cb1(const char *path, const struct stat *ptr, int flag, struct FTW *ftw) {
  printf("cb1 %s %x\n", path, flag);
  if (flag == FTW_F) {
    if (unlink(path) != 0)
      fprintf(stderr, "failed to unlink %s: %s\n", path, strerror(errno));
  }
  return 0;
}


x86 assembly (clang, -O0):
<cb1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    0xe9b(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
mov    0x2e74(%rip),%rcx
cmp    (%rcx),%eax
jne    11cc <cb1+0x8c>
mov    -0x8(%rbp),%rdi
call   1030 <unlink@plt>
cmp    $0x0,%rax
je     11c7 <cb1+0x87>
mov    0x2e42(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    0x2e26(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%rdx
mov    %rax,%rcx
lea    0xe49(%rip),%rsi
call   1050 <fprintf@plt>
jmp    11cc <cb1+0x8c>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cb1>:
push   %rbp
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rdi,%rbx
lea    0xeb1(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    0x2e8a(%rip),%rax
cmp    %ebp,(%rax)
jne    119a <cb1+0x5a>
mov    %rbx,%rdi
call   1030 <unlink@plt>
test   %rax,%rax
je     119a <cb1+0x5a>
mov    0x2e62(%rip),%rax
mov    (%rax),%ebp
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
lea    0xe7e(%rip),%rsi
mov    %ebp,%edi
mov    %rbx,%rdx
mov    %rax,%rcx
call   1050 <fprintf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
%struct.stat = type { i32 }
%struct.FTW = type { i32 }
@.str = [11 x i8] c"cb1 %s %x\0A\00"
@FTW_F = global i32 0
@stderr = global i32 0
@.str.1 = [25 x i8] c"failed to unlink %s: %s\0A\00"
@errno = global i32 0
define i32 @cb1(i8* %0, %struct.stat* nocapture readnone %1, i32 %2, %struct.FTW* nocapture readnone %3) {
%5 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %2)
%6 = load i32, i32* @FTW_F
%7 = icmp eq i32 %6, %2
br i1 %7, label %8, label %16
8: ; preds = %4
%9 = tail call i64 @unlink(i8* %0)
%10 = icmp eq i64 %9, 0
br i1 %10, label %16, label %11
11: ; preds = %8
%12 = load i32, i32* @stderr
%13 = load i32, i32* @errno
%14 = tail call i8* @strerror(i32 %13)
%15 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %14)
br label %16
16: ; preds = %8, %11, %4
ret i32 0
}