#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 */
int /*<<< orphan*/ sprintf(char *, char *, unsigned int);
int /*<<< orphan*/ strcpy(char *, char *);
char *getTileString(char *buffer, unsigned int value) {
  if (value == 0) {
    strcpy(buffer, ".  ");
    return buffer;
  } else if (value < 1024) {
    sprintf(buffer, "%-3hu", value);
    return buffer;
  } else {
    switch (value) {
    case 1024:
      strcpy(buffer, "a24");
      break;
    case 2048:
      strcpy(buffer, "b48");
      break;
    case 4096:
      strcpy(buffer, "c96");
      break;
    case 8192:
      strcpy(buffer, "d92");
      break;
    case 16384:
      strcpy(buffer, "e84");
      break;
    case 32768:
      strcpy(buffer, "f68");
      break;
    default:
      strcpy(buffer, "xxx");
      break;
    }
    return buffer;
  }
}


x86 assembly (clang, -O0):
<getTileString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1156 <getTileString+0x36>
mov    -0x10(%rbp),%rdi
lea    0xebc(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    128e <getTileString+0x16e>
cmpl   $0x400,-0x14(%rbp)
jae    1183 <getTileString+0x63>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xe93(%rip),%rsi
call   1040 <sprintf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    128e <getTileString+0x16e>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
sub    $0x400,%eax
je     11f8 <getTileString+0xd8>
jmp    1199 <getTileString+0x79>
mov    -0x18(%rbp),%eax
sub    $0x800,%eax
je     120d <getTileString+0xed>
jmp    11ac <getTileString+0x8c>
mov    -0x18(%rbp),%eax
sub    $0x1000,%eax
je     1222 <getTileString+0x102>
jmp    11bf <getTileString+0x9f>
mov    -0x18(%rbp),%eax
sub    $0x2000,%eax
je     1237 <getTileString+0x117>
jmp    11d2 <getTileString+0xb2>
mov    -0x18(%rbp),%eax
sub    $0x4000,%eax
je     124c <getTileString+0x12c>
jmp    11e5 <getTileString+0xc5>
mov    -0x18(%rbp),%eax
sub    $0x8000,%eax
je     1261 <getTileString+0x141>
jmp    1276 <getTileString+0x156>
mov    -0x10(%rbp),%rdi
lea    0xe07(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1286 <getTileString+0x166>
mov    -0x10(%rbp),%rdi
lea    0xdf6(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1286 <getTileString+0x166>
mov    -0x10(%rbp),%rdi
lea    0xde5(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1286 <getTileString+0x166>
mov    -0x10(%rbp),%rdi
lea    0xdd4(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1286 <getTileString+0x166>
mov    -0x10(%rbp),%rdi
lea    0xdc3(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1286 <getTileString+0x166>
mov    -0x10(%rbp),%rdi
lea    0xdb2(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1286 <getTileString+0x166>
mov    -0x10(%rbp),%rdi
lea    0xda1(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getTileString>:
push   %rbx
mov    %rdi,%rbx
test   %esi,%esi
je     1143 <getTileString+0x23>
mov    %esi,%edx
cmp    $0x3ff,%esi
ja     1157 <getTileString+0x37>
lea    0xecb(%rip),%rsi
mov    %rbx,%rdi
call   1040 <sprintf@plt>
jmp    1152 <getTileString+0x32>
lea    0xeb6(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rax
pop    %rbx
ret
cmp    $0x1fff,%edx
jg     1180 <getTileString+0x60>
cmp    $0x400,%edx
je     11a1 <getTileString+0x81>
cmp    $0x800,%edx
je     11aa <getTileString+0x8a>
cmp    $0x1000,%edx
jne    11c5 <getTileString+0xa5>
lea    0xe94(%rip),%rsi
jmp    114a <getTileString+0x2a>
cmp    $0x2000,%edx
je     11b3 <getTileString+0x93>
cmp    $0x4000,%edx
je     11bc <getTileString+0x9c>
cmp    $0x8000,%edx
jne    11c5 <getTileString+0xa5>
lea    0xe7f(%rip),%rsi
jmp    114a <getTileString+0x2a>
lea    0xe62(%rip),%rsi
jmp    114a <getTileString+0x2a>
lea    0xe5d(%rip),%rsi
jmp    114a <getTileString+0x2a>
lea    0xe5c(%rip),%rsi
jmp    114a <getTileString+0x2a>
lea    0xe57(%rip),%rsi
jmp    114a <getTileString+0x2a>
lea    0xe56(%rip),%rsi
jmp    114a <getTileString+0x2a>

LLVM IR (-O0):
@.str = [4 x i8] c". \00"
@.str.1 = [6 x i8] c"%-3hu\00"
@.str.2 = [4 x i8] c"a24\00"
@.str.3 = [4 x i8] c"b48\00"
@.str.4 = [4 x i8] c"c96\00"
@.str.5 = [4 x i8] c"d92\00"
@.str.6 = [4 x i8] c"e84\00"
@.str.7 = [4 x i8] c"f68\00"
@.str.8 = [4 x i8] c"xxx\00"
define i8* @getTileString(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%6 = load i32, i32* %5
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = load i8*, i8** %4
%10 = call i32 @strcpy(i8* %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%11 = load i8*, i8** %4
store i8* %11, i8** %3
br label %45
12: ; preds = %2
%13 = load i32, i32* %5
%14 = icmp ult i32 %13, 1024
br i1 %14, label %15, label %20
15: ; preds = %12
%16 = load i8*, i8** %4
%17 = load i32, i32* %5
%18 = call i32 @sprintf(i8* %16, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %17)
%19 = load i8*, i8** %4
store i8* %19, i8** %3
br label %45
20: ; preds = %12
%21 = load i32, i32* %5
switch i32 %21, label %40 [
i32 1024, label %22
i32 2048, label %25
i32 4096, label %28
i32 8192, label %31
i32 16384, label %34
i32 32768, label %37
]
22: ; preds = %20
%23 = load i8*, i8** %4
%24 = call i32 @strcpy(i8* %23, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %43
25: ; preds = %20
%26 = load i8*, i8** %4
%27 = call i32 @strcpy(i8* %26, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %43
28: ; preds = %20
%29 = load i8*, i8** %4
%30 = call i32 @strcpy(i8* %29, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br label %43
31: ; preds = %20
%32 = load i8*, i8** %4
%33 = call i32 @strcpy(i8* %32, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
br label %43
34: ; preds = %20
%35 = load i8*, i8** %4
%36 = call i32 @strcpy(i8* %35, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
br label %43
37: ; preds = %20
%38 = load i8*, i8** %4
%39 = call i32 @strcpy(i8* %38, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
br label %43
40: ; preds = %20
%41 = load i8*, i8** %4
%42 = call i32 @strcpy(i8* %41, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
br label %43
43: ; preds = %40, %37, %34, %31, %28, %25, %22
%44 = load i8*, i8** %4
store i8* %44, i8** %3
br label %45
45: ; preds = %43, %15, %8
%46 = load i8*, i8** %3
ret i8* %46
}

LLVM IR (-O2):
@.str = [4 x i8] c". \00"
@.str.1 = [6 x i8] c"%-3hu\00"
@.str.2 = [4 x i8] c"a24\00"
@.str.3 = [4 x i8] c"b48\00"
@.str.4 = [4 x i8] c"c96\00"
@.str.5 = [4 x i8] c"d92\00"
@.str.6 = [4 x i8] c"e84\00"
@.str.7 = [4 x i8] c"f68\00"
@.str.8 = [4 x i8] c"xxx\00"
define i8* @getTileString(i8* returned %0, i32 %1) {
%3 = icmp eq i32 %1, 0
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %25
6: ; preds = %2
%7 = icmp ult i32 %1, 1024
br i1 %7, label %8, label %10
8: ; preds = %6
%9 = tail call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %1)
br label %25
10: ; preds = %6
switch i32 %1, label %23 [
i32 1024, label %11
i32 2048, label %13
i32 4096, label %15
i32 8192, label %17
i32 16384, label %19
i32 32768, label %21
]
11: ; preds = %10
%12 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %25
13: ; preds = %10
%14 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %25
15: ; preds = %10
%16 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br label %25
17: ; preds = %10
%18 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
br label %25
19: ; preds = %10
%20 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
br label %25
21: ; preds = %10
%22 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
br label %25
23: ; preds = %10
%24 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
br label %25
25: ; preds = %11, %13, %15, %17, %19, %21, %23, %8, %4
ret i8* %0
}