#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 */
typedef scalar_t__ KeySym;
typedef int Bool;

/* Variables and functions */
scalar_t__ NoSymbol;
int True;
scalar_t__ XStringToKeysym(char *);
char *copy_to_scratch(char const *, int);
int parse_number(char *, scalar_t__ *);
int /*<<< orphan*/ strcmp(char *, char *);
Bool parse_keysym(const char *line, int n, char **name, KeySym *keysym) {
  *name = copy_to_scratch(line, n);
  if (!strcmp(*name, "NoSymbol")) {
    *keysym = NoSymbol;
    return (True);
  }
  *keysym = XStringToKeysym(*name);
  if (*keysym == NoSymbol && '0' <= **name && **name <= '9')
    return parse_number(*name, keysym);
  return (*keysym != NoSymbol);
}


x86 assembly (clang, -O0):
<parse_keysym>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <copy_to_scratch@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
lea    0xe85(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11ab <parse_keysym+0x6b>
mov    0x2e58(%rip),%rax
mov    (%rax),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
mov    0x2e3f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1236 <parse_keysym+0xf6>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
call   1060 <XStringToKeysym@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
mov    0x2e19(%rip),%rcx
cmp    (%rcx),%rax
jne    121a <parse_keysym+0xda>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%ecx
mov    $0x30,%eax
cmp    %ecx,%eax
jg     121a <parse_keysym+0xda>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x39,%eax
jg     121a <parse_keysym+0xda>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
mov    -0x28(%rbp),%rsi
call   1050 <parse_number@plt>
mov    %eax,-0x4(%rbp)
jmp    1236 <parse_keysym+0xf6>
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
mov    0x2dc0(%rip),%rcx
cmp    (%rcx),%rax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_keysym>:
push   %r15
push   %r14
push   %rbx
mov    %rcx,%r14
mov    %rdx,%r15
call   1040 <copy_to_scratch@plt>
mov    %rax,%rbx
mov    %rax,(%r15)
lea    0xea3(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11a7 <parse_keysym+0x67>
mov    %rbx,%rdi
call   1060 <XStringToKeysym@plt>
mov    %rax,(%r14)
mov    0x2e6d(%rip),%rcx
mov    (%rcx),%rdx
cmp    %rdx,%rax
jne    119d <parse_keysym+0x5d>
mov    (%r15),%rdi
mov    (%rdi),%cl
add    $0xd0,%cl
cmp    $0x9,%cl
ja     119d <parse_keysym+0x5d>
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <parse_number@plt>
xor    %ecx,%ecx
cmp    %rdx,%rax
setne  %cl
jmp    11bd <parse_keysym+0x7d>
mov    0x2e3a(%rip),%rax
mov    (%rax),%rax
mov    %rax,(%r14)
mov    0x2e25(%rip),%rax
mov    (%rax),%ecx
mov    %ecx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [9 x i8] c"NoSymbol\00"
@NoSymbol = global i64 0
@True = global i32 0
define i32 @parse_keysym(i8* %0, i32 %1, i8** %2, i64* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8**
%9 = alloca i64*
store i8* %0, i8** %6
store i32 %1, i32* %7
store i8** %2, i8*** %8
store i64* %3, i64** %9
%10 = load i8*, i8** %6
%11 = load i32, i32* %7
%12 = call i8* @copy_to_scratch(i8* %10, i32 %11)
%13 = load i8**, i8*** %8
store i8* %12, i8** %13
%14 = load i8**, i8*** %8
%15 = load i8*, i8** %14
%16 = call i32 @strcmp(i8* %15, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%17 = icmp ne i32 %16, 0
br i1 %17, label %22, label %18
18: ; preds = %4
%19 = load i64, i64* @NoSymbol
%20 = load i64*, i64** %9
store i64 %19, i64* %20
%21 = load i32, i32* @True
store i32 %21, i32* %5
br label %54
22: ; preds = %4
%23 = load i8**, i8*** %8
%24 = load i8*, i8** %23
%25 = call i64 @XStringToKeysym(i8* %24)
%26 = load i64*, i64** %9
store i64 %25, i64* %26
%27 = load i64*, i64** %9
%28 = load i64, i64* %27
%29 = load i64, i64* @NoSymbol
%30 = icmp eq i64 %28, %29
br i1 %30, label %31, label %48
31: ; preds = %22
%32 = load i8**, i8*** %8
%33 = load i8*, i8** %32
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp sle i32 48, %35
br i1 %36, label %37, label %48
37: ; preds = %31
%38 = load i8**, i8*** %8
%39 = load i8*, i8** %38
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = icmp sle i32 %41, 57
br i1 %42, label %43, label %48
43: ; preds = %37
%44 = load i8**, i8*** %8
%45 = load i8*, i8** %44
%46 = load i64*, i64** %9
%47 = call i32 @parse_number(i8* %45, i64* %46)
store i32 %47, i32* %5
br label %54
48: ; preds = %37, %31, %22
%49 = load i64*, i64** %9
%50 = load i64, i64* %49
%51 = load i64, i64* @NoSymbol
%52 = icmp ne i64 %50, %51
%53 = zext i1 %52 to i32
store i32 %53, i32* %5
br label %54
54: ; preds = %48, %43, %18
%55 = load i32, i32* %5
ret i32 %55
}

LLVM IR (-O2):
@.str = [9 x i8] c"NoSymbol\00"
@NoSymbol = global i64 0
@True = global i32 0
define i32 @parse_keysym(i8* %0, i32 %1, i8** nocapture %2, i64* %3) {
%5 = tail call i8* @copy_to_scratch(i8* %0, i32 %1)
store i8* %5, i8** %2
%6 = tail call i32 @strcmp(i8* dereferenceable(1) %5, i8* dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %4
%9 = load i64, i64* @NoSymbol
store i64 %9, i64* %3
%10 = load i32, i32* @True
br label %25
11: ; preds = %4
%12 = tail call i64 @XStringToKeysym(i8* %5)
store i64 %12, i64* %3
%13 = load i64, i64* @NoSymbol
%14 = icmp eq i64 %12, %13
br i1 %14, label %15, label %22
15: ; preds = %11
%16 = load i8*, i8** %2
%17 = load i8, i8* %16
%18 = add i8 %17, -48
%19 = icmp ult i8 %18, 10
br i1 %19, label %20, label %22
20: ; preds = %15
%21 = tail call i32 @parse_number(i8* %16, i64* %3)
br label %25
22: ; preds = %15, %11
%23 = icmp ne i64 %12, %13
%24 = zext i1 %23 to i32
br label %25
25: ; preds = %22, %20, %8
%26 = phi i32 [ %21, %20 ], [ %24, %22 ], [ %10, %8 ]
ret i32 %26
}