#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 */
char EOF;
int /*<<< orphan*/ SEEK_END;
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
void copiar(FILE *f1, FILE *f2) {
  char ch;
  fseek(f2, 0, SEEK_END);
  while ((ch = fgetc(f1)) != EOF) {
    fprintf(f2, "%c", ch);
  }
}


x86 assembly (clang, -O0):
<copiar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e9d(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1050 <fseek@plt>
mov    -0x8(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0x11(%rbp)
movsbl %al,%eax
mov    0x2e76(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     118e <copiar+0x5e>
mov    -0x10(%rbp),%rdi
lea    0xe80(%rip),%rsi
movsbl -0x11(%rbp),%edx
call   1040 <fprintf@plt>
jmp    1154 <copiar+0x24>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<copiar>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
mov    0x2ea6(%rip),%rax
mov    (%rax),%edx
mov    %rsi,%rdi
xor    %esi,%esi
call   1050 <fseek@plt>
mov    %rbx,%rdi
call   1030 <fgetc@plt>
mov    0x2e83(%rip),%r15
cmp    (%r15),%al
je     1188 <copiar+0x58>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl %al,%edi
mov    %r14,%rsi
call   1040 <fputc@plt>
mov    %rbx,%rdi
call   1030 <fgetc@plt>
cmp    (%r15),%al
jne    1170 <copiar+0x40>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@SEEK_END = global i32 0
@EOF = global i8 0
@.str = [3 x i8] c"%c\00"
define void @copiar(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i8
store i32* %0, i32** %3
store i32* %1, i32** %4
%6 = load i32*, i32** %4
%7 = load i32, i32* @SEEK_END
%8 = call i32 @fseek(i32* %6, i32 0, i32 %7)
br label %9
9: ; preds = %16, %2
%10 = load i32*, i32** %3
%11 = call signext i8 @fgetc(i32* %10)
store i8 %11, i8* %5
%12 = sext i8 %11 to i32
%13 = load i8, i8* @EOF
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %12, %14
br i1 %15, label %16, label %20
16: ; preds = %9
%17 = load i32*, i32** %4
%18 = load i8, i8* %5
%19 = call i32 @fprintf(i32* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %18)
br label %9
20: ; preds = %9
ret void
}

LLVM IR (-O2):
@SEEK_END = global i32 0
@EOF = global i8 0
define void @copiar(i32* nocapture %0, i32* nocapture %1) {
%3 = load i32, i32* @SEEK_END
%4 = tail call i32 @fseek(i32* %1, i32 0, i32 %3)
%5 = tail call signext i8 @fgetc(i32* %0)
%6 = load i8, i8* @EOF
%7 = icmp eq i8 %5, %6
br i1 %7, label %15, label %8
8: ; preds = %2, %8
%9 = phi i8 [ %12, %8 ], [ %5, %2 ]
%10 = sext i8 %9 to i32
%11 = tail call i32 @fputc(i32 %10, i32* %1)
%12 = tail call signext i8 @fgetc(i32* %0)
%13 = load i8, i8* @EOF
%14 = icmp eq i8 %12, %13
br i1 %14, label %15, label %8
15: ; preds = %8, %2
ret void
}