#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*/ usage();
long long scale_by_kmg(long long value, char scale) {
  switch (scale) {
  case 'g':
  case 'G':
    value *= 1024;
  case 'm':
  case 'M':
    value *= 1024;
  case 'k':
  case 'K':
    value *= 1024;
    break;
  case '\0':
    break;
  default:
    usage();
    break;
  }
  return value;
}


x86 assembly (clang, -O0):
<scale_by_kmg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%eax
mov    %eax,-0x10(%rbp)
test   %eax,%eax
je     11c5 <scale_by_kmg+0xb5>
jmp    1136 <scale_by_kmg+0x26>
mov    -0x10(%rbp),%eax
sub    $0x47,%eax
je     119c <scale_by_kmg+0x8c>
jmp    1147 <scale_by_kmg+0x37>
mov    -0x10(%rbp),%eax
sub    $0x4b,%eax
je     11b4 <scale_by_kmg+0xa4>
jmp    1158 <scale_by_kmg+0x48>
mov    -0x10(%rbp),%eax
sub    $0x4d,%eax
je     11a8 <scale_by_kmg+0x98>
jmp    1169 <scale_by_kmg+0x59>
mov    -0x10(%rbp),%eax
sub    $0x67,%eax
je     119c <scale_by_kmg+0x8c>
jmp    117a <scale_by_kmg+0x6a>
mov    -0x10(%rbp),%eax
sub    $0x6b,%eax
je     11b4 <scale_by_kmg+0xa4>
jmp    118b <scale_by_kmg+0x7b>
mov    -0x10(%rbp),%eax
sub    $0x6d,%eax
je     11a8 <scale_by_kmg+0x98>
jmp    11ca <scale_by_kmg+0xba>
mov    -0x8(%rbp),%rax
shl    $0xa,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
shl    $0xa,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
shl    $0xa,%rax
mov    %rax,-0x8(%rbp)
jmp    11d1 <scale_by_kmg+0xc1>
jmp    11d1 <scale_by_kmg+0xc1>
mov    $0x0,%al
call   1030 <usage@plt>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scale_by_kmg>:
push   %rbx
mov    %rdi,%rbx
lea    -0x47(%rsi),%eax
cmp    $0x26,%eax
ja     114c <scale_by_kmg+0x3c>
movabs $0x100000001,%rcx
bt     %rax,%rcx
jb     1159 <scale_by_kmg+0x49>
movabs $0x1000000010,%rcx
bt     %rax,%rcx
jb     1161 <scale_by_kmg+0x51>
movabs $0x4000000040,%rcx
bt     %rax,%rcx
jb     115d <scale_by_kmg+0x4d>
test   %esi,%esi
je     1165 <scale_by_kmg+0x55>
xor    %eax,%eax
call   1030 <usage@plt>
jmp    1165 <scale_by_kmg+0x55>
shl    $0xa,%rbx
shl    $0xa,%rbx
shl    $0xa,%rbx
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
define i64 @scale_by_kmg(i64 %0, i8 signext %1) {
%3 = alloca i64
%4 = alloca i8
store i64 %0, i64* %3
store i8 %1, i8* %4
%5 = load i8, i8* %4
%6 = sext i8 %5 to i32
switch i32 %6, label %17 [
i32 103, label %7
i32 71, label %7
i32 109, label %10
i32 77, label %10
i32 107, label %13
i32 75, label %13
i32 0, label %16
]
7: ; preds = %2, %2
%8 = load i64, i64* %3
%9 = mul nsw i64 %8, 1024
store i64 %9, i64* %3
br label %10
10: ; preds = %2, %2, %7
%11 = load i64, i64* %3
%12 = mul nsw i64 %11, 1024
store i64 %12, i64* %3
br label %13
13: ; preds = %2, %2, %10
%14 = load i64, i64* %3
%15 = mul nsw i64 %14, 1024
store i64 %15, i64* %3
br label %19
16: ; preds = %2
br label %19
17: ; preds = %2
%18 = call i32 (...) @usage()
br label %19
19: ; preds = %17, %16, %13
%20 = load i64, i64* %3
ret i64 %20
}

LLVM IR (-O2):
define i64 @scale_by_kmg(i64 %0, i8 signext %1) {
%3 = sext i8 %1 to i32
switch i32 %3, label %12 [
i32 103, label %4
i32 71, label %4
i32 109, label %6
i32 77, label %6
i32 107, label %9
i32 75, label %9
i32 0, label %14
]
4: ; preds = %2, %2
%5 = shl nsw i64 %0, 10
br label %6
6: ; preds = %2, %2, %4
%7 = phi i64 [ %0, %2 ], [ %0, %2 ], [ %5, %4 ]
%8 = shl nsw i64 %7, 10
br label %9
9: ; preds = %2, %2, %6
%10 = phi i64 [ %0, %2 ], [ %0, %2 ], [ %8, %6 ]
%11 = shl nsw i64 %10, 10
br label %14
12: ; preds = %2
%13 = tail call i32 (...) @usage()
br label %14
14: ; preds = %12, %2, %9
%15 = phi i64 [ %0, %12 ], [ %0, %2 ], [ %11, %9 ]
ret i64 %15
}