#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 */
char *malloc(int);
char *GetScoreAsString(char score) {
  char *scoreString = malloc(sizeof(char) * 3);
  if (score > 9) {
    scoreString[0] = (score / 10) + 48;
    scoreString[1] = (score % 10) + 48;
    scoreString[2] = '\0';
  } else {
    scoreString[0] = (score % 10) + 48;
    scoreString[1] = '\0';
  }
  return scoreString;
}


x86 assembly (clang, -O0):
<GetScoreAsString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    $0x3,%edi
call   1030 <malloc@plt>
mov    %rax,-0x10(%rbp)
movsbl -0x1(%rbp),%eax
cmp    $0x9,%eax
jle    1175 <GetScoreAsString+0x65>
movsbl -0x1(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x30,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
movsbl -0x1(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x30,%edx
mov    %dl,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x10(%rbp),%rax
movb   $0x0,0x2(%rax)
jmp    1194 <GetScoreAsString+0x84>
movsbl -0x1(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x30,%edx
mov    %dl,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
movb   $0x0,0x1(%rax)
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetScoreAsString>:
push   %rbx
mov    %edi,%ebx
mov    $0x3,%edi
call   1030 <malloc@plt>
cmp    $0xa,%bl
jl     1143 <GetScoreAsString+0x33>
movzbl %bl,%ecx
imul   $0xcd,%ecx,%ecx
shr    $0xb,%ecx
lea    0x30(%rcx),%edx
mov    %dl,(%rax)
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %cl,%bl
or     $0x30,%bl
movb   $0x0,0x2(%rax)
jmp    1165 <GetScoreAsString+0x55>
movsbl %bl,%ecx
imul   $0x67,%ecx,%ecx
movzwl %cx,%edx
shr    $0xa,%ecx
shr    $0xf,%edx
add    %cl,%dl
movzbl %dl,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %cl,%bl
add    $0x30,%bl
mov    %bl,(%rax)
xor    %ebx,%ebx
mov    %bl,0x1(%rax)
pop    %rbx
ret

LLVM IR (-O0):
define i8* @GetScoreAsString(i8 signext %0) {
%2 = alloca i8
%3 = alloca i8*
store i8 %0, i8* %2
%4 = call i8* @malloc(i32 3)
store i8* %4, i8** %3
%5 = load i8, i8* %2
%6 = sext i8 %5 to i32
%7 = icmp sgt i32 %6, 9
br i1 %7, label %8, label %25
8: ; preds = %1
%9 = load i8, i8* %2
%10 = sext i8 %9 to i32
%11 = sdiv i32 %10, 10
%12 = add nsw i32 %11, 48
%13 = trunc i32 %12 to i8
%14 = load i8*, i8** %3
%15 = getelementptr inbounds i8, i8* %14, i64 0
store i8 %13, i8* %15
%16 = load i8, i8* %2
%17 = sext i8 %16 to i32
%18 = srem i32 %17, 10
%19 = add nsw i32 %18, 48
%20 = trunc i32 %19 to i8
%21 = load i8*, i8** %3
%22 = getelementptr inbounds i8, i8* %21, i64 1
store i8 %20, i8* %22
%23 = load i8*, i8** %3
%24 = getelementptr inbounds i8, i8* %23, i64 2
store i8 0, i8* %24
br label %35
25: ; preds = %1
%26 = load i8, i8* %2
%27 = sext i8 %26 to i32
%28 = srem i32 %27, 10
%29 = add nsw i32 %28, 48
%30 = trunc i32 %29 to i8
%31 = load i8*, i8** %3
%32 = getelementptr inbounds i8, i8* %31, i64 0
store i8 %30, i8* %32
%33 = load i8*, i8** %3
%34 = getelementptr inbounds i8, i8* %33, i64 1
store i8 0, i8* %34
br label %35
35: ; preds = %25, %8
%36 = load i8*, i8** %3
ret i8* %36
}

LLVM IR (-O2):
define noalias i8* @GetScoreAsString(i8 signext %0) {
%2 = tail call dereferenceable_or_null(3) i8* @malloc(i32 3)
%3 = icmp sgt i8 %0, 9
br i1 %3, label %4, label %10
4: ; preds = %1
%5 = udiv i8 %0, 10
%6 = add nuw nsw i8 %5, 48
store i8 %6, i8* %2
%7 = urem i8 %0, 10
%8 = or i8 %7, 48
%9 = getelementptr inbounds i8, i8* %2, i64 2
store i8 0, i8* %9
br label %13
10: ; preds = %1
%11 = srem i8 %0, 10
%12 = add nsw i8 %11, 48
store i8 %12, i8* %2
br label %13
13: ; preds = %10, %4
%14 = phi i8 [ %8, %4 ], [ 0, %10 ]
%15 = getelementptr inbounds i8, i8* %2, i64 1
store i8 %14, i8* %15
ret i8* %2
}