#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 */
scalar_t__ ERANGE;
long long LLONG_MAX;
long long LLONG_MIN;
scalar_t__ errno;
long long strtoll(char *, char **, int);
int parse_number(char *start, long long *size, int *range, char **error) {
  char *end;
  long long number;
  if (*start == '>' || *start == '+') {
    *range = 3;
    start++;
  } else if (*start == '<' || *start == '-') {
    *range = 2;
    start++;
  } else
    *range = 1;
  errno = 0;
  number = strtoll(start, &end, 10);
  if ((errno == ERANGE && (number == LLONG_MAX || number == LLONG_MIN)) ||
      (errno != 0 && number == 0)) {
    *error = "Long long underflow, overflow or other conversion "
             "error";
    return 0;
  }
  if (end == start) {
    *error = "Number expected";
    return 0;
  }
  switch (end[0]) {
  case 'g':
  case 'G':
    number *= 1024;
  case 'm':
  case 'M':
    number *= 1024;
  case 'k':
  case 'K':
    number *= 1024;
    if (end[1] != '\0') {
      *error = "Trailing junk after size specifier";
      return 0;
    }
    break;
  case '\0':
    break;
  default:
    *error = "Trailing junk after number";
    return 0;
  }
  *size = number;
  return 1;
}


x86 assembly (clang, -O0):
<parse_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3e,%eax
je     1148 <parse_number+0x38>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2b,%eax
jne    1163 <parse_number+0x53>
mov    -0x20(%rbp),%rax
movl   $0x3,(%rax)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11ad <parse_number+0x9d>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3c,%eax
je     1183 <parse_number+0x73>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    119e <parse_number+0x8e>
mov    -0x20(%rbp),%rax
movl   $0x2,(%rax)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11a8 <parse_number+0x98>
mov    -0x20(%rbp),%rax
movl   $0x1,(%rax)
jmp    11ad <parse_number+0x9d>
mov    0x2e14(%rip),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
lea    -0x30(%rbp),%rsi
mov    $0xa,%edx
call   1030 <strtoll@plt>
mov    %rax,-0x38(%rbp)
mov    0x2df0(%rip),%rax
mov    (%rax),%rax
mov    0x2e06(%rip),%rcx
cmp    (%rcx),%rax
jne    1213 <parse_number+0x103>
mov    -0x38(%rbp),%rax
mov    0x2dea(%rip),%rcx
cmp    (%rcx),%rax
je     122f <parse_number+0x11f>
mov    -0x38(%rbp),%rax
mov    0x2dc6(%rip),%rcx
cmp    (%rcx),%rax
je     122f <parse_number+0x11f>
mov    0x2dae(%rip),%rax
cmpq   $0x0,(%rax)
je     1249 <parse_number+0x139>
cmpq   $0x0,-0x38(%rbp)
jne    1249 <parse_number+0x139>
mov    -0x28(%rbp),%rax
lea    0xdc6(%rip),%rcx
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    1373 <parse_number+0x263>
mov    -0x30(%rbp),%rax
cmp    -0x10(%rbp),%rax
jne    1271 <parse_number+0x161>
mov    -0x28(%rbp),%rax
lea    0xdd6(%rip),%rcx
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    1373 <parse_number+0x263>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x3c(%rbp)
test   %eax,%eax
je     1342 <parse_number+0x232>
jmp    1288 <parse_number+0x178>
mov    -0x3c(%rbp),%eax
sub    $0x47,%eax
je     12ee <parse_number+0x1de>
jmp    1299 <parse_number+0x189>
mov    -0x3c(%rbp),%eax
sub    $0x4b,%eax
je     1306 <parse_number+0x1f6>
jmp    12aa <parse_number+0x19a>
mov    -0x3c(%rbp),%eax
sub    $0x4d,%eax
je     12fa <parse_number+0x1ea>
jmp    12bb <parse_number+0x1ab>
mov    -0x3c(%rbp),%eax
sub    $0x67,%eax
je     12ee <parse_number+0x1de>
jmp    12cc <parse_number+0x1bc>
mov    -0x3c(%rbp),%eax
sub    $0x6b,%eax
je     1306 <parse_number+0x1f6>
jmp    12dd <parse_number+0x1cd>
mov    -0x3c(%rbp),%eax
sub    $0x6d,%eax
je     12fa <parse_number+0x1ea>
jmp    1347 <parse_number+0x237>
mov    -0x38(%rbp),%rax
shl    $0xa,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
shl    $0xa,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
shl    $0xa,%rax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
je     133d <parse_number+0x22d>
mov    -0x28(%rbp),%rax
lea    0xd1a(%rip),%rcx
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    1373 <parse_number+0x263>
jmp    1361 <parse_number+0x251>
jmp    1361 <parse_number+0x251>
mov    -0x28(%rbp),%rax
lea    0xd19(%rip),%rcx
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    1373 <parse_number+0x263>
mov    -0x38(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_number>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
mov    (%rdi),%al
add    $0xd5,%al
cmp    $0x13,%al
ja     1154 <parse_number+0x44>
movzbl %al,%eax
lea    0xecd(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x3,(%rdx)
add    $0x1,%rbx
jmp    115a <parse_number+0x4a>
movl   $0x2,(%rdx)
add    $0x1,%rbx
jmp    115a <parse_number+0x4a>
movl   $0x1,(%rdx)
mov    0x2e67(%rip),%r12
movq   $0x0,(%r12)
mov    %rsp,%rsi
mov    %rbx,%rdi
mov    $0xa,%edx
call   1030 <strtoll@plt>
mov    (%r12),%rcx
mov    0x2e64(%rip),%rdx
cmp    (%rdx),%rcx
jne    11a1 <parse_number+0x91>
mov    0x2e50(%rip),%rdx
cmp    (%rdx),%rax
je     11ab <parse_number+0x9b>
mov    0x2e34(%rip),%rdx
cmp    (%rdx),%rax
je     11ab <parse_number+0x9b>
test   %rcx,%rcx
je     11c3 <parse_number+0xb3>
test   %rax,%rax
jne    11c3 <parse_number+0xb3>
lea    0xe9e(%rip),%rax
mov    %rax,(%r15)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    (%rsp),%rcx
cmp    %rbx,%rcx
je     1214 <parse_number+0x104>
movsbl (%rcx),%edx
lea    -0x47(%rdx),%esi
cmp    $0x26,%esi
ja     1207 <parse_number+0xf7>
movabs $0x100000001,%rdi
bt     %rsi,%rdi
jb     121d <parse_number+0x10d>
movabs $0x1000000010,%rdi
bt     %rsi,%rdi
jb     1225 <parse_number+0x115>
movabs $0x4000000040,%rdi
bt     %rsi,%rdi
jb     1221 <parse_number+0x111>
test   %edx,%edx
je     123b <parse_number+0x12b>
lea    0xea9(%rip),%rax
jmp    11b2 <parse_number+0xa2>
lea    0xe6d(%rip),%rax
jmp    11b2 <parse_number+0xa2>
shl    $0xa,%rax
shl    $0xa,%rax
cmpb   $0x0,0x1(%rcx)
je     1237 <parse_number+0x127>
lea    0xe66(%rip),%rax
jmp    11b2 <parse_number+0xa2>
shl    $0xa,%rax
mov    %rax,(%r14)
mov    $0x1,%eax
jmp    11b7 <parse_number+0xa7>

LLVM IR (-O0):
@errno = global i64 0
@ERANGE = global i64 0
@LLONG_MAX = global i64 0
@LLONG_MIN = global i64 0
@.str = [56 x i8] c"Long long underflow, overflow or other conversion error\00"
@.str.1 = [16 x i8] c"Number expected\00"
@.str.2 = [35 x i8] c"Trailing junk after size specifier\00"
@.str.3 = [27 x i8] c"Trailing junk after number\00"
define i32 @parse_number(i8* %0, i64* %1, i32* %2, i8** %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64*
%8 = alloca i32*
%9 = alloca i8**
%10 = alloca i8*
%11 = alloca i64
store i8* %0, i8** %6
store i64* %1, i64** %7
store i32* %2, i32** %8
store i8** %3, i8*** %9
%12 = load i8*, i8** %6
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 62
br i1 %15, label %21, label %16
16: ; preds = %4
%17 = load i8*, i8** %6
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 43
br i1 %20, label %21, label %25
21: ; preds = %16, %4
%22 = load i32*, i32** %8
store i32 3, i32* %22
%23 = load i8*, i8** %6
%24 = getelementptr inbounds i8, i8* %23, i32 1
store i8* %24, i8** %6
br label %42
25: ; preds = %16
%26 = load i8*, i8** %6
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 60
br i1 %29, label %35, label %30
30: ; preds = %25
%31 = load i8*, i8** %6
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 45
br i1 %34, label %35, label %39
35: ; preds = %30, %25
%36 = load i32*, i32** %8
store i32 2, i32* %36
%37 = load i8*, i8** %6
%38 = getelementptr inbounds i8, i8* %37, i32 1
store i8* %38, i8** %6
br label %41
39: ; preds = %30
%40 = load i32*, i32** %8
store i32 1, i32* %40
br label %41
41: ; preds = %39, %35
br label %42
42: ; preds = %41, %21
store i64 0, i64* @errno
%43 = load i8*, i8** %6
%44 = call i64 @strtoll(i8* %43, i8** %10, i32 10)
store i64 %44, i64* %11
%45 = load i64, i64* @errno
%46 = load i64, i64* @ERANGE
%47 = icmp eq i64 %45, %46
br i1 %47, label %48, label %56
48: ; preds = %42
%49 = load i64, i64* %11
%50 = load i64, i64* @LLONG_MAX
%51 = icmp eq i64 %49, %50
br i1 %51, label %62, label %52
52: ; preds = %48
%53 = load i64, i64* %11
%54 = load i64, i64* @LLONG_MIN
%55 = icmp eq i64 %53, %54
br i1 %55, label %62, label %56
56: ; preds = %52, %42
%57 = load i64, i64* @errno
%58 = icmp ne i64 %57, 0
br i1 %58, label %59, label %64
59: ; preds = %56
%60 = load i64, i64* %11
%61 = icmp eq i64 %60, 0
br i1 %61, label %62, label %64
62: ; preds = %59, %52, %48
%63 = load i8**, i8*** %9
store i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), i8** %63
store i32 0, i32* %5
br label %98
64: ; preds = %59, %56
%65 = load i8*, i8** %10
%66 = load i8*, i8** %6
%67 = icmp eq i8* %65, %66
br i1 %67, label %68, label %70
68: ; preds = %64
%69 = load i8**, i8*** %9
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8** %69
store i32 0, i32* %5
br label %98
70: ; preds = %64
%71 = load i8*, i8** %10
%72 = getelementptr inbounds i8, i8* %71, i64 0
%73 = load i8, i8* %72
%74 = sext i8 %73 to i32
switch i32 %74, label %93 [
i32 103, label %75
i32 71, label %75
i32 109, label %78
i32 77, label %78
i32 107, label %81
i32 75, label %81
i32 0, label %92
]
75: ; preds = %70, %70
%76 = load i64, i64* %11
%77 = mul nsw i64 %76, 1024
store i64 %77, i64* %11
br label %78
78: ; preds = %70, %70, %75
%79 = load i64, i64* %11
%80 = mul nsw i64 %79, 1024
store i64 %80, i64* %11
br label %81
81: ; preds = %70, %70, %78
%82 = load i64, i64* %11
%83 = mul nsw i64 %82, 1024
store i64 %83, i64* %11
%84 = load i8*, i8** %10
%85 = getelementptr inbounds i8, i8* %84, i64 1
%86 = load i8, i8* %85
%87 = sext i8 %86 to i32
%88 = icmp ne i32 %87, 0
br i1 %88, label %89, label %91
89: ; preds = %81
%90 = load i8**, i8*** %9
store i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i8** %90
store i32 0, i32* %5
br label %98
91: ; preds = %81
br label %95
92: ; preds = %70
br label %95
93: ; preds = %70
%94 = load i8**, i8*** %9
store i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i8** %94
store i32 0, i32* %5
br label %98
95: ; preds = %92, %91
%96 = load i64, i64* %11
%97 = load i64*, i64** %7
store i64 %96, i64* %97
store i32 1, i32* %5
br label %98
98: ; preds = %95, %93, %89, %68, %62
%99 = load i32, i32* %5
ret i32 %99
}

LLVM IR (-O2):
@errno = global i64 0
@ERANGE = global i64 0
@LLONG_MAX = global i64 0
@LLONG_MIN = global i64 0
@.str = [56 x i8] c"Long long underflow, overflow or other conversion error\00"
@.str.1 = [16 x i8] c"Number expected\00"
@.str.2 = [35 x i8] c"Trailing junk after size specifier\00"
@.str.3 = [27 x i8] c"Trailing junk after number\00"
define i32 @parse_number(i8* %0, i64* nocapture writeonly %1, i32* nocapture writeonly %2, i8** nocapture writeonly %3) {
%5 = alloca i8*
%6 = bitcast i8** %5 to i8*
%7 = load i8, i8* %0
switch i8 %7, label %12 [
i8 62, label %8
i8 43, label %8
i8 60, label %10
i8 45, label %10
]
8: ; preds = %4, %4
store i32 3, i32* %2
%9 = getelementptr inbounds i8, i8* %0, i64 1
br label %13
10: ; preds = %4, %4
store i32 2, i32* %2
%11 = getelementptr inbounds i8, i8* %0, i64 1
br label %13
12: ; preds = %4
store i32 1, i32* %2
br label %13
13: ; preds = %10, %12, %8
%14 = phi i8* [ %9, %8 ], [ %11, %10 ], [ %0, %12 ]
store i64 0, i64* @errno
%15 = call i64 @strtoll(i8* %14, i8** %5, i32 10)
%16 = load i64, i64* @errno
%17 = load i64, i64* @ERANGE
%18 = icmp eq i64 %16, %17
br i1 %18, label %19, label %25
19: ; preds = %13
%20 = load i64, i64* @LLONG_MAX
%21 = icmp eq i64 %15, %20
%22 = load i64, i64* @LLONG_MIN
%23 = icmp eq i64 %15, %22
%24 = select i1 %21, i1 true, i1 %23
br i1 %24, label %29, label %25
25: ; preds = %19, %13
%26 = icmp ne i64 %16, 0
%27 = icmp eq i64 %15, 0
%28 = select i1 %26, i1 %27, i1 false
br i1 %28, label %29, label %30
29: ; preds = %25, %19
store i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), i8** %3
br label %52
30: ; preds = %25
%31 = load i8*, i8** %5
%32 = icmp eq i8* %31, %14
br i1 %32, label %33, label %34
33: ; preds = %30
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8** %3
br label %52
34: ; preds = %30
%35 = load i8, i8* %31
%36 = sext i8 %35 to i32
switch i32 %36, label %49 [
i32 103, label %37
i32 71, label %37
i32 109, label %39
i32 77, label %39
i32 107, label %42
i32 75, label %42
i32 0, label %50
]
37: ; preds = %34, %34
%38 = shl nsw i64 %15, 10
br label %39
39: ; preds = %34, %34, %37
%40 = phi i64 [ %15, %34 ], [ %15, %34 ], [ %38, %37 ]
%41 = shl nsw i64 %40, 10
br label %42
42: ; preds = %34, %34, %39
%43 = phi i64 [ %15, %34 ], [ %15, %34 ], [ %41, %39 ]
%44 = shl nsw i64 %43, 10
%45 = getelementptr inbounds i8, i8* %31, i64 1
%46 = load i8, i8* %45
%47 = icmp eq i8 %46, 0
br i1 %47, label %50, label %48
48: ; preds = %42
store i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i8** %3
br label %52
49: ; preds = %34
store i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i8** %3
br label %52
50: ; preds = %42, %34
%51 = phi i64 [ %15, %34 ], [ %44, %42 ]
store i64 %51, i64* %1
br label %52
52: ; preds = %50, %49, %48, %33, %29
%53 = phi i32 [ 0, %29 ], [ 0, %33 ], [ 0, %49 ], [ 1, %50 ], [ 0, %48 ]
ret i32 %53
}