#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, int off_to, FILE *from, int off_from, int len) {
  int ch, i;
  fseek(to, off_to, SEEK_SET);
  fseek(from, off_from, 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    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    0x2e88(%rip),%rax
mov    (%rax),%edx
call   1040 <fseek@plt>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    0x2e73(%rip),%rax
mov    (%rax),%edx
call   1040 <fseek@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    11ad <copydata+0x7d>
mov    -0x18(%rbp),%rdi
call   1050 <getc@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   1030 <putc@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    117b <copydata+0x4b>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<copydata>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8d,%ebx
mov    %ecx,%ebp
mov    %rdx,%r14
mov    %rdi,%r15
mov    0x2e96(%rip),%r12
mov    (%r12),%edx
call   1040 <fseek@plt>
mov    (%r12),%edx
mov    %r14,%rdi
mov    %ebp,%esi
call   1040 <fseek@plt>
test   %ebx,%ebx
jle    1187 <copydata+0x57>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
call   1050 <getc@plt>
mov    %eax,%edi
mov    %r15,%rsi
call   1030 <putc@plt>
add    $0xffffffff,%ebx
jne    1170 <copydata+0x40>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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