#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 */
struct argp_state {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ argp_error(struct argp_state const *, char *, ...);
long long strtoll(char const *, char **, int /*<<< orphan*/);
long long arg_to_ll_bytes(const struct argp_state *state, const char *arg) {
  char *end;
  long long ll = strtoll(arg, &end, 0);
  if (end == arg)
    argp_error(state, "An integer must be provided");
  switch (*end) {
  case 's':
  case 'S':
    ll <<= 9;
    end++;
    break;
  case 'k':
  case 'K':
    ll <<= 10;
    end++;
    break;
  case 'm':
  case 'M':
    ll <<= 20;
    end++;
    break;
  case 'g':
  case 'G':
    ll <<= 30;
    end++;
    break;
  case 't':
  case 'T':
    ll <<= 40;
    end++;
    break;
  }
  if (*end)
    argp_error(state, "`%s' is not an integer", arg);
  return ll;
}


x86 assembly (clang, -O0):
<arg_to_ll_bytes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
xor    %edx,%edx
call   1040 <strtoll@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jne    1163 <arg_to_ll_bytes+0x43>
mov    -0x8(%rbp),%rdi
lea    0xf5c(%rip),%rsi
mov    $0x0,%al
call   1030 <argp_error@plt>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
add    $0xffffffb9,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x2d,%eax
ja     121c <arg_to_ll_bytes+0xfc>
mov    -0x28(%rbp),%rax
lea    0xe79(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x20(%rbp),%rax
shl    $0x9,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    121c <arg_to_ll_bytes+0xfc>
mov    -0x20(%rbp),%rax
shl    $0xa,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    121c <arg_to_ll_bytes+0xfc>
mov    -0x20(%rbp),%rax
shl    $0x14,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    121c <arg_to_ll_bytes+0xfc>
mov    -0x20(%rbp),%rax
shl    $0x1e,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    121c <arg_to_ll_bytes+0xfc>
mov    -0x20(%rbp),%rax
shl    $0x28,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     123f <arg_to_ll_bytes+0x11f>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe9c(%rip),%rsi
mov    $0x0,%al
call   1030 <argp_error@plt>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<arg_to_ll_bytes>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%r14
mov    %rsp,%rsi
mov    %r15,%rdi
xor    %edx,%edx
call   1040 <strtoll@plt>
mov    %rax,%r12
mov    (%rsp),%rbx
cmp    %r15,%rbx
jne    1158 <arg_to_ll_bytes+0x38>
lea    0xf6a(%rip),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <argp_error@plt>
movsbl (%rbx),%eax
mov    %eax,%edx
add    $0xffffffb9,%edx
cmp    $0x2d,%edx
ja     119a <arg_to_ll_bytes+0x7a>
mov    $0x9,%ecx
lea    0xe8f(%rip),%rsi
movslq (%rsi,%rdx,4),%rdx
add    %rsi,%rdx
jmp    *%rdx
mov    $0x1e,%ecx
jmp    1194 <arg_to_ll_bytes+0x74>
mov    $0xa,%ecx
jmp    1194 <arg_to_ll_bytes+0x74>
mov    $0x14,%ecx
jmp    1194 <arg_to_ll_bytes+0x74>
mov    $0x28,%ecx
shl    %cl,%r12
mov    0x1(%rbx),%al
test   %al,%al
je     11b2 <arg_to_ll_bytes+0x92>
lea    0xf2f(%rip),%rsi
mov    %r14,%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   1030 <argp_error@plt>
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.argp_state = type { i32 }
@.str = [28 x i8] c"An integer must be provided\00"
@.str.1 = [23 x i8] c"`%s' is not an integer\00"
define i64 @arg_to_ll_bytes(%struct.argp_state* %0, i8* %1) {
%3 = alloca %struct.argp_state*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
store %struct.argp_state* %0, %struct.argp_state** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %4
%8 = call i64 @strtoll(i8* %7, i8** %5, i32 0)
store i64 %8, i64* %6
%9 = load i8*, i8** %5
%10 = load i8*, i8** %4
%11 = icmp eq i8* %9, %10
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = load %struct.argp_state*, %struct.argp_state** %3
%14 = call i32 (%struct.argp_state*, i8*, ...) @argp_error(%struct.argp_state* %13, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %12, %2
%16 = load i8*, i8** %5
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
switch i32 %18, label %44 [
i32 115, label %19
i32 83, label %19
i32 107, label %24
i32 75, label %24
i32 109, label %29
i32 77, label %29
i32 103, label %34
i32 71, label %34
i32 116, label %39
i32 84, label %39
]
19: ; preds = %15, %15
%20 = load i64, i64* %6
%21 = shl i64 %20, 9
store i64 %21, i64* %6
%22 = load i8*, i8** %5
%23 = getelementptr inbounds i8, i8* %22, i32 1
store i8* %23, i8** %5
br label %44
24: ; preds = %15, %15
%25 = load i64, i64* %6
%26 = shl i64 %25, 10
store i64 %26, i64* %6
%27 = load i8*, i8** %5
%28 = getelementptr inbounds i8, i8* %27, i32 1
store i8* %28, i8** %5
br label %44
29: ; preds = %15, %15
%30 = load i64, i64* %6
%31 = shl i64 %30, 20
store i64 %31, i64* %6
%32 = load i8*, i8** %5
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %5
br label %44
34: ; preds = %15, %15
%35 = load i64, i64* %6
%36 = shl i64 %35, 30
store i64 %36, i64* %6
%37 = load i8*, i8** %5
%38 = getelementptr inbounds i8, i8* %37, i32 1
store i8* %38, i8** %5
br label %44
39: ; preds = %15, %15
%40 = load i64, i64* %6
%41 = shl i64 %40, 40
store i64 %41, i64* %6
%42 = load i8*, i8** %5
%43 = getelementptr inbounds i8, i8* %42, i32 1
store i8* %43, i8** %5
br label %44
44: ; preds = %15, %39, %34, %29, %24, %19
%45 = load i8*, i8** %5
%46 = load i8, i8* %45
%47 = icmp ne i8 %46, 0
br i1 %47, label %48, label %52
48: ; preds = %44
%49 = load %struct.argp_state*, %struct.argp_state** %3
%50 = load i8*, i8** %4
%51 = call i32 (%struct.argp_state*, i8*, ...) @argp_error(%struct.argp_state* %49, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %50)
br label %52
52: ; preds = %48, %44
%53 = load i64, i64* %6
ret i64 %53
}

LLVM IR (-O2):
%struct.argp_state = type { i32 }
@.str = [28 x i8] c"An integer must be provided\00"
@.str.1 = [23 x i8] c"`%s' is not an integer\00"
define i64 @arg_to_ll_bytes(%struct.argp_state* %0, i8* %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = call i64 @strtoll(i8* %1, i8** %3, i32 0)
%6 = load i8*, i8** %3
%7 = icmp eq i8* %6, %1
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = tail call i32 (%struct.argp_state*, i8*, ...) @argp_error(%struct.argp_state* %0, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %8, %2
%11 = load i8, i8* %6
%12 = sext i8 %11 to i32
switch i32 %12, label %22 [
i32 115, label %17
i32 83, label %17
i32 107, label %13
i32 75, label %13
i32 109, label %14
i32 77, label %14
i32 103, label %15
i32 71, label %15
i32 116, label %16
i32 84, label %16
]
13: ; preds = %10, %10
br label %17
14: ; preds = %10, %10
br label %17
15: ; preds = %10, %10
br label %17
16: ; preds = %10, %10
br label %17
17: ; preds = %10, %10, %13, %14, %15, %16
%18 = phi i64 [ 10, %13 ], [ 20, %14 ], [ 30, %15 ], [ 40, %16 ], [ 9, %10 ], [ 9, %10 ]
%19 = shl i64 %5, %18
%20 = getelementptr inbounds i8, i8* %6, i64 1
%21 = load i8, i8* %20
br label %22
22: ; preds = %17, %10
%23 = phi i8 [ %21, %17 ], [ %11, %10 ]
%24 = phi i64 [ %19, %17 ], [ %5, %10 ]
%25 = icmp eq i8 %23, 0
br i1 %25, label %28, label %26
26: ; preds = %22
%27 = tail call i32 (%struct.argp_state*, i8*, ...) @argp_error(%struct.argp_state* %0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %1)
br label %28
28: ; preds = %26, %22
ret i64 %24
}