#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 *, int);
char *sylk_fmt_to_str(int f1, int p1) {
  static char p_buf[40];
  p_buf[1] = '\0';
  switch (f1) {
  case 0:
    p_buf[0] = 'D';
    break;
  case 1:
    p_buf[0] = 'H';
    break;
  case 2:
    p_buf[0] = '*';
    break;
  default:
    if (p1 == 15) {
      p_buf[1] = 'F';
      p_buf[2] = '\0';
    } else
      sprintf(&p_buf[1], "%d", p1);
    switch (f1) {
    case 6:
      p_buf[0] = 'U';
      break;
    case 9:
      p_buf[0] = 'G';
      break;
    case 3:
      p_buf[0] = '$';
      break;
    case 5:
      p_buf[0] = '%';
      break;
    case 7:
      p_buf[0] = 'F';
      break;
    case 4:
      p_buf[0] = ',';
      break;
    case 8:
      p_buf[0] = 'E';
      break;
    default:
      p_buf[0] = '?';
      break;
    }
    break;
  }
  return p_buf;
}


x86 assembly (clang, -O0):
<sylk_fmt_to_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movb   $0x0,0x2f1c(%rip)
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
test   %eax,%eax
je     115a <sylk_fmt_to_str+0x4a>
jmp    1138 <sylk_fmt_to_str+0x28>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
je     1166 <sylk_fmt_to_str+0x56>
jmp    1149 <sylk_fmt_to_str+0x39>
mov    -0xc(%rbp),%eax
sub    $0x2,%eax
je     1172 <sylk_fmt_to_str+0x62>
jmp    117e <sylk_fmt_to_str+0x6e>
movb   $0x44,0x2edf(%rip)
jmp    123e <sylk_fmt_to_str+0x12e>
movb   $0x48,0x2ed3(%rip)
jmp    123e <sylk_fmt_to_str+0x12e>
movb   $0x2a,0x2ec7(%rip)
jmp    123e <sylk_fmt_to_str+0x12e>
cmpl   $0xf,-0x8(%rbp)
jne    119b <sylk_fmt_to_str+0x8b>
movb   $0x46,0x2eb2(%rip)
movb   $0x0,0x2eac(%rip)
jmp    11b5 <sylk_fmt_to_str+0xa5>
mov    -0x8(%rbp),%edx
lea    0x2e9b(%rip),%rdi
add    $0x1,%rdi
lea    0xe6c(%rip),%rsi
call   1030 <sprintf@plt>
mov    -0x4(%rbp),%eax
add    $0xfffffffd,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x6,%eax
ja     1232 <sylk_fmt_to_str+0x122>
mov    -0x18(%rbp),%rax
lea    0xe2b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movb   $0x55,0x2e5b(%rip)
jmp    1239 <sylk_fmt_to_str+0x129>
movb   $0x47,0x2e4f(%rip)
jmp    1239 <sylk_fmt_to_str+0x129>
movb   $0x24,0x2e43(%rip)
jmp    1239 <sylk_fmt_to_str+0x129>
movb   $0x25,0x2e37(%rip)
jmp    1239 <sylk_fmt_to_str+0x129>
movb   $0x46,0x2e2b(%rip)
jmp    1239 <sylk_fmt_to_str+0x129>
movb   $0x2c,0x2e1f(%rip)
jmp    1239 <sylk_fmt_to_str+0x129>
movb   $0x45,0x2e13(%rip)
jmp    1239 <sylk_fmt_to_str+0x129>
movb   $0x3f,0x2e07(%rip)
jmp    123e <sylk_fmt_to_str+0x12e>
lea    0x2dfb(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sylk_fmt_to_str>:
push   %rbx
mov    %edi,%ebx
movb   $0x0,0x2f27(%rip)
cmp    $0x3,%edi
jae    112d <sylk_fmt_to_str+0x1d>
shl    $0x3,%ebx
mov    $0x2a4844,%eax
mov    %ebx,%ecx
shr    %cl,%eax
jmp    116e <sylk_fmt_to_str+0x5e>
mov    %esi,%edx
cmp    $0xf,%esi
jne    113f <sylk_fmt_to_str+0x2f>
movw   $0x46,0x2f04(%rip)
jmp    1152 <sylk_fmt_to_str+0x42>
lea    0x2efb(%rip),%rdi
lea    0xeb3(%rip),%rsi
call   1030 <sprintf@plt>
add    $0xfffffffd,%ebx
mov    $0x3f,%al
cmp    $0x7,%ebx
jae    116e <sylk_fmt_to_str+0x5e>
shl    $0x3,%ebx
movabs $0x47454655252c24,%rax
mov    %ebx,%ecx
shr    %cl,%rax
mov    %al,0x2ecc(%rip)
lea    0x2ec5(%rip),%rax
pop    %rbx
ret

LLVM IR (-O0):
@sylk_fmt_to_str.p_buf = internal global [40 x i8] zeroinitializer
@.str = [3 x i8] c"%d\00"
define i8* @sylk_fmt_to_str(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
store i8 0, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @sylk_fmt_to_str.p_buf, i64 0, i64 1)
%5 = load i32, i32* %3
switch i32 %5, label %9 [
i32 0, label %6
i32 1, label %7
i32 2, label %8
]
6: ; preds = %2
store i8 68, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @sylk_fmt_to_str.p_buf, i64 0, i64 0)
br label %27
7: ; preds = %2
store i8 72, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @sylk_fmt_to_str.p_buf, i64 0, i64 0)
br label %27
8: ; preds = %2
store i8 42, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @sylk_fmt_to_str.p_buf, i64 0, i64 0)
br label %27
9: ; preds = %2
%10 = load i32, i32* %4
%11 = icmp eq i32 %10, 15
br i1 %11, label %12, label %13
12: ; preds = %9
store i8 70, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @sylk_fmt_to_str.p_buf, i64 0, i64 1)
store i8 0, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @sylk_fmt_to_str.p_buf, i64 0, i64 2)
br label %16
13: ; preds = %9
%14 = load i32, i32* %4
%15 = call i32 @sprintf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @sylk_fmt_to_str.p_buf, i64 0, i64 1), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %14)
br label %16
16: ; preds = %13, %12
%17 = load i32, i32* %3
switch i32 %17, label %25 [
i32 6, label %18
i32 9, label %19
i32 3, label %20
i32 5, label %21
i32 7, label %22
i32 4, label %23
i32 8, label %24
]
18: ; preds = %16
store i8 85, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @sylk_fmt_to_str.p_buf, i64 0, i64 0)
br label %26
19: ; preds = %16
store i8 71, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @sylk_fmt_to_str.p_buf, i64 0, i64 0)
br label %26
20: ; preds = %16
store i8 36, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @sylk_fmt_to_str.p_buf, i64 0, i64 0)
br label %26
21: ; preds = %16
store i8 37, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @sylk_fmt_to_str.p_buf, i64 0, i64 0)
br label %26
22: ; preds = %16
store i8 70, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @sylk_fmt_to_str.p_buf, i64 0, i64 0)
br label %26
23: ; preds = %16
store i8 44, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @sylk_fmt_to_str.p_buf, i64 0, i64 0)
br label %26
24: ; preds = %16
store i8 69, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @sylk_fmt_to_str.p_buf, i64 0, i64 0)
br label %26
25: ; preds = %16
store i8 63, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @sylk_fmt_to_str.p_buf, i64 0, i64 0)
br label %26
26: ; preds = %25, %24, %23, %22, %21, %20, %19, %18
br label %27
27: ; preds = %26, %8, %7, %6
ret i8* getelementptr inbounds ([40 x i8], [40 x i8]* @sylk_fmt_to_str.p_buf, i64 0, i64 0)
}

