#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 *, ...);
void chrom_intToString(char *string, int chr) {
  int chrNum = chr;
  if (chrNum == 22)
    sprintf(string, "chrX");
  else if (chrNum == 23)
    sprintf(string, "chrY");
  else {
    chrNum++;
    sprintf(string, "chr%d", chrNum);
  }
}


x86 assembly (clang, -O0):
<chrom_intToString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x16,-0x10(%rbp)
jne    1146 <chrom_intToString+0x36>
mov    -0x8(%rbp),%rdi
lea    0xec6(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    118a <chrom_intToString+0x7a>
cmpl   $0x17,-0x10(%rbp)
jne    1167 <chrom_intToString+0x57>
mov    -0x8(%rbp),%rdi
lea    0xeaa(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    1185 <chrom_intToString+0x75>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%edx
lea    0xe8c(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    118a <chrom_intToString+0x7a>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chrom_intToString>:
cmp    $0x17,%esi
je     1127 <chrom_intToString+0x17>
mov    %esi,%edx
cmp    $0x16,%esi
jne    1132 <chrom_intToString+0x22>
movb   $0x0,0x4(%rdi)
movl   $0x58726863,(%rdi)
ret
movb   $0x0,0x4(%rdi)
movl   $0x59726863,(%rdi)
ret
add    $0x1,%edx
lea    0xece(%rip),%rsi
xor    %eax,%eax
jmp    1030 <sprintf@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"chrX\00"
@.str.1 = [5 x i8] c"chrY\00"
@.str.2 = [6 x i8] c"chr%d\00"
define void @chrom_intToString(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = load i32, i32* %4
store i32 %6, i32* %5
%7 = load i32, i32* %5
%8 = icmp eq i32 %7, 22
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i8*, i8** %3
%11 = call i32 (i8*, i8*, ...) @sprintf(i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %25
12: ; preds = %2
%13 = load i32, i32* %5
%14 = icmp eq i32 %13, 23
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = load i8*, i8** %3
%17 = call i32 (i8*, i8*, ...) @sprintf(i8* %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %24
18: ; preds = %12
%19 = load i32, i32* %5
%20 = add nsw i32 %19, 1
store i32 %20, i32* %5
%21 = load i8*, i8** %3
%22 = load i32, i32* %5
%23 = call i32 (i8*, i8*, ...) @sprintf(i8* %21, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %22)
br label %24
24: ; preds = %18, %15
br label %25
25: ; preds = %24, %9
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"chrX\00"
@.str.1 = [5 x i8] c"chrY\00"
@.str.2 = [6 x i8] c"chr%d\00"
define void @chrom_intToString(i8* nocapture writeonly %0, i32 %1) {
switch i32 %1, label %5 [
i32 22, label %3
i32 23, label %4
]
3: ; preds = %2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(5) %0, i8* align 1 dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 5, i1 false)
br label %8
4: ; preds = %2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(5) %0, i8* align 1 dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 5, i1 false)
br label %8
5: ; preds = %2
%6 = add nsw i32 %1, 1
%7 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %6)
br label %8
8: ; preds = %4, %5, %3
ret void
}