#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 /*<<< orphan*/ strlen(char *);
char *AddBppString(char *outstring, int bpp) {
  switch (bpp) {
  case 0: {
    sprintf(outstring, "4-bit(16 colors)\r\n");
    outstring += strlen(outstring);
  }; break;
  case 1: {
    sprintf(outstring, "8-bit(256 colors)\r\n");
    outstring += strlen(outstring);
  }; break;
  case 2: {
    sprintf(outstring, "16-bit(2048 colors)\r\n");
    outstring += strlen(outstring);
  }; break;
  case 3: {
    sprintf(outstring, "16-bit(32,768 colors)\r\n");
    outstring += strlen(outstring);
  }; break;
  case 4: {
    sprintf(outstring, "32-bit(16.7 mil colors)\r\n");
    outstring += strlen(outstring);
  }; break;
  default: {
    sprintf(outstring, "Unsupported BPP\r\n");
    outstring += strlen(outstring);
  }; break;
  }
  return outstring;
}


x86 assembly (clang, -O0):
<AddBppString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0x4,%rax
ja     123a <AddBppString+0x11a>
mov    -0x18(%rbp),%rax
lea    0xeb5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%rdi
lea    0xeb5(%rip),%rsi
call   1040 <sprintf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
jmp    1263 <AddBppString+0x143>
mov    -0x8(%rbp),%rdi
lea    0xe9a(%rip),%rsi
call   1040 <sprintf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
jmp    1263 <AddBppString+0x143>
mov    -0x8(%rbp),%rdi
lea    0xe80(%rip),%rsi
call   1040 <sprintf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
jmp    1263 <AddBppString+0x143>
mov    -0x8(%rbp),%rdi
lea    0xe68(%rip),%rsi
call   1040 <sprintf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
jmp    1263 <AddBppString+0x143>
mov    -0x8(%rbp),%rdi
lea    0xe52(%rip),%rsi
call   1040 <sprintf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
jmp    1263 <AddBppString+0x143>
mov    -0x8(%rbp),%rdi
lea    0xe3e(%rip),%rsi
call   1040 <sprintf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<AddBppString>:
push   %rbx
mov    %rdi,%rbx
cmp    $0x4,%esi
ja     113e <AddBppString+0x2e>
mov    %esi,%eax
lea    0xede(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movups 0xee2(%rip),%xmm0
movups %xmm0,(%rbx)
movl   $0xa0d29,0xf(%rbx)
jmp    11ac <AddBppString+0x9c>
movups 0xf3e(%rip),%xmm0
movups %xmm0,(%rbx)
movw   $0xa,0x10(%rbx)
jmp    11ac <AddBppString+0x9c>
movups 0xed0(%rip),%xmm0
movups %xmm0,(%rbx)
movl   $0xa0d29,0x10(%rbx)
jmp    11ac <AddBppString+0x9c>
movups 0xed1(%rip),%xmm0
movups %xmm0,(%rbx)
movabs $0xa0d2973726f6c,%rax
mov    %rax,0xe(%rbx)
jmp    11ac <AddBppString+0x9c>
movups 0xecd(%rip),%xmm0
movups %xmm0,(%rbx)
movabs $0xa0d2973726f6c,%rax
mov    %rax,0x10(%rbx)
jmp    11ac <AddBppString+0x9c>
movups 0xed5(%rip),%xmm0
movups %xmm0,0xa(%rbx)
movups 0xec0(%rip),%xmm0
movups %xmm0,(%rbx)
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
add    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [19 x i8] c"4-bit(16 colors)\0D\0A\00"
@.str.1 = [20 x i8] c"8-bit(256 colors)\0D\0A\00"
@.str.2 = [22 x i8] c"16-bit(2048 colors)\0D\0A\00"
@.str.3 = [24 x i8] c"16-bit(32,768 colors)\0D\0A\00"
@.str.4 = [26 x i8] c"32-bit(16.7 mil colors)\0D\0A\00"
@.str.5 = [18 x i8] c"Unsupported BPP\0D\0A\00"
define i8* @AddBppString(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
switch i32 %5, label %46 [
i32 0, label %6
i32 1, label %14
i32 2, label %22
i32 3, label %30
i32 4, label %38
]
6: ; preds = %2
%7 = load i8*, i8** %3
%8 = call i32 @sprintf(i8* %7, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%9 = load i8*, i8** %3
%10 = call i32 @strlen(i8* %9)
%11 = load i8*, i8** %3
%12 = sext i32 %10 to i64
%13 = getelementptr inbounds i8, i8* %11, i64 %12
store i8* %13, i8** %3
br label %54
14: ; preds = %2
%15 = load i8*, i8** %3
%16 = call i32 @sprintf(i8* %15, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%17 = load i8*, i8** %3
%18 = call i32 @strlen(i8* %17)
%19 = load i8*, i8** %3
%20 = sext i32 %18 to i64
%21 = getelementptr inbounds i8, i8* %19, i64 %20
store i8* %21, i8** %3
br label %54
22: ; preds = %2
%23 = load i8*, i8** %3
%24 = call i32 @sprintf(i8* %23, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%25 = load i8*, i8** %3
%26 = call i32 @strlen(i8* %25)
%27 = load i8*, i8** %3
%28 = sext i32 %26 to i64
%29 = getelementptr inbounds i8, i8* %27, i64 %28
store i8* %29, i8** %3
br label %54
30: ; preds = %2
%31 = load i8*, i8** %3
%32 = call i32 @sprintf(i8* %31, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%33 = load i8*, i8** %3
%34 = call i32 @strlen(i8* %33)
%35 = load i8*, i8** %3
%36 = sext i32 %34 to i64
%37 = getelementptr inbounds i8, i8* %35, i64 %36
store i8* %37, i8** %3
br label %54
38: ; preds = %2
%39 = load i8*, i8** %3
%40 = call i32 @sprintf(i8* %39, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%41 = load i8*, i8** %3
%42 = call i32 @strlen(i8* %41)
%43 = load i8*, i8** %3
%44 = sext i32 %42 to i64
%45 = getelementptr inbounds i8, i8* %43, i64 %44
store i8* %45, i8** %3
br label %54
46: ; preds = %2
%47 = load i8*, i8** %3
%48 = call i32 @sprintf(i8* %47, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
%49 = load i8*, i8** %3
%50 = call i32 @strlen(i8* %49)
%51 = load i8*, i8** %3
%52 = sext i32 %50 to i64
%53 = getelementptr inbounds i8, i8* %51, i64 %52
store i8* %53, i8** %3
br label %54
54: ; preds = %46, %38, %30, %22, %14, %6
%55 = load i8*, i8** %3
ret i8* %55
}

LLVM IR (-O2):
@.str = [19 x i8] c"4-bit(16 colors)\0D\0A\00"
@.str.1 = [20 x i8] c"8-bit(256 colors)\0D\0A\00"
@.str.2 = [22 x i8] c"16-bit(2048 colors)\0D\0A\00"
@.str.3 = [24 x i8] c"16-bit(32,768 colors)\0D\0A\00"
@.str.4 = [26 x i8] c"32-bit(16.7 mil colors)\0D\0A\00"
@.str.5 = [18 x i8] c"Unsupported BPP\0D\0A\00"
define i8* @AddBppString(i8* %0, i32 %1) {
switch i32 %1, label %8 [
i32 0, label %3
i32 1, label %4
i32 2, label %5
i32 3, label %6
i32 4, label %7
]
3: ; preds = %2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(19) %0, i8* align 1 dereferenceable(19) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i64 19, i1 false)
br label %9
4: ; preds = %2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(20) %0, i8* align 1 dereferenceable(20) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i64 20, i1 false)
br label %9
5: ; preds = %2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(22) %0, i8* align 1 dereferenceable(22) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i64 22, i1 false)
br label %9
6: ; preds = %2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(24) %0, i8* align 1 dereferenceable(24) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i64 24, i1 false)
br label %9
7: ; preds = %2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(26) %0, i8* align 1 dereferenceable(26) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i64 26, i1 false)
br label %9
8: ; preds = %2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(18) %0, i8* align 1 dereferenceable(18) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i64 18, i1 false)
br label %9
9: ; preds = %8, %7, %6, %5, %4, %3
%10 = tail call i32 @strlen(i8* %0)
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %0, i64 %11
ret i8* %12
}