#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*/ free(int *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int getushort(int /*<<< orphan*/ *);
int *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ showgpossublookup(int /*<<< orphan*/ *, int, int,
                                     struct ttfinfo *, int);
void readttfjustmax(char *label, FILE *ttf, int base, int offset,
                    struct ttfinfo *info) {
  int lcnt, i;
  int *offsets;
  if (offset == 0) {
    printf("\t    No %s data\n", label);
    return;
  }
  base += offset;
  fseek(ttf, base, SEEK_SET);
  lcnt = getushort(ttf);
  offsets = malloc(lcnt * sizeof(int));
  printf("\t    %d lookup%s for %s\n", lcnt, lcnt == 1 ? "" : "s", label);
  for (i = 0; i < lcnt; ++i)
    printf("\t\tOffset to lookup %d\n", offsets[i] = getushort(ttf));
  for (i = 0; i < lcnt; ++i)
    showgpossublookup(ttf, base, offsets[i], info, 1);
  free(offsets);
}


x86 assembly (clang, -O0):
<readttfjustmax>:
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    %r8,-0x20(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    119b <readttfjustmax+0x3b>
mov    -0x8(%rbp),%rsi
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1295 <readttfjustmax+0x135>
mov    -0x18(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    0x2e2e(%rip),%rax
mov    (%rax),%edx
call   1070 <fseek@plt>
mov    -0x10(%rbp),%rdi
call   1080 <getushort@plt>
mov    %eax,-0x24(%rbp)
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x24(%rbp),%esi
mov    -0x24(%rbp),%ecx
lea    0xe45(%rip),%rdx
lea    0xe24(%rip),%rax
cmp    $0x1,%ecx
cmove  %rax,%rdx
mov    -0x8(%rbp),%rcx
lea    0xe13(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    124a <readttfjustmax+0xea>
mov    -0x10(%rbp),%rdi
call   1080 <getushort@plt>
mov    %eax,%esi
mov    -0x30(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    %esi,(%rax,%rcx,4)
lea    0xdf7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    120c <readttfjustmax+0xac>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    128c <readttfjustmax+0x12c>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x30(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x20(%rbp),%rcx
mov    $0x1,%r8d
call   1050 <showgpossublookup@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1251 <readttfjustmax+0xf1>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readttfjustmax>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r13
test   %ecx,%ecx
je     1277 <readttfjustmax+0x117>
mov    %r8,%r14
mov    %ecx,%ebx
mov    %rsi,%r15
add    %edx,%ebx
mov    0x2e56(%rip),%rax
mov    (%rax),%edx
mov    %rsi,%rdi
mov    %ebx,%esi
call   1070 <fseek@plt>
mov    %r15,%rdi
call   1080 <getushort@plt>
mov    %eax,%r12d
lea    0x0(,%r12,4),%edi
call   1060 <malloc@plt>
mov    %rax,%rbp
cmp    $0x1,%r12d
lea    0xe54(%rip),%rax
lea    0xe67(%rip),%rdx
cmove  %rax,%rdx
lea    0xe43(%rip),%rdi
mov    %r12d,%esi
mov    %r13,%rcx
xor    %eax,%eax
call   1040 <printf@plt>
test   %r12d,%r12d
jle    1261 <readttfjustmax+0x101>
mov    %ebx,0xc(%rsp)
mov    %r14,0x10(%rsp)
mov    %r12,%rbx
mov    %r12d,%r12d
lea    0xe32(%rip),%r13
xor    %r14d,%r14d
nopl   (%rax)
mov    %r15,%rdi
call   1080 <getushort@plt>
mov    %eax,0x0(%rbp,%r14,4)
mov    %r13,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r14
cmp    %r14,%r12
jne    1200 <readttfjustmax+0xa0>
test   %ebx,%ebx
mov    0x10(%rsp),%r14
mov    0xc(%rsp),%r13d
jle    1261 <readttfjustmax+0x101>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x0(%rbp,%rbx,4),%edx
mov    %r15,%rdi
mov    %r13d,%esi
mov    %r14,%rcx
mov    $0x1,%r8d
call   1050 <showgpossublookup@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1240 <readttfjustmax+0xe0>
mov    %rbp,%rdi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>
lea    0xd82(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
%struct.ttfinfo = type { i32 }
@.str = [17 x i8] c"\09 No %s data\0A\00"
@SEEK_SET = global i32 0
@.str.1 = [25 x i8] c"\09 %d lookup%s for %s\0A\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [2 x i8] c"s\00"
@.str.4 = [23 x i8] c"\09\09Offset to lookup %d\0A\00"
define void @readttfjustmax(i8* %0, i32* %1, i32 %2, i32 %3, %struct.ttfinfo* %4) {
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca %struct.ttfinfo*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32*
store i8* %0, i8** %6
store i32* %1, i32** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store %struct.ttfinfo* %4, %struct.ttfinfo** %10
%14 = load i32, i32* %9
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %5
%17 = load i8*, i8** %6
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %17)
br label %77
19: ; preds = %5
%20 = load i32, i32* %9
%21 = load i32, i32* %8
%22 = add nsw i32 %21, %20
store i32 %22, i32* %8
%23 = load i32*, i32** %7
%24 = load i32, i32* %8
%25 = load i32, i32* @SEEK_SET
%26 = call i32 @fseek(i32* %23, i32 %24, i32 %25)
%27 = load i32*, i32** %7
%28 = call i32 @getushort(i32* %27)
store i32 %28, i32* %11
%29 = load i32, i32* %11
%30 = sext i32 %29 to i64
%31 = mul i64 %30, 4
%32 = trunc i64 %31 to i32
%33 = call i32* @malloc(i32 %32)
store i32* %33, i32** %13
%34 = load i32, i32* %11
%35 = load i32, i32* %11
%36 = icmp eq i32 %35, 1
%37 = zext i1 %36 to i64
%38 = select i1 %36, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0)
%39 = load i8*, i8** %6
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %34, i8* %38, i8* %39)
store i32 0, i32* %12
br label %41
41: ; preds = %53, %19
%42 = load i32, i32* %12
%43 = load i32, i32* %11
%44 = icmp slt i32 %42, %43
br i1 %44, label %45, label %56
45: ; preds = %41
%46 = load i32*, i32** %7
%47 = call i32 @getushort(i32* %46)
%48 = load i32*, i32** %13
%49 = load i32, i32* %12
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i32, i32* %48, i64 %50
store i32 %47, i32* %51
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %47)
br label %53
53: ; preds = %45
%54 = load i32, i32* %12
%55 = add nsw i32 %54, 1
store i32 %55, i32* %12
br label %41
56: ; preds = %41
store i32 0, i32* %12
br label %57
57: ; preds = %71, %56
%58 = load i32, i32* %12
%59 = load i32, i32* %11
%60 = icmp slt i32 %58, %59
br i1 %60, label %61, label %74
61: ; preds = %57
%62 = load i32*, i32** %7
%63 = load i32, i32* %8
%64 = load i32*, i32** %13
%65 = load i32, i32* %12
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i32, i32* %64, i64 %66
%68 = load i32, i32* %67
%69 = load %struct.ttfinfo*, %struct.ttfinfo** %10
%70 = call i32 @showgpossublookup(i32* %62, i32 %63, i32 %68, %struct.ttfinfo* %69, i32 1)
br label %71
71: ; preds = %61
%72 = load i32, i32* %12
%73 = add nsw i32 %72, 1
store i32 %73, i32* %12
br label %57
74: ; preds = %57
%75 = load i32*, i32** %13
%76 = call i32 @free(i32* %75)
br label %77
77: ; preds = %74, %16
ret void
}

LLVM IR (-O2):
%struct.ttfinfo = type { i32 }
@.str = [17 x i8] c"\09 No %s data\0A\00"
@SEEK_SET = global i32 0
@.str.1 = [25 x i8] c"\09 %d lookup%s for %s\0A\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [2 x i8] c"s\00"
@.str.4 = [23 x i8] c"\09\09Offset to lookup %d\0A\00"
define void @readttfjustmax(i8* %0, i32* %1, i32 %2, i32 %3, %struct.ttfinfo* %4) {
%6 = icmp eq i32 %3, 0
br i1 %6, label %7, label %9
7: ; preds = %5
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %41
9: ; preds = %5
%10 = add nsw i32 %3, %2
%11 = load i32, i32* @SEEK_SET
%12 = tail call i32 @fseek(i32* %1, i32 %10, i32 %11)
%13 = tail call i32 @getushort(i32* %1)
%14 = shl i32 %13, 2
%15 = tail call i32* @malloc(i32 %14)
%16 = icmp eq i32 %13, 1
%17 = select i1 %16, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0)
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %13, i8* %17, i8* %0)
%19 = icmp sgt i32 %13, 0
br i1 %19, label %20, label %39
20: ; preds = %9
%21 = zext i32 %13 to i64
br label %25
22: ; preds = %25
br i1 %19, label %23, label %39
23: ; preds = %22
%24 = zext i32 %13 to i64
br label %32
25: ; preds = %20, %25
%26 = phi i64 [ 0, %20 ], [ %30, %25 ]
%27 = tail call i32 @getushort(i32* %1)
%28 = getelementptr inbounds i32, i32* %15, i64 %26
store i32 %27, i32* %28
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %27)
%30 = add nuw nsw i64 %26, 1
%31 = icmp eq i64 %30, %21
br i1 %31, label %22, label %25
32: ; preds = %23, %32
%33 = phi i64 [ 0, %23 ], [ %37, %32 ]
%34 = getelementptr inbounds i32, i32* %15, i64 %33
%35 = load i32, i32* %34
%36 = tail call i32 @showgpossublookup(i32* %1, i32 %10, i32 %35, %struct.ttfinfo* %4, i32 1)
%37 = add nuw nsw i64 %33, 1
%38 = icmp eq i64 %37, %24
br i1 %38, label %39, label %32
39: ; preds = %32, %9, %22
%40 = tail call i32 @free(i32* %15)
br label %41
41: ; preds = %39, %7
ret void
}