#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 off_t;

/* Variables and functions */
int atoul(char *);
int strlen(char *);
off_t number(char *s) {
  if (!s || !*s) {
    return 0;
  } else {
    int n = atoul(s);
    switch (s[strlen(s) - 1]) {
    case 'G':
    case 'g':
      n *= 1024;
    case 'M':
    case 'm':
      n *= 1024;
    case 'k':
    case 'K':
      n *= 1024;
      break;
    }
    return n;
  }
}


x86 assembly (clang, -O0):
<number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1144 <number+0x24>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1150 <number+0x30>
movl   $0x0,-0x4(%rbp)
jmp    1200 <number+0xe0>
mov    -0x10(%rbp),%rdi
call   1040 <atoul@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    %rdi,-0x20(%rbp)
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
add    $0xffffffff,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x18(%rbp)
sub    $0x47,%eax
je     11df <number+0xbf>
jmp    118a <number+0x6a>
mov    -0x18(%rbp),%eax
sub    $0x4b,%eax
je     11f1 <number+0xd1>
jmp    119b <number+0x7b>
mov    -0x18(%rbp),%eax
sub    $0x4d,%eax
je     11e8 <number+0xc8>
jmp    11ac <number+0x8c>
mov    -0x18(%rbp),%eax
sub    $0x67,%eax
je     11df <number+0xbf>
jmp    11bd <number+0x9d>
mov    -0x18(%rbp),%eax
sub    $0x6b,%eax
je     11f1 <number+0xd1>
jmp    11ce <number+0xae>
mov    -0x18(%rbp),%eax
sub    $0x6d,%eax
je     11e8 <number+0xc8>
jmp    11fa <number+0xda>
mov    -0x14(%rbp),%eax
shl    $0xa,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
shl    $0xa,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
shl    $0xa,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<number>:
push   %rbp
push   %rbx
push   %rax
xor    %ebp,%ebp
test   %rdi,%rdi
je     118e <number+0x6e>
mov    %rdi,%rbx
cmpb   $0x0,(%rdi)
je     118e <number+0x6e>
mov    %rbx,%rdi
call   1040 <atoul@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
movsbl -0x1(%rax,%rbx,1),%eax
add    $0xffffffb9,%eax
cmp    $0x26,%eax
ja     118e <number+0x6e>
movabs $0x100000001,%rcx
bt     %rax,%rcx
jb     1185 <number+0x65>
movabs $0x1000000010,%rcx
bt     %rax,%rcx
jb     118b <number+0x6b>
movabs $0x4000000040,%rcx
bt     %rax,%rcx
jb     1188 <number+0x68>
jmp    118e <number+0x6e>
shl    $0xa,%ebp
shl    $0xa,%ebp
shl    $0xa,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @number(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %7, label %11
7: ; preds = %1
%8 = load i8*, i8** %3
%9 = load i8, i8* %8
%10 = icmp ne i8 %9, 0
br i1 %10, label %12, label %11
11: ; preds = %7, %1
store i32 0, i32* %2
br label %34
12: ; preds = %7
%13 = load i8*, i8** %3
%14 = call i32 @atoul(i8* %13)
store i32 %14, i32* %4
%15 = load i8*, i8** %3
%16 = load i8*, i8** %3
%17 = call i32 @strlen(i8* %16)
%18 = sub nsw i32 %17, 1
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %15, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
switch i32 %22, label %32 [
i32 71, label %23
i32 103, label %23
i32 77, label %26
i32 109, label %26
i32 107, label %29
i32 75, label %29
]
23: ; preds = %12, %12
%24 = load i32, i32* %4
%25 = mul nsw i32 %24, 1024
store i32 %25, i32* %4
br label %26
26: ; preds = %12, %12, %23
%27 = load i32, i32* %4
%28 = mul nsw i32 %27, 1024
store i32 %28, i32* %4
br label %29
29: ; preds = %12, %12, %26
%30 = load i32, i32* %4
%31 = mul nsw i32 %30, 1024
store i32 %31, i32* %4
br label %32
32: ; preds = %12, %29
%33 = load i32, i32* %4
store i32 %33, i32* %2
br label %34
34: ; preds = %32, %11
%35 = load i32, i32* %2
ret i32 %35
}

LLVM IR (-O2):
define i32 @number(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %22, label %3
3: ; preds = %1
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %22, label %6
6: ; preds = %3
%7 = tail call i32 @atoul(i8* %0)
%8 = tail call i32 @strlen(i8* %0)
%9 = add nsw i32 %8, -1
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
switch i32 %13, label %22 [
i32 71, label %14
i32 103, label %14
i32 77, label %16
i32 109, label %16
i32 107, label %19
i32 75, label %19
]
14: ; preds = %6, %6
%15 = shl nsw i32 %7, 10
br label %16
16: ; preds = %6, %6, %14
%17 = phi i32 [ %7, %6 ], [ %7, %6 ], [ %15, %14 ]
%18 = shl nsw i32 %17, 10
br label %19
19: ; preds = %6, %6, %16
%20 = phi i32 [ %7, %6 ], [ %7, %6 ], [ %18, %16 ]
%21 = shl nsw i32 %20, 10
br label %22
22: ; preds = %19, %6, %1, %3
%23 = phi i32 [ 0, %3 ], [ 0, %1 ], [ %7, %6 ], [ %21, %19 ]
ret i32 %23
}