#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 */
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int parse_hotkey(char *key, char hotkey[10]) {
  strncpy(hotkey, key, 10 - 1);
  if (strcmp(key, "up") == 0)
    return 321;
  if (strcmp(key, "down") == 0)
    return 322;
  if (strcmp(key, "right") == 0)
    return 323;
  if (strcmp(key, "left") == 0)
    return 324;
  if (strcmp(key, "enter") == 0)
    return 13;
  hotkey[0] = key[0];
  hotkey[1] = 0;
  return key[0];
}


x86 assembly (clang, -O0):
<parse_hotkey>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x9,%edx
call   1030 <strncpy@plt>
mov    -0x10(%rbp),%rdi
lea    0xeb3(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1168 <parse_hotkey+0x48>
movl   $0x141,-0x4(%rbp)
jmp    121e <parse_hotkey+0xfe>
mov    -0x10(%rbp),%rdi
lea    0xe90(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    118e <parse_hotkey+0x6e>
movl   $0x142,-0x4(%rbp)
jmp    121e <parse_hotkey+0xfe>
mov    -0x10(%rbp),%rdi
lea    0xe6f(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11b4 <parse_hotkey+0x94>
movl   $0x143,-0x4(%rbp)
jmp    121e <parse_hotkey+0xfe>
mov    -0x10(%rbp),%rdi
lea    0xe4f(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11da <parse_hotkey+0xba>
movl   $0x144,-0x4(%rbp)
jmp    121e <parse_hotkey+0xfe>
mov    -0x10(%rbp),%rdi
lea    0xe2e(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1200 <parse_hotkey+0xe0>
movl   $0xd,-0x4(%rbp)
jmp    121e <parse_hotkey+0xfe>
mov    -0x10(%rbp),%rax
mov    (%rax),%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
movb   $0x0,0x1(%rax)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_hotkey>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsi,%rdi
mov    %rbx,%rsi
mov    $0x9,%edx
call   1030 <strncpy@plt>
lea    0xebf(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11ad <parse_hotkey+0x8d>
lea    0xeae(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11b4 <parse_hotkey+0x94>
lea    0xe9f(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11bb <parse_hotkey+0x9b>
lea    0xe91(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11c2 <parse_hotkey+0xa2>
lea    0xe82(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11c9 <parse_hotkey+0xa9>
mov    (%rbx),%al
mov    %al,(%r14)
movb   $0x0,0x1(%r14)
movsbl (%rbx),%eax
jmp    11ce <parse_hotkey+0xae>
mov    $0x141,%eax
jmp    11ce <parse_hotkey+0xae>
mov    $0x142,%eax
jmp    11ce <parse_hotkey+0xae>
mov    $0x143,%eax
jmp    11ce <parse_hotkey+0xae>
mov    $0x144,%eax
jmp    11ce <parse_hotkey+0xae>
mov    $0xd,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"up\00"
@.str.1 = [5 x i8] c"down\00"
@.str.2 = [6 x i8] c"right\00"
@.str.3 = [5 x i8] c"left\00"
@.str.4 = [6 x i8] c"enter\00"
define i32 @parse_hotkey(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%6 = load i8*, i8** %5
%7 = load i8*, i8** %4
%8 = call i32 @strncpy(i8* %6, i8* %7, i32 9)
%9 = load i8*, i8** %4
%10 = call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %2
store i32 321, i32* %3
br label %45
13: ; preds = %2
%14 = load i8*, i8** %4
%15 = call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %13
store i32 322, i32* %3
br label %45
18: ; preds = %13
%19 = load i8*, i8** %4
%20 = call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %18
store i32 323, i32* %3
br label %45
23: ; preds = %18
%24 = load i8*, i8** %4
%25 = call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %23
store i32 324, i32* %3
br label %45
28: ; preds = %23
%29 = load i8*, i8** %4
%30 = call i64 @strcmp(i8* %29, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %28
store i32 13, i32* %3
br label %45
33: ; preds = %28
%34 = load i8*, i8** %4
%35 = getelementptr inbounds i8, i8* %34, i64 0
%36 = load i8, i8* %35
%37 = load i8*, i8** %5
%38 = getelementptr inbounds i8, i8* %37, i64 0
store i8 %36, i8* %38
%39 = load i8*, i8** %5
%40 = getelementptr inbounds i8, i8* %39, i64 1
store i8 0, i8* %40
%41 = load i8*, i8** %4
%42 = getelementptr inbounds i8, i8* %41, i64 0
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
store i32 %44, i32* %3
br label %45
45: ; preds = %33, %32, %27, %22, %17, %12
%46 = load i32, i32* %3
ret i32 %46
}

LLVM IR (-O2):
@.str = [3 x i8] c"up\00"
@.str.1 = [5 x i8] c"down\00"
@.str.2 = [6 x i8] c"right\00"
@.str.3 = [5 x i8] c"left\00"
@.str.4 = [6 x i8] c"enter\00"
define i32 @parse_hotkey(i8* %0, i8* %1) {
%3 = tail call i32 @strncpy(i8* %1, i8* %0, i32 9)
%4 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
br i1 %5, label %23, label %6
6: ; preds = %2
%7 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %23, label %9
9: ; preds = %6
%10 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %23, label %12
12: ; preds = %9
%13 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %23, label %15
15: ; preds = %12
%16 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %23, label %18
18: ; preds = %15
%19 = load i8, i8* %0
store i8 %19, i8* %1
%20 = getelementptr inbounds i8, i8* %1, i64 1
store i8 0, i8* %20
%21 = load i8, i8* %0
%22 = sext i8 %21 to i32
br label %23
23: ; preds = %15, %12, %9, %6, %2, %18
%24 = phi i32 [ %22, %18 ], [ 321, %2 ], [ 322, %6 ], [ 323, %9 ], [ 324, %12 ], [ 13, %15 ]
ret i32 %24
}