#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 */
struct label {
  int dummy;
};

/* Variables and functions */
int get_cconst(char *, char *);
int get_dconst(char *, char *);
int get_hconst(char *, char *);
int get_lconst(char *, char *, struct label *);
scalar_t__ isalpha(char);
scalar_t__ isdigit(char);
int /*<<< orphan*/ printf(char *, int);
int get_const(char *str, char *delim, struct label *l, int line) {
  int val;
  if (*str == '\'') {
    if ((val = get_cconst(str, delim)) < 0) {
      printf("Illegal character constant in Line %d.\n", line);
      return (-3);
    }
  } else if (*str == '0' && *(str + 1) == 'x') {
    if ((val = get_hconst(str, delim)) < 0) {
      printf("Illegal hex constant in Line %d.\n", line);
      return (-3);
    }
  } else if (isalpha(*str) || *str == '_') {
    if ((val = get_lconst(str, delim, l)) < 0) {
      printf("Illegal label constant in line %d.\n", line);
      return (-3);
    }
  } else if (isdigit(*str)) {
    if ((val = get_dconst(str, delim)) < 0) {
      printf("Illegal decimal constant in line %d.\n", line);
      return (-3);
    }
  } else {
    printf("Unknown constant in line %d\n", line);
    return (-3);
  }
  return val;
}


x86 assembly (clang, -O0):
<get_const>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x27,%eax
jne    11d0 <get_const+0x60>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <get_cconst@plt>
mov    %eax,-0x28(%rbp)
cmp    $0x0,%eax
jge    11cb <get_const+0x5b>
mov    -0x24(%rbp),%esi
lea    0xe46(%rip),%rdi
call   1050 <printf@plt>
movl   $0xfffffffd,-0x4(%rbp)
jmp    130c <get_const+0x19c>
jmp    1306 <get_const+0x196>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
jne    122a <get_const+0xba>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x78,%eax
jne    122a <get_const+0xba>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1090 <get_hconst@plt>
mov    %eax,-0x28(%rbp)
cmp    $0x0,%eax
jge    1225 <get_const+0xb5>
mov    -0x24(%rbp),%esi
lea    0xe14(%rip),%rdi
call   1050 <printf@plt>
movl   $0xfffffffd,-0x4(%rbp)
jmp    130c <get_const+0x19c>
jmp    1301 <get_const+0x191>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1060 <isalpha@plt>
cmp    $0x0,%rax
jne    1250 <get_const+0xe0>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5f,%eax
jne    128d <get_const+0x11d>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1080 <get_lconst@plt>
mov    %eax,-0x28(%rbp)
cmp    $0x0,%eax
jge    1288 <get_const+0x118>
mov    -0x24(%rbp),%esi
lea    0xdd3(%rip),%rdi
call   1050 <printf@plt>
movl   $0xfffffffd,-0x4(%rbp)
jmp    130c <get_const+0x19c>
jmp    12fc <get_const+0x18c>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     12dc <get_const+0x16c>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <get_dconst@plt>
mov    %eax,-0x28(%rbp)
cmp    $0x0,%eax
jge    12d7 <get_const+0x167>
mov    -0x24(%rbp),%esi
lea    0xda8(%rip),%rdi
call   1050 <printf@plt>
movl   $0xfffffffd,-0x4(%rbp)
jmp    130c <get_const+0x19c>
jmp    12f7 <get_const+0x187>
mov    -0x24(%rbp),%esi
lea    0xdae(%rip),%rdi
call   1050 <printf@plt>
movl   $0xfffffffd,-0x4(%rbp)
jmp    130c <get_const+0x19c>
jmp    12fc <get_const+0x18c>
jmp    1301 <get_const+0x191>
jmp    1306 <get_const+0x196>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_const>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%rbp
mov    (%rdi),%al
cmp    $0x30,%al
je     11a5 <get_const+0x35>
cmp    $0x27,%al
jne    11c3 <get_const+0x53>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1070 <get_cconst@plt>
test   %eax,%eax
jns    11fd <get_const+0x8d>
lea    0xe5d(%rip),%rdi
jmp    11f0 <get_const+0x80>
cmpb   $0x78,0x1(%rbp)
jne    11c3 <get_const+0x53>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1090 <get_hconst@plt>
test   %eax,%eax
jns    11fd <get_const+0x8d>
lea    0xe67(%rip),%rdi
jmp    11f0 <get_const+0x80>
movsbl %al,%edi
call   1060 <isalpha@plt>
test   %rax,%rax
jne    11d7 <get_const+0x67>
mov    0x0(%rbp),%al
cmp    $0x5f,%al
jne    1208 <get_const+0x98>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1080 <get_lconst@plt>
test   %eax,%eax
jns    11fd <get_const+0x8d>
lea    0xe5a(%rip),%rdi
mov    %r14d,%esi
call   1050 <printf@plt>
mov    $0xfffffffd,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
movsbl %al,%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     122d <get_const+0xbd>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1040 <get_dconst@plt>
test   %eax,%eax
jns    11fd <get_const+0x8d>
lea    0xe43(%rip),%rdi
jmp    11f0 <get_const+0x80>
lea    0xe60(%rip),%rdi
jmp    11f0 <get_const+0x80>

