#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 */
struct ttfinfo {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
long getlong(int /*<<< orphan*/ *);
int getushort(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ readttfIndexSubTab(int /*<<< orphan*/ *, long, int, int,
                                      struct ttfinfo *);
void readttfIndexSizeSubTab(FILE *ttf, long offset, long size, long num,
                            struct ttfinfo *info) {
  int i, first, last;
  long here, moreoff;
  fseek(ttf, offset, SEEK_SET);
  for (i = 0; i < num; ++i) {
    printf("\t indexSubTable[%d]\n", i);
    printf("\t  first glyph=%d\n", first = getushort(ttf));
    printf("\t  last glyph=%d\n", last = getushort(ttf));
    printf("\t  additional offset=%d\n", (int)(moreoff = getlong(ttf)));
    here = ftell(ttf);
    readttfIndexSubTab(ttf, offset + moreoff, first, last, info);
    fseek(ttf, here, SEEK_SET);
  }
}


x86 assembly (clang, -O0):
<readttfIndexSizeSubTab>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    0x2e55(%rip),%rax
mov    (%rax),%edx
call   1060 <fseek@plt>
movl   $0x0,-0x2c(%rbp)
movslq -0x2c(%rbp),%rax
cmp    -0x20(%rbp),%rax
jge    1251 <readttfIndexSizeSubTab+0xf1>
mov    -0x2c(%rbp),%esi
lea    0xe4f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1070 <getushort@plt>
mov    %eax,%esi
mov    %esi,-0x30(%rbp)
lea    0xe4a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1070 <getushort@plt>
mov    %eax,%esi
mov    %esi,-0x34(%rbp)
lea    0xe43(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1080 <getlong@plt>
mov    %rax,-0x48(%rbp)
mov    %eax,%esi
lea    0xe3a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1040 <ftell@plt>
mov    %rax,-0x40(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    -0x48(%rbp),%rsi
mov    -0x30(%rbp),%edx
mov    -0x34(%rbp),%ecx
mov    -0x28(%rbp),%r8
call   1050 <readttfIndexSubTab@plt>
mov    -0x8(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    0x2da4(%rip),%rax
mov    (%rax),%edx
call   1060 <fseek@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1199 <readttfIndexSizeSubTab+0x39>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readttfIndexSizeSubTab>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r8,%r14
mov    %rcx,%rbp
mov    %rdi,%r13
mov    0x2e62(%rip),%r15
mov    (%r15),%edx
mov    %rsi,0x20(%rsp)
call   1060 <fseek@plt>
test   %rbp,%rbp
jle    1248 <readttfIndexSizeSubTab+0xe8>
xor    %ebx,%ebx
mov    %r14,0x18(%rsp)
mov    %rbp,0x10(%rsp)
lea    0xe59(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    %r13,%rdi
call   1070 <getushort@plt>
mov    %eax,0xc(%rsp)
lea    0xe54(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %r13,%rdi
call   1070 <getushort@plt>
mov    %eax,%r14d
lea    0xe4e(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %r13,%rdi
call   1080 <getlong@plt>
mov    %r15,%rbp
mov    %rax,%r15
lea    0xe44(%rip),%rdi
mov    %r15d,%esi
call   1030 <printf@plt>
mov    %r13,%rdi
call   1040 <ftell@plt>
mov    %rax,%r12
add    0x20(%rsp),%r15
mov    %r13,%rdi
mov    %r15,%rsi
mov    %rbp,%r15
mov    0xc(%rsp),%edx
mov    %r14d,%ecx
mov    0x10(%rsp),%rbp
mov    0x18(%rsp),%r8
call   1050 <readttfIndexSubTab@plt>
mov    (%r15),%edx
mov    %r13,%rdi
mov    %r12,%rsi
call   1060 <fseek@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    11a0 <readttfIndexSizeSubTab+0x40>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.ttfinfo = type { i32 }
@SEEK_SET = global i32 0
@.str = [21 x i8] c"\09 indexSubTable[%d]\0A\00"
@.str.1 = [19 x i8] c"\09 first glyph=%d\0A\00"
@.str.2 = [18 x i8] c"\09 last glyph=%d\0A\00"
@.str.3 = [25 x i8] c"\09 additional offset=%d\0A\00"
define void @readttfIndexSizeSubTab(i32* %0, i64 %1, i64 %2, i64 %3, %struct.ttfinfo* %4) {
%6 = alloca i32*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca %struct.ttfinfo*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i64
%15 = alloca i64
store i32* %0, i32** %6
store i64 %1, i64* %7
store i64 %2, i64* %8
store i64 %3, i64* %9
store %struct.ttfinfo* %4, %struct.ttfinfo** %10
%16 = load i32*, i32** %6
%17 = load i64, i64* %7
%18 = load i32, i32* @SEEK_SET
%19 = call i32 @fseek(i32* %16, i64 %17, i32 %18)
store i32 0, i32* %11
br label %20
20: ; preds = %52, %5
%21 = load i32, i32* %11
%22 = sext i32 %21 to i64
%23 = load i64, i64* %9
%24 = icmp slt i64 %22, %23
br i1 %24, label %25, label %55
25: ; preds = %20
%26 = load i32, i32* %11
%27 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %26)
%28 = load i32*, i32** %6
%29 = call i32 @getushort(i32* %28)
store i32 %29, i32* %12
%30 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %29)
%31 = load i32*, i32** %6
%32 = call i32 @getushort(i32* %31)
store i32 %32, i32* %13
%33 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %32)
%34 = load i32*, i32** %6
%35 = call i64 @getlong(i32* %34)
store i64 %35, i64* %15
%36 = trunc i64 %35 to i32
%37 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 %36)
%38 = load i32*, i32** %6
%39 = call i64 @ftell(i32* %38)
store i64 %39, i64* %14
%40 = load i32*, i32** %6
%41 = load i64, i64* %7
%42 = load i64, i64* %15
%43 = add nsw i64 %41, %42
%44 = load i32, i32* %12
%45 = load i32, i32* %13
%46 = load %struct.ttfinfo*, %struct.ttfinfo** %10
%47 = call i32 @readttfIndexSubTab(i32* %40, i64 %43, i32 %44, i32 %45, %struct.ttfinfo* %46)
%48 = load i32*, i32** %6
%49 = load i64, i64* %14
%50 = load i32, i32* @SEEK_SET
%51 = call i32 @fseek(i32* %48, i64 %49, i32 %50)
br label %52
52: ; preds = %25
%53 = load i32, i32* %11
%54 = add nsw i32 %53, 1
store i32 %54, i32* %11
br label %20
55: ; preds = %20
ret void
}

LLVM IR (-O2):
%struct.ttfinfo = type { i32 }
@SEEK_SET = global i32 0
@.str = [21 x i8] c"\09 indexSubTable[%d]\0A\00"
@.str.1 = [19 x i8] c"\09 first glyph=%d\0A\00"
@.str.2 = [18 x i8] c"\09 last glyph=%d\0A\00"
@.str.3 = [25 x i8] c"\09 additional offset=%d\0A\00"
define void @readttfIndexSizeSubTab(i32* %0, i64 %1, i64 %2, i64 %3, %struct.ttfinfo* %4) {
%6 = load i32, i32* @SEEK_SET
%7 = tail call i32 @fseek(i32* %0, i64 %1, i32 %6)
%8 = icmp sgt i64 %3, 0
br i1 %8, label %9, label %27
9: ; preds = %5, %9
%10 = phi i64 [ %25, %9 ], [ 0, %5 ]
%11 = trunc i64 %10 to i32
%12 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = tail call i32 @getushort(i32* %0)
%14 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%15 = tail call i32 @getushort(i32* %0)
%16 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = tail call i64 @getlong(i32* %0)
%18 = trunc i64 %17 to i32
%19 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 %18)
%20 = tail call i64 @ftell(i32* %0)
%21 = add nsw i64 %17, %1
%22 = tail call i32 @readttfIndexSubTab(i32* %0, i64 %21, i32 %13, i32 %15, %struct.ttfinfo* %4)
%23 = load i32, i32* @SEEK_SET
%24 = tail call i32 @fseek(i32* %0, i64 %20, i32 %23)
%25 = add nuw nsw i64 %10, 1
%26 = icmp eq i64 %25, %3
br i1 %26, label %27, label %9
27: ; preds = %9, %5
ret void
}