#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_NONBLOCK;
int O_WRONLY;
int /*<<< orphan*/ exit(int);
int open(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcpy(char *, char *);
int write(int, char *, int);
int main(int argc, char **argv) {
  char buf[100];
  int fd;
  if (1 == argc) {
    printf("please send something!\r\n");
    exit(1);
  }
  strcpy(buf, argv[1]);
  fd = open("/tmp/myfifio", O_WRONLY | O_NONBLOCK, 0);
  if (-1 == fd) {
    printf("open fifo error!\r\n");
    exit(1);
  }
  if (-1 == write(fd, buf, 100)) {
    printf("write fifo error!\r\n");
    exit(1);
  } else {
    printf("write %s to the %s", buf, "/tmp/myfifio");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x1,%eax
cmp    -0x4(%rbp),%eax
jne    1188 <main+0x38>
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1030 <strcpy@plt>
mov    0x2e30(%rip),%rax
mov    (%rax),%esi
mov    0x2e3f(%rip),%rax
or     (%rax),%esi
lea    0xe67(%rip),%rdi
xor    %edx,%edx
call   1060 <open@plt>
mov    %eax,-0x84(%rbp)
mov    $0xffffffff,%eax
cmp    -0x84(%rbp),%eax
jne    11e8 <main+0x98>
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x84(%rbp),%edi
lea    -0x80(%rbp),%rsi
mov    $0x64,%edx
call   1040 <write@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    1223 <main+0xd3>
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
lea    -0x80(%rbp),%rsi
lea    0xe1f(%rip),%rdi
lea    0xde4(%rip),%rdx
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x68,%rsp
cmp    $0x1,%edi
je     11cd <main+0x6d>
mov    0x8(%rsi),%rsi
mov    %rsp,%rdi
call   1030 <strcpy@plt>
mov    0x2e54(%rip),%rax
mov    0x2e65(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
lea    0xe72(%rip),%rdi
xor    %edx,%edx
call   1070 <open@plt>
cmp    $0xffffffff,%eax
je     11d6 <main+0x76>
mov    %rsp,%rsi
mov    %eax,%edi
mov    $0x64,%edx
call   1050 <write@plt>
cmp    $0xffffffff,%eax
je     11df <main+0x7f>
lea    0xe58(%rip),%rdi
lea    0xe44(%rip),%rdx
mov    %rsp,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x68,%rsp
ret
lea    0xe71(%rip),%rdi
jmp    11e6 <main+0x86>
lea    0xe56(%rip),%rdi
jmp    11e6 <main+0x86>
lea    0xe3a(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [25 x i8] c"please send something!\0D\0A\00"
@.str.1 = [13 x i8] c"/tmp/myfifio\00"
@O_WRONLY = global i32 0
@O_NONBLOCK = global i32 0
@.str.2 = [19 x i8] c"open fifo error!\0D\0A\00"
@.str.3 = [20 x i8] c"write fifo error!\0D\0A\00"
@.str.4 = [19 x i8] c"write %s to the %s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca [100 x i8]
%6 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
%7 = load i32, i32* %3
%8 = icmp eq i32 1, %7
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @exit(i32 1)
unreachable
12: ; preds = %2
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%14 = load i8**, i8*** %4
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @strcpy(i8* %13, i8* %16)
%18 = load i32, i32* @O_WRONLY
%19 = load i32, i32* @O_NONBLOCK
%20 = or i32 %18, %19
%21 = call i32 @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %20, i32 0)
store i32 %21, i32* %6
%22 = load i32, i32* %6
%23 = icmp eq i32 -1, %22
br i1 %23, label %24, label %27
24: ; preds = %12
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%26 = call i32 @exit(i32 1)
unreachable
27: ; preds = %12
%28 = load i32, i32* %6
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%30 = call i32 @write(i32 %28, i8* %29, i32 100)
%31 = icmp eq i32 -1, %30
br i1 %31, label %32, label %35
32: ; preds = %27
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%34 = call i32 @exit(i32 1)
unreachable
35: ; preds = %27
%36 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %36, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %38
38: ; preds = %35
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [13 x i8] c"/tmp/myfifio\00"
@O_WRONLY = global i32 0
@O_NONBLOCK = global i32 0
@.str.4 = [19 x i8] c"write %s to the %s\00"
@str = [19 x i8] c"write fifo error!\0D\00"
@str.5 = [18 x i8] c"open fifo error!\0D\00"
@str.6 = [24 x i8] c"please send something!\0D\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 1
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.6, i64 0, i64 0))
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = call i32 @strcpy(i8* %4, i8* %11)
%13 = load i32, i32* @O_WRONLY
%14 = load i32, i32* @O_NONBLOCK
%15 = or i32 %14, %13
%16 = call i32 @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %15, i32 0)
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %21
18: ; preds = %9
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.5, i64 0, i64 0))
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %9
%22 = call i32 @write(i32 %16, i8* %4, i32 100)
%23 = icmp eq i32 %22, -1
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%26 = call i32 @exit(i32 1)
unreachable
27: ; preds = %21
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %4, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}