#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 frozen {
  int dummy;
};

/* Variables and functions */
int cur(struct frozen *);
scalar_t__ is_alpha(int);
int parse_identifier(struct frozen *);
int parse_string(struct frozen *);
int parse_key(struct frozen *f) {
  int ch = cur(f);
  if (is_alpha(ch)) {
    do {
      int n = parse_identifier(f);
      if (n < 0)
        return n;
    } while (0);
  } else if (ch == '"') {
    do {
      int n = parse_string(f);
      if (n < 0)
        return n;
    } while (0);
  } else {
    return ch == (-1) ? -2 : -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<parse_key>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <cur@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1060 <is_alpha@plt>
cmp    $0x0,%rax
je     119a <parse_key+0x5a>
jmp    116f <parse_key+0x2f>
mov    -0x10(%rbp),%rdi
call   1040 <parse_identifier@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    1190 <parse_key+0x50>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11fb <parse_key+0xbb>
jmp    1195 <parse_key+0x55>
jmp    11f4 <parse_key+0xb4>
cmpl   $0x22,-0x14(%rbp)
jne    11d4 <parse_key+0x94>
jmp    11a9 <parse_key+0x69>
mov    -0x10(%rbp),%rdi
call   1030 <parse_string@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    11ca <parse_key+0x8a>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11fb <parse_key+0xbb>
jmp    11cf <parse_key+0x8f>
jmp    11ef <parse_key+0xaf>
mov    -0x14(%rbp),%edx
mov    $0xffffffff,%eax
mov    $0xfffffffe,%ecx
cmp    $0xffffffff,%edx
cmove  %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    11fb <parse_key+0xbb>
jmp    11f4 <parse_key+0xb4>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_key>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1050 <cur@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   1060 <is_alpha@plt>
test   %rax,%rax
je     1167 <parse_key+0x27>
mov    %rbx,%rdi
call   1040 <parse_identifier@plt>
test   %eax,%eax
jns    1178 <parse_key+0x38>
jmp    1186 <parse_key+0x46>
cmp    $0x22,%ebp
jne    117c <parse_key+0x3c>
mov    %rbx,%rdi
call   1030 <parse_string@plt>
test   %eax,%eax
js     1186 <parse_key+0x46>
xor    %eax,%eax
jmp    1186 <parse_key+0x46>
xor    %eax,%eax
cmp    $0xffffffff,%ebp
sete   %al
not    %eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.frozen = type { i32 }
define i32 @parse_key(%struct.frozen* %0) {
%2 = alloca i32
%3 = alloca %struct.frozen*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store %struct.frozen* %0, %struct.frozen** %3
%7 = load %struct.frozen*, %struct.frozen** %3
%8 = call i32 @cur(%struct.frozen* %7)
store i32 %8, i32* %4
%9 = load i32, i32* %4
%10 = call i64 @is_alpha(i32 %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %22
12: ; preds = %1
br label %13
13: ; preds = %12
%14 = load %struct.frozen*, %struct.frozen** %3
%15 = call i32 @parse_identifier(%struct.frozen* %14)
store i32 %15, i32* %5
%16 = load i32, i32* %5
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = load i32, i32* %5
store i32 %19, i32* %2
br label %42
20: ; preds = %13
br label %21
21: ; preds = %20
br label %41
22: ; preds = %1
%23 = load i32, i32* %4
%24 = icmp eq i32 %23, 34
br i1 %24, label %25, label %35
25: ; preds = %22
br label %26
26: ; preds = %25
%27 = load %struct.frozen*, %struct.frozen** %3
%28 = call i32 @parse_string(%struct.frozen* %27)
store i32 %28, i32* %6
%29 = load i32, i32* %6
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %26
%32 = load i32, i32* %6
store i32 %32, i32* %2
br label %42
33: ; preds = %26
br label %34
34: ; preds = %33
br label %40
35: ; preds = %22
%36 = load i32, i32* %4
%37 = icmp eq i32 %36, -1
%38 = zext i1 %37 to i64
%39 = select i1 %37, i32 -2, i32 -1
store i32 %39, i32* %2
br label %42
40: ; preds = %34
br label %41
41: ; preds = %40, %21
store i32 0, i32* %2
br label %42
42: ; preds = %41, %35, %31, %18
%43 = load i32, i32* %2
ret i32 %43
}

LLVM IR (-O2):
%struct.frozen = type { i32 }
define i32 @parse_key(%struct.frozen* %0) {
%2 = tail call i32 @cur(%struct.frozen* %0)
%3 = tail call i64 @is_alpha(i32 %2)
%4 = icmp eq i64 %3, 0
br i1 %4, label %8, label %5
5: ; preds = %1
%6 = tail call i32 @parse_identifier(%struct.frozen* %0)
%7 = icmp slt i32 %6, 0
br i1 %7, label %17, label %16
8: ; preds = %1
%9 = icmp eq i32 %2, 34
br i1 %9, label %10, label %13
10: ; preds = %8
%11 = tail call i32 @parse_string(%struct.frozen* %0)
%12 = icmp slt i32 %11, 0
br i1 %12, label %17, label %16
13: ; preds = %8
%14 = icmp eq i32 %2, -1
%15 = select i1 %14, i32 -2, i32 -1
br label %17
16: ; preds = %10, %5
br label %17
17: ; preds = %5, %10, %16, %13
%18 = phi i32 [ 0, %16 ], [ %6, %5 ], [ %11, %10 ], [ %15, %13 ]
ret i32 %18
}