#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*/ EXIT_FAILURE;
int /*<<< orphan*/ O_RDWR;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stderr;
scalar_t__ unlink(char *);
int main(void) {
  if (open("tempfile", O_RDWR) < 0) {
    fprintf(stderr, "open error");
    exit(EXIT_FAILURE);
  }
  if (unlink("tempfile") < 0) {
    fprintf(stderr, "unlink error");
    exit(EXIT_FAILURE);
  }
  printf("file unlinked\n");
  sleep(15);
  printf("done\n");
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e72(%rip),%rax
mov    (%rax),%esi
lea    0xe81(%rip),%rdi
call   1060 <open@plt>
cmp    $0x0,%rax
jge    11b1 <main+0x51>
mov    0x2e43(%rip),%rax
mov    (%rax),%edi
lea    0xe6b(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e26(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
lea    0xe48(%rip),%rdi
call   1030 <unlink@plt>
cmp    $0x0,%rax
jge    11ea <main+0x8a>
mov    0x2e0a(%rip),%rax
mov    (%rax),%edi
lea    0xe3d(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2ded(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
lea    0xe30(%rip),%rdi
call   1040 <printf@plt>
mov    $0xf,%edi
call   1080 <sleep@plt>
lea    0xe29(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    0x2e80(%rip),%rax
mov    (%rax),%esi
lea    0xe8f(%rip),%rdi
call   1060 <open@plt>
test   %rax,%rax
jns    118d <main+0x2d>
mov    0x2e56(%rip),%rax
mov    (%rax),%edi
lea    0xe7e(%rip),%rsi
jmp    11ae <main+0x4e>
lea    0xe6c(%rip),%rdi
call   1030 <unlink@plt>
test   %rax,%rax
jns    11c1 <main+0x61>
mov    0x2e33(%rip),%rax
mov    (%rax),%edi
lea    0xe66(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e16(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
lea    0xe59(%rip),%rdi
call   1040 <puts@plt>
mov    $0xf,%edi
call   1080 <sleep@plt>
lea    0xe51(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"tempfile\00"
@O_RDWR = global i32 0
@stderr = global i32 0
@.str.1 = [11 x i8] c"open error\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [13 x i8] c"unlink error\00"
@.str.3 = [15 x i8] c"file unlinked\0A\00"
@.str.4 = [6 x i8] c"done\0A\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = load i32, i32* @O_RDWR
%3 = call i64 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %2)
%4 = icmp slt i64 %3, 0
br i1 %4, label %5, label %10
5: ; preds = %0
%6 = load i32, i32* @stderr
%7 = call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%8 = load i32, i32* @EXIT_FAILURE
%9 = call i32 @exit(i32 %8)
unreachable
10: ; preds = %0
%11 = call i64 @unlink(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%12 = icmp slt i64 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %10
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%16 = load i32, i32* @EXIT_FAILURE
%17 = call i32 @exit(i32 %16)
unreachable
18: ; preds = %10
%19 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%20 = call i32 @sleep(i32 15)
%21 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%22 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [9 x i8] c"tempfile\00"
@O_RDWR = global i32 0
@stderr = global i32 0
@.str.1 = [11 x i8] c"open error\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [13 x i8] c"unlink error\00"
@str = [14 x i8] c"file unlinked\00"
@str.5 = [5 x i8] c"done\00"
define i32 @main() {
%1 = load i32, i32* @O_RDWR
%2 = tail call i64 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %1)
%3 = icmp slt i64 %2, 0
br i1 %3, label %4, label %9
4: ; preds = %0
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%7 = load i32, i32* @EXIT_FAILURE
%8 = tail call i32 @exit(i32 %7)
unreachable
9: ; preds = %0
%10 = tail call i64 @unlink(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%11 = icmp slt i64 %10, 0
br i1 %11, label %12, label %17
12: ; preds = %9
%13 = load i32, i32* @stderr
%14 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%15 = load i32, i32* @EXIT_FAILURE
%16 = tail call i32 @exit(i32 %15)
unreachable
17: ; preds = %9
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
%19 = tail call i32 @sleep(i32 15)
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.5, i64 0, i64 0))
%21 = tail call i32 @exit(i32 0)
unreachable
}