#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 EOF;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ putc(char, int /*<<< orphan*/ *);
int /*<<< orphan*/ putshort(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
void copytable(FILE *ttf, FILE *ttc, int offset, int length) {
  int i, ch;
  fseek(ttc, offset, SEEK_SET);
  for (i = 0; i < length && (ch = getc(ttc)) != EOF; ++i)
    putc(ch, ttf);
  if (ch == EOF)
    fprintf(stderr, "File ended before table\n");
  if (length & 1) {
    putc('\0', ttf);
    ++length;
  }
  if (length & 2) {
    putshort(ttf, 0);
  }
}


x86 assembly (clang, -O0):
<copytable>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%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    0x2e5c(%rip),%rax
mov    (%rax),%edx
call   1060 <fseek@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%ecx
xor    %eax,%eax
cmp    -0x18(%rbp),%ecx
mov    %al,-0x21(%rbp)
jge    11ae <copytable+0x5e>
mov    -0x10(%rbp),%rdi
call   1070 <getc@plt>
mov    %eax,-0x20(%rbp)
mov    0x2e42(%rip),%rcx
cmp    (%rcx),%eax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    11be <copytable+0x6e>
jmp    11db <copytable+0x8b>
mov    -0x20(%rbp),%eax
mov    -0x8(%rbp),%rsi
movsbl %al,%edi
call   1040 <putc@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1182 <copytable+0x32>
mov    -0x20(%rbp),%eax
mov    0x2e03(%rip),%rcx
cmp    (%rcx),%eax
jne    1202 <copytable+0xb2>
mov    0x2de4(%rip),%rax
mov    (%rax),%edi
lea    0xe03(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1225 <copytable+0xd5>
mov    -0x8(%rbp),%rsi
xor    %edi,%edi
call   1040 <putc@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     123f <copytable+0xef>
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
call   1030 <putshort@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<copytable>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %rsi,%r13
mov    %rdi,%r15
mov    0x2e65(%rip),%rax
mov    (%rax),%eax
mov    %rsi,%rdi
mov    %edx,%esi
mov    %eax,%edx
call   1060 <fseek@plt>
test   %r14d,%r14d
jle    11d1 <copytable+0x81>
mov    0x2e63(%rip),%r12
mov    %r14d,%ebp
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
call   1070 <getc@plt>
mov    %eax,%ebx
cmp    (%r12),%eax
je     11b0 <copytable+0x60>
movsbl %bl,%edi
mov    %r15,%rsi
call   1040 <putc@plt>
add    $0xffffffff,%ebp
jne    1190 <copytable+0x40>
cmp    (%r12),%ebx
je     11d1 <copytable+0x81>
test   $0x1,%r14b
jne    11ec <copytable+0x9c>
test   $0x2,%r14b
jne    1200 <copytable+0xb0>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2e00(%rip),%rax
mov    (%rax),%edi
lea    0xe1f(%rip),%rsi
call   1050 <fprintf@plt>
test   $0x1,%r14b
je     11bc <copytable+0x6c>
xor    %edi,%edi
mov    %r15,%rsi
call   1040 <putc@plt>
add    $0x1,%r14d
test   $0x2,%r14b
je     11c2 <copytable+0x72>
mov    %r15,%rdi
xor    %esi,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putshort@plt>

LLVM IR (-O0):
@SEEK_SET = global i32 0
@EOF = global i32 0
@stderr = global i32 0
@.str = [25 x i8] c"File ended before table\0A\00"
define void @copytable(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 = %31, %4
%16 = load i32, i32* %9
%17 = load i32, i32* %8
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %24
19: ; preds = %15
%20 = load i32*, i32** %6
%21 = call i32 @getc(i32* %20)
store i32 %21, i32* %10
%22 = load i32, i32* @EOF
%23 = icmp ne i32 %21, %22
br label %24
24: ; preds = %19, %15
%25 = phi i1 [ false, %15 ], [ %23, %19 ]
br i1 %25, label %26, label %34
26: ; preds = %24
%27 = load i32, i32* %10
%28 = trunc i32 %27 to i8
%29 = load i32*, i32** %5
%30 = call i32 @putc(i8 signext %28, i32* %29)
br label %31
31: ; preds = %26
%32 = load i32, i32* %9
%33 = add nsw i32 %32, 1
store i32 %33, i32* %9
br label %15
34: ; preds = %24
%35 = load i32, i32* %10
%36 = load i32, i32* @EOF
%37 = icmp eq i32 %35, %36
br i1 %37, label %38, label %41
38: ; preds = %34
%39 = load i32, i32* @stderr
%40 = call i32 @fprintf(i32 %39, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
br label %41
41: ; preds = %38, %34
%42 = load i32, i32* %8
%43 = and i32 %42, 1
%44 = icmp ne i32 %43, 0
br i1 %44, label %45, label %50
45: ; preds = %41
%46 = load i32*, i32** %5
%47 = call i32 @putc(i8 signext 0, i32* %46)
%48 = load i32, i32* %8
%49 = add nsw i32 %48, 1
store i32 %49, i32* %8
br label %50
50: ; preds = %45, %41
%51 = load i32, i32* %8
%52 = and i32 %51, 2
%53 = icmp ne i32 %52, 0
br i1 %53, label %54, label %57
54: ; preds = %50
%55 = load i32*, i32** %5
%56 = call i32 @putshort(i32* %55, i32 0)
br label %57
57: ; preds = %54, %50
ret void
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
@EOF = global i32 0
@stderr = global i32 0
@.str = [25 x i8] c"File ended before table\0A\00"
define void @copytable(i32* %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 %21
8: ; preds = %4, %13
%9 = phi i32 [ %16, %13 ], [ 0, %4 ]
%10 = tail call i32 @getc(i32* %1)
%11 = load i32, i32* @EOF
%12 = icmp eq i32 %10, %11
br i1 %12, label %18, label %13
13: ; preds = %8
%14 = trunc i32 %10 to i8
%15 = tail call i32 @putc(i8 signext %14, i32* %0)
%16 = add nuw nsw i32 %9, 1
%17 = icmp eq i32 %16, %3
br i1 %17, label %18, label %8
18: ; preds = %8, %13
%19 = load i32, i32* @EOF
%20 = icmp eq i32 %10, %19
br i1 %20, label %21, label %24
21: ; preds = %4, %18
%22 = load i32, i32* @stderr
%23 = tail call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
br label %24
24: ; preds = %21, %18
%25 = and i32 %3, 1
%26 = icmp eq i32 %25, 0
br i1 %26, label %30, label %27
27: ; preds = %24
%28 = tail call i32 @putc(i8 signext 0, i32* %0)
%29 = add nsw i32 %3, 1
br label %30
30: ; preds = %27, %24
%31 = phi i32 [ %29, %27 ], [ %3, %24 ]
%32 = and i32 %31, 2
%33 = icmp eq i32 %32, 0
br i1 %33, label %36, label %34
34: ; preds = %30
%35 = tail call i32 @putshort(i32* %0, i32 0)
br label %36
36: ; preds = %34, %30
ret void
}