void translate_joyname(int *joysymbol, char **name, int mode) {
  static struct {
    int joysymbol;
    char *name;
  } translate_joy[] = {
      {(1 << 0), "joystick_left"},     {(1 << 1), "joystick_right"},
      {(1 << 2), "joystick_up"},       {(1 << 3), "joystick_down"},
      {(1 << 4), "joystick_button_1"}, {(1 << 5), "joystick_button_2"},
  };
  int i;
  if (mode == 0) {
    *name = "[undefined]";
    for (i = 0; i < 6; i++) {
      if (*joysymbol == translate_joy[i].joysymbol) {
        *name = translate_joy[i].name;
        break;
      }
    }
  } else if (mode == 1) {
    *joysymbol = 0;
    for (i = 0; i < 6; i++) {
      if (strEqual(*name, translate_joy[i].name)) {
        *joysymbol = translate_joy[i].joysymbol;
        break;
      }
    }
  }
}


x86 assembly (clang, -O0):
<translate_joyname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    11a6 <translate_joyname+0x96>
mov    -0x10(%rbp),%rax
lea    0xf23(%rip),%rcx
mov    %rcx,(%rax)
movl   $0x0,-0x18(%rbp)
cmpl   $0x6,-0x18(%rbp)
jge    11a1 <translate_joyname+0x91>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
movslq -0x18(%rbp),%rdx
lea    0x2ed3(%rip),%rcx
shl    $0x4,%rdx
add    %rdx,%rcx
cmp    (%rcx),%eax
jne    118e <translate_joyname+0x7e>
movslq -0x18(%rbp),%rcx
lea    0x2eb9(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    0x8(%rax),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
jmp    11a1 <translate_joyname+0x91>
jmp    1193 <translate_joyname+0x83>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1142 <translate_joyname+0x32>
jmp    1234 <translate_joyname+0x124>
cmpl   $0x1,-0x14(%rbp)
jne    122f <translate_joyname+0x11f>
mov    -0x8(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x0,-0x18(%rbp)
cmpl   $0x6,-0x18(%rbp)
jge    122a <translate_joyname+0x11a>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
movslq -0x18(%rbp),%rcx
lea    0x2e53(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    0x8(%rax),%rsi
mov    $0x0,%al
call   1030 <strEqual@plt>
cmp    $0x0,%eax
je     1217 <translate_joyname+0x107>
movslq -0x18(%rbp),%rcx
lea    0x2e2d(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
jmp    122a <translate_joyname+0x11a>
jmp    121c <translate_joyname+0x10c>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11c1 <translate_joyname+0xb1>
jmp    122f <translate_joyname+0x11f>
jmp    1234 <translate_joyname+0x124>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<translate_joyname>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
cmp    $0x1,%edx
je     115d <translate_joyname+0x4d>
test   %edx,%edx
jne    1241 <translate_joyname+0x131>
lea    0xfac(%rip),%rax
mov    %rax,(%r14)
mov    (%r15),%ecx
add    $0xffffffff,%ecx
cmp    $0x1f,%ecx
ja     1241 <translate_joyname+0x131>
xor    %eax,%eax
lea    0xeb6(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
mov    $0x1,%eax
jmp    122e <translate_joyname+0x11e>
movl   $0x0,(%r15)
mov    (%r14),%rdi
lea    0xf12(%rip),%rsi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <strEqual@plt>
test   %eax,%eax
jne    1201 <translate_joyname+0xf1>
mov    (%r14),%rdi
lea    0xf05(%rip),%rsi
xor    %eax,%eax
call   1030 <strEqual@plt>
mov    $0x1,%ebx
test   %eax,%eax
jne    1201 <translate_joyname+0xf1>
mov    (%r14),%rdi
lea    0xefa(%rip),%rsi
xor    %eax,%eax
call   1030 <strEqual@plt>
mov    $0x2,%ebx
test   %eax,%eax
jne    1201 <translate_joyname+0xf1>
mov    (%r14),%rdi
lea    0xeec(%rip),%rsi
xor    %eax,%eax
call   1030 <strEqual@plt>
mov    $0x3,%ebx
test   %eax,%eax
jne    1201 <translate_joyname+0xf1>
mov    (%r14),%rdi
lea    0xee0(%rip),%rsi
xor    %eax,%eax
call   1030 <strEqual@plt>
mov    $0x4,%ebx
test   %eax,%eax
jne    1201 <translate_joyname+0xf1>
mov    (%r14),%rdi
lea    0xed8(%rip),%rsi
xor    %eax,%eax
call   1030 <strEqual@plt>
mov    $0x5,%ebx
test   %eax,%eax
je     1241 <translate_joyname+0x131>
shl    $0x4,%rbx
lea    0x2bb4(%rip),%rax
mov    (%rbx,%rax,1),%eax
mov    %eax,(%r15)
jmp    1241 <translate_joyname+0x131>
mov    $0x2,%eax
jmp    122e <translate_joyname+0x11e>
mov    $0x3,%eax
jmp    122e <translate_joyname+0x11e>
mov    $0x4,%eax
jmp    122e <translate_joyname+0x11e>
mov    $0x5,%eax
shl    $0x4,%rax
lea    0x2b87(%rip),%rcx
mov    0x8(%rax,%rcx,1),%rax
mov    %rax,(%r14)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.anon = type { i32, i8* }
@translate_joyname.translate_joy = internal global [6 x %struct.anon] [%struct.anon { i32 1, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i32 0, i32 0) }, %struct.anon { i32 2, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i32 0, i32 0) }, %struct.anon { i32 4, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i32 0, i32 0) }, %struct.anon { i32 8, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i32 0, i32 0) }, %struct.anon { i32 16, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i32 0, i32 0) }, %struct.anon { i32 32, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i32 0, i32 0) }]
@.str = [14 x i8] c"joystick_left\00"
@.str.1 = [15 x i8] c"joystick_right\00"
@.str.2 = [12 x i8] c"joystick_up\00"
@.str.3 = [14 x i8] c"joystick_down\00"
@.str.4 = [18 x i8] c"joystick_button_1\00"
@.str.5 = [18 x i8] c"joystick_button_2\00"
@.str.6 = [12 x i8] c"[undefined]\00"
define void @translate_joyname(i32* %0, i8** %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %4
store i8** %1, i8*** %5
store i32 %2, i32* %6
%8 = load i32, i32* %6
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %36
10: ; preds = %3
%11 = load i8**, i8*** %5
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8** %11
store i32 0, i32* %7
br label %12
12: ; preds = %32, %10
%13 = load i32, i32* %7
%14 = icmp slt i32 %13, 6
br i1 %14, label %15, label %35
15: ; preds = %12
%16 = load i32*, i32** %4
%17 = load i32, i32* %16
%18 = load i32, i32* %7
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [6 x %struct.anon], [6 x %struct.anon]* @translate_joyname.translate_joy, i64 0, i64 %19
%21 = getelementptr inbounds %struct.anon, %struct.anon* %20, i32 0, i32 0
%22 = load i32, i32* %21
%23 = icmp eq i32 %17, %22
br i1 %23, label %24, label %31
24: ; preds = %15
%25 = load i32, i32* %7
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [6 x %struct.anon], [6 x %struct.anon]* @translate_joyname.translate_joy, i64 0, i64 %26
%28 = getelementptr inbounds %struct.anon, %struct.anon* %27, i32 0, i32 1
%29 = load i8*, i8** %28
%30 = load i8**, i8*** %5
store i8* %29, i8** %30
br label %35
31: ; preds = %15
br label %32
32: ; preds = %31
%33 = load i32, i32* %7
%34 = add nsw i32 %33, 1
store i32 %34, i32* %7
br label %12
35: ; preds = %24, %12
br label %67
36: ; preds = %3
%37 = load i32, i32* %6
%38 = icmp eq i32 %37, 1
br i1 %38, label %39, label %66
39: ; preds = %36
%40 = load i32*, i32** %4
store i32 0, i32* %40
store i32 0, i32* %7
br label %41
41: ; preds = %62, %39
%42 = load i32, i32* %7
%43 = icmp slt i32 %42, 6
br i1 %43, label %44, label %65
44: ; preds = %41
%45 = load i8**, i8*** %5
%46 = load i8*, i8** %45
%47 = load i32, i32* %7
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [6 x %struct.anon], [6 x %struct.anon]* @translate_joyname.translate_joy, i64 0, i64 %48
%50 = getelementptr inbounds %struct.anon, %struct.anon* %49, i32 0, i32 1
%51 = load i8*, i8** %50
%52 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @strEqual to i32 (i8*, i8*, ...)*)(i8* %46, i8* %51)
%53 = icmp ne i32 %52, 0
br i1 %53, label %54, label %61
54: ; preds = %44
%55 = load i32, i32* %7
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [6 x %struct.anon], [6 x %struct.anon]* @translate_joyname.translate_joy, i64 0, i64 %56
%58 = getelementptr inbounds %struct.anon, %struct.anon* %57, i32 0, i32 0
%59 = load i32, i32* %58
%60 = load i32*, i32** %4
store i32 %59, i32* %60
br label %65
61: ; preds = %44
br label %62
62: ; preds = %61
%63 = load i32, i32* %7
%64 = add nsw i32 %63, 1
store i32 %64, i32* %7
br label %41
65: ; preds = %54, %41
br label %66
66: ; preds = %65, %36
br label %67
67: ; preds = %66, %35
ret void
}

