#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*/ exit(int);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  char str[100];
  if (fgets(str, 99, stdin) == NULL) {
    fprintf(stderr, "pipe read failed\n");
    exit(-1);
  }
  printf("blablabla\n");
  fprintf(stdout, "Output: %s\n", str);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x80(%rbp),%rdi
mov    0x2e84(%rip),%rax
mov    (%rax),%edx
mov    $0x63,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
jne    119b <main+0x5b>
mov    0x2e57(%rip),%rax
mov    (%rax),%edi
lea    0xe76(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>
lea    0xe70(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e22(%rip),%rax
mov    (%rax),%edi
lea    -0x80(%rbp),%rdx
lea    0xe62(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x68,%rsp
mov    0x2e9d(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rdi
mov    $0x63,%esi
call   1040 <fgets@plt>
test   %rax,%rax
je     118c <main+0x4c>
lea    0xeb8(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
lea    0xe97(%rip),%rsi
mov    %rsp,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
xor    %eax,%eax
add    $0x68,%rsp
ret
mov    0x2e45(%rip),%rax
mov    (%rax),%edi
lea    0xe64(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stdin = global i32 0
@stderr = global i32 0
@.str = [18 x i8] c"pipe read failed\0A\00"
@.str.1 = [11 x i8] c"blablabla\0A\00"
@stdout = global i32 0
@.str.2 = [12 x i8] c"Output: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [100 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%8 = load i32, i32* @stdin
%9 = call i32* @fgets(i8* %7, i32 99, i32 %8)
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @exit(i32 -1)
unreachable
15: ; preds = %2
%16 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%17 = load i32, i32* @stdout
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%19 = call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %18)
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@stderr = global i32 0
@.str = [18 x i8] c"pipe read failed\0A\00"
@stdout = global i32 0
@.str.2 = [12 x i8] c"Output: %s\0A\00"
@str = [10 x i8] c"blablabla\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%5 = load i32, i32* @stdin
%6 = call i32* @fgets(i8* %4, i32 99, i32 %5)
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @exit(i32 -1)
unreachable
12: ; preds = %2
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
%14 = load i32, i32* @stdout
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %4)
ret i32 0
}