#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 get_bin_constant(char *);
int get_dec_constant(char *);
int get_hex_constant(char *);
int get_pointer_from_line(char *);
scalar_t__ isdigit(char);
scalar_t__ string_match(char *, char *);
int get_constant(char *line) {
  if (string_match(line, "0x"))
    return get_hex_constant(line + 2);
  else if (string_match(line, "h"))
    return get_hex_constant(line + 1);
  else if (string_match(line, "b"))
    return get_bin_constant(line + 1);
  else if (string_match(line, "-"))
    return get_dec_constant(line + 1) * -1;
  else if (isdigit(line[0]))
    return get_dec_constant(line);
  else if (string_match(line, "_"))
    return get_pointer_from_line(line);
  else
    return 0xffff;
}


x86 assembly (clang, -O0):
<get_constant>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe89(%rip),%rsi
call   1080 <string_match@plt>
cmp    $0x0,%rax
je     119b <get_constant+0x3b>
mov    -0x10(%rbp),%rdi
add    $0x2,%rdi
call   1050 <get_hex_constant@plt>
mov    %eax,-0x4(%rbp)
jmp    1284 <get_constant+0x124>
mov    -0x10(%rbp),%rdi
lea    0xe5d(%rip),%rsi
call   1080 <string_match@plt>
cmp    $0x0,%rax
je     11ca <get_constant+0x6a>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
call   1050 <get_hex_constant@plt>
mov    %eax,-0x4(%rbp)
jmp    1284 <get_constant+0x124>
mov    -0x10(%rbp),%rdi
lea    0xe30(%rip),%rsi
call   1080 <string_match@plt>
cmp    $0x0,%rax
je     11f9 <get_constant+0x99>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
call   1070 <get_bin_constant@plt>
mov    %eax,-0x4(%rbp)
jmp    1284 <get_constant+0x124>
mov    -0x10(%rbp),%rdi
lea    0xe03(%rip),%rsi
call   1080 <string_match@plt>
cmp    $0x0,%rax
je     122b <get_constant+0xcb>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
call   1040 <get_dec_constant@plt>
imul   $0xffffffff,%eax,%eax
mov    %eax,-0x4(%rbp)
jmp    1284 <get_constant+0x124>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     1252 <get_constant+0xf2>
mov    -0x10(%rbp),%rdi
call   1040 <get_dec_constant@plt>
mov    %eax,-0x4(%rbp)
jmp    1284 <get_constant+0x124>
mov    -0x10(%rbp),%rdi
lea    0xdac(%rip),%rsi
call   1080 <string_match@plt>
cmp    $0x0,%rax
je     127d <get_constant+0x11d>
mov    -0x10(%rbp),%rdi
call   1060 <get_pointer_from_line@plt>
mov    %eax,-0x4(%rbp)
jmp    1284 <get_constant+0x124>
movl   $0xffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_constant>:
push   %rbx
mov    %rdi,%rbx
lea    0xe95(%rip),%rsi
call   1080 <string_match@plt>
test   %rax,%rax
je     117b <get_constant+0x1b>
add    $0x2,%rbx
jmp    1193 <get_constant+0x33>
lea    0xe81(%rip),%rsi
mov    %rbx,%rdi
call   1080 <string_match@plt>
test   %rax,%rax
je     119c <get_constant+0x3c>
add    $0x1,%rbx
mov    %rbx,%rdi
pop    %rbx
jmp    1050 <get_hex_constant@plt>
lea    0xe62(%rip),%rsi
mov    %rbx,%rdi
call   1080 <string_match@plt>
test   %rax,%rax
je     11bd <get_constant+0x5d>
add    $0x1,%rbx
mov    %rbx,%rdi
pop    %rbx
jmp    1070 <get_bin_constant@plt>
lea    0xe43(%rip),%rsi
mov    %rbx,%rdi
call   1080 <string_match@plt>
test   %rax,%rax
je     11e1 <get_constant+0x81>
add    $0x1,%rbx
mov    %rbx,%rdi
call   1040 <get_dec_constant@plt>
neg    %eax
pop    %rbx
ret
movsbl (%rbx),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     11f7 <get_constant+0x97>
mov    %rbx,%rdi
pop    %rbx
jmp    1040 <get_dec_constant@plt>
lea    0xe0b(%rip),%rsi
mov    %rbx,%rdi
call   1080 <string_match@plt>
test   %rax,%rax
je     1214 <get_constant+0xb4>
mov    %rbx,%rdi
pop    %rbx
jmp    1060 <get_pointer_from_line@plt>
mov    $0xffff,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"0x\00"
@.str.1 = [2 x i8] c"h\00"
@.str.2 = [2 x i8] c"b\00"
@.str.3 = [2 x i8] c"-\00"
@.str.4 = [2 x i8] c"_\00"
define i32 @get_constant(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = call i64 @string_match(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %1
%8 = load i8*, i8** %3
%9 = getelementptr inbounds i8, i8* %8, i64 2
%10 = call i32 @get_hex_constant(i8* %9)
store i32 %10, i32* %2
br label %53
11: ; preds = %1
%12 = load i8*, i8** %3
%13 = call i64 @string_match(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %11
%16 = load i8*, i8** %3
%17 = getelementptr inbounds i8, i8* %16, i64 1
%18 = call i32 @get_hex_constant(i8* %17)
store i32 %18, i32* %2
br label %53
19: ; preds = %11
%20 = load i8*, i8** %3
%21 = call i64 @string_match(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %19
%24 = load i8*, i8** %3
%25 = getelementptr inbounds i8, i8* %24, i64 1
%26 = call i32 @get_bin_constant(i8* %25)
store i32 %26, i32* %2
br label %53
27: ; preds = %19
%28 = load i8*, i8** %3
%29 = call i64 @string_match(i8* %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %36
31: ; preds = %27
%32 = load i8*, i8** %3
%33 = getelementptr inbounds i8, i8* %32, i64 1
%34 = call i32 @get_dec_constant(i8* %33)
%35 = mul nsw i32 %34, -1
store i32 %35, i32* %2
br label %53
36: ; preds = %27
%37 = load i8*, i8** %3
%38 = getelementptr inbounds i8, i8* %37, i64 0
%39 = load i8, i8* %38
%40 = call i64 @isdigit(i8 signext %39)
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %45
42: ; preds = %36
%43 = load i8*, i8** %3
%44 = call i32 @get_dec_constant(i8* %43)
store i32 %44, i32* %2
br label %53
45: ; preds = %36
%46 = load i8*, i8** %3
%47 = call i64 @string_match(i8* %46, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%48 = icmp ne i64 %47, 0
br i1 %48, label %49, label %52
49: ; preds = %45
%50 = load i8*, i8** %3
%51 = call i32 @get_pointer_from_line(i8* %50)
store i32 %51, i32* %2
br label %53
52: ; preds = %45
store i32 65535, i32* %2
br label %53
53: ; preds = %52, %49, %42, %31, %23, %15, %7
%54 = load i32, i32* %2
ret i32 %54
}

LLVM IR (-O2):
@.str = [3 x i8] c"0x\00"
@.str.1 = [2 x i8] c"h\00"
@.str.2 = [2 x i8] c"b\00"
@.str.3 = [2 x i8] c"-\00"
@.str.4 = [2 x i8] c"_\00"
define i32 @get_constant(i8* %0) {
%2 = tail call i64 @string_match(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i64 %2, 0
br i1 %3, label %7, label %4
4: ; preds = %1
%5 = getelementptr inbounds i8, i8* %0, i64 2
%6 = tail call i32 @get_hex_constant(i8* %5)
br label %37
7: ; preds = %1
%8 = tail call i64 @string_match(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %7
%11 = getelementptr inbounds i8, i8* %0, i64 1
%12 = tail call i32 @get_hex_constant(i8* %11)
br label %37
13: ; preds = %7
%14 = tail call i64 @string_match(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %13
%17 = getelementptr inbounds i8, i8* %0, i64 1
%18 = tail call i32 @get_bin_constant(i8* %17)
br label %37
19: ; preds = %13
%20 = tail call i64 @string_match(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %26, label %22
22: ; preds = %19
%23 = getelementptr inbounds i8, i8* %0, i64 1
%24 = tail call i32 @get_dec_constant(i8* %23)
%25 = sub nsw i32 0, %24
br label %37
26: ; preds = %19
%27 = load i8, i8* %0
%28 = tail call i64 @isdigit(i8 signext %27)
%29 = icmp eq i64 %28, 0
br i1 %29, label %32, label %30
30: ; preds = %26
%31 = tail call i32 @get_dec_constant(i8* %0)
br label %37
32: ; preds = %26
%33 = tail call i64 @string_match(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %37, label %35
35: ; preds = %32
%36 = tail call i32 @get_pointer_from_line(i8* %0)
br label %37
37: ; preds = %32, %35, %30, %22, %16, %10, %4
%38 = phi i32 [ %6, %4 ], [ %12, %10 ], [ %18, %16 ], [ %25, %22 ], [ %31, %30 ], [ %36, %35 ], [ 65535, %32 ]
ret i32 %38
}