#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;
int /*<<< orphan*/ err_sys(char *);
scalar_t__ open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sleep(int);
scalar_t__ unlink(char *);
int main(int argc, char **argv) {
  if (open("tmpfile", O_RDWR) < 0) {
    err_sys("opening file 'tmpfile' error");
  }
  if (unlink("tmpfile") < 0) {
    err_sys("error on unlink 'tmpfile'");
  }
  printf("'tmpfile' has been removed\n");
  sleep(15);
  printf("done\n");
  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    0x2e7b(%rip),%rax
mov    (%rax),%esi
lea    0xe8a(%rip),%rdi
call   1060 <open@plt>
cmp    $0x0,%rax
jge    1191 <main+0x41>
lea    0xe7c(%rip),%rdi
call   1040 <err_sys@plt>
lea    0xe68(%rip),%rdi
call   1030 <unlink@plt>
cmp    $0x0,%rax
jge    11b3 <main+0x63>
lea    0xe77(%rip),%rdi
call   1040 <err_sys@plt>
lea    0xe85(%rip),%rdi
call   1050 <printf@plt>
mov    $0xf,%edi
call   1070 <sleep@plt>
lea    0xe8b(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    0x2e90(%rip),%rax
mov    (%rax),%esi
lea    0xe9f(%rip),%rdi
call   1060 <open@plt>
test   %rax,%rax
jns    1177 <main+0x27>
lea    0xe96(%rip),%rdi
call   1050 <err_sys@plt>
lea    0xe82(%rip),%rdi
call   1030 <unlink@plt>
test   %rax,%rax
jns    1194 <main+0x44>
lea    0xe96(%rip),%rdi
call   1050 <err_sys@plt>
lea    0xea4(%rip),%rdi
call   1040 <puts@plt>
mov    $0xf,%edi
call   1070 <sleep@plt>
lea    0xea9(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [8 x i8] c"tmpfile\00"
@O_RDWR = global i32 0
@.str.1 = [29 x i8] c"opening file 'tmpfile' error\00"
@.str.2 = [26 x i8] c"error on unlink 'tmpfile'\00"
@.str.3 = [28 x i8] c"'tmpfile' has been removed\0A\00"
@.str.4 = [6 x i8] c"done\0A\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 ([8 x i8], [8 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 @err_sys(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
br label %11
11: ; preds = %9, %2
%12 = call i64 @unlink(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%13 = icmp slt i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = call i32 @err_sys(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %16
16: ; preds = %14, %11
%17 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
%18 = call i32 @sleep(i32 15)
%19 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"tmpfile\00"
@O_RDWR = global i32 0
@.str.1 = [29 x i8] c"opening file 'tmpfile' error\00"
@.str.2 = [26 x i8] c"error on unlink 'tmpfile'\00"
@str = [27 x i8] c"'tmpfile' has been removed\00"
@str.5 = [5 x i8] c"done\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @O_RDWR
%4 = tail call i64 @open(i8* getelementptr inbounds ([8 x i8], [8 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 @err_sys(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
br label %8
8: ; preds = %6, %2
%9 = tail call i64 @unlink(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%10 = icmp slt i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = tail call i32 @err_sys(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %13
13: ; preds = %11, %8
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%15 = tail call i32 @sleep(i32 15)
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.5, i64 0, i64 0))
ret i32 0
}