#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 /*<<< orphan*/ printf(char *);
int getRomSize(int sizeCode) {
  int size = 0;
  switch (sizeCode) {
  case 0:
  case 1:
  case 2:
  case 3:
  case 4:
  case 5:
  case 6:
  case 7:
    size = (32 << sizeCode) * 0x400;
    break;
  case 0x52:
    size = 1152 * 0x400;
    break;
  case 0x53:
    size = 1280 * 0x400;
    break;
  case 0x54:
    size = 1536 * 0x400;
    break;
  default:
    size = 128 * 0x400;
    printf("Unknown ROM size code\n");
    break;
  }
  return size;
}


x86 assembly (clang, -O0):
<getRomSize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    %rax,-0x10(%rbp)
sub    $0x54,%rax
ja     1180 <getRomSize+0x70>
mov    -0x10(%rbp),%rax
lea    0xec2(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x4(%rbp),%ecx
mov    $0x20,%eax
shl    %cl,%eax
shl    $0xa,%eax
mov    %eax,-0x8(%rbp)
jmp    1193 <getRomSize+0x83>
movl   $0x120000,-0x8(%rbp)
jmp    1193 <getRomSize+0x83>
movl   $0x140000,-0x8(%rbp)
jmp    1193 <getRomSize+0x83>
movl   $0x180000,-0x8(%rbp)
jmp    1193 <getRomSize+0x83>
movl   $0x20000,-0x8(%rbp)
lea    0xfc6(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getRomSize>:
cmp    $0x8,%edi
jae    111f <getRomSize+0xf>
mov    $0x8000,%eax
mov    %edi,%ecx
shl    %cl,%eax
ret
cmp    $0x52,%edi
je     1134 <getRomSize+0x24>
cmp    $0x53,%edi
je     113a <getRomSize+0x2a>
cmp    $0x54,%edi
jne    1140 <getRomSize+0x30>
mov    $0x180000,%eax
ret
mov    $0x120000,%eax
ret
mov    $0x140000,%eax
ret
push   %rax
lea    0xeb8(%rip),%rdi
call   1030 <puts@plt>
mov    $0x20000,%eax
add    $0x8,%rsp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Unknown ROM size code\0A\00"
define i32 @getRomSize(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
%4 = load i32, i32* %2
switch i32 %4, label %12 [
i32 0, label %5
i32 1, label %5
i32 2, label %5
i32 3, label %5
i32 4, label %5
i32 5, label %5
i32 6, label %5
i32 7, label %5
i32 82, label %9
i32 83, label %10
i32 84, label %11
]
5: ; preds = %1, %1, %1, %1, %1, %1, %1, %1
%6 = load i32, i32* %2
%7 = shl i32 32, %6
%8 = mul nsw i32 %7, 1024
store i32 %8, i32* %3
br label %14
9: ; preds = %1
store i32 1179648, i32* %3
br label %14
10: ; preds = %1
store i32 1310720, i32* %3
br label %14
11: ; preds = %1
store i32 1572864, i32* %3
br label %14
12: ; preds = %1
store i32 131072, i32* %3
%13 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %12, %11, %10, %9, %5
%15 = load i32, i32* %3
ret i32 %15
}

LLVM IR (-O2):
@str = [22 x i8] c"Unknown ROM size code\00"
define i32 @getRomSize(i32 %0) {
switch i32 %0, label %6 [
i32 0, label %2
i32 1, label %2
i32 2, label %2
i32 3, label %2
i32 4, label %2
i32 5, label %2
i32 6, label %2
i32 7, label %2
i32 82, label %8
i32 83, label %4
i32 84, label %5
]
2: ; preds = %1, %1, %1, %1, %1, %1, %1, %1
%3 = shl nuw nsw i32 32768, %0
br label %8
4: ; preds = %1
br label %8
5: ; preds = %1
br label %8
6: ; preds = %1
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
br label %8
8: ; preds = %1, %6, %5, %4, %2
%9 = phi i32 [ 131072, %6 ], [ 1572864, %5 ], [ 1310720, %4 ], [ %3, %2 ], [ 1179648, %1 ]
ret i32 %9
}