#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*/ F_GETFL;
int /*<<< orphan*/ F_SETFL;
int O_NDELAY;
int O_WRONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int fcntl(int, int /*<<< orphan*/, int);
int open(char *, int);
int /*<<< orphan*/ write(int, char *, int);
int main(int argc, char *argv[]) {
  int fd;
  fd = open(argv[1], O_WRONLY | O_NDELAY);
  if (fd > -1) {
    (void)fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NDELAY);
    (void)write(fd, "", 1);
    (void)close(fd);
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e4b(%rip),%rax
mov    (%rax),%esi
mov    0x2e5a(%rip),%rax
or     (%rax),%esi
call   1060 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jle    11e9 <main+0x99>
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2e41(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edi
mov    0x2e22(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1030 <fcntl@plt>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    %eax,%edx
mov    0x2e12(%rip),%rax
or     (%rax),%edx
call   1030 <fcntl@plt>
mov    -0x14(%rbp),%edi
lea    0xe29(%rip),%rsi
mov    $0x1,%edx
call   1040 <write@plt>
mov    -0x14(%rbp),%edi
call   1050 <close@plt>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    0x8(%rsi),%rdi
mov    0x2e61(%rip),%rax
mov    0x2e72(%rip),%r14
mov    (%r14),%esi
or     (%rax),%esi
call   1060 <open@plt>
test   %eax,%eax
js     11b9 <main+0x69>
mov    %eax,%ebx
mov    0x2e63(%rip),%rax
mov    (%rax),%ebp
mov    0x2e4a(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
xor    %edx,%edx
call   1030 <fcntl@plt>
or     (%r14),%eax
mov    %ebx,%edi
mov    %ebp,%esi
mov    %eax,%edx
call   1030 <fcntl@plt>
lea    0xe5a(%rip),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
call   1040 <write@plt>
mov    %ebx,%edi
call   1050 <close@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@O_WRONLY = global i32 0
@O_NDELAY = global i32 0
@F_SETFL = global i32 0
@F_GETFL = global i32 0
@.str = [1 x i8] zeroinitializer
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i8**, i8*** %5
%8 = getelementptr inbounds i8*, i8** %7, i64 1
%9 = load i8*, i8** %8
%10 = load i32, i32* @O_WRONLY
%11 = load i32, i32* @O_NDELAY
%12 = or i32 %10, %11
%13 = call i32 @open(i8* %9, i32 %12)
store i32 %13, i32* %6
%14 = load i32, i32* %6
%15 = icmp sgt i32 %14, -1
br i1 %15, label %16, label %29
16: ; preds = %2
%17 = load i32, i32* %6
%18 = load i32, i32* @F_SETFL
%19 = load i32, i32* %6
%20 = load i32, i32* @F_GETFL
%21 = call i32 @fcntl(i32 %19, i32 %20, i32 0)
%22 = load i32, i32* @O_NDELAY
%23 = or i32 %21, %22
%24 = call i32 @fcntl(i32 %17, i32 %18, i32 %23)
%25 = load i32, i32* %6
%26 = call i32 @write(i32 %25, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i32 1)
%27 = load i32, i32* %6
%28 = call i32 @close(i32 %27)
br label %29
29: ; preds = %16, %2
%30 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@O_WRONLY = global i32 0
@O_NDELAY = global i32 0
@F_SETFL = global i32 0
@F_GETFL = global i32 0
@.str = [1 x i8] zeroinitializer
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = load i32, i32* @O_WRONLY
%6 = load i32, i32* @O_NDELAY
%7 = or i32 %6, %5
%8 = tail call i32 @open(i8* %4, i32 %7)
%9 = icmp sgt i32 %8, -1
br i1 %9, label %10, label %19
10: ; preds = %2
%11 = load i32, i32* @F_SETFL
%12 = load i32, i32* @F_GETFL
%13 = tail call i32 @fcntl(i32 %8, i32 %12, i32 0)
%14 = load i32, i32* @O_NDELAY
%15 = or i32 %14, %13
%16 = tail call i32 @fcntl(i32 %8, i32 %11, i32 %15)
%17 = tail call i32 @write(i32 %8, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i32 1)
%18 = tail call i32 @close(i32 %8)
br label %19
19: ; preds = %10, %2
%20 = tail call i32 @exit(i32 0)
unreachable
}