#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*/ die_errno(char *, char const *);
int errno;
int /*<<< orphan*/ rmdir(char const *);
int /*<<< orphan*/ unlink(char const *);
__attribute__((noreturn)) void
die_unlink_errno(const char *str, const char *file, const char *dir) {
  int saved = errno;
  if (file)
    unlink(file);
  if (dir)
    rmdir(dir);
  errno = saved;
  die_errno("%s", str);
}


x86 assembly (clang, -O0):
<die_unlink_errno>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    0x2e95(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1164 <die_unlink_errno+0x34>
mov    -0x10(%rbp),%rdi
call   1030 <unlink@plt>
cmpq   $0x0,-0x18(%rbp)
je     1178 <die_unlink_errno+0x48>
mov    -0x18(%rbp),%rdi
call   1040 <rmdir@plt>
mov    -0x1c(%rbp),%ecx
mov    0x2e5e(%rip),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rsi
lea    0xe71(%rip),%rdi
call   1050 <die_errno@plt>

x86 assembly (clang, -O2):
<die_unlink_errno>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rdi,%r14
mov    0x2e9c(%rip),%r15
mov    (%r15),%ebp
test   %rsi,%rsi
je     1154 <die_unlink_errno+0x24>
mov    %rsi,%rdi
call   1030 <unlink@plt>
test   %rbx,%rbx
je     1161 <die_unlink_errno+0x31>
mov    %rbx,%rdi
call   1040 <rmdir@plt>
mov    %ebp,(%r15)
lea    0xe95(%rip),%rdi
mov    %r14,%rsi
call   1050 <die_errno@plt>

LLVM IR (-O0):
@errno = global i32 0
@.str = [3 x i8] c"%s\00"
define void @die_unlink_errno(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%8 = load i32, i32* @errno
store i32 %8, i32* %7
%9 = load i8*, i8** %5
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %14
11: ; preds = %3
%12 = load i8*, i8** %5
%13 = call i32 @unlink(i8* %12)
br label %14
14: ; preds = %11, %3
%15 = load i8*, i8** %6
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = load i8*, i8** %6
%19 = call i32 @rmdir(i8* %18)
br label %20
20: ; preds = %17, %14
%21 = load i32, i32* %7
store i32 %21, i32* @errno
%22 = load i8*, i8** %4
%23 = call i32 @die_errno(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %22)
unreachable
}

LLVM IR (-O2):
@errno = global i32 0
@.str = [3 x i8] c"%s\00"
define void @die_unlink_errno(i8* %0, i8* %1, i8* %2) {
%4 = load i32, i32* @errno
%5 = icmp eq i8* %1, null
br i1 %5, label %8, label %6
6: ; preds = %3
%7 = tail call i32 @unlink(i8* %1)
br label %8
8: ; preds = %6, %3
%9 = icmp eq i8* %2, null
br i1 %9, label %12, label %10
10: ; preds = %8
%11 = tail call i32 @rmdir(i8* %2)
br label %12
12: ; preds = %10, %8
store i32 %4, i32* @errno
%13 = tail call i32 @die_errno(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %0)
unreachable
}