#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 */

/* Variables and functions */
int get16();
int get8();
int get8u();
int tga_test(void) {
  int sz;
  get8u();
  sz = get8u();
  if (sz > 1)
    return 0;
  sz = get8u();
  if ((sz != 1) && (sz != 2) && (sz != 3) && (sz != 9) && (sz != 10) &&
      (sz != 11))
    return 0;
  get16();
  get16();
  get8();
  get16();
  get16();
  if (get16() < 1)
    return 0;
  if (get16() < 1)
    return 0;
  sz = get8();
  if ((sz != 8) && (sz != 16) && (sz != 24) && (sz != 32))
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<tga_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <get8u@plt>
mov    $0x0,%al
call   1030 <get8u@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    115f <tga_test+0x2f>
movl   $0x0,-0x4(%rbp)
jmp    1251 <tga_test+0x121>
mov    $0x0,%al
call   1030 <get8u@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x1,-0x8(%rbp)
je     11b1 <tga_test+0x81>
cmpl   $0x2,-0x8(%rbp)
je     11b1 <tga_test+0x81>
cmpl   $0x3,-0x8(%rbp)
je     11b1 <tga_test+0x81>
cmpl   $0x9,-0x8(%rbp)
je     11b1 <tga_test+0x81>
cmpl   $0xa,-0x8(%rbp)
je     11b1 <tga_test+0x81>
cmpl   $0xb,-0x8(%rbp)
je     11b1 <tga_test+0x81>
movl   $0x0,-0x4(%rbp)
jmp    1251 <tga_test+0x121>
mov    $0x0,%al
call   1050 <get16@plt>
mov    $0x0,%al
call   1050 <get16@plt>
mov    $0x0,%al
call   1040 <get8@plt>
mov    $0x0,%al
call   1050 <get16@plt>
mov    $0x0,%al
call   1050 <get16@plt>
mov    $0x0,%al
call   1050 <get16@plt>
cmp    $0x1,%eax
jge    11f0 <tga_test+0xc0>
movl   $0x0,-0x4(%rbp)
jmp    1251 <tga_test+0x121>
mov    $0x0,%al
call   1050 <get16@plt>
cmp    $0x1,%eax
jge    120c <tga_test+0xdc>
movl   $0x0,-0x4(%rbp)
jmp    1251 <tga_test+0x121>
mov    $0x0,%al
call   1040 <get8@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x8,-0x8(%rbp)
je     124a <tga_test+0x11a>
cmpl   $0x10,-0x8(%rbp)
je     124a <tga_test+0x11a>
cmpl   $0x18,-0x8(%rbp)
je     124a <tga_test+0x11a>
cmpl   $0x20,-0x8(%rbp)
je     124a <tga_test+0x11a>
movl   $0x0,-0x4(%rbp)
jmp    1251 <tga_test+0x121>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tga_test>:
push   %rbx
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <get8u@plt>
xor    %eax,%eax
call   1030 <get8u@plt>
cmp    $0x1,%eax
jg     11b0 <tga_test+0x80>
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <get8u@plt>
cmp    $0xb,%eax
ja     11b0 <tga_test+0x80>
mov    $0xe0e,%ecx
bt     %eax,%ecx
jae    11b0 <tga_test+0x80>
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <get16@plt>
xor    %eax,%eax
call   1050 <get16@plt>
xor    %eax,%eax
call   1040 <get8@plt>
xor    %eax,%eax
call   1050 <get16@plt>
xor    %eax,%eax
call   1050 <get16@plt>
xor    %eax,%eax
call   1050 <get16@plt>
test   %eax,%eax
jle    11b0 <tga_test+0x80>
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <get16@plt>
test   %eax,%eax
jle    11b0 <tga_test+0x80>
xor    %eax,%eax
call   1040 <get8@plt>
add    $0xfffffff8,%eax
rol    $0x1d,%eax
xor    %ebx,%ebx
cmp    $0x4,%eax
setb   %bl
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @tga_test() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 (...) @get8u()
%4 = call i32 (...) @get8u()
store i32 %4, i32* %2
%5 = load i32, i32* %2
%6 = icmp sgt i32 %5, 1
br i1 %6, label %7, label %8
7: ; preds = %0
store i32 0, i32* %1
br label %56
8: ; preds = %0
%9 = call i32 (...) @get8u()
store i32 %9, i32* %2
%10 = load i32, i32* %2
%11 = icmp ne i32 %10, 1
br i1 %11, label %12, label %28
12: ; preds = %8
%13 = load i32, i32* %2
%14 = icmp ne i32 %13, 2
br i1 %14, label %15, label %28
15: ; preds = %12
%16 = load i32, i32* %2
%17 = icmp ne i32 %16, 3
br i1 %17, label %18, label %28
18: ; preds = %15
%19 = load i32, i32* %2
%20 = icmp ne i32 %19, 9
br i1 %20, label %21, label %28
21: ; preds = %18
%22 = load i32, i32* %2
%23 = icmp ne i32 %22, 10
br i1 %23, label %24, label %28
24: ; preds = %21
%25 = load i32, i32* %2
%26 = icmp ne i32 %25, 11
br i1 %26, label %27, label %28
27: ; preds = %24
store i32 0, i32* %1
br label %56
28: ; preds = %24, %21, %18, %15, %12, %8
%29 = call i32 (...) @get16()
%30 = call i32 (...) @get16()
%31 = call i32 (...) @get8()
%32 = call i32 (...) @get16()
%33 = call i32 (...) @get16()
%34 = call i32 (...) @get16()
%35 = icmp slt i32 %34, 1
br i1 %35, label %36, label %37
36: ; preds = %28
store i32 0, i32* %1
br label %56
37: ; preds = %28
%38 = call i32 (...) @get16()
%39 = icmp slt i32 %38, 1
br i1 %39, label %40, label %41
40: ; preds = %37
store i32 0, i32* %1
br label %56
41: ; preds = %37
%42 = call i32 (...) @get8()
store i32 %42, i32* %2
%43 = load i32, i32* %2
%44 = icmp ne i32 %43, 8
br i1 %44, label %45, label %55
45: ; preds = %41
%46 = load i32, i32* %2
%47 = icmp ne i32 %46, 16
br i1 %47, label %48, label %55
48: ; preds = %45
%49 = load i32, i32* %2
%50 = icmp ne i32 %49, 24
br i1 %50, label %51, label %55
51: ; preds = %48
%52 = load i32, i32* %2
%53 = icmp ne i32 %52, 32
br i1 %53, label %54, label %55
54: ; preds = %51
store i32 0, i32* %1
br label %56
55: ; preds = %51, %48, %45, %41
store i32 1, i32* %1
br label %56
56: ; preds = %55, %54, %40, %36, %27, %7
%57 = load i32, i32* %1
ret i32 %57
}

