#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 */
char *addnibble(char *, int);
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int);
double strtod(char *, int /*<<< orphan*/ *);
int readcffthing(FILE *ttf, int *_ival, double *dval, int *operand) {
  char buffer[50], *pt;
  int ch, ival;
  ch = getc(ttf);
  if (ch == 12) {
    *operand = (12 << 8) | getc(ttf);
    return (3);
  } else if (ch <= 21) {
    *operand = ch;
    return (3);
  } else if (ch == 30) {
    pt = buffer;
    do {
      ch = getc(ttf);
      pt = addnibble(pt, ch >> 4);
      pt = addnibble(pt, ch & 0xf);
    } while (pt[-1] != '\0');
    *dval = strtod(buffer, NULL);
    return (2);
  } else if (ch >= 32 && ch <= 246) {
    *_ival = ch - 139;
    return (1);
  } else if (ch >= 247 && ch <= 250) {
    *_ival = ((ch - 247) << 8) + getc(ttf) + 108;
    return (1);
  } else if (ch >= 251 && ch <= 254) {
    *_ival = -((ch - 251) << 8) - getc(ttf) - 108;
    return (1);
  } else if (ch == 28) {
    ival = getc(ttf) << 8;
    *_ival = (short)(ival | getc(ttf));
    return (1);
  } else if (ch == 29) {
    ival = getc(ttf) << 24;
    ival = ival | getc(ttf) << 16;
    ival = ival | getc(ttf) << 8;
    *_ival = (int)(ival | getc(ttf));
    return (1);
  }
  printf("Unexpected value in dictionary %d\n", ch);
  *_ival = 0;
  return (0);
}


