#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ sprintf(char *, char *);
char *CVDiagGetReturnFlagName(int flag) {
  char *name;
  name = (char *)malloc(30 * sizeof(char));
  switch (flag) {
  case 0:
    sprintf(name, "CVDIAG_SUCCESS");
    break;
  case -1:
    sprintf(name, "CVDIAG_MEM_NULL");
    break;
  case -2:
    sprintf(name, "CVDIAG_LMEM_NULL");
    break;
  case -3:
    sprintf(name, "CVDIAG_ILL_INPUT");
    break;
  case -4:
    sprintf(name, "CVDIAG_MEM_FAIL");
    break;
  case -5:
    sprintf(name, "CVDIAG_INV_FAIL");
    break;
  case -6:
    sprintf(name, "CVDIAG_RHSFUNC_UNRECVR");
    break;
  case -7:
    sprintf(name, "CVDIAG_RHSFUNC_RECVR");
    break;
  default:
    sprintf(name, "NONE");
  }
  return (name);
}


x86 assembly (clang, -O0):
<CVDiagGetReturnFlagName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x1e,%edi
call   1030 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
add    $0x7,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x7,%eax
ja     120a <CVDiagGetReturnFlagName+0xea>
mov    -0x18(%rbp),%rax
lea    0xea7(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rdi
lea    0xeb3(%rip),%rsi
call   1040 <sprintf@plt>
jmp    121a <CVDiagGetReturnFlagName+0xfa>
mov    -0x10(%rbp),%rdi
lea    0xead(%rip),%rsi
call   1040 <sprintf@plt>
jmp    121a <CVDiagGetReturnFlagName+0xfa>
mov    -0x10(%rbp),%rdi
lea    0xea8(%rip),%rsi
call   1040 <sprintf@plt>
jmp    121a <CVDiagGetReturnFlagName+0xfa>
mov    -0x10(%rbp),%rdi
lea    0xea4(%rip),%rsi
call   1040 <sprintf@plt>
jmp    121a <CVDiagGetReturnFlagName+0xfa>
mov    -0x10(%rbp),%rdi
lea    0xea0(%rip),%rsi
call   1040 <sprintf@plt>
jmp    121a <CVDiagGetReturnFlagName+0xfa>
mov    -0x10(%rbp),%rdi
lea    0xe9b(%rip),%rsi
call   1040 <sprintf@plt>
jmp    121a <CVDiagGetReturnFlagName+0xfa>
mov    -0x10(%rbp),%rdi
lea    0xe96(%rip),%rsi
call   1040 <sprintf@plt>
jmp    121a <CVDiagGetReturnFlagName+0xfa>
mov    -0x10(%rbp),%rdi
lea    0xe98(%rip),%rsi
call   1040 <sprintf@plt>
jmp    121a <CVDiagGetReturnFlagName+0xfa>
mov    -0x10(%rbp),%rdi
lea    0xe98(%rip),%rsi
call   1040 <sprintf@plt>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CVDiagGetReturnFlagName>:
push   %rbx
mov    %edi,%ebx
mov    $0x1e,%edi
call   1030 <malloc@plt>
add    $0x7,%ebx
cmp    $0x7,%ebx
ja     114f <CVDiagGetReturnFlagName+0x3f>
lea    0xed4(%rip),%rcx
movslq (%rcx,%rbx,4),%rdx
add    %rcx,%rdx
jmp    *%rdx
movups 0xf5c(%rip),%xmm0
movups %xmm0,(%rax)
movabs $0x52564345525f43,%rcx
mov    %rcx,0xd(%rax)
pop    %rbx
ret
movb   $0x0,0x4(%rax)
movl   $0x454e4f4e,(%rax)
pop    %rbx
ret
movups 0xf1f(%rip),%xmm0
movups %xmm0,(%rax)
movabs $0x52564345524e55,%rcx
mov    %rcx,0xf(%rax)
pop    %rbx
ret
movups 0xef5(%rip),%xmm0
jmp    11a7 <CVDiagGetReturnFlagName+0x97>
movups 0xedc(%rip),%xmm0
jmp    11a7 <CVDiagGetReturnFlagName+0x97>
movups 0xec2(%rip),%xmm0
jmp    1197 <CVDiagGetReturnFlagName+0x87>
movups 0xea8(%rip),%xmm0
movups %xmm0,(%rax)
movb   $0x0,0x10(%rax)
pop    %rbx
ret
movups 0xe88(%rip),%xmm0
movups %xmm0,(%rax)
pop    %rbx
ret
movabs $0x53534543435553,%rcx
mov    %rcx,0x7(%rax)
movabs $0x535f474149445643,%rcx
47 5f 53
mov    %rcx,(%rax)
pop    %rbx
ret

LLVM IR (-O0):
@.str = [15 x i8] c"CVDIAG_SUCCESS\00"
@.str.1 = [16 x i8] c"CVDIAG_MEM_NULL\00"
@.str.2 = [17 x i8] c"CVDIAG_LMEM_NULL\00"
@.str.3 = [17 x i8] c"CVDIAG_ILL_INPUT\00"
@.str.4 = [16 x i8] c"CVDIAG_MEM_FAIL\00"
@.str.5 = [16 x i8] c"CVDIAG_INV_FAIL\00"
@.str.6 = [23 x i8] c"CVDIAG_RHSFUNC_UNRECVR\00"
@.str.7 = [21 x i8] c"CVDIAG_RHSFUNC_RECVR\00"
@.str.8 = [5 x i8] c"NONE\00"
define i8* @CVDiagGetReturnFlagName(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
store i32 %0, i32* %2
%4 = call i64 @malloc(i32 30)
%5 = inttoptr i64 %4 to i8*
store i8* %5, i8** %3
%6 = load i32, i32* %2
switch i32 %6, label %31 [
i32 0, label %7
i32 -1, label %10
i32 -2, label %13
i32 -3, label %16
i32 -4, label %19
i32 -5, label %22
i32 -6, label %25
i32 -7, label %28
]
7: ; preds = %1
%8 = load i8*, i8** %3
%9 = call i32 @sprintf(i8* %8, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %34
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = call i32 @sprintf(i8* %11, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
br label %34
13: ; preds = %1
%14 = load i8*, i8** %3
%15 = call i32 @sprintf(i8* %14, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %34
16: ; preds = %1
%17 = load i8*, i8** %3
%18 = call i32 @sprintf(i8* %17, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
br label %34
19: ; preds = %1
%20 = load i8*, i8** %3
%21 = call i32 @sprintf(i8* %20, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
br label %34
22: ; preds = %1
%23 = load i8*, i8** %3
%24 = call i32 @sprintf(i8* %23, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
br label %34
25: ; preds = %1
%26 = load i8*, i8** %3
%27 = call i32 @sprintf(i8* %26, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
br label %34
28: ; preds = %1
%29 = load i8*, i8** %3
%30 = call i32 @sprintf(i8* %29, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
br label %34
31: ; preds = %1
%32 = load i8*, i8** %3
%33 = call i32 @sprintf(i8* %32, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
br label %34
34: ; preds = %31, %28, %25, %22, %19, %16, %13, %10, %7
%35 = load i8*, i8** %3
ret i8* %35
}

LLVM IR (-O2):
@.str = [15 x i8] c"CVDIAG_SUCCESS\00"
@.str.1 = [16 x i8] c"CVDIAG_MEM_NULL\00"
@.str.2 = [17 x i8] c"CVDIAG_LMEM_NULL\00"
@.str.3 = [17 x i8] c"CVDIAG_ILL_INPUT\00"
@.str.4 = [16 x i8] c"CVDIAG_MEM_FAIL\00"
@.str.5 = [16 x i8] c"CVDIAG_INV_FAIL\00"
@.str.6 = [23 x i8] c"CVDIAG_RHSFUNC_UNRECVR\00"
@.str.7 = [21 x i8] c"CVDIAG_RHSFUNC_RECVR\00"
@.str.8 = [5 x i8] c"NONE\00"
define i8* @CVDiagGetReturnFlagName(i32 %0) {
%2 = tail call i64 @malloc(i32 30)
%3 = inttoptr i64 %2 to i8*
switch i32 %0, label %12 [
i32 0, label %4
i32 -1, label %5
i32 -2, label %6
i32 -3, label %7
i32 -4, label %8
i32 -5, label %9
i32 -6, label %10
i32 -7, label %11
]
4: ; preds = %1
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(15) %3, i8* align 1 dereferenceable(15) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i64 15, i1 false)
br label %13
5: ; preds = %1
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(16) %3, i8* align 1 dereferenceable(16) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i64 16, i1 false)
br label %13
6: ; preds = %1
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(17) %3, i8* align 1 dereferenceable(17) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i64 17, i1 false)
br label %13
7: ; preds = %1
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(17) %3, i8* align 1 dereferenceable(17) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i64 17, i1 false)
br label %13
8: ; preds = %1
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(16) %3, i8* align 1 dereferenceable(16) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i64 16, i1 false)
br label %13
9: ; preds = %1
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(16) %3, i8* align 1 dereferenceable(16) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i64 16, i1 false)
br label %13
10: ; preds = %1
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(23) %3, i8* align 1 dereferenceable(23) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i64 23, i1 false)
br label %13
11: ; preds = %1
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(21) %3, i8* align 1 dereferenceable(21) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i64 21, i1 false)
br label %13
12: ; preds = %1
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(5) %3, i8* align 1 dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i64 5, i1 false)
br label %13
13: ; preds = %12, %11, %10, %9, %8, %7, %6, %5, %4
ret i8* %3
}