#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 atoi(char const *);
int roadmap_gpsd2_decode_numeric(const char *input) {
  if (input[0] == '?')
    return -512000000;
  while (*input == '0')
    ++input;
  if (*input == 0)
    return 0;
  return atoi(input);
}


x86 assembly (clang, -O0):
<roadmap_gpsd2_decode_numeric>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3f,%eax
jne    1138 <roadmap_gpsd2_decode_numeric+0x28>
movl   $0xe17b8000,-0x4(%rbp)
jmp    1186 <roadmap_gpsd2_decode_numeric+0x76>
jmp    113d <roadmap_gpsd2_decode_numeric+0x2d>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
jne    115e <roadmap_gpsd2_decode_numeric+0x4e>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    113d <roadmap_gpsd2_decode_numeric+0x2d>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    117a <roadmap_gpsd2_decode_numeric+0x6a>
movl   $0x0,-0x4(%rbp)
jmp    1186 <roadmap_gpsd2_decode_numeric+0x76>
mov    -0x10(%rbp),%rdi
call   1030 <atoi@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<roadmap_gpsd2_decode_numeric>:
mov    (%rdi),%cl
mov    $0xe17b8000,%eax
cmp    $0x3f,%cl
je     1138 <roadmap_gpsd2_decode_numeric+0x28>
nopl   0x0(%rax)
cmp    $0x30,%cl
jne    1132 <roadmap_gpsd2_decode_numeric+0x22>
movzbl 0x1(%rdi),%ecx
add    $0x1,%rdi
cmp    $0x30,%cl
je     1125 <roadmap_gpsd2_decode_numeric+0x15>
test   %cl,%cl
jne    1139 <roadmap_gpsd2_decode_numeric+0x29>
xor    %eax,%eax
ret
jmp    1030 <atoi@plt>

LLVM IR (-O0):
define i32 @roadmap_gpsd2_decode_numeric(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = getelementptr inbounds i8, i8* %4, i64 0
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
%8 = icmp eq i32 %7, 63
br i1 %8, label %9, label %10
9: ; preds = %1
store i32 -512000000, i32* %2
br label %28
10: ; preds = %1
br label %11
11: ; preds = %16, %10
%12 = load i8*, i8** %3
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 48
br i1 %15, label %16, label %19
16: ; preds = %11
%17 = load i8*, i8** %3
%18 = getelementptr inbounds i8, i8* %17, i32 1
store i8* %18, i8** %3
br label %11
19: ; preds = %11
%20 = load i8*, i8** %3
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %19
store i32 0, i32* %2
br label %28
25: ; preds = %19
%26 = load i8*, i8** %3
%27 = call i32 @atoi(i8* %26)
store i32 %27, i32* %2
br label %28
28: ; preds = %25, %24, %9
%29 = load i32, i32* %2
ret i32 %29
}

LLVM IR (-O2):
define i32 @roadmap_gpsd2_decode_numeric(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 63
br i1 %3, label %12, label %4
4: ; preds = %1, %7
%5 = phi i8 [ %9, %7 ], [ %2, %1 ]
%6 = phi i8* [ %8, %7 ], [ %0, %1 ]
switch i8 %5, label %10 [
i8 48, label %7
i8 0, label %12
]
7: ; preds = %4
%8 = getelementptr inbounds i8, i8* %6, i64 1
%9 = load i8, i8* %8
br label %4
10: ; preds = %4
%11 = tail call i32 @atoi(i8* %6)
br label %12
12: ; preds = %4, %1, %10
%13 = phi i32 [ %11, %10 ], [ -512000000, %1 ], [ 0, %4 ]
ret i32 %13
}