#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 uint64_t;
typedef int uint32_t;

/* Variables and functions */
uint64_t ConvertToBytes(uint32_t from_memory_unit, uint64_t original_value) {
  uint64_t converted_value = 0;
  if (from_memory_unit == 0)
    converted_value = original_value * ((uint64_t)1);
  else if (from_memory_unit == 1)
    converted_value = original_value * ((uint64_t)1024);
  else if (from_memory_unit == 2)
    converted_value = original_value * (((uint64_t)1024) * ((uint64_t)1024));
  else if (from_memory_unit == 3)
    converted_value = original_value *
                      (((uint64_t)1024) * ((uint64_t)1024) * ((uint64_t)1024));
  return converted_value;
}


x86 assembly (clang, -O0):
<ConvertToBytes>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1129 <ConvertToBytes+0x29>
mov    -0x8(%rbp),%eax
shl    $0x0,%eax
mov    %eax,-0xc(%rbp)
jmp    117b <ConvertToBytes+0x7b>
cmpl   $0x1,-0x4(%rbp)
jne    1141 <ConvertToBytes+0x41>
mov    -0x8(%rbp),%eax
shl    $0xa,%eax
mov    %eax,-0xc(%rbp)
jmp    1176 <ConvertToBytes+0x76>
cmpl   $0x2,-0x4(%rbp)
jne    1159 <ConvertToBytes+0x59>
mov    -0x8(%rbp),%eax
shl    $0x14,%eax
mov    %eax,-0xc(%rbp)
jmp    1171 <ConvertToBytes+0x71>
cmpl   $0x3,-0x4(%rbp)
jne    116c <ConvertToBytes+0x6c>
mov    -0x8(%rbp),%eax
shl    $0x1e,%eax
mov    %eax,-0xc(%rbp)
jmp    1171 <ConvertToBytes+0x71>
jmp    1176 <ConvertToBytes+0x76>
jmp    117b <ConvertToBytes+0x7b>
mov    -0xc(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<ConvertToBytes>:
cmp    $0x3,%edi
ja     111d <ConvertToBytes+0x1d>
mov    %esi,%eax
mov    %edi,%ecx
lea    0xef0(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
shl    $0xa,%eax
ret
xor    %eax,%eax
ret
shl    $0x14,%eax
ret
shl    $0x1e,%eax
ret

LLVM IR (-O0):
define i32 @ConvertToBytes(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 0, i32* %5
%6 = load i32, i32* %3
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load i32, i32* %4
%10 = mul nsw i32 %9, 1
store i32 %10, i32* %5
br label %32
11: ; preds = %2
%12 = load i32, i32* %3
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = load i32, i32* %4
%16 = mul nsw i32 %15, 1024
store i32 %16, i32* %5
br label %31
17: ; preds = %11
%18 = load i32, i32* %3
%19 = icmp eq i32 %18, 2
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = load i32, i32* %4
%22 = mul nsw i32 %21, 1048576
store i32 %22, i32* %5
br label %30
23: ; preds = %17
%24 = load i32, i32* %3
%25 = icmp eq i32 %24, 3
br i1 %25, label %26, label %29
26: ; preds = %23
%27 = load i32, i32* %4
%28 = mul nsw i32 %27, 1073741824
store i32 %28, i32* %5
br label %29
29: ; preds = %26, %23
br label %30
30: ; preds = %29, %20
br label %31
31: ; preds = %30, %14
br label %32
32: ; preds = %31, %8
%33 = load i32, i32* %5
ret i32 %33
}

LLVM IR (-O2):
define i32 @ConvertToBytes(i32 %0, i32 %1) {
switch i32 %0, label %9 [
i32 0, label %10
i32 1, label %3
i32 2, label %5
i32 3, label %7
]
3: ; preds = %2
%4 = shl nsw i32 %1, 10
br label %10
5: ; preds = %2
%6 = shl nsw i32 %1, 20
br label %10
7: ; preds = %2
%8 = shl nsw i32 %1, 30
br label %10
9: ; preds = %2
br label %10
10: ; preds = %2, %9, %3, %7, %5
%11 = phi i32 [ %4, %3 ], [ %6, %5 ], [ %8, %7 ], [ %1, %2 ], [ 0, %9 ]
ret i32 %11
}