#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 unsigned long long uint64_t;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
int sscanf(char const *, char *, unsigned long long *, char *, char *);
int /*<<< orphan*/ stderr;
uint64_t parse_rate(const char *str) {
  unsigned long long value = 0;
  char suffix = 0;
  char eos = 0;
  if (sscanf(str, "%llu%c%c", &value, &suffix, &eos) >= 1 && eos == 0) {
    switch (suffix) {
    case 'G':
    case 'g':
      return value * 1000000000ULL;
    case 'M':
    case 'm':
      return value * 1000000ULL;
    case 'K':
    case 'k':
      return value * 1000ULL;
    case 0:
      return value;
    }
  }
  fprintf(stderr, "Invalid bitrate %s\n", str);
  exit(EXIT_FAILURE);
}


x86 assembly (clang, -O0):
<parse_rate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movb   $0x0,-0x19(%rbp)
movb   $0x0,-0x1a(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea9(%rip),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x19(%rbp),%rcx
lea    -0x1a(%rbp),%r8
call   1040 <sscanf@plt>
cmp    $0x1,%eax
jl     123d <parse_rate+0x10d>
movsbl -0x1a(%rbp),%eax
cmp    $0x0,%eax
jne    123d <parse_rate+0x10d>
movsbl -0x19(%rbp),%eax
mov    %eax,-0x20(%rbp)
test   %eax,%eax
je     122b <parse_rate+0xfb>
jmp    1192 <parse_rate+0x62>
mov    -0x20(%rbp),%eax
sub    $0x47,%eax
je     11f8 <parse_rate+0xc8>
jmp    11a3 <parse_rate+0x73>
mov    -0x20(%rbp),%eax
sub    $0x4b,%eax
je     121a <parse_rate+0xea>
jmp    11b4 <parse_rate+0x84>
mov    -0x20(%rbp),%eax
sub    $0x4d,%eax
je     1209 <parse_rate+0xd9>
jmp    11c5 <parse_rate+0x95>
mov    -0x20(%rbp),%eax
sub    $0x67,%eax
je     11f8 <parse_rate+0xc8>
jmp    11d6 <parse_rate+0xa6>
mov    -0x20(%rbp),%eax
sub    $0x6b,%eax
je     121a <parse_rate+0xea>
jmp    11e7 <parse_rate+0xb7>
mov    -0x20(%rbp),%eax
sub    $0x6d,%eax
je     1209 <parse_rate+0xd9>
jmp    1238 <parse_rate+0x108>
imul   $0x3b9aca00,-0x18(%rbp),%rax
3b
mov    %rax,-0x8(%rbp)
jmp    1264 <parse_rate+0x134>
imul   $0xf4240,-0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1264 <parse_rate+0x134>
imul   $0x3e8,-0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1264 <parse_rate+0x134>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1264 <parse_rate+0x134>
jmp    123d <parse_rate+0x10d>
mov    0x2d9c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xdb8(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2d7b(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_rate>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
movq   $0x0,0x8(%rsp)
movb   $0x0,0x7(%rsp)
movb   $0x0,0x6(%rsp)
lea    0xeae(%rip),%rsi
lea    0x8(%rsp),%rdx
lea    0x7(%rsp),%rcx
lea    0x6(%rsp),%r8
call   1040 <sscanf@plt>
test   %eax,%eax
jle    11de <parse_rate+0xae>
cmpb   $0x0,0x6(%rsp)
jne    11de <parse_rate+0xae>
movsbl 0x7(%rsp),%eax
lea    -0x47(%rax),%ecx
cmp    $0x26,%ecx
ja     11cf <parse_rate+0x9f>
movabs $0x100000001,%rdx
bt     %rcx,%rdx
jb     11b9 <parse_rate+0x89>
movabs $0x1000000010,%rdx
bt     %rcx,%rdx
jb     11c4 <parse_rate+0x94>
movabs $0x4000000040,%rdx
bt     %rcx,%rdx
jae    11cf <parse_rate+0x9f>
imul   $0xf4240,0x8(%rsp),%rax
jmp    11d8 <parse_rate+0xa8>
imul   $0x3b9aca00,0x8(%rsp),%rax
9a 3b
jmp    11d8 <parse_rate+0xa8>
imul   $0x3e8,0x8(%rsp),%rax
jmp    11d8 <parse_rate+0xa8>
test   %eax,%eax
jne    11de <parse_rate+0xae>
mov    0x8(%rsp),%rax
add    $0x10,%rsp
pop    %rbx
ret
mov    0x2dfb(%rip),%rax
mov    (%rax),%edi
lea    0xe1b(%rip),%rsi
mov    %rbx,%rdx
call   1030 <fprintf@plt>
mov    0x2ddb(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"%llu%c%c\00"
@stderr = global i32 0
@.str.1 = [20 x i8] c"Invalid bitrate %s\0A\00"
@EXIT_FAILURE = global i32 0
define i64 @parse_rate(i8* %0) {
%2 = alloca i64
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i8
%6 = alloca i8
store i8* %0, i8** %3
store i64 0, i64* %4
store i8 0, i8* %5
store i8 0, i8* %6
%7 = load i8*, i8** %3
%8 = call i32 @sscanf(i8* %7, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i64* %4, i8* %5, i8* %6)
%9 = icmp sge i32 %8, 1
br i1 %9, label %10, label %29
10: ; preds = %1
%11 = load i8, i8* %6
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %29
14: ; preds = %10
%15 = load i8, i8* %5
%16 = sext i8 %15 to i32
switch i32 %16, label %28 [
i32 71, label %17
i32 103, label %17
i32 77, label %20
i32 109, label %20
i32 75, label %23
i32 107, label %23
i32 0, label %26
]
17: ; preds = %14, %14
%18 = load i64, i64* %4
%19 = mul i64 %18, 1000000000
store i64 %19, i64* %2
br label %35
20: ; preds = %14, %14
%21 = load i64, i64* %4
%22 = mul i64 %21, 1000000
store i64 %22, i64* %2
br label %35
23: ; preds = %14, %14
%24 = load i64, i64* %4
%25 = mul i64 %24, 1000
store i64 %25, i64* %2
br label %35
26: ; preds = %14
%27 = load i64, i64* %4
store i64 %27, i64* %2
br label %35
28: ; preds = %14
br label %29
29: ; preds = %28, %10, %1
%30 = load i32, i32* @stderr
%31 = load i8*, i8** %3
%32 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %31)
%33 = load i32, i32* @EXIT_FAILURE
%34 = call i32 @exit(i32 %33)
unreachable
35: ; preds = %26, %23, %20, %17
%36 = load i64, i64* %2
ret i64 %36
}

LLVM IR (-O2):
@.str = [9 x i8] c"%llu%c%c\00"
@stderr = global i32 0
@.str.1 = [20 x i8] c"Invalid bitrate %s\0A\00"
@EXIT_FAILURE = global i32 0
define i64 @parse_rate(i8* %0) {
%2 = alloca i64
%3 = alloca i8
%4 = alloca i8
%5 = bitcast i64* %2 to i8*
store i64 0, i64* %2
store i8 0, i8* %3
store i8 0, i8* %4
%6 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i64* %2, i8* %3, i8* %4)
%7 = icmp sgt i32 %6, 0
%8 = load i8, i8* %4
%9 = icmp eq i8 %8, 0
%10 = select i1 %7, i1 %9, i1 false
br i1 %10, label %11, label %25
11: ; preds = %1
%12 = load i8, i8* %3
%13 = sext i8 %12 to i32
switch i32 %13, label %25 [
i32 71, label %14
i32 103, label %14
i32 77, label %17
i32 109, label %17
i32 75, label %20
i32 107, label %20
i32 0, label %23
]
14: ; preds = %11, %11
%15 = load i64, i64* %2
%16 = mul i64 %15, 1000000000
br label %30
17: ; preds = %11, %11
%18 = load i64, i64* %2
%19 = mul i64 %18, 1000000
br label %30
20: ; preds = %11, %11
%21 = load i64, i64* %2
%22 = mul i64 %21, 1000
br label %30
23: ; preds = %11
%24 = load i64, i64* %2
br label %30
25: ; preds = %11, %1
%26 = load i32, i32* @stderr
%27 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%28 = load i32, i32* @EXIT_FAILURE
%29 = call i32 @exit(i32 %28)
unreachable
30: ; preds = %23, %20, %17, %14
%31 = phi i64 [ %24, %23 ], [ %22, %20 ], [ %19, %17 ], [ %16, %14 ]
ret i64 %31
}