#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 atoi(char *);
scalar_t__ strstr(char *, char *);
unsigned int convert(char *string) {
  unsigned int base;
  base = atoi(string);
  if (strstr(string, "K")) {
    base *= 1024;
  }
  if (strstr(string, "M")) {
    base *= (1024 * 1024);
  }
  if (strstr(string, "G")) {
    base *= (1024 * 1024 * 1024);
  }
  if (strstr(string, "k")) {
    base *= (1000);
  }
  if (strstr(string, "m")) {
    base *= (1000 * 1000);
  }
  if (strstr(string, "g")) {
    base *= (1000 * 1000 * 1000);
  }
  return (base);
}


x86 assembly (clang, -O0):
<convert>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <atoi@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xebd(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     115b <convert+0x3b>
mov    -0xc(%rbp),%eax
shl    $0xa,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe9c(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     117e <convert+0x5e>
mov    -0xc(%rbp),%eax
shl    $0x14,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe7b(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     11a1 <convert+0x81>
mov    -0xc(%rbp),%eax
shl    $0x1e,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe5a(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     11c5 <convert+0xa5>
imul   $0x3e8,-0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe38(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     11e9 <convert+0xc9>
imul   $0xf4240,-0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe16(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     120d <convert+0xed>
imul   $0x3b9aca00,-0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convert>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r15
call   1030 <atoi@plt>
mov    %eax,%r14d
lea    0xec7(%rip),%rsi
mov    %r15,%rdi
call   1040 <strstr@plt>
mov    %r14d,%ebp
shl    $0xa,%ebp
test   %rax,%rax
cmove  %r14d,%ebp
lea    0xead(%rip),%rsi
mov    %r15,%rdi
call   1040 <strstr@plt>
mov    %ebp,%ebx
shl    $0x14,%ebx
test   %rax,%rax
cmove  %ebp,%ebx
lea    0xe95(%rip),%rsi
mov    %r15,%rdi
call   1040 <strstr@plt>
mov    %ebx,%ebp
shl    $0x1e,%ebp
test   %rax,%rax
cmove  %ebx,%ebp
lea    0xe7d(%rip),%rsi
mov    %r15,%rdi
call   1040 <strstr@plt>
imul   $0x3e8,%ebp,%ebx
test   %rax,%rax
cmove  %ebp,%ebx
lea    0xe64(%rip),%rsi
mov    %r15,%rdi
call   1040 <strstr@plt>
imul   $0xf4240,%ebx,%ebp
test   %rax,%rax
cmove  %ebx,%ebp
lea    0xe4b(%rip),%rsi
mov    %r15,%rdi
call   1040 <strstr@plt>
imul   $0x3b9aca00,%ebp,%ecx
test   %rax,%rax
cmove  %ebp,%ecx
mov    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"K\00"
@.str.1 = [2 x i8] c"M\00"
@.str.2 = [2 x i8] c"G\00"
@.str.3 = [2 x i8] c"k\00"
@.str.4 = [2 x i8] c"m\00"
@.str.5 = [2 x i8] c"g\00"
define i32 @convert(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i32 @atoi(i8* %4)
store i32 %5, i32* %3
%6 = load i8*, i8** %2
%7 = call i64 @strstr(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = load i32, i32* %3
%11 = mul i32 %10, 1024
store i32 %11, i32* %3
br label %12
12: ; preds = %9, %1
%13 = load i8*, i8** %2
%14 = call i64 @strstr(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %12
%17 = load i32, i32* %3
%18 = mul i32 %17, 1048576
store i32 %18, i32* %3
br label %19
19: ; preds = %16, %12
%20 = load i8*, i8** %2
%21 = call i64 @strstr(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %19
%24 = load i32, i32* %3
%25 = mul i32 %24, 1073741824
store i32 %25, i32* %3
br label %26
26: ; preds = %23, %19
%27 = load i8*, i8** %2
%28 = call i64 @strstr(i8* %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %26
%31 = load i32, i32* %3
%32 = mul i32 %31, 1000
store i32 %32, i32* %3
br label %33
33: ; preds = %30, %26
%34 = load i8*, i8** %2
%35 = call i64 @strstr(i8* %34, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %33
%38 = load i32, i32* %3
%39 = mul i32 %38, 1000000
store i32 %39, i32* %3
br label %40
40: ; preds = %37, %33
%41 = load i8*, i8** %2
%42 = call i64 @strstr(i8* %41, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%43 = icmp ne i64 %42, 0
br i1 %43, label %44, label %47
44: ; preds = %40
%45 = load i32, i32* %3
%46 = mul i32 %45, 1000000000
store i32 %46, i32* %3
br label %47
47: ; preds = %44, %40
%48 = load i32, i32* %3
ret i32 %48
}

LLVM IR (-O2):
@.str = [2 x i8] c"K\00"
@.str.1 = [2 x i8] c"M\00"
@.str.2 = [2 x i8] c"G\00"
@.str.3 = [2 x i8] c"k\00"
@.str.4 = [2 x i8] c"m\00"
@.str.5 = [2 x i8] c"g\00"
define i32 @convert(i8* %0) {
%2 = tail call i32 @atoi(i8* %0)
%3 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i64 %3, 0
%5 = shl i32 %2, 10
%6 = select i1 %4, i32 %2, i32 %5
%7 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
%9 = shl i32 %6, 20
%10 = select i1 %8, i32 %6, i32 %9
%11 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
%13 = shl i32 %10, 30
%14 = select i1 %12, i32 %10, i32 %13
%15 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
%17 = mul i32 %14, 1000
%18 = select i1 %16, i32 %14, i32 %17
%19 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
%21 = mul i32 %18, 1000000
%22 = select i1 %20, i32 %18, i32 %21
%23 = tail call i64 @strstr(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
%25 = mul i32 %22, 1000000000
%26 = select i1 %24, i32 %22, i32 %25
ret i32 %26
}