#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 */
scalar_t__ EOF;
int ferror(int /*<<< orphan*/);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
scalar_t__ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int main(void) {
  char x[32];
  if (fgets(x, sizeof x, stdin) == NULL) {
    return ferror(stdin);
  }
  if (fputs(x, stdout) == EOF) {
    return ferror(stdout);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
mov    0x2e9e(%rip),%rax
mov    (%rax),%edx
mov    $0x20,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
jne    1176 <main+0x46>
mov    0x2e81(%rip),%rax
mov    (%rax),%edi
call   1030 <ferror@plt>
mov    %eax,-0x4(%rbp)
jmp    11b5 <main+0x85>
lea    -0x30(%rbp),%rdi
mov    0x2e4f(%rip),%rax
mov    (%rax),%esi
call   1040 <fputs@plt>
mov    0x2e51(%rip),%rcx
cmp    (%rcx),%rax
jne    11ae <main+0x7e>
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
call   1030 <ferror@plt>
mov    %eax,-0x4(%rbp)
jmp    11b5 <main+0x85>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
mov    0x2eac(%rip),%rbx
mov    (%rbx),%edx
mov    %rsp,%rdi
mov    $0x20,%esi
call   1050 <fgets@plt>
test   %rax,%rax
je     1172 <main+0x42>
mov    0x2e79(%rip),%rbx
mov    (%rbx),%esi
mov    %rsp,%rdi
call   1040 <fputs@plt>
mov    %rax,%rcx
mov    0x2e75(%rip),%rdx
xor    %eax,%eax
cmp    (%rdx),%rcx
jne    1179 <main+0x49>
mov    (%rbx),%edi
call   1030 <ferror@plt>
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@stdin = global i32 0
@stdout = global i32 0
@EOF = global i64 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [32 x i8]
store i32 0, i32* %1
%3 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%4 = load i32, i32* @stdin
%5 = call i32* @fgets(i8* %3, i32 32, i32 %4)
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %10
7: ; preds = %0
%8 = load i32, i32* @stdin
%9 = call i32 @ferror(i32 %8)
store i32 %9, i32* %1
br label %20
10: ; preds = %0
%11 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%12 = load i32, i32* @stdout
%13 = call i64 @fputs(i8* %11, i32 %12)
%14 = load i64, i64* @EOF
%15 = icmp eq i64 %13, %14
br i1 %15, label %16, label %19
16: ; preds = %10
%17 = load i32, i32* @stdout
%18 = call i32 @ferror(i32 %17)
store i32 %18, i32* %1
br label %20
19: ; preds = %10
store i32 0, i32* %1
br label %20
20: ; preds = %19, %16, %7
%21 = load i32, i32* %1
ret i32 %21
}

LLVM IR (-O2):
@stdin = global i32 0
@stdout = global i32 0
@EOF = global i64 0
define i32 @main() {
%1 = alloca [32 x i8]
%2 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @stdin
%4 = call i32* @fgets(i8* %2, i32 32, i32 %3)
%5 = icmp eq i32* %4, null
br i1 %5, label %11, label %6
6: ; preds = %0
%7 = load i32, i32* @stdout
%8 = call i64 @fputs(i8* %2, i32 %7)
%9 = load i64, i64* @EOF
%10 = icmp eq i64 %8, %9
br i1 %10, label %11, label %15
11: ; preds = %6, %0
%12 = phi i32* [ @stdin, %0 ], [ @stdout, %6 ]
%13 = load i32, i32* %12
%14 = call i32 @ferror(i32 %13)
br label %15
15: ; preds = %11, %6
%16 = phi i32 [ 0, %6 ], [ %14, %11 ]
ret i32 %16
}