#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);
size_t fread(char *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ fwrite(char *, int, size_t, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
scalar_t__ strcmp(char *, char *);
int strlen(char *);
int /*<<< orphan*/ usage(char *);
int main(int argc, char *argv[]) {
  size_t nread;
  char buf[65536];
  char *utf8bom = "\xef\xbb\xbf";
  if (argc > 1)
    usage(argv[0]);
  nread = fread(buf, 1, strlen(utf8bom), stdin);
  if (nread == 0)
    return 0;
  if (strcmp(buf, utf8bom) != 0)
    fwrite(buf, 1, nread, stdout);
  for (;;) {
    nread = fread(buf, 1, sizeof buf, stdin);
    if (nread < 0)
      exit(1);
    if (nread == 0)
      return 0;
    fwrite(buf, 1, nread, stdout);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10030,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe80(%rip),%rax
mov    %rax,-0x10028(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    119d <main+0x3d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <usage@plt>
lea    -0x10020(%rbp),%rax
mov    %rax,-0x10030(%rbp)
mov    -0x10028(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x10030(%rbp),%rdi
mov    %eax,%edx
mov    0x2e21(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
call   1030 <fread@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11ee <main+0x8e>
movl   $0x0,-0x4(%rbp)
jmp    12a0 <main+0x140>
lea    -0x10020(%rbp),%rdi
mov    -0x10028(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     1229 <main+0xc9>
lea    -0x10020(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    0x2dbb(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
call   1080 <fwrite@plt>
jmp    122e <main+0xce>
lea    -0x10020(%rbp),%rdi
mov    0x2dac(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
mov    $0x10000,%edx
call   1030 <fread@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jae    1266 <main+0x106>
mov    $0x1,%edi
call   1070 <exit@plt>
cmpq   $0x0,-0x18(%rbp)
jne    127d <main+0x11d>
movl   $0x0,-0x4(%rbp)
jmp    12a0 <main+0x140>
lea    -0x10020(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    0x2d49(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
call   1080 <fwrite@plt>
jmp    122e <main+0xce>
mov    -0x4(%rbp),%eax
add    $0x10030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10000,%rsp
cmp    $0x2,%edi
jl     1169 <main+0x19>
mov    (%rsi),%rdi
call   1060 <usage@plt>
lea    0xe90(%rip),%rdi
call   1040 <strlen@plt>
mov    0x2e6c(%rip),%r14
mov    (%r14),%ecx
mov    %rsp,%rdi
mov    $0x1,%esi
mov    %eax,%edx
call   1030 <fread@plt>
test   %rax,%rax
je     121d <main+0xcd>
mov    %rax,%rbx
lea    0xe5f(%rip),%rsi
mov    %rsp,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11c7 <main+0x77>
mov    0x2e23(%rip),%rax
mov    (%rax),%ecx
mov    %rsp,%rdi
mov    $0x1,%esi
mov    %rbx,%rdx
call   1070 <fwrite@plt>
mov    (%r14),%ecx
mov    %rsp,%rdi
mov    $0x1,%esi
mov    $0x10000,%edx
call   1030 <fread@plt>
test   %rax,%rax
je     121d <main+0xcd>
mov    0x2df0(%rip),%r15
mov    %rsp,%rbx
nopl   0x0(%rax,%rax,1)
mov    (%r15),%ecx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %rax,%rdx
call   1070 <fwrite@plt>
mov    (%r14),%ecx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x10000,%edx
call   1030 <fread@plt>
test   %rax,%rax
jne    11f0 <main+0xa0>
xor    %eax,%eax
add    $0x10000,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"\EF\BB\BF\00"
@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 i64
%7 = alloca [65536 x i8]
%8 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %8
%9 = load i32, i32* %4
%10 = icmp sgt i32 %9, 1
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 @usage(i8* %14)
br label %16
16: ; preds = %11, %2
%17 = getelementptr inbounds [65536 x i8], [65536 x i8]* %7, i64 0, i64 0
%18 = load i8*, i8** %8
%19 = call i32 @strlen(i8* %18)
%20 = load i32, i32* @stdin
%21 = call i64 @fread(i8* %17, i32 1, i32 %19, i32 %20)
store i64 %21, i64* %6
%22 = load i64, i64* %6
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %16
store i32 0, i32* %3
br label %53
25: ; preds = %16
%26 = getelementptr inbounds [65536 x i8], [65536 x i8]* %7, i64 0, i64 0
%27 = load i8*, i8** %8
%28 = call i64 @strcmp(i8* %26, i8* %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %35
30: ; preds = %25
%31 = getelementptr inbounds [65536 x i8], [65536 x i8]* %7, i64 0, i64 0
%32 = load i64, i64* %6
%33 = load i32, i32* @stdout
%34 = call i32 @fwrite(i8* %31, i32 1, i64 %32, i32 %33)
br label %35
35: ; preds = %30, %25
br label %36
36: ; preds = %48, %35
%37 = getelementptr inbounds [65536 x i8], [65536 x i8]* %7, i64 0, i64 0
%38 = load i32, i32* @stdin
%39 = call i64 @fread(i8* %37, i32 1, i32 65536, i32 %38)
store i64 %39, i64* %6
%40 = load i64, i64* %6
%41 = icmp ult i64 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %36
%43 = call i32 @exit(i32 1)
unreachable
44: ; preds = %36
%45 = load i64, i64* %6
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %48
47: ; preds = %44
store i32 0, i32* %3
br label %53
48: ; preds = %44
%49 = getelementptr inbounds [65536 x i8], [65536 x i8]* %7, i64 0, i64 0
%50 = load i64, i64* %6
%51 = load i32, i32* @stdout
%52 = call i32 @fwrite(i8* %49, i32 1, i64 %50, i32 %51)
br label %36
53: ; preds = %47, %24
%54 = load i32, i32* %3
ret i32 %54
}

LLVM IR (-O2):
@.str = [4 x i8] c"\EF\BB\BF\00"
@stdin = global i32 0
@stdout = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [65536 x i8]
%4 = getelementptr inbounds [65536 x i8], [65536 x i8]* %3, i64 0, i64 0
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = load i8*, i8** %1
%8 = tail call i32 @usage(i8* %7)
br label %9
9: ; preds = %6, %2
%10 = tail call i32 @strlen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* @stdin
%12 = call i64 @fread(i8* %4, i32 1, i32 %10, i32 %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %31, label %14
14: ; preds = %9
%15 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %14
%18 = load i32, i32* @stdout
%19 = call i32 @fwrite(i8* %4, i32 1, i64 %12, i32 %18)
br label %20
20: ; preds = %17, %14
%21 = load i32, i32* @stdin
%22 = call i64 @fread(i8* %4, i32 1, i32 65536, i32 %21)
%23 = icmp eq i64 %22, 0
br i1 %23, label %31, label %24
24: ; preds = %20, %24
%25 = phi i64 [ %29, %24 ], [ %22, %20 ]
%26 = load i32, i32* @stdout
%27 = call i32 @fwrite(i8* %4, i32 1, i64 %25, i32 %26)
%28 = load i32, i32* @stdin
%29 = call i64 @fread(i8* %4, i32 1, i32 65536, i32 %28)
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %24
31: ; preds = %24, %20, %9
ret i32 0
}