LLVM IR (-O0):
%struct.label = type { i32 }
@.str = [40 x i8] c"Illegal character constant in Line %d.\0A\00"
@.str.1 = [34 x i8] c"Illegal hex constant in Line %d.\0A\00"
@.str.2 = [36 x i8] c"Illegal label constant in line %d.\0A\00"
@.str.3 = [38 x i8] c"Illegal decimal constant in line %d.\0A\00"
@.str.4 = [29 x i8] c"Unknown constant in line %d\0A\00"
define i32 @get_const(i8* %0, i8* %1, %struct.label* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca %struct.label*
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store %struct.label* %2, %struct.label** %8
store i32 %3, i32* %9
%11 = load i8*, i8** %6
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 39
br i1 %14, label %15, label %24
15: ; preds = %4
%16 = load i8*, i8** %6
%17 = load i8*, i8** %7
%18 = call i32 @get_cconst(i8* %16, i8* %17)
store i32 %18, i32* %10
%19 = icmp slt i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %15
%21 = load i32, i32* %9
%22 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 %21)
store i32 -3, i32* %5
br label %86
23: ; preds = %15
br label %84
24: ; preds = %4
%25 = load i8*, i8** %6
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 48
br i1 %28, label %29, label %44
29: ; preds = %24
%30 = load i8*, i8** %6
%31 = getelementptr inbounds i8, i8* %30, i64 1
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 120
br i1 %34, label %35, label %44
35: ; preds = %29
%36 = load i8*, i8** %6
%37 = load i8*, i8** %7
%38 = call i32 @get_hconst(i8* %36, i8* %37)
store i32 %38, i32* %10
%39 = icmp slt i32 %38, 0
br i1 %39, label %40, label %43
40: ; preds = %35
%41 = load i32, i32* %9
%42 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 %41)
store i32 -3, i32* %5
br label %86
43: ; preds = %35
br label %83
44: ; preds = %29, %24
%45 = load i8*, i8** %6
%46 = load i8, i8* %45
%47 = call i64 @isalpha(i8 signext %46)
%48 = icmp ne i64 %47, 0
br i1 %48, label %54, label %49
49: ; preds = %44
%50 = load i8*, i8** %6
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = icmp eq i32 %52, 95
br i1 %53, label %54, label %64
54: ; preds = %49, %44
%55 = load i8*, i8** %6
%56 = load i8*, i8** %7
%57 = load %struct.label*, %struct.label** %8
%58 = call i32 @get_lconst(i8* %55, i8* %56, %struct.label* %57)
store i32 %58, i32* %10
%59 = icmp slt i32 %58, 0
br i1 %59, label %60, label %63
60: ; preds = %54
%61 = load i32, i32* %9
%62 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i32 %61)
store i32 -3, i32* %5
br label %86
63: ; preds = %54
br label %82
64: ; preds = %49
%65 = load i8*, i8** %6
%66 = load i8, i8* %65
%67 = call i64 @isdigit(i8 signext %66)
%68 = icmp ne i64 %67, 0
br i1 %68, label %69, label %78
69: ; preds = %64
%70 = load i8*, i8** %6
%71 = load i8*, i8** %7
%72 = call i32 @get_dconst(i8* %70, i8* %71)
store i32 %72, i32* %10
%73 = icmp slt i32 %72, 0
br i1 %73, label %74, label %77
74: ; preds = %69
%75 = load i32, i32* %9
%76 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 %75)
store i32 -3, i32* %5
br label %86
77: ; preds = %69
br label %81
78: ; preds = %64
%79 = load i32, i32* %9
%80 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i32 %79)
store i32 -3, i32* %5
br label %86
81: ; preds = %77
br label %82
82: ; preds = %81, %63
br label %83
83: ; preds = %82, %43
br label %84
84: ; preds = %83, %23
%85 = load i32, i32* %10
store i32 %85, i32* %5
br label %86
86: ; preds = %84, %78, %74, %60, %40, %20
%87 = load i32, i32* %5
ret i32 %87
}

