#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 */
unsigned int get_revision_code();
int get_model_type(void) {
  unsigned int revision_num = get_revision_code();
  if (!revision_num)
    return 0;
  if (revision_num & 0x800000)
    return (revision_num & 0xff0) >> 4;
  else {
    revision_num &= 0xffffff;
    if (revision_num < 2 || revision_num > 21)
      return 0;
    static const unsigned char type_map[] = {1, 1, 1, 1, 1, 0, 0, 0, 0, 0,
                                             0, 1, 1, 1, 3, 6, 2, 3, 6, 2};
    return type_map[revision_num - 2];
  }
  return 0;
}


x86 assembly (clang, -O0):
<get_model_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <get_revision_code@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1138 <get_model_type+0x28>
movl   $0x0,-0x4(%rbp)
jmp    119f <get_model_type+0x8f>
mov    -0x8(%rbp),%eax
and    $0x800000,%eax
cmp    $0x0,%eax
je     115c <get_model_type+0x4c>
mov    -0x8(%rbp),%eax
and    $0xff0,%eax
shr    $0x4,%eax
mov    %eax,-0x4(%rbp)
jmp    119f <get_model_type+0x8f>
mov    -0x8(%rbp),%eax
and    $0xffffff,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x2,-0x8(%rbp)
jb     117b <get_model_type+0x6b>
cmpl   $0x15,-0x8(%rbp)
jbe    1187 <get_model_type+0x77>
movl   $0x0,-0x4(%rbp)
jmp    119f <get_model_type+0x8f>
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
mov    %eax,%eax
mov    %eax,%ecx
lea    0xe68(%rip),%rax
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_model_type>:
push   %rbx
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <get_revision_code@plt>
test   %eax,%eax
je     1148 <get_model_type+0x38>
test   $0x800000,%eax
jne    1142 <get_model_type+0x32>
and    $0xffffff,%eax
lea    -0x16(%rax),%ecx
cmp    $0xffffffec,%ecx
jb     1148 <get_model_type+0x38>
add    $0xfffffffe,%eax
lea    0xec4(%rip),%rcx
movzbl (%rax,%rcx,1),%ebx
jmp    1148 <get_model_type+0x38>
shr    $0x4,%eax
movzbl %al,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@get_model_type.type_map = internal constant [20 x i8] c"\01\01\01\01\01\00\00\00\00\00\00\01\01\01\03\06\02\03\06\02"
define i32 @get_model_type() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 (...) @get_revision_code()
store i32 %3, i32* %2
%4 = load i32, i32* %2
%5 = icmp ne i32 %4, 0
br i1 %5, label %7, label %6
6: ; preds = %0
store i32 0, i32* %1
br label %31
7: ; preds = %0
%8 = load i32, i32* %2
%9 = and i32 %8, 8388608
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %7
%12 = load i32, i32* %2
%13 = and i32 %12, 4080
%14 = lshr i32 %13, 4
store i32 %14, i32* %1
br label %31
15: ; preds = %7
%16 = load i32, i32* %2
%17 = and i32 %16, 16777215
store i32 %17, i32* %2
%18 = load i32, i32* %2
%19 = icmp ult i32 %18, 2
br i1 %19, label %23, label %20
20: ; preds = %15
%21 = load i32, i32* %2
%22 = icmp ugt i32 %21, 21
br i1 %22, label %23, label %24
23: ; preds = %20, %15
store i32 0, i32* %1
br label %31
24: ; preds = %20
%25 = load i32, i32* %2
%26 = sub i32 %25, 2
%27 = zext i32 %26 to i64
%28 = getelementptr inbounds [20 x i8], [20 x i8]* @get_model_type.type_map, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = zext i8 %29 to i32
store i32 %30, i32* %1
br label %31
31: ; preds = %24, %23, %11, %6
%32 = load i32, i32* %1
ret i32 %32
}

LLVM IR (-O2):
@get_model_type.type_map = internal unnamed_addr constant [20 x i8] c"\01\01\01\01\01\00\00\00\00\00\00\01\01\01\03\06\02\03\06\02"
define i32 @get_model_type() {
%1 = tail call i32 (...) @get_revision_code()
%2 = icmp eq i32 %1, 0
br i1 %2, label %19, label %3
3: ; preds = %0
%4 = and i32 %1, 8388608
%5 = icmp eq i32 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %3
%7 = lshr i32 %1, 4
%8 = and i32 %7, 255
br label %19
9: ; preds = %3
%10 = and i32 %1, 16777215
%11 = add nsw i32 %10, -22
%12 = icmp ult i32 %11, -20
br i1 %12, label %19, label %13
13: ; preds = %9
%14 = add nsw i32 %10, -2
%15 = zext i32 %14 to i64
%16 = getelementptr inbounds [20 x i8], [20 x i8]* @get_model_type.type_map, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = zext i8 %17 to i32
br label %19
19: ; preds = %9, %0, %13, %6
%20 = phi i32 [ %8, %6 ], [ %18, %13 ], [ 0, %0 ], [ 0, %9 ]
ret i32 %20
}