#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__ malloc(int);
int /*<<< orphan*/ strcpy(char *, char *);
char *result_to_s(unsigned short int r) {
  char *s = (char *)malloc(8);
  switch (r) {
  case 0:
    strcpy(s, "1-0");
    break;
  case 1:
    strcpy(s, "0-1");
    break;
  case 2:
    strcpy(s, "1/2-1/2");
    break;
  default:
    strcpy(s, "*");
    break;
  }
  return s;
}


x86 assembly (clang, -O0):
<result_to_s>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
mov    $0x8,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
movzwl -0x2(%rbp),%eax
mov    %eax,-0x14(%rbp)
test   %eax,%eax
je     1173 <result_to_s+0x53>
jmp    1151 <result_to_s+0x31>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
je     1188 <result_to_s+0x68>
jmp    1162 <result_to_s+0x42>
mov    -0x14(%rbp),%eax
sub    $0x2,%eax
je     119d <result_to_s+0x7d>
jmp    11b2 <result_to_s+0x92>
mov    -0x10(%rbp),%rdi
lea    0xe82(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11c2 <result_to_s+0xa2>
mov    -0x10(%rbp),%rdi
lea    0xe71(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11c2 <result_to_s+0xa2>
mov    -0x10(%rbp),%rdi
lea    0xe60(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11c2 <result_to_s+0xa2>
mov    -0x10(%rbp),%rdi
lea    0xe53(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<result_to_s>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
mov    $0x8,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
cmp    $0x2,%bp
ja     114c <result_to_s+0x2c>
movswq %bp,%rax
lea    0xed1(%rip),%rcx
movslq (%rcx,%rax,4),%rsi
add    %rcx,%rsi
jmp    1153 <result_to_s+0x33>
lea    0xebd(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"1-0\00"
@.str.1 = [4 x i8] c"0-1\00"
@.str.2 = [8 x i8] c"1/2-1/2\00"
@.str.3 = [2 x i8] c"*\00"
define i8* @result_to_s(i16 zeroext %0) {
%2 = alloca i16
%3 = alloca i8*
store i16 %0, i16* %2
%4 = call i64 @malloc(i32 8)
%5 = inttoptr i64 %4 to i8*
store i8* %5, i8** %3
%6 = load i16, i16* %2
%7 = zext i16 %6 to i32
switch i32 %7, label %17 [
i32 0, label %8
i32 1, label %11
i32 2, label %14
]
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = call i32 @strcpy(i8* %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %20
11: ; preds = %1
%12 = load i8*, i8** %3
%13 = call i32 @strcpy(i8* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %20
14: ; preds = %1
%15 = load i8*, i8** %3
%16 = call i32 @strcpy(i8* %15, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
br label %20
17: ; preds = %1
%18 = load i8*, i8** %3
%19 = call i32 @strcpy(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %20
20: ; preds = %17, %14, %11, %8
%21 = load i8*, i8** %3
ret i8* %21
}

LLVM IR (-O2):
@.str = [4 x i8] c"1-0\00"
@.str.1 = [4 x i8] c"0-1\00"
@.str.2 = [8 x i8] c"1/2-1/2\00"
@.str.3 = [2 x i8] c"*\00"
@reltable.result_to_s = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str to i64), i64 ptrtoint ([3 x i32]* @reltable.result_to_s to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.1 to i64), i64 ptrtoint ([3 x i32]* @reltable.result_to_s to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.2 to i64), i64 ptrtoint ([3 x i32]* @reltable.result_to_s to i64)) to i32)]
define i8* @result_to_s(i16 zeroext %0) {
%2 = tail call i64 @malloc(i32 8)
%3 = inttoptr i64 %2 to i8*
%4 = icmp ult i16 %0, 3
br i1 %4, label %5, label %9
5: ; preds = %1
%6 = sext i16 %0 to i64
%7 = shl i64 %6, 2
%8 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.result_to_s to i8*), i64 %7)
br label %9
9: ; preds = %1, %5
%10 = phi i8* [ %8, %5 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), %1 ]
%11 = tail call i32 @strcpy(i8* %3, i8* %10)
ret i8* %3
}