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

/* Variables and functions */
int parse_uint32(char const **, int *);
bool parse_size32(const char **string, uint32_t *result) {
  bool ok = parse_uint32(string, result);
  if (ok)
    switch (**string) {
    case 'K':
      *result <<= 10;
      (*string)++;
      break;
    case 'M':
      *result <<= 20;
      (*string)++;
      break;
    }
  return ok;
}


x86 assembly (clang, -O0):
<parse_size32>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <parse_uint32@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11a2 <parse_size32+0x92>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
mov    %eax,-0x18(%rbp)
sub    $0x4b,%eax
je     1166 <parse_size32+0x56>
jmp    1155 <parse_size32+0x45>
mov    -0x18(%rbp),%eax
sub    $0x4d,%eax
je     1184 <parse_size32+0x74>
jmp    119d <parse_size32+0x8d>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
shl    $0xa,%ecx
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
jmp    119d <parse_size32+0x8d>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
shl    $0x14,%ecx
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
jmp    11a2 <parse_size32+0x92>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_size32>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <parse_uint32@plt>
test   %eax,%eax
je     1149 <parse_size32+0x39>
mov    (%rbx),%rdx
movsbl (%rdx),%ecx
cmp    $0x4b,%ecx
je     113a <parse_size32+0x2a>
cmp    $0x4d,%ecx
jne    1149 <parse_size32+0x39>
mov    $0x14,%ecx
jmp    113f <parse_size32+0x2f>
mov    $0xa,%ecx
shll   %cl,(%r14)
add    $0x1,%rdx
mov    %rdx,(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @parse_size32(i8** %0, i32* %1) {
%3 = alloca i8**
%4 = alloca i32*
%5 = alloca i32
store i8** %0, i8*** %3
store i32* %1, i32** %4
%6 = load i8**, i8*** %3
%7 = load i32*, i32** %4
%8 = call i32 @parse_uint32(i8** %6, i32* %7)
store i32 %8, i32* %5
%9 = load i32, i32* %5
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %31
11: ; preds = %2
%12 = load i8**, i8*** %3
%13 = load i8*, i8** %12
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
switch i32 %15, label %30 [
i32 75, label %16
i32 77, label %23
]
16: ; preds = %11
%17 = load i32*, i32** %4
%18 = load i32, i32* %17
%19 = shl i32 %18, 10
store i32 %19, i32* %17
%20 = load i8**, i8*** %3
%21 = load i8*, i8** %20
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %20
br label %30
23: ; preds = %11
%24 = load i32*, i32** %4
%25 = load i32, i32* %24
%26 = shl i32 %25, 20
store i32 %26, i32* %24
%27 = load i8**, i8*** %3
%28 = load i8*, i8** %27
%29 = getelementptr inbounds i8, i8* %28, i32 1
store i8* %29, i8** %27
br label %30
30: ; preds = %11, %23, %16
br label %31
31: ; preds = %30, %2
%32 = load i32, i32* %5
ret i32 %32
}

LLVM IR (-O2):
define i32 @parse_size32(i8** %0, i32* %1) {
%3 = tail call i32 @parse_uint32(i8** %0, i32* %1)
%4 = icmp eq i32 %3, 0
br i1 %4, label %15, label %5
5: ; preds = %2
%6 = load i8*, i8** %0
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
switch i32 %8, label %15 [
i32 75, label %10
i32 77, label %9
]
9: ; preds = %5
br label %10
10: ; preds = %5, %9
%11 = phi i32 [ 20, %9 ], [ 10, %5 ]
%12 = load i32, i32* %1
%13 = shl i32 %12, %11
store i32 %13, i32* %1
%14 = getelementptr inbounds i8, i8* %6, i64 1
store i8* %14, i8** %0
br label %15
15: ; preds = %10, %5, %2
ret i32 %3
}