#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*/ O_RDWR;
scalar_t__ open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
scalar_t__ unlink(char *);
int main(int argc, char *argv[]) {
  if (open("tempfile", O_RDWR) < 0)
    perror("open tempfile error");
  if (unlink("tempfile"))
    perror("unlink tempfile error");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e9b(%rip),%rax
mov    (%rax),%esi
lea    0xeaa(%rip),%rdi
call   1040 <open@plt>
cmp    $0x0,%rax
jge    1171 <main+0x41>
lea    0xe9d(%rip),%rdi
call   1050 <perror@plt>
lea    0xe88(%rip),%rdi
call   1030 <unlink@plt>
cmp    $0x0,%rax
je     1193 <main+0x63>
lea    0xe8f(%rip),%rdi
call   1050 <perror@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    0x2eb0(%rip),%rax
mov    (%rax),%esi
lea    0xebf(%rip),%rdi
call   1040 <open@plt>
test   %rax,%rax
js     1160 <main+0x30>
lea    0xeae(%rip),%rdi
call   1030 <unlink@plt>
test   %rax,%rax
jne    116e <main+0x3e>
xor    %eax,%eax
pop    %rcx
ret
lea    0xea2(%rip),%rdi
call   1050 <perror@plt>
jmp    114b <main+0x1b>
lea    0xea8(%rip),%rdi
call   1050 <perror@plt>
jmp    115c <main+0x2c>

LLVM IR (-O0):
@.str = [9 x i8] c"tempfile\00"
@O_RDWR = global i32 0
@.str.1 = [20 x i8] c"open tempfile error\00"
@.str.2 = [22 x i8] c"unlink tempfile error\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* @O_RDWR
%7 = call i64 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = icmp slt i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %11
11: ; preds = %9, %2
%12 = call i64 @unlink(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
br label %16
16: ; preds = %14, %11
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"tempfile\00"
@O_RDWR = global i32 0
@.str.1 = [20 x i8] c"open tempfile error\00"
@.str.2 = [22 x i8] c"unlink tempfile error\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @O_RDWR
%4 = tail call i64 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = icmp slt i64 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %8
8: ; preds = %6, %2
%9 = tail call i64 @unlink(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %8
%12 = tail call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
br label %13
13: ; preds = %11, %8
ret i32 0
}