LLVM IR (-O2):
define i32 @tga_test() {
%1 = tail call i32 (...) @get8u()
%2 = tail call i32 (...) @get8u()
%3 = icmp sgt i32 %2, 1
br i1 %3, label %23, label %4
4: ; preds = %0
%5 = tail call i32 (...) @get8u()
switch i32 %5, label %23 [
i32 11, label %6
i32 10, label %6
i32 9, label %6
i32 3, label %6
i32 2, label %6
i32 1, label %6
]
6: ; preds = %4, %4, %4, %4, %4, %4
%7 = tail call i32 (...) @get16()
%8 = tail call i32 (...) @get16()
%9 = tail call i32 (...) @get8()
%10 = tail call i32 (...) @get16()
%11 = tail call i32 (...) @get16()
%12 = tail call i32 (...) @get16()
%13 = icmp slt i32 %12, 1
br i1 %13, label %23, label %14
14: ; preds = %6
%15 = tail call i32 (...) @get16()
%16 = icmp slt i32 %15, 1
br i1 %16, label %23, label %17
17: ; preds = %14
%18 = tail call i32 (...) @get8()
%19 = add i32 %18, -8
%20 = tail call i32 @llvm.fshl.i32(i32 %19, i32 %19, i32 29)
%21 = icmp ult i32 %20, 4
%22 = zext i1 %21 to i32
br label %23
23: ; preds = %17, %14, %6, %4, %0
%24 = phi i32 [ 0, %0 ], [ 0, %4 ], [ 0, %6 ], [ 0, %14 ], [ %22, %17 ]
ret i32 %24
}