#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
scalar_t__ strcmp(char *, char *);
int main() {
  FILE *fifo;
  char buf[100];
  while (strcmp(buf, "end") != 0) {
    fifo = fopen("myfifo", "a");
    printf(">");
    scanf("%s", buf);
    fprintf(fifo, "%s\n", buf);
    fclose(fifo);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x80(%rbp),%rdi
lea    0xe83(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     11e1 <main+0x81>
lea    0xe71(%rip),%rdi
lea    0xe71(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    0xe63(%rip),%rdi
call   1040 <printf@plt>
lea    -0x80(%rbp),%rsi
lea    0xe55(%rip),%rdi
call   1070 <scanf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x80(%rbp),%rdx
lea    0xe44(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
jmp    1172 <main+0x12>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
lea    0xe8b(%rip),%rsi
mov    %rsp,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11fd <main+0x9d>
lea    0xe82(%rip),%r15
lea    0xe7d(%rip),%r12
mov    %rsp,%rbx
lea    0xe76(%rip),%r13
lea    0xe5f(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xe4d(%rip),%rdi
mov    %r15,%rsi
call   1080 <fopen@plt>
mov    %rax,%r14
mov    $0x3e,%edi
call   1030 <putchar@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
mov    %r14,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
call   1060 <fprintf@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    11b0 <main+0x50>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"end\00"
@.str.1 = [7 x i8] c"myfifo\00"
@.str.2 = [2 x i8] c"a\00"
@.str.3 = [2 x i8] c">\00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca [100 x i8]
store i32 0, i32* %1
br label %4
4: ; preds = %8, %0
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%6 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %18
8: ; preds = %4
%9 = call i32* @fopen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %9, i32** %2
%10 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %11)
%13 = load i32*, i32** %2
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%15 = call i32 @fprintf(i32* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %14)
%16 = load i32*, i32** %2
%17 = call i32 @fclose(i32* %16)
br label %4
18: ; preds = %4
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"end\00"
@.str.1 = [7 x i8] c"myfifo\00"
@.str.2 = [2 x i8] c"a\00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i64 %3, 0
br i1 %4, label %13, label %5
5: ; preds = %0, %5
%6 = call i32* @fopen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @putchar(i32 62)
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %2)
%9 = call i32 @fprintf(i32* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %2)
%10 = call i32 @fclose(i32* %6)
%11 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %5
13: ; preds = %5, %0
ret i32 0
}