LLVM IR (-O2):
@sylk_fmt_to_str.p_buf = internal global [40 x i8] zeroinitializer
@.str = [3 x i8] c"%d\00"
define i8* @sylk_fmt_to_str(i32 %0, i32 %1) {
store i8 0, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @sylk_fmt_to_str.p_buf, i64 0, i64 1)
%3 = icmp ult i32 %0, 3
br i1 %3, label %12, label %4
4: ; preds = %2
%5 = icmp eq i32 %1, 15
br i1 %5, label %6, label %7
6: ; preds = %4
store i8 70, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @sylk_fmt_to_str.p_buf, i64 0, i64 1)
store i8 0, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @sylk_fmt_to_str.p_buf, i64 0, i64 2)
br label %9
7: ; preds = %4
%8 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @sylk_fmt_to_str.p_buf, i64 0, i64 1), i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %1)
br label %9
9: ; preds = %7, %6
%10 = add i32 %0, -3
%11 = icmp ult i32 %10, 7
br i1 %11, label %17, label %22
12: ; preds = %2
%13 = trunc i32 %0 to i24
%14 = shl i24 %13, 3
%15 = lshr i24 2771012, %14
%16 = trunc i24 %15 to i8
br label %22
17: ; preds = %9
%18 = zext i32 %10 to i56
%19 = shl nuw nsw i56 %18, 3
%20 = lshr i56 20060891724983332, %19
%21 = trunc i56 %20 to i8
br label %22
22: ; preds = %9, %17, %12
%23 = phi i8 [ %16, %12 ], [ %21, %17 ], [ 63, %9 ]
store i8 %23, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @sylk_fmt_to_str.p_buf, i64 0, i64 0)
ret i8* getelementptr inbounds ([40 x i8], [40 x i8]* @sylk_fmt_to_str.p_buf, i64 0, i64 0)
}