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

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ fwrite(char *, int, unsigned int, int /*<<< orphan*/);
int getchar();
int /*<<< orphan*/ putchar(unsigned int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int main(void) {
  char buf[32766];
  unsigned int i, j;
  int c;
  for (i = 0; (c = getchar()) > -1; i++) {
    if (i >= sizeof(buf)) {
      fprintf(stderr, "Error: File too big to fit.\n");
      return 1;
    }
    buf[i] = c;
  }
  putchar(i % 256);
  putchar(i / 256);
  fwrite(buf, 1, i, stdout);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x8020,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8014(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x801c(%rbp)
cmp    $0xffffffff,%eax
jle    11ce <main+0x8e>
mov    -0x8014(%rbp),%eax
cmp    $0x7ffe,%rax
jb     11a5 <main+0x65>
mov    0x2e55(%rip),%rax
mov    (%rax),%edi
lea    0xe6c(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1214 <main+0xd4>
mov    -0x801c(%rbp),%eax
mov    %al,%cl
mov    -0x8014(%rbp),%eax
mov    %cl,-0x8010(%rbp,%rax,1)
mov    -0x8014(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8014(%rbp)
jmp    115c <main+0x1c>
mov    -0x8014(%rbp),%edi
and    $0xff,%edi
call   1030 <putchar@plt>
mov    -0x8014(%rbp),%edi
shr    $0x8,%edi
call   1030 <putchar@plt>
lea    -0x8010(%rbp),%rdi
mov    -0x8014(%rbp),%edx
mov    0x2dd7(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
call   1060 <fwrite@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x8020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x8008,%rsp
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <getchar@plt>
mov    $0x0,%ebx
test   %eax,%eax
js     117b <main+0x3b>
xor    %ebx,%ebx
nopl   (%rax)
cmp    $0x7ffe,%rbx
je     11a7 <main+0x67>
mov    %al,(%rsp,%rbx,1)
add    $0x1,%rbx
xor    %eax,%eax
call   1040 <getchar@plt>
test   %eax,%eax
jns    1160 <main+0x20>
movzbl %bl,%edi
call   1030 <putchar@plt>
mov    %ebx,%edi
shr    $0x8,%edi
call   1030 <putchar@plt>
mov    0x2e44(%rip),%rax
mov    (%rax),%ecx
mov    %rsp,%rdi
mov    $0x1,%esi
mov    %ebx,%edx
call   1060 <fwrite@plt>
jmp    11c1 <main+0x81>
mov    0x2e32(%rip),%rax
mov    (%rax),%edi
lea    0xe49(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8008,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [29 x i8] c"Error: File too big to fit.\0A\00"
@stdout = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [32766 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
br label %6
6: ; preds = %22, %0
%7 = call i32 (...) @getchar()
store i32 %7, i32* %5
%8 = icmp sgt i32 %7, -1
br i1 %8, label %9, label %25
9: ; preds = %6
%10 = load i32, i32* %3
%11 = zext i32 %10 to i64
%12 = icmp uge i64 %11, 32766
br i1 %12, label %13, label %16
13: ; preds = %9
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %1
br label %36
16: ; preds = %9
%17 = load i32, i32* %5
%18 = trunc i32 %17 to i8
%19 = load i32, i32* %3
%20 = zext i32 %19 to i64
%21 = getelementptr inbounds [32766 x i8], [32766 x i8]* %2, i64 0, i64 %20
store i8 %18, i8* %21
br label %22
22: ; preds = %16
%23 = load i32, i32* %3
%24 = add i32 %23, 1
store i32 %24, i32* %3
br label %6
25: ; preds = %6
%26 = load i32, i32* %3
%27 = urem i32 %26, 256
%28 = call i32 @putchar(i32 %27)
%29 = load i32, i32* %3
%30 = udiv i32 %29, 256
%31 = call i32 @putchar(i32 %30)
%32 = getelementptr inbounds [32766 x i8], [32766 x i8]* %2, i64 0, i64 0
%33 = load i32, i32* %3
%34 = load i32, i32* @stdout
%35 = call i32 @fwrite(i8* %32, i32 1, i32 %33, i32 %34)
store i32 0, i32* %1
br label %36
36: ; preds = %25, %13
%37 = load i32, i32* %1
ret i32 %37
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [29 x i8] c"Error: File too big to fit.\0A\00"
@stdout = global i32 0
define i32 @main() {
%1 = alloca [32766 x i8]
%2 = getelementptr inbounds [32766 x i8], [32766 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (...) @getchar()
%4 = icmp sgt i32 %3, -1
br i1 %4, label %5, label %20
5: ; preds = %0, %12
%6 = phi i64 [ %15, %12 ], [ 0, %0 ]
%7 = phi i32 [ %16, %12 ], [ %3, %0 ]
%8 = icmp eq i64 %6, 32766
br i1 %8, label %9, label %12
9: ; preds = %5
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %28
12: ; preds = %5
%13 = trunc i32 %7 to i8
%14 = getelementptr inbounds [32766 x i8], [32766 x i8]* %1, i64 0, i64 %6
store i8 %13, i8* %14
%15 = add nuw nsw i64 %6, 1
%16 = tail call i32 (...) @getchar()
%17 = icmp sgt i32 %16, -1
br i1 %17, label %5, label %18
18: ; preds = %12
%19 = trunc i64 %15 to i32
br label %20
20: ; preds = %18, %0
%21 = phi i32 [ 0, %0 ], [ %19, %18 ]
%22 = and i32 %21, 255
%23 = tail call i32 @putchar(i32 %22)
%24 = lshr i32 %21, 8
%25 = tail call i32 @putchar(i32 %24)
%26 = load i32, i32* @stdout
%27 = call i32 @fwrite(i8* %2, i32 1, i32 %21, i32 %26)
br label %28
28: ; preds = %20, %9
%29 = phi i32 [ 1, %9 ], [ 0, %20 ]
ret i32 %29
}