#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*/ sscanf(char *, char *, float *, char *);
int psnd_scan_integer(char *value) {
  float result = 0;
  char modify = 0;
  sscanf(value, "%f%c", &result, &modify);
  if (modify) {
    switch (modify) {
    case 'k':
    case 'K':
      result *= 1024;
      break;
    case 'm':
    case 'M':
      result *= 1024000;
      break;
    }
  }
  return (int)result;
}


x86 assembly (clang, -O0):
<psnd_scan_integer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
movb   $0x0,-0xd(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xf61(%rip),%rsi
lea    -0xc(%rbp),%rdx
lea    -0xd(%rbp),%rcx
call   1030 <sscanf@plt>
cmpb   $0x0,-0xd(%rbp)
je     11a2 <psnd_scan_integer+0x92>
movsbl -0xd(%rbp),%eax
add    $0xffffffb5,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x22,%eax
ja     119d <psnd_scan_integer+0x8d>
mov    -0x18(%rbp),%rax
lea    0xe9d(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movss  0xe88(%rip),%xmm0
mulss  -0xc(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    119d <psnd_scan_integer+0x8d>
movss  0xe6d(%rip),%xmm0
mulss  -0xc(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    11a2 <psnd_scan_integer+0x92>
cvttss2si -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<psnd_scan_integer>:
push   %rax
movl   $0x0,0x4(%rsp)
movb   $0x0,0x3(%rsp)
lea    0xf6f(%rip),%rsi
lea    0x4(%rsp),%rdx
lea    0x3(%rsp),%rcx
call   1030 <sscanf@plt>
movsbl 0x3(%rsp),%eax
test   %eax,%eax
je     1179 <psnd_scan_integer+0x69>
add    $0xffffffb5,%eax
cmp    $0x22,%eax
ja     1179 <psnd_scan_integer+0x69>
lea    0xebc(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movss  0x4(%rsp),%xmm0
mulss  0xea1(%rip),%xmm0
jmp    1173 <psnd_scan_integer+0x63>
movss  0x4(%rsp),%xmm0
mulss  0xe8d(%rip),%xmm0
movss  %xmm0,0x4(%rsp)
cvttss2si 0x4(%rsp),%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%f%c\00"
define i32 @psnd_scan_integer(i8* %0) {
%2 = alloca i8*
%3 = alloca float
%4 = alloca i8
store i8* %0, i8** %2
store float 0.000000e+00, float* %3
store i8 0, i8* %4
%5 = load i8*, i8** %2
%6 = call i32 @sscanf(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), float* %3, i8* %4)
%7 = load i8, i8* %4
%8 = icmp ne i8 %7, 0
br i1 %8, label %9, label %19
9: ; preds = %1
%10 = load i8, i8* %4
%11 = sext i8 %10 to i32
switch i32 %11, label %18 [
i32 107, label %12
i32 75, label %12
i32 109, label %15
i32 77, label %15
]
12: ; preds = %9, %9
%13 = load float, float* %3
%14 = fmul float %13, 1.024000e+03
store float %14, float* %3
br label %18
15: ; preds = %9, %9
%16 = load float, float* %3
%17 = fmul float %16, 1.024000e+06
store float %17, float* %3
br label %18
18: ; preds = %9, %15, %12
br label %19
19: ; preds = %18, %1
%20 = load float, float* %3
%21 = fptosi float %20 to i32
ret i32 %21
}

LLVM IR (-O2):
@.str = [5 x i8] c"%f%c\00"
define i32 @psnd_scan_integer(i8* nocapture %0) {
%2 = alloca float
%3 = alloca i8
%4 = bitcast float* %2 to i8*
store float 0.000000e+00, float* %2
store i8 0, i8* %3
%5 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), float* %2, i8* %3)
%6 = load i8, i8* %3
%7 = icmp eq i8 %6, 0
br i1 %7, label %16, label %8
8: ; preds = %1
%9 = sext i8 %6 to i32
switch i32 %9, label %16 [
i32 107, label %10
i32 75, label %10
i32 109, label %13
i32 77, label %13
]
10: ; preds = %8, %8
%11 = load float, float* %2
%12 = fmul float %11, 1.024000e+03
store float %12, float* %2
br label %16
13: ; preds = %8, %8
%14 = load float, float* %2
%15 = fmul float %14, 1.024000e+06
store float %15, float* %2
br label %16
16: ; preds = %10, %13, %8, %1
%17 = load float, float* %2
%18 = fptosi float %17 to i32
ret i32 %18
}