LLVM IR (-O2):
%struct.label = type { i32 }
@.str = [40 x i8] c"Illegal character constant in Line %d.\0A\00"
@.str.1 = [34 x i8] c"Illegal hex constant in Line %d.\0A\00"
@.str.2 = [36 x i8] c"Illegal label constant in line %d.\0A\00"
@.str.3 = [38 x i8] c"Illegal decimal constant in line %d.\0A\00"
@.str.4 = [29 x i8] c"Unknown constant in line %d\0A\00"
define i32 @get_const(i8* %0, i8* %1, %struct.label* %2, i32 %3) {
%5 = load i8, i8* %0
switch i8 %5, label %16 [
i8 39, label %6
i8 48, label %9
]
6: ; preds = %4
%7 = tail call i32 @get_cconst(i8* %0, i8* %1)
%8 = icmp slt i32 %7, 0
br i1 %8, label %31, label %34
9: ; preds = %4
%10 = getelementptr inbounds i8, i8* %0, i64 1
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 120
br i1 %12, label %13, label %16
13: ; preds = %9
%14 = tail call i32 @get_hconst(i8* %0, i8* %1)
%15 = icmp slt i32 %14, 0
br i1 %15, label %31, label %34
16: ; preds = %4, %9
%17 = tail call i64 @isalpha(i8 signext %5)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = load i8, i8* %0
%21 = icmp eq i8 %20, 95
br i1 %21, label %22, label %25
22: ; preds = %19, %16
%23 = tail call i32 @get_lconst(i8* %0, i8* %1, %struct.label* %2)
%24 = icmp slt i32 %23, 0
br i1 %24, label %31, label %34
25: ; preds = %19
%26 = tail call i64 @isdigit(i8 signext %20)
%27 = icmp eq i64 %26, 0
br i1 %27, label %31, label %28
28: ; preds = %25
%29 = tail call i32 @get_dconst(i8* %0, i8* %1)
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %25, %28, %22, %13, %6
%32 = phi i8* [ getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), %6 ], [ getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), %13 ], [ getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), %22 ], [ getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), %28 ], [ getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), %25 ]
%33 = tail call i32 @printf(i8* %32, i32 %3)
br label %34
34: ; preds = %31, %6, %22, %28, %13
%35 = phi i32 [ %7, %6 ], [ %14, %13 ], [ %23, %22 ], [ %29, %28 ], [ -3, %31 ]
ret i32 %35
}