LLVM IR (-O2):
%struct.anon = type { i32, i8* }
@translate_joyname.translate_joy = internal unnamed_addr constant [6 x %struct.anon] [%struct.anon { i32 1, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i32 0, i32 0) }, %struct.anon { i32 2, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i32 0, i32 0) }, %struct.anon { i32 4, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i32 0, i32 0) }, %struct.anon { i32 8, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i32 0, i32 0) }, %struct.anon { i32 16, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i32 0, i32 0) }, %struct.anon { i32 32, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i32 0, i32 0) }]
@.str = [14 x i8] c"joystick_left\00"
@.str.1 = [15 x i8] c"joystick_right\00"
@.str.2 = [12 x i8] c"joystick_up\00"
@.str.3 = [14 x i8] c"joystick_down\00"
@.str.4 = [18 x i8] c"joystick_button_1\00"
@.str.5 = [18 x i8] c"joystick_button_2\00"
@.str.6 = [12 x i8] c"[undefined]\00"
define void @translate_joyname(i32* nocapture %0, i8** nocapture %1, i32 %2) {
switch i32 %2, label %43 [
i32 0, label %4
i32 1, label %15
]
4: ; preds = %3
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8** %1
%5 = load i32, i32* %0
switch i32 %5, label %43 [
i32 1, label %11
i32 2, label %6
i32 4, label %7
i32 8, label %8
i32 16, label %9
i32 32, label %10
]
6: ; preds = %4
br label %11
7: ; preds = %4
br label %11
8: ; preds = %4
br label %11
9: ; preds = %4
br label %11
10: ; preds = %4
br label %11
11: ; preds = %4, %10, %9, %8, %7, %6
%12 = phi i64 [ 0, %4 ], [ 1, %6 ], [ 2, %7 ], [ 3, %8 ], [ 4, %9 ], [ 5, %10 ]
%13 = getelementptr inbounds [6 x %struct.anon], [6 x %struct.anon]* @translate_joyname.translate_joy, i64 0, i64 %12, i32 1
%14 = load i8*, i8** %13
store i8* %14, i8** %1
br label %43
15: ; preds = %3
store i32 0, i32* %0
%16 = load i8*, i8** %1
%17 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @strEqual to i32 (i8*, i8*, ...)*)(i8* %16, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%18 = icmp eq i32 %17, 0
br i1 %18, label %23, label %19
19: ; preds = %39, %35, %31, %27, %23, %15
%20 = phi i64 [ 0, %15 ], [ 1, %23 ], [ 2, %27 ], [ 3, %31 ], [ 4, %35 ], [ 5, %39 ]
%21 = getelementptr inbounds [6 x %struct.anon], [6 x %struct.anon]* @translate_joyname.translate_joy, i64 0, i64 %20, i32 0
%22 = load i32, i32* %21
store i32 %22, i32* %0
br label %43
23: ; preds = %15
%24 = load i8*, i8** %1
%25 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @strEqual to i32 (i8*, i8*, ...)*)(i8* %24, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %19
27: ; preds = %23
%28 = load i8*, i8** %1
%29 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @strEqual to i32 (i8*, i8*, ...)*)(i8* %28, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %19
31: ; preds = %27
%32 = load i8*, i8** %1
%33 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @strEqual to i32 (i8*, i8*, ...)*)(i8* %32, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %19
35: ; preds = %31
%36 = load i8*, i8** %1
%37 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @strEqual to i32 (i8*, i8*, ...)*)(i8* %36, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %19
39: ; preds = %35
%40 = load i8*, i8** %1
%41 = tail call i32 (i8*, i8*, ...) bitcast (i32 (...)* @strEqual to i32 (i8*, i8*, ...)*)(i8* %40, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %19
43: ; preds = %4, %39, %3, %19, %11
ret void
}