#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_WRONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
size_t write(int, char *, int);
int main() {
  int fd;
  size_t size;
  char name[] = "aaa.fifo";
  if ((fd = open(name, O_WRONLY)) < 0) {
    printf("Can\'t open FIFO for writting\n");
    exit(-1);
  }
  size = write(fd, "Hello, world!", 14);
  if (size != 14) {
    printf("Can\'t write all string to FIFO\n");
    exit(-1);
  }
  close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe9a(%rip),%rax
mov    %rax,-0x19(%rbp)
mov    0xe98(%rip),%al
mov    %al,-0x11(%rbp)
lea    -0x19(%rbp),%rdi
mov    0x2e5a(%rip),%rax
mov    (%rax),%esi
call   1060 <open@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jge    11a7 <main+0x57>
lea    0xe71(%rip),%rdi
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>
mov    -0x8(%rbp),%edi
lea    0xe76(%rip),%rsi
mov    $0xe,%edx
call   1030 <write@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0xe,-0x10(%rbp)
je     11e0 <main+0x90>
lea    0xe64(%rip),%rdi
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>
mov    -0x8(%rbp),%edi
call   1050 <close@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movabs $0x6f6669662e616161,%rax
69 66 6f
mov    %rax,(%rsp)
movb   $0x0,0x8(%rsp)
mov    0x2e69(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rdi
call   1060 <open@plt>
test   %eax,%eax
js     11a7 <main+0x57>
mov    %eax,%ebx
lea    0xe83(%rip),%rsi
mov    %eax,%edi
mov    $0xe,%edx
call   1040 <write@plt>
cmp    $0xe,%rax
jne    11b0 <main+0x60>
mov    %ebx,%edi
call   1050 <close@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe88(%rip),%rdi
jmp    11b7 <main+0x67>
lea    0xe60(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@__const.main.name = [9 x i8] c"aaa.fifo\00"
@O_WRONLY = global i32 0
@.str = [30 x i8] c"Can't open FIFO for writting\0A\00"
@.str.1 = [14 x i8] c"Hello, world!\00"
@.str.2 = [32 x i8] c"Can't write all string to FIFO\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i64
%4 = alloca [9 x i8]
store i32 0, i32* %1
%5 = bitcast [9 x i8]* %4 to i8*
%6 = getelementptr inbounds [9 x i8], [9 x i8]* %4, i64 0, i64 0
%7 = load i32, i32* @O_WRONLY
%8 = call i32 @open(i8* %6, i32 %7)
store i32 %8, i32* %2
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %0
%11 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @exit(i32 -1)
unreachable
13: ; preds = %0
%14 = load i32, i32* %2
%15 = call i64 @write(i32 %14, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 14)
store i64 %15, i64* %3
%16 = load i64, i64* %3
%17 = icmp ne i64 %16, 14
br i1 %17, label %18, label %21
18: ; preds = %13
%19 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%20 = call i32 @exit(i32 -1)
unreachable
21: ; preds = %13
%22 = load i32, i32* %2
%23 = call i32 @close(i32 %22)
ret i32 0
}

LLVM IR (-O2):
@__const.main.name = [9 x i8] c"aaa.fifo\00"
@O_WRONLY = global i32 0
@.str.1 = [14 x i8] c"Hello, world!\00"
@str = [31 x i8] c"Can't write all string to FIFO\00"
@str.3 = [29 x i8] c"Can't open FIFO for writting\00"
define i32 @main() {
%1 = alloca [9 x i8]
%2 = getelementptr inbounds [9 x i8], [9 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @O_WRONLY
%4 = call i32 @open(i8* %2, i32 %3)
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %0
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.3, i64 0, i64 0))
%8 = tail call i32 @exit(i32 -1)
unreachable
9: ; preds = %0
%10 = tail call i64 @write(i32 %4, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 14)
%11 = icmp eq i64 %10, 14
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
%14 = tail call i32 @exit(i32 -1)
unreachable
15: ; preds = %9
%16 = tail call i32 @close(i32 %4)
ret i32 0
}