#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 append(FILE *source, FILE *dest) {
  size_t bytes;
  static char temp[4096];
  while ((bytes = fread(temp, sizeof(char), 4096, source)) > 0) {
    fwrite(temp, sizeof(char), bytes, dest);
  }
}


x86 assembly (clang, -O0):
<append>:
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    $0x1000,%edx
call   1030 <fread@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jbe    1176 <append+0x56>
mov    -0x18(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0x2ed9(%rip),%rdi
mov    $0x1,%esi
call   1040 <fwrite@plt>
jmp    1130 <append+0x10>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<append>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
lea    0x2f0e(%rip),%rdi
mov    $0x1,%esi
mov    $0x1000,%edx
mov    %r15,%rcx
call   1030 <fread@plt>
test   %rax,%rax
je     117d <append+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    $0x1000,%edx
mov    %r15,%rcx
call   1030 <fread@plt>
test   %rax,%rax
jne    1150 <append+0x30>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@append.temp = internal global [4096 x i8] zeroinitializer
define void @append(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 ([4096 x i8], [4096 x i8]* @append.temp, i64 0, i64 0), i32 1, i32 4096, i32* %7)
store i64 %8, i64* %5
%9 = icmp ugt 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 ([4096 x i8], [4096 x i8]* @append.temp, i64 0, i64 0), i32 1, i64 %11, i32* %12)
br label %6
14: ; preds = %6
ret void
}

LLVM IR (-O2):
@append.temp = internal global [4096 x i8] zeroinitializer
define void @append(i32* nocapture %0, i32* nocapture %1) {
%3 = tail call i64 @fread(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @append.temp, i64 0, i64 0), i32 1, i32 4096, 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 ([4096 x i8], [4096 x i8]* @append.temp, i64 0, i64 0), i32 1, i64 %6, i32* %1)
%8 = tail call i64 @fread(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @append.temp, i64 0, i64 0), i32 1, i32 4096, i32* %0)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %5
10: ; preds = %5, %2
ret void
}