#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*/ SEEK_SET;
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ putc(int, int /*<<< orphan*/ *);
void copydata(FILE *to, FILE *from, int offset, int len) {
  int i, ch;
  fseek(from, offset, SEEK_SET);
  for (i = 0; i < len; ++i) {
    ch = getc(from);
    putc(ch, to);
  }
}


x86 assembly (clang, -O0):
<copydata>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    0x2e8c(%rip),%rax
mov    (%rax),%edx
call   1040 <fseek@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1194 <copydata+0x64>
mov    -0x10(%rbp),%rdi
call   1050 <getc@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   1030 <putc@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1162 <copydata+0x32>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<copydata>:
push   %r15
push   %r14
push   %rbx
mov    %ecx,%ebx
mov    %rsi,%r14
mov    %rdi,%r15
mov    0x2e9c(%rip),%rax
mov    (%rax),%eax
mov    %rsi,%rdi
mov    %edx,%esi
mov    %eax,%edx
call   1040 <fseek@plt>
test   %ebx,%ebx
jle    1177 <copydata+0x47>
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1050 <getc@plt>
mov    %eax,%edi
mov    %r15,%rsi
call   1030 <putc@plt>
add    $0xffffffff,%ebx
jne    1160 <copydata+0x30>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@SEEK_SET = global i32 0
define void @copydata(i32* %0, i32* %1, i32 %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%11 = load i32*, i32** %6
%12 = load i32, i32* %7
%13 = load i32, i32* @SEEK_SET
%14 = call i32 @fseek(i32* %11, i32 %12, i32 %13)
store i32 0, i32* %9
br label %15
15: ; preds = %25, %4
%16 = load i32, i32* %9
%17 = load i32, i32* %8
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %28
19: ; preds = %15
%20 = load i32*, i32** %6
%21 = call i32 @getc(i32* %20)
store i32 %21, i32* %10
%22 = load i32, i32* %10
%23 = load i32*, i32** %5
%24 = call i32 @putc(i32 %22, i32* %23)
br label %25
25: ; preds = %19
%26 = load i32, i32* %9
%27 = add nsw i32 %26, 1
store i32 %27, i32* %9
br label %15
28: ; preds = %15
ret void
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
define void @copydata(i32* nocapture %0, i32* nocapture %1, i32 %2, i32 %3) {
%5 = load i32, i32* @SEEK_SET
%6 = tail call i32 @fseek(i32* %1, i32 %2, i32 %5)
%7 = icmp sgt i32 %3, 0
br i1 %7, label %8, label %14
8: ; preds = %4, %8
%9 = phi i32 [ %12, %8 ], [ 0, %4 ]
%10 = tail call i32 @getc(i32* %1)
%11 = tail call i32 @putc(i32 %10, i32* %0)
%12 = add nuw nsw i32 %9, 1
%13 = icmp eq i32 %12, %3
br i1 %13, label %14, label %8
14: ; preds = %8, %4
ret void
}