x86 assembly (clang, -O0):
<readcffthing>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <getc@plt>
mov    %eax,-0x6c(%rbp)
cmpl   $0xc,-0x6c(%rbp)
jne    1194 <readcffthing+0x54>
mov    -0x10(%rbp),%rdi
call   1060 <getc@plt>
mov    %eax,%ecx
or     $0xc00,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x3,-0x4(%rbp)
jmp    1400 <readcffthing+0x2c0>
cmpl   $0x15,-0x6c(%rbp)
jg     11b3 <readcffthing+0x73>
mov    -0x6c(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x3,-0x4(%rbp)
jmp    1400 <readcffthing+0x2c0>
cmpl   $0x1e,-0x6c(%rbp)
jne    1229 <readcffthing+0xe9>
lea    -0x60(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <getc@plt>
mov    %eax,-0x6c(%rbp)
mov    -0x68(%rbp),%rdi
mov    -0x6c(%rbp),%esi
sar    $0x4,%esi
call   1050 <addnibble@plt>
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rdi
mov    -0x6c(%rbp),%esi
and    $0xf,%esi
call   1050 <addnibble@plt>
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rax
movsbl -0x1(%rax),%eax
cmp    $0x0,%eax
jne    11c5 <readcffthing+0x85>
lea    -0x60(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <strtod@plt>
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x2,-0x4(%rbp)
jmp    1400 <readcffthing+0x2c0>
cmpl   $0x20,-0x6c(%rbp)
jl     125b <readcffthing+0x11b>
cmpl   $0xf6,-0x6c(%rbp)
jg     125b <readcffthing+0x11b>
mov    -0x6c(%rbp),%ecx
sub    $0x8b,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    1400 <readcffthing+0x2c0>
cmpl   $0xf7,-0x6c(%rbp)
jl     12a6 <readcffthing+0x166>
cmpl   $0xfa,-0x6c(%rbp)
jg     12a6 <readcffthing+0x166>
mov    -0x6c(%rbp),%eax
sub    $0xf7,%eax
shl    $0x8,%eax
mov    %eax,-0x74(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <getc@plt>
mov    -0x74(%rbp),%ecx
add    %eax,%ecx
add    $0x6c,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    1400 <readcffthing+0x2c0>
cmpl   $0xfb,-0x6c(%rbp)
jl     12f6 <readcffthing+0x1b6>
cmpl   $0xfe,-0x6c(%rbp)
jg     12f6 <readcffthing+0x1b6>
mov    -0x6c(%rbp),%ecx
sub    $0xfb,%ecx
shl    $0x8,%ecx
xor    %eax,%eax
sub    %ecx,%eax
mov    %eax,-0x78(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <getc@plt>
mov    -0x78(%rbp),%ecx
sub    %eax,%ecx
sub    $0x6c,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    1400 <readcffthing+0x2c0>
cmpl   $0x1c,-0x6c(%rbp)
jne    133a <readcffthing+0x1fa>
mov    -0x10(%rbp),%rdi
call   1060 <getc@plt>
shl    $0x8,%eax
mov    %eax,-0x70(%rbp)
mov    -0x70(%rbp),%eax
mov    %eax,-0x7c(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <getc@plt>
mov    %eax,%ecx
mov    -0x7c(%rbp),%eax
or     %ecx,%eax
movswl %ax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    1400 <readcffthing+0x2c0>
cmpl   $0x1d,-0x6c(%rbp)
jne    13bd <readcffthing+0x27d>
mov    -0x10(%rbp),%rdi
call   1060 <getc@plt>
shl    $0x18,%eax
mov    %eax,-0x70(%rbp)
mov    -0x70(%rbp),%eax
mov    %eax,-0x88(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <getc@plt>
mov    %eax,%ecx
mov    -0x88(%rbp),%eax
shl    $0x10,%ecx
or     %ecx,%eax
mov    %eax,-0x70(%rbp)
mov    -0x70(%rbp),%eax
mov    %eax,-0x84(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <getc@plt>
mov    %eax,%ecx
mov    -0x84(%rbp),%eax
shl    $0x8,%ecx
or     %ecx,%eax
mov    %eax,-0x70(%rbp)
mov    -0x70(%rbp),%eax
mov    %eax,-0x80(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <getc@plt>
mov    -0x80(%rbp),%ecx
or     %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    1400 <readcffthing+0x2c0>
jmp    13c2 <readcffthing+0x282>
jmp    13c7 <readcffthing+0x287>
jmp    13cc <readcffthing+0x28c>
jmp    13d1 <readcffthing+0x291>
jmp    13d6 <readcffthing+0x296>
jmp    13db <readcffthing+0x29b>
jmp    13e0 <readcffthing+0x2a0>
mov    -0x6c(%rbp),%esi
lea    0xc16(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readcffthing>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rcx,%r13
mov    %rdx,%r12
mov    %rsi,%rbx
mov    %rdi,%r14
call   1060 <getc@plt>
cmp    $0xc,%eax
jne    117f <readcffthing+0x3f>
mov    %r14,%rdi
call   1060 <getc@plt>
or     $0xc00,%eax
mov    %eax,0x0(%r13)
mov    $0x3,%eax
jmp    12e2 <readcffthing+0x1a2>
mov    %eax,%r15d
cmp    $0x15,%eax
jg     1195 <readcffthing+0x55>
mov    %r15d,0x0(%r13)
mov    $0x3,%eax
jmp    12e2 <readcffthing+0x1a2>
cmp    $0x1e,%r15d
jne    11e7 <readcffthing+0xa7>
mov    %rsp,%rbx
xchg   %ax,%ax
mov    %r14,%rdi
call   1060 <getc@plt>
mov    %eax,%ebp
mov    %eax,%esi
sar    $0x4,%esi
mov    %rbx,%rdi
call   1050 <addnibble@plt>
and    $0xf,%ebp
mov    %rax,%rdi
mov    %ebp,%esi
call   1050 <addnibble@plt>
mov    %rax,%rbx
cmpb   $0x0,-0x1(%rax)
jne    11a0 <readcffthing+0x60>
mov    %rsp,%rdi
xor    %esi,%esi
call   1030 <strtod@plt>
movsd  %xmm0,(%r12)
mov    $0x2,%eax
jmp    12e2 <readcffthing+0x1a2>
lea    -0x20(%r15),%eax
cmp    $0xd6,%eax
ja     1206 <readcffthing+0xc6>
add    $0xffffff75,%r15d
mov    %r15d,(%rbx)
mov    $0x1,%eax
jmp    12e2 <readcffthing+0x1a2>
lea    -0xf7(%r15),%eax
cmp    $0x3,%eax
ja     1232 <readcffthing+0xf2>
shl    $0x8,%r15d
mov    %r14,%rdi
call   1060 <getc@plt>
add    %r15d,%eax
add    $0xffff096c,%eax
mov    %eax,(%rbx)
mov    $0x1,%eax
jmp    12e2 <readcffthing+0x1a2>
lea    -0xfb(%r15),%eax
cmp    $0x3,%eax
ja     1260 <readcffthing+0x120>
shl    $0x8,%r15d
mov    %r14,%rdi
call   1060 <getc@plt>
add    %r15d,%eax
mov    $0xfa94,%ecx
sub    %eax,%ecx
mov    %ecx,(%rbx)
mov    $0x1,%eax
jmp    12e2 <readcffthing+0x1a2>
cmp    $0x1d,%r15d
je     128b <readcffthing+0x14b>
cmp    $0x1c,%r15d
jne    12cb <readcffthing+0x18b>
mov    %r14,%rdi
call   1060 <getc@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1060 <getc@plt>
shl    $0x18,%ebp
shl    $0x10,%eax
or     %ebp,%eax
sar    $0x10,%eax
jmp    1226 <readcffthing+0xe6>
mov    %r14,%rdi
call   1060 <getc@plt>
mov    %eax,%r15d
shl    $0x18,%r15d
mov    %r14,%rdi
call   1060 <getc@plt>
mov    %eax,%ebp
shl    $0x10,%ebp
or     %r15d,%ebp
mov    %r14,%rdi
call   1060 <getc@plt>
mov    %eax,%r15d
shl    $0x8,%r15d
mov    %r14,%rdi
call   1060 <getc@plt>
or     %r15d,%eax
or     %ebp,%eax
jmp    1226 <readcffthing+0xe6>
lea    0xd2e(%rip),%rdi
mov    %r15d,%esi
call   1040 <printf@plt>
movl   $0x0,(%rbx)
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [35 x i8] c"Unexpected value in dictionary %d\0A\00"
define i32 @readcffthing(i32* %0, i32* %1, double* %2, i32* %3) {
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca double*
%9 = alloca i32*
%10 = alloca [50 x i8]
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
store i32* %0, i32** %6
store i32* %1, i32** %7
store double* %2, double** %8
store i32* %3, i32** %9
%14 = load i32*, i32** %6
%15 = call i32 @getc(i32* %14)
store i32 %15, i32* %12
%16 = load i32, i32* %12
%17 = icmp eq i32 %16, 12
br i1 %17, label %18, label %23
18: ; preds = %4
%19 = load i32*, i32** %6
%20 = call i32 @getc(i32* %19)
%21 = or i32 3072, %20
%22 = load i32*, i32** %9
store i32 %21, i32* %22
store i32 3, i32* %5
br label %143
23: ; preds = %4
%24 = load i32, i32* %12
%25 = icmp sle i32 %24, 21
br i1 %25, label %26, label %29
26: ; preds = %23
%27 = load i32, i32* %12
%28 = load i32*, i32** %9
store i32 %27, i32* %28
store i32 3, i32* %5
br label %143
29: ; preds = %23
%30 = load i32, i32* %12
%31 = icmp eq i32 %30, 30
br i1 %31, label %32, label %55
32: ; preds = %29
%33 = getelementptr inbounds [50 x i8], [50 x i8]* %10, i64 0, i64 0
store i8* %33, i8** %11
br label %34
34: ; preds = %45, %32
%35 = load i32*, i32** %6
%36 = call i32 @getc(i32* %35)
store i32 %36, i32* %12
%37 = load i8*, i8** %11
%38 = load i32, i32* %12
%39 = ashr i32 %38, 4
%40 = call i8* @addnibble(i8* %37, i32 %39)
store i8* %40, i8** %11
%41 = load i8*, i8** %11
%42 = load i32, i32* %12
%43 = and i32 %42, 15
%44 = call i8* @addnibble(i8* %41, i32 %43)
store i8* %44, i8** %11
br label %45
45: ; preds = %34
%46 = load i8*, i8** %11
%47 = getelementptr inbounds i8, i8* %46, i64 -1
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = icmp ne i32 %49, 0
br i1 %50, label %34, label %51
51: ; preds = %45
%52 = getelementptr inbounds [50 x i8], [50 x i8]* %10, i64 0, i64 0
%53 = call double @strtod(i8* %52, i32* null)
%54 = load double*, double** %8
store double %53, double* %54
store i32 2, i32* %5
br label %143
55: ; preds = %29
%56 = load i32, i32* %12
%57 = icmp sge i32 %56, 32
br i1 %57, label %58, label %65
58: ; preds = %55
%59 = load i32, i32* %12
%60 = icmp sle i32 %59, 246
br i1 %60, label %61, label %65
61: ; preds = %58
%62 = load i32, i32* %12
%63 = sub nsw i32 %62, 139
%64 = load i32*, i32** %7
store i32 %63, i32* %64
store i32 1, i32* %5
br label %143
65: ; preds = %58, %55
%66 = load i32, i32* %12
%67 = icmp sge i32 %66, 247
br i1 %67, label %68, label %80
68: ; preds = %65
%69 = load i32, i32* %12
%70 = icmp sle i32 %69, 250
br i1 %70, label %71, label %80
71: ; preds = %68
%72 = load i32, i32* %12
%73 = sub nsw i32 %72, 247
%74 = shl i32 %73, 8
%75 = load i32*, i32** %6
%76 = call i32 @getc(i32* %75)
%77 = add nsw i32 %74, %76
%78 = add nsw i32 %77, 108
%79 = load i32*, i32** %7
store i32 %78, i32* %79
store i32 1, i32* %5
br label %143
80: ; preds = %68, %65
%81 = load i32, i32* %12
%82 = icmp sge i32 %81, 251
br i1 %82, label %83, label %96
83: ; preds = %80
%84 = load i32, i32* %12
%85 = icmp sle i32 %84, 254
br i1 %85, label %86, label %96
86: ; preds = %83
%87 = load i32, i32* %12
%88 = sub nsw i32 %87, 251
%89 = shl i32 %88, 8
%90 = sub nsw i32 0, %89
%91 = load i32*, i32** %6
%92 = call i32 @getc(i32* %91)
%93 = sub nsw i32 %90, %92
%94 = sub nsw i32 %93, 108
%95 = load i32*, i32** %7
store i32 %94, i32* %95
store i32 1, i32* %5
br label %143
96: ; preds = %83, %80
%97 = load i32, i32* %12
%98 = icmp eq i32 %97, 28
br i1 %98, label %99, label %110
99: ; preds = %96
%100 = load i32*, i32** %6
%101 = call i32 @getc(i32* %100)
%102 = shl i32 %101, 8
store i32 %102, i32* %13
%103 = load i32, i32* %13
%104 = load i32*, i32** %6
%105 = call i32 @getc(i32* %104)
%106 = or i32 %103, %105
%107 = trunc i32 %106 to i16
%108 = sext i16 %107 to i32
%109 = load i32*, i32** %7
store i32 %108, i32* %109
store i32 1, i32* %5
br label %143
110: ; preds = %96
%111 = load i32, i32* %12
%112 = icmp eq i32 %111, 29
br i1 %112, label %113, label %132
113: ; preds = %110
%114 = load i32*, i32** %6
%115 = call i32 @getc(i32* %114)
%116 = shl i32 %115, 24
store i32 %116, i32* %13
%117 = load i32, i32* %13
%118 = load i32*, i32** %6
%119 = call i32 @getc(i32* %118)
%120 = shl i32 %119, 16
%121 = or i32 %117, %120
store i32 %121, i32* %13
%122 = load i32, i32* %13
%123 = load i32*, i32** %6
%124 = call i32 @getc(i32* %123)
%125 = shl i32 %124, 8
%126 = or i32 %122, %125
store i32 %126, i32* %13
%127 = load i32, i32* %13
%128 = load i32*, i32** %6
%129 = call i32 @getc(i32* %128)
%130 = or i32 %127, %129
%131 = load i32*, i32** %7
store i32 %130, i32* %131
store i32 1, i32* %5
br label %143
132: ; preds = %110
br label %133
133: ; preds = %132
br label %134
134: ; preds = %133
br label %135
135: ; preds = %134
br label %136
136: ; preds = %135
br label %137
137: ; preds = %136
br label %138
138: ; preds = %137
br label %139
139: ; preds = %138
%140 = load i32, i32* %12
%141 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %140)
%142 = load i32*, i32** %7
store i32 0, i32* %142
store i32 0, i32* %5
br label %143
143: ; preds = %139, %113, %99, %86, %71, %61, %51, %26, %18
%144 = load i32, i32* %5
ret i32 %144
}

LLVM IR (-O2):
@.str = [35 x i8] c"Unexpected value in dictionary %d\0A\00"
define i32 @readcffthing(i32* nocapture %0, i32* nocapture writeonly %1, double* nocapture writeonly %2, i32* nocapture writeonly %3) {
%5 = alloca [50 x i8]
%6 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%7 = tail call i32 @getc(i32* %0)
%8 = icmp eq i32 %7, 12
br i1 %8, label %9, label %12
9: ; preds = %4
%10 = tail call i32 @getc(i32* %0)
%11 = or i32 %10, 3072
store i32 %11, i32* %3
br label %71
12: ; preds = %4
%13 = icmp slt i32 %7, 22
br i1 %13, label %14, label %15
14: ; preds = %12
store i32 %7, i32* %3
br label %71
15: ; preds = %12
%16 = icmp eq i32 %7, 30
br i1 %16, label %17, label %29
17: ; preds = %15, %17
%18 = phi i8* [ %23, %17 ], [ %6, %15 ]
%19 = call i32 @getc(i32* %0)
%20 = ashr i32 %19, 4
%21 = call i8* @addnibble(i8* %18, i32 %20)
%22 = and i32 %19, 15
%23 = call i8* @addnibble(i8* %21, i32 %22)
%24 = getelementptr inbounds i8, i8* %23, i64 -1
%25 = load i8, i8* %24
%26 = icmp eq i8 %25, 0
br i1 %26, label %27, label %17
27: ; preds = %17
%28 = call double @strtod(i8* nocapture %6, i32* null)
store double %28, double* %2
br label %71
29: ; preds = %15
%30 = add nsw i32 %7, -32
%31 = icmp ult i32 %30, 215
br i1 %31, label %32, label %34
32: ; preds = %29
%33 = add nsw i32 %7, -139
store i32 %33, i32* %1
br label %71
34: ; preds = %29
%35 = add nsw i32 %7, -247
%36 = icmp ult i32 %35, 4
br i1 %36, label %37, label %42
37: ; preds = %34
%38 = shl nuw nsw i32 %7, 8
%39 = tail call i32 @getc(i32* %0)
%40 = add nsw i32 %38, -63124
%41 = add i32 %40, %39
store i32 %41, i32* %1
br label %71
42: ; preds = %34
%43 = add nsw i32 %7, -251
%44 = icmp ult i32 %43, 4
br i1 %44, label %45, label %50
45: ; preds = %42
%46 = mul nsw i32 %7, -256
%47 = tail call i32 @getc(i32* %0)
%48 = add nuw nsw i32 %46, 64148
%49 = sub i32 %48, %47
store i32 %49, i32* %1
br label %71
50: ; preds = %42
switch i32 %7, label %69 [
i32 28, label %51
i32 29, label %58
]
51: ; preds = %50
%52 = tail call i32 @getc(i32* %0)
%53 = tail call i32 @getc(i32* %0)
%54 = shl i32 %52, 24
%55 = shl i32 %53, 16
%56 = or i32 %55, %54
%57 = ashr exact i32 %56, 16
store i32 %57, i32* %1
br label %71
58: ; preds = %50
%59 = tail call i32 @getc(i32* %0)
%60 = shl i32 %59, 24
%61 = tail call i32 @getc(i32* %0)
%62 = shl i32 %61, 16
%63 = or i32 %62, %60
%64 = tail call i32 @getc(i32* %0)
%65 = shl i32 %64, 8
%66 = or i32 %63, %65
%67 = tail call i32 @getc(i32* %0)
%68 = or i32 %66, %67
store i32 %68, i32* %1
br label %71
69: ; preds = %50
%70 = tail call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %7)
store i32 0, i32* %1
br label %71
71: ; preds = %69, %58, %51, %45, %37, %32, %27, %14, %9
%72 = phi i32 [ 3, %9 ], [ 3, %14 ], [ 2, %27 ], [ 1, %32 ], [ 1, %37 ], [ 1, %45 ], [ 1, %51 ], [ 1, %58 ], [ 0, %69 ]
ret i32 %72
}