#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*/ zero;
typedef int /*<<< orphan*/ val;
typedef int uint8_t;

/* Variables and functions */
int /*<<< orphan*/ feof(int /*<<< orphan*/);
int fread(int *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ fwrite(int *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  uint8_t zero = 0;
  uint8_t val;
  int ret;
  ret = fread(&val, sizeof(val), 1, stdin);
  fwrite(&zero, sizeof(zero), 1, stdout);
  fwrite(&val, sizeof(val), 1, stdout);
  ret = fread(&val, sizeof(val), 1, stdin);
  fwrite(&zero, sizeof(zero), 1, stdout);
  fwrite(&val, sizeof(val), 1, stdout);
  ret = fread(&val, sizeof(val), 1, stdin);
  fwrite(&val, sizeof(val), 1, stdout);
  ret = fread(&val, sizeof(val), 1, stdin);
  fwrite(&val, sizeof(val), 1, stdout);
  val = 1;
  fwrite(&val, sizeof(val), 1, stdout);
  fwrite(&val, sizeof(val), 1, stdout);
  while (!feof(stdin)) {
    ret = fread(&val, sizeof(val), 1, stdin);
    if (!feof(stdin)) {
      fwrite(&val, sizeof(val), 1, stdout);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    0x2e94(%rip),%rax
mov    (%rax),%ecx
lea    -0x18(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2e65(%rip),%rax
mov    (%rax),%ecx
lea    -0x14(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1050 <fwrite@plt>
mov    0x2e49(%rip),%rax
mov    (%rax),%ecx
lea    -0x18(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1050 <fwrite@plt>
mov    0x2e3d(%rip),%rax
mov    (%rax),%ecx
lea    -0x18(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2e0e(%rip),%rax
mov    (%rax),%ecx
lea    -0x14(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1050 <fwrite@plt>
mov    0x2df2(%rip),%rax
mov    (%rax),%ecx
lea    -0x18(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1050 <fwrite@plt>
mov    0x2de6(%rip),%rax
mov    (%rax),%ecx
lea    -0x18(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2db7(%rip),%rax
mov    (%rax),%ecx
lea    -0x18(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1050 <fwrite@plt>
mov    0x2dab(%rip),%rax
mov    (%rax),%ecx
lea    -0x18(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2d7c(%rip),%rax
mov    (%rax),%ecx
lea    -0x18(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1050 <fwrite@plt>
movl   $0x1,-0x18(%rbp)
mov    0x2d59(%rip),%rax
mov    (%rax),%ecx
lea    -0x18(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1050 <fwrite@plt>
mov    0x2d3d(%rip),%rax
mov    (%rax),%ecx
lea    -0x18(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1050 <fwrite@plt>
mov    0x2d31(%rip),%rax
mov    (%rax),%edi
call   1040 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    12d3 <main+0x1a3>
jmp    132a <main+0x1fa>
mov    0x2d0e(%rip),%rax
mov    (%rax),%ecx
lea    -0x18(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2cef(%rip),%rax
mov    (%rax),%edi
call   1040 <feof@plt>
cmp    $0x0,%eax
jne    1325 <main+0x1f5>
mov    0x2cc8(%rip),%rax
mov    (%rax),%ecx
lea    -0x18(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1050 <fwrite@plt>
jmp    12b0 <main+0x180>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
movl   $0x0,0x4(%rsp)
mov    0x2ea1(%rip),%r15
mov    (%r15),%ecx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    0x2e72(%rip),%r12
mov    (%r12),%ecx
lea    0x4(%rsp),%r14
mov    %r14,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1050 <fwrite@plt>
mov    (%r12),%ecx
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1050 <fwrite@plt>
mov    (%r15),%ecx
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    (%r12),%ecx
mov    %r14,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1050 <fwrite@plt>
mov    (%r12),%ecx
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1050 <fwrite@plt>
mov    (%r15),%ecx
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    (%r12),%ecx
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1050 <fwrite@plt>
mov    (%r15),%ecx
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    (%r12),%ecx
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1050 <fwrite@plt>
movl   $0x1,(%rsp)
mov    (%r12),%ecx
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1050 <fwrite@plt>
mov    (%r12),%ecx
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1050 <fwrite@plt>
mov    (%r15),%edi
call   1040 <feof@plt>
test   %eax,%eax
je     127b <main+0x14b>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    %rsp,%rbx
jmp    128c <main+0x15c>
mov    (%r15),%edi
call   1040 <feof@plt>
test   %eax,%eax
jne    126d <main+0x13d>
mov    (%r15),%ecx
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    (%r15),%edi
call   1040 <feof@plt>
test   %eax,%eax
jne    1280 <main+0x150>
mov    (%r12),%ecx
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1050 <fwrite@plt>
jmp    1280 <main+0x150>

LLVM IR (-O0):
@stdin = global i32 0
@stdout = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%9 = load i32, i32* @stdin
%10 = call i32 @fread(i32* %7, i32 4, i32 1, i32 %9)
store i32 %10, i32* %8
%11 = load i32, i32* @stdout
%12 = call i32 @fwrite(i32* %6, i32 4, i32 1, i32 %11)
%13 = load i32, i32* @stdout
%14 = call i32 @fwrite(i32* %7, i32 4, i32 1, i32 %13)
%15 = load i32, i32* @stdin
%16 = call i32 @fread(i32* %7, i32 4, i32 1, i32 %15)
store i32 %16, i32* %8
%17 = load i32, i32* @stdout
%18 = call i32 @fwrite(i32* %6, i32 4, i32 1, i32 %17)
%19 = load i32, i32* @stdout
%20 = call i32 @fwrite(i32* %7, i32 4, i32 1, i32 %19)
%21 = load i32, i32* @stdin
%22 = call i32 @fread(i32* %7, i32 4, i32 1, i32 %21)
store i32 %22, i32* %8
%23 = load i32, i32* @stdout
%24 = call i32 @fwrite(i32* %7, i32 4, i32 1, i32 %23)
%25 = load i32, i32* @stdin
%26 = call i32 @fread(i32* %7, i32 4, i32 1, i32 %25)
store i32 %26, i32* %8
%27 = load i32, i32* @stdout
%28 = call i32 @fwrite(i32* %7, i32 4, i32 1, i32 %27)
store i32 1, i32* %7
%29 = load i32, i32* @stdout
%30 = call i32 @fwrite(i32* %7, i32 4, i32 1, i32 %29)
%31 = load i32, i32* @stdout
%32 = call i32 @fwrite(i32* %7, i32 4, i32 1, i32 %31)
br label %33
33: ; preds = %47, %2
%34 = load i32, i32* @stdin
%35 = call i32 @feof(i32 %34)
%36 = icmp ne i32 %35, 0
%37 = xor i1 %36, true
br i1 %37, label %38, label %48
38: ; preds = %33
%39 = load i32, i32* @stdin
%40 = call i32 @fread(i32* %7, i32 4, i32 1, i32 %39)
store i32 %40, i32* %8
%41 = load i32, i32* @stdin
%42 = call i32 @feof(i32 %41)
%43 = icmp ne i32 %42, 0
br i1 %43, label %47, label %44
44: ; preds = %38
%45 = load i32, i32* @stdout
%46 = call i32 @fwrite(i32* %7, i32 4, i32 1, i32 %45)
br label %47
47: ; preds = %44, %38
br label %33
48: ; preds = %33
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@stdout = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%6 = bitcast i32* %4 to i8*
%7 = load i32, i32* @stdin
%8 = call i32 @fread(i32* %4, i32 4, i32 1, i32 %7)
%9 = load i32, i32* @stdout
%10 = call i32 @fwrite(i32* %3, i32 4, i32 1, i32 %9)
%11 = load i32, i32* @stdout
%12 = call i32 @fwrite(i32* %4, i32 4, i32 1, i32 %11)
%13 = load i32, i32* @stdin
%14 = call i32 @fread(i32* %4, i32 4, i32 1, i32 %13)
%15 = load i32, i32* @stdout
%16 = call i32 @fwrite(i32* %3, i32 4, i32 1, i32 %15)
%17 = load i32, i32* @stdout
%18 = call i32 @fwrite(i32* %4, i32 4, i32 1, i32 %17)
%19 = load i32, i32* @stdin
%20 = call i32 @fread(i32* %4, i32 4, i32 1, i32 %19)
%21 = load i32, i32* @stdout
%22 = call i32 @fwrite(i32* %4, i32 4, i32 1, i32 %21)
%23 = load i32, i32* @stdin
%24 = call i32 @fread(i32* %4, i32 4, i32 1, i32 %23)
%25 = load i32, i32* @stdout
%26 = call i32 @fwrite(i32* %4, i32 4, i32 1, i32 %25)
store i32 1, i32* %4
%27 = load i32, i32* @stdout
%28 = call i32 @fwrite(i32* %4, i32 4, i32 1, i32 %27)
%29 = load i32, i32* @stdout
%30 = call i32 @fwrite(i32* %4, i32 4, i32 1, i32 %29)
%31 = load i32, i32* @stdin
%32 = call i32 @feof(i32 %31)
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %47
34: ; preds = %2, %43
%35 = load i32, i32* @stdin
%36 = call i32 @fread(i32* %4, i32 4, i32 1, i32 %35)
%37 = load i32, i32* @stdin
%38 = call i32 @feof(i32 %37)
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %43
40: ; preds = %34
%41 = load i32, i32* @stdout
%42 = call i32 @fwrite(i32* %4, i32 4, i32 1, i32 %41)
br label %43
43: ; preds = %40, %34
%44 = load i32, i32* @stdin
%45 = call i32 @feof(i32 %44)
%46 = icmp eq i32 %45, 0
br i1 %46, label %34, label %47
47: ; preds = %43, %2
ret i32 0
}