#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 */
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ O_WRONLY;
int /*<<< orphan*/ memset(int *, int, int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sleep(int);
int main() {
  int ret, fd;
  int buf[11] = {0};
  fd = open("/tmp/my_fifo", O_WRONLY);
  if (ret < 0)
    printf("Failed to open fifo\n");
  printf("open fifo is ok\n");
  while (1) {
    memset(buf, 0x11, sizeof(buf));
    sleep(1);
  }
  printf("open fifo close\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x2c,%edx
call   1040 <memset@plt>
mov    0x2e72(%rip),%rax
mov    (%rax),%esi
lea    0xe91(%rip),%rdi
call   1050 <open@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    118d <main+0x4d>
lea    0xe85(%rip),%rdi
call   1030 <printf@plt>
lea    0xe8e(%rip),%rdi
call   1030 <printf@plt>
lea    -0x40(%rbp),%rdi
mov    $0x11,%esi
mov    $0x2c,%edx
call   1040 <memset@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
jmp    1199 <main+0x59>

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
xorps  %xmm0,%xmm0
movups %xmm0,0x1c(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
mov    0x2e7b(%rip),%rax
mov    (%rax),%esi
lea    0xe9a(%rip),%rdi
call   1050 <open@plt>
lea    0xe9b(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rbx
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x11,%esi
mov    $0x2c,%edx
call   1040 <memset@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
jmp    1180 <main+0x40>

LLVM IR (-O0):
@.str = [13 x i8] c"/tmp/my_fifo\00"
@O_WRONLY = global i32 0
@.str.1 = [21 x i8] c"Failed to open fifo\0A\00"
@.str.2 = [17 x i8] c"open fifo is ok\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [11 x i32]
store i32 0, i32* %1
%5 = bitcast [11 x i32]* %4 to i8*
%6 = load i32, i32* @O_WRONLY
%7 = call i32 @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %6)
store i32 %7, i32* %3
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %10, %0
%13 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %14
14: ; preds = %12, %14
%15 = getelementptr inbounds [11 x i32], [11 x i32]* %4, i64 0, i64 0
%16 = call i32 @memset(i32* %15, i32 17, i32 44)
%17 = call i32 @sleep(i32 1)
br label %14
}

LLVM IR (-O2):
@.str = [13 x i8] c"/tmp/my_fifo\00"
@O_WRONLY = global i32 0
@str = [16 x i8] c"open fifo is ok\00"
define i32 @main() {
%1 = alloca [11 x i32]
%2 = bitcast [11 x i32]* %1 to i8*
%3 = load i32, i32* @O_WRONLY
%4 = tail call i32 @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%6 = getelementptr inbounds [11 x i32], [11 x i32]* %1, i64 0, i64 0
br label %7
7: ; preds = %7, %0
%8 = call i32 @memset(i32* %6, i32 17, i32 44)
%9 = call i32 @sleep(i32 1)
br label %7
}