#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 */
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(char *, int, int, int /*<<< orphan*/ *);
int write_file(FILE *target, FILE *source) {
  char buffer[128];
  int read;
  while (!feof(source)) {
    read = fread(buffer, 1, 128, source);
    fwrite(buffer, 1, read, target);
  }
  return !0;
}


x86 assembly (clang, -O0):
<write_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1161 <write_file+0x31>
jmp    11a1 <write_file+0x71>
lea    -0x90(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
mov    $0x80,%edx
call   1030 <fread@plt>
mov    %eax,-0x94(%rbp)
lea    -0x90(%rbp),%rdi
mov    -0x94(%rbp),%edx
mov    -0x8(%rbp),%rcx
mov    $0x1,%esi
call   1050 <fwrite@plt>
jmp    1143 <write_file+0x13>
mov    $0x1,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_file>:
push   %r15
push   %r14
push   %rbx
sub    $0x80,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1040 <feof@plt>
test   %eax,%eax
jne    1193 <write_file+0x63>
mov    %rsp,%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    $0x1,%esi
mov    $0x80,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
mov    %r15,%rdi
mov    $0x1,%esi
mov    %eax,%edx
mov    %r14,%rcx
call   1050 <fwrite@plt>
mov    %rbx,%rdi
call   1040 <feof@plt>
test   %eax,%eax
je     1160 <write_file+0x30>
mov    $0x1,%eax
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @write_file(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca [128 x i8]
%6 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
br label %7
7: ; preds = %12, %2
%8 = load i32*, i32** %4
%9 = call i32 @feof(i32* %8)
%10 = icmp ne i32 %9, 0
%11 = xor i1 %10, true
br i1 %11, label %12, label %20
12: ; preds = %7
%13 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%14 = load i32*, i32** %4
%15 = call i32 @fread(i8* %13, i32 1, i32 128, i32* %14)
store i32 %15, i32* %6
%16 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%17 = load i32, i32* %6
%18 = load i32*, i32** %3
%19 = call i32 @fwrite(i8* %16, i32 1, i32 %17, i32* %18)
br label %7
20: ; preds = %7
ret i32 1
}

LLVM IR (-O2):
define i32 @write_file(i32* nocapture %0, i32* nocapture %1) {
%3 = alloca [128 x i8]
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @feof(i32* %1)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %12
7: ; preds = %2, %7
%8 = call i32 @fread(i8* %4, i32 1, i32 128, i32* %1)
%9 = call i32 @fwrite(i8* %4, i32 1, i32 %8, i32* %0)
%10 = tail call i32 @feof(i32* %1)
%11 = icmp eq i32 %10, 0
br i1 %11, label %7, label %12
12: ; preds = %7, %2
ret i32 1
}