#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 O_CREAT;
int O_EXCL;
int O_RDWR;
int O_WRONLY;
int /*<<< orphan*/ close(int);
int open(char *, int, ...);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ unlink(char *);
int main() {
  int fd1 = open("furong", O_WRONLY);
  if (fd1 == -1)
    perror("furong");
  int fd2 = open("furong", O_WRONLY | O_CREAT, 0666);
  if (fd2 == -1) {
    perror("furong2");
    return 1;
  }
  int fd3 = open("fengjie", O_RDWR | O_EXCL | O_CREAT, 0666);
  if (fd3 == -1)
    perror("fengjie");
  else
    puts("成功");
  close(fd1);
  close(fd2);
  close(fd3);
  sleep(10);
  unlink("furong");
  unlink("fengjie");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e4a(%rip),%rax
mov    (%rax),%esi
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1060 <open@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    119f <main+0x3f>
lea    0xe66(%rip),%rdi
call   1070 <perror@plt>
mov    0x2e1a(%rip),%rax
mov    (%rax),%esi
mov    0x2e49(%rip),%rax
or     (%rax),%esi
lea    0xe48(%rip),%rdi
mov    $0x1b6,%edx
mov    $0x0,%al
call   1060 <open@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    11e9 <main+0x89>
lea    0xe2f(%rip),%rdi
call   1070 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    127b <main+0x11b>
mov    0x2df0(%rip),%rax
mov    (%rax),%esi
mov    0x2dd7(%rip),%rax
or     (%rax),%esi
mov    0x2df6(%rip),%rax
or     (%rax),%esi
lea    0xe04(%rip),%rdi
mov    $0x1b6,%edx
mov    $0x0,%al
call   1060 <open@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0xffffffff,-0x10(%rbp)
jne    1235 <main+0xd5>
lea    0xde4(%rip),%rdi
call   1070 <perror@plt>
jmp    1241 <main+0xe1>
lea    0xddb(%rip),%rdi
call   1040 <puts@plt>
mov    -0x8(%rbp),%edi
call   1050 <close@plt>
mov    -0xc(%rbp),%edi
call   1050 <close@plt>
mov    -0x10(%rbp),%edi
call   1050 <close@plt>
mov    $0xa,%edi
call   1080 <sleep@plt>
lea    0xd96(%rip),%rdi
call   1030 <unlink@plt>
lea    0xd99(%rip),%rdi
call   1030 <unlink@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    0x2e55(%rip),%rbp
mov    0x0(%rbp),%esi
lea    0xe8b(%rip),%rdi
xor    %eax,%eax
call   1060 <open@plt>
mov    %eax,%r14d
cmp    $0xffffffff,%eax
je     122b <main+0xcb>
mov    0x2e69(%rip),%rbx
mov    (%rbx),%esi
or     0x0(%rbp),%esi
lea    0xe65(%rip),%rdi
mov    $0x1b6,%edx
xor    %eax,%eax
call   1060 <open@plt>
cmp    $0xffffffff,%eax
je     123c <main+0xdc>
mov    %eax,%ebp
mov    0x2e27(%rip),%rax
mov    0x2e10(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
or     (%rbx),%esi
lea    0xe42(%rip),%rdi
mov    $0x1b6,%edx
xor    %eax,%eax
call   1060 <open@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
je     124f <main+0xef>
lea    0xe30(%rip),%rdi
call   1040 <puts@plt>
mov    %r14d,%edi
call   1050 <close@plt>
mov    %ebp,%edi
call   1050 <close@plt>
mov    %ebx,%edi
call   1050 <close@plt>
mov    $0xa,%edi
call   1080 <sleep@plt>
lea    0xded(%rip),%rdi
call   1030 <unlink@plt>
lea    0xdf0(%rip),%rdi
call   1030 <unlink@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xdce(%rip),%rdi
call   1070 <perror@plt>
jmp    1188 <main+0x28>
lea    0xdc4(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%eax
jmp    1226 <main+0xc6>
lea    0xdb9(%rip),%rdi
call   1070 <perror@plt>
jmp    11ec <main+0x8c>

LLVM IR (-O0):
@.str = [7 x i8] c"furong\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@.str.1 = [8 x i8] c"furong2\00"
@.str.2 = [8 x i8] c"fengjie\00"
@O_RDWR = global i32 0
@O_EXCL = global i32 0
@.str.3 = [7 x i8] c"\E6\88\90\E5\8A\9F\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = load i32, i32* @O_WRONLY
%6 = call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %5)
store i32 %6, i32* %2
%7 = load i32, i32* %2
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %9, %0
%12 = load i32, i32* @O_WRONLY
%13 = load i32, i32* @O_CREAT
%14 = or i32 %12, %13
%15 = call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %14, i32 438)
store i32 %15, i32* %3
%16 = load i32, i32* %3
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %20
18: ; preds = %11
%19 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %1
br label %43
20: ; preds = %11
%21 = load i32, i32* @O_RDWR
%22 = load i32, i32* @O_EXCL
%23 = or i32 %21, %22
%24 = load i32, i32* @O_CREAT
%25 = or i32 %23, %24
%26 = call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %25, i32 438)
store i32 %26, i32* %4
%27 = load i32, i32* %4
%28 = icmp eq i32 %27, -1
br i1 %28, label %29, label %31
29: ; preds = %20
%30 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
br label %33
31: ; preds = %20
%32 = call i32 @puts(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %33
33: ; preds = %31, %29
%34 = load i32, i32* %2
%35 = call i32 @close(i32 %34)
%36 = load i32, i32* %3
%37 = call i32 @close(i32 %36)
%38 = load i32, i32* %4
%39 = call i32 @close(i32 %38)
%40 = call i32 @sleep(i32 10)
%41 = call i32 @unlink(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%42 = call i32 @unlink(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
br label %43
43: ; preds = %33, %18
%44 = load i32, i32* %1
ret i32 %44
}

LLVM IR (-O2):
@.str = [7 x i8] c"furong\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@.str.1 = [8 x i8] c"furong2\00"
@.str.2 = [8 x i8] c"fengjie\00"
@O_RDWR = global i32 0
@O_EXCL = global i32 0
@.str.3 = [7 x i8] c"\E6\88\90\E5\8A\9F\00"
define i32 @main() {
%1 = load i32, i32* @O_WRONLY
%2 = tail call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %1)
%3 = icmp eq i32 %2, -1
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %4, %0
%7 = load i32, i32* @O_WRONLY
%8 = load i32, i32* @O_CREAT
%9 = or i32 %8, %7
%10 = tail call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %9, i32 438)
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %14
12: ; preds = %6
%13 = tail call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %33
14: ; preds = %6
%15 = load i32, i32* @O_RDWR
%16 = load i32, i32* @O_EXCL
%17 = or i32 %16, %15
%18 = load i32, i32* @O_CREAT
%19 = or i32 %17, %18
%20 = tail call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %19, i32 438)
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %24
22: ; preds = %14
%23 = tail call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
br label %26
24: ; preds = %14
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %26
26: ; preds = %24, %22
%27 = tail call i32 @close(i32 %2)
%28 = tail call i32 @close(i32 %10)
%29 = tail call i32 @close(i32 %20)
%30 = tail call i32 @sleep(i32 10)
%31 = tail call i32 @unlink(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%32 = tail call i32 @unlink(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
br label %33
33: ; preds = %26, %12
%34 = phi i32 [ 1, %12 ], [ 0, %26 ]
ret i32 %34
}