#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 /*<<< orphan*/ 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;
  fread(&val, sizeof(val), 1, stdin);
  fwrite(&zero, sizeof(zero), 1, stdout);
  fwrite(&val, sizeof(val), 1, stdout);
  fread(&val, sizeof(val), 1, stdin);
  fwrite(&zero, sizeof(zero), 1, stdout);
  fwrite(&val, sizeof(val), 1, stdout);
  fread(&val, sizeof(val), 1, stdin);
  fwrite(&val, sizeof(val), 1, stdout);
  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)) {
    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    0x2e68(%rip),%rax
mov    (%rax),%ecx
lea    -0x14(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1050 <fwrite@plt>
mov    0x2e4c(%rip),%rax
mov    (%rax),%ecx
lea    -0x18(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1050 <fwrite@plt>
mov    0x2e40(%rip),%rax
mov    (%rax),%ecx
lea    -0x18(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    0x2e14(%rip),%rax
mov    (%rax),%ecx
lea    -0x14(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1050 <fwrite@plt>
mov    0x2df8(%rip),%rax
mov    (%rax),%ecx
lea    -0x18(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1050 <fwrite@plt>
mov    0x2dec(%rip),%rax
mov    (%rax),%ecx
lea    -0x18(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    0x2dc0(%rip),%rax
mov    (%rax),%ecx
lea    -0x18(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1050 <fwrite@plt>
mov    0x2db4(%rip),%rax
mov    (%rax),%ecx
lea    -0x18(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    0x2d88(%rip),%rax
mov    (%rax),%ecx
lea    -0x18(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1050 <fwrite@plt>
movl   $0x1,-0x18(%rbp)
mov    0x2d65(%rip),%rax
mov    (%rax),%ecx
lea    -0x18(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1050 <fwrite@plt>
mov    0x2d49(%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),%edi
call   1040 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    12c7 <main+0x197>
jmp    131b <main+0x1eb>
mov    0x2d1a(%rip),%rax
mov    (%rax),%ecx
lea    -0x18(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    0x2cfe(%rip),%rax
mov    (%rax),%edi
call   1040 <feof@plt>
cmp    $0x0,%eax
jne    1316 <main+0x1e6>
mov    0x2cd7(%rip),%rax
mov    (%rax),%ecx
lea    -0x18(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1050 <fwrite@plt>
jmp    12a4 <main+0x174>
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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%8 = load i32, i32* @stdin
%9 = call i32 @fread(i32* %7, i32 4, i32 1, i32 %8)
%10 = load i32, i32* @stdout
%11 = call i32 @fwrite(i32* %6, i32 4, i32 1, i32 %10)
%12 = load i32, i32* @stdout
%13 = call i32 @fwrite(i32* %7, i32 4, i32 1, i32 %12)
%14 = load i32, i32* @stdin
%15 = call i32 @fread(i32* %7, i32 4, i32 1, i32 %14)
%16 = load i32, i32* @stdout
%17 = call i32 @fwrite(i32* %6, i32 4, i32 1, i32 %16)
%18 = load i32, i32* @stdout
%19 = call i32 @fwrite(i32* %7, i32 4, i32 1, i32 %18)
%20 = load i32, i32* @stdin
%21 = call i32 @fread(i32* %7, i32 4, i32 1, i32 %20)
%22 = load i32, i32* @stdout
%23 = call i32 @fwrite(i32* %7, i32 4, i32 1, i32 %22)
%24 = load i32, i32* @stdin
%25 = call i32 @fread(i32* %7, i32 4, i32 1, i32 %24)
%26 = load i32, i32* @stdout
%27 = call i32 @fwrite(i32* %7, i32 4, i32 1, i32 %26)
store i32 1, i32* %7
%28 = load i32, i32* @stdout
%29 = call i32 @fwrite(i32* %7, i32 4, i32 1, i32 %28)
%30 = load i32, i32* @stdout
%31 = call i32 @fwrite(i32* %7, i32 4, i32 1, i32 %30)
br label %32
32: ; preds = %46, %2
%33 = load i32, i32* @stdin
%34 = call i32 @feof(i32 %33)
%35 = icmp ne i32 %34, 0
%36 = xor i1 %35, true
br i1 %36, label %37, label %47
37: ; preds = %32
%38 = load i32, i32* @stdin
%39 = call i32 @fread(i32* %7, i32 4, i32 1, i32 %38)
%40 = load i32, i32* @stdin
%41 = call i32 @feof(i32 %40)
%42 = icmp ne i32 %41, 0
br i1 %42, label %46, label %43
43: ; preds = %37
%44 = load i32, i32* @stdout
%45 = call i32 @fwrite(i32* %7, i32 4, i32 1, i32 %44)
br label %46
46: ; preds = %43, %37
br label %32
47: ; preds = %32
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
}