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

/* Variables and functions */
size_t fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(char *, int, size_t, int /*<<< orphan*/ *);
void output_file(FILE *in, FILE *out) {
  static char buffer[1024];
  size_t size;
  while ((size = fread(buffer, 1, 1024, in)) != 0) {
    fwrite(buffer, 1, size, out);
  }
}


x86 assembly (clang, -O0):
<output_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rcx
lea    0x2f05(%rip),%rdi
mov    $0x1,%esi
mov    $0x400,%edx
call   1030 <fread@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     1176 <output_file+0x56>
mov    -0x18(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0x2ed9(%rip),%rdi
mov    $0x1,%esi
call   1040 <fwrite@plt>
jmp    1130 <output_file+0x10>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<output_file>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
lea    0x2f0e(%rip),%rdi
mov    $0x1,%esi
mov    $0x400,%edx
mov    %r15,%rcx
call   1030 <fread@plt>
test   %rax,%rax
je     117d <output_file+0x5d>
lea    0x2ef0(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %rax,%rdx
mov    %r14,%rcx
call   1040 <fwrite@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
mov    %r15,%rcx
call   1030 <fread@plt>
test   %rax,%rax
jne    1150 <output_file+0x30>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@output_file.buffer = internal global [1024 x i8] zeroinitializer
define void @output_file(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i64
store i32* %0, i32** %3
store i32* %1, i32** %4
br label %6
6: ; preds = %10, %2
%7 = load i32*, i32** %3
%8 = call i64 @fread(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @output_file.buffer, i64 0, i64 0), i32 1, i32 1024, i32* %7)
store i64 %8, i64* %5
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %6
%11 = load i64, i64* %5
%12 = load i32*, i32** %4
%13 = call i32 @fwrite(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @output_file.buffer, i64 0, i64 0), i32 1, i64 %11, i32* %12)
br label %6
14: ; preds = %6
ret void
}

LLVM IR (-O2):
@output_file.buffer = internal global [1024 x i8] zeroinitializer
define void @output_file(i32* nocapture %0, i32* nocapture %1) {
%3 = tail call i64 @fread(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @output_file.buffer, i64 0, i64 0), i32 1, i32 1024, i32* %0)
%4 = icmp eq i64 %3, 0
br i1 %4, label %10, label %5
5: ; preds = %2, %5
%6 = phi i64 [ %8, %5 ], [ %3, %2 ]
%7 = tail call i32 @fwrite(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @output_file.buffer, i64 0, i64 0), i32 1, i64 %6, i32* %1)
%8 = tail call i64 @fread(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @output_file.buffer, i64 0, i64 0), i32 1, i32 1024, i32* %0)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %5
10: ; preds = %5, %2
ret void
}