#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 get_mode_string(unsigned char *data, char *description) {
  unsigned int val =
      (unsigned int)(((&data[4])[0] << 24) + ((&data[4])[1] << 16) +
                     ((&data[4])[2] << 8) + ((&data[4])[3]));
  switch (val) {
  case 0x00022000:
    sprintf(description, "vertex RGB, no culling");
    break;
  case 0x00020000:
    sprintf(description, "vertex RGB, culling");
    break;
  case 0x00000000:
    sprintf(description, "no vertex RGB, culling");
    break;
  case 0x00002200:
    sprintf(description, "no vertex RGB, no culling");
    break;
  default:
    sprintf(description, "unknown");
    break;
  }
}


x86 assembly (clang, -O0):
<get_mode_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%eax
bswap  %eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
test   %eax,%eax
je     11a2 <get_mode_string+0x92>
jmp    113f <get_mode_string+0x2f>
mov    -0x18(%rbp),%eax
sub    $0x2200,%eax
je     11b7 <get_mode_string+0xa7>
jmp    1152 <get_mode_string+0x42>
mov    -0x18(%rbp),%eax
sub    $0x20000,%eax
je     118d <get_mode_string+0x7d>
jmp    1165 <get_mode_string+0x55>
mov    -0x18(%rbp),%eax
sub    $0x22000,%eax
jne    11cc <get_mode_string+0xbc>
jmp    1178 <get_mode_string+0x68>
mov    -0x10(%rbp),%rdi
lea    0xe97(%rip),%rsi
call   1030 <sprintf@plt>
jmp    11dc <get_mode_string+0xcc>
mov    -0x10(%rbp),%rdi
lea    0xe6b(%rip),%rsi
call   1030 <sprintf@plt>
jmp    11dc <get_mode_string+0xcc>
mov    -0x10(%rbp),%rdi
lea    0xe53(%rip),%rsi
call   1030 <sprintf@plt>
jmp    11dc <get_mode_string+0xcc>
mov    -0x10(%rbp),%rdi
lea    0xe55(%rip),%rsi
call   1030 <sprintf@plt>
jmp    11dc <get_mode_string+0xcc>
mov    -0x10(%rbp),%rdi
lea    0xe5a(%rip),%rsi
call   1030 <sprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_mode_string>:
mov    0x4(%rdi),%eax
bswap  %eax
cmp    $0x1ffff,%eax
jg     112d <get_mode_string+0x2d>
test   %eax,%eax
je     1152 <get_mode_string+0x52>
cmp    $0x2200,%eax
jne    1144 <get_mode_string+0x44>
movups 0xf03(%rip),%xmm0
movups %xmm0,0xa(%rsi)
movups 0xeee(%rip),%xmm0
movups %xmm0,(%rsi)
ret
cmp    $0x20000,%eax
je     116b <get_mode_string+0x6b>
cmp    $0x22000,%eax
jne    1144 <get_mode_string+0x44>
movups 0xed8(%rip),%xmm0
jmp    1159 <get_mode_string+0x59>
movabs $0x6e776f6e6b6e75,%rax
mov    %rax,(%rsi)
ret
movups 0xea7(%rip),%xmm0
movups %xmm0,(%rsi)
movabs $0x676e696c6c7563,%rax
mov    %rax,0xf(%rsi)
ret
movups 0xe91(%rip),%xmm0
movups %xmm0,(%rsi)
movl   $0x676e69,0x10(%rsi)
ret

LLVM IR (-O0):
@.str = [23 x i8] c"vertex RGB, no culling\00"
@.str.1 = [20 x i8] c"vertex RGB, culling\00"
@.str.2 = [23 x i8] c"no vertex RGB, culling\00"
@.str.3 = [26 x i8] c"no vertex RGB, no culling\00"
@.str.4 = [8 x i8] c"unknown\00"
define void @get_mode_string(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %3
%7 = getelementptr inbounds i8, i8* %6, i64 4
%8 = getelementptr inbounds i8, i8* %7, i64 0
%9 = load i8, i8* %8
%10 = zext i8 %9 to i32
%11 = shl i32 %10, 24
%12 = load i8*, i8** %3
%13 = getelementptr inbounds i8, i8* %12, i64 4
%14 = getelementptr inbounds i8, i8* %13, i64 1
%15 = load i8, i8* %14
%16 = zext i8 %15 to i32
%17 = shl i32 %16, 16
%18 = add nsw i32 %11, %17
%19 = load i8*, i8** %3
%20 = getelementptr inbounds i8, i8* %19, i64 4
%21 = getelementptr inbounds i8, i8* %20, i64 2
%22 = load i8, i8* %21
%23 = zext i8 %22 to i32
%24 = shl i32 %23, 8
%25 = add nsw i32 %18, %24
%26 = load i8*, i8** %3
%27 = getelementptr inbounds i8, i8* %26, i64 4
%28 = getelementptr inbounds i8, i8* %27, i64 3
%29 = load i8, i8* %28
%30 = zext i8 %29 to i32
%31 = add nsw i32 %25, %30
store i32 %31, i32* %5
%32 = load i32, i32* %5
switch i32 %32, label %45 [
i32 139264, label %33
i32 131072, label %36
i32 0, label %39
i32 8704, label %42
]
33: ; preds = %2
%34 = load i8*, i8** %4
%35 = call i32 @sprintf(i8* %34, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %48
36: ; preds = %2
%37 = load i8*, i8** %4
%38 = call i32 @sprintf(i8* %37, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %48
39: ; preds = %2
%40 = load i8*, i8** %4
%41 = call i32 @sprintf(i8* %40, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
br label %48
42: ; preds = %2
%43 = load i8*, i8** %4
%44 = call i32 @sprintf(i8* %43, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
br label %48
45: ; preds = %2
%46 = load i8*, i8** %4
%47 = call i32 @sprintf(i8* %46, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
br label %48
48: ; preds = %45, %42, %39, %36, %33
ret void
}

LLVM IR (-O2):
@.str = [23 x i8] c"vertex RGB, no culling\00"
@.str.1 = [20 x i8] c"vertex RGB, culling\00"
@.str.2 = [23 x i8] c"no vertex RGB, culling\00"
@.str.3 = [26 x i8] c"no vertex RGB, no culling\00"
define void @get_mode_string(i8* nocapture %0, i8* nocapture writeonly %1) {
%3 = getelementptr inbounds i8, i8* %0, i64 4
%4 = load i8, i8* %3
%5 = zext i8 %4 to i32
%6 = shl nuw i32 %5, 24
%7 = getelementptr inbounds i8, i8* %0, i64 5
%8 = load i8, i8* %7
%9 = zext i8 %8 to i32
%10 = shl nuw nsw i32 %9, 16
%11 = or i32 %10, %6
%12 = getelementptr inbounds i8, i8* %0, i64 6
%13 = load i8, i8* %12
%14 = zext i8 %13 to i32
%15 = shl nuw nsw i32 %14, 8
%16 = or i32 %11, %15
%17 = getelementptr inbounds i8, i8* %0, i64 7
%18 = load i8, i8* %17
%19 = zext i8 %18 to i32
%20 = or i32 %16, %19
switch i32 %20, label %25 [
i32 139264, label %21
i32 131072, label %22
i32 0, label %23
i32 8704, label %24
]
21: ; preds = %2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(23) %1, i8* align 1 dereferenceable(23) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i64 23, i1 false)
br label %27
22: ; preds = %2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(20) %1, 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 %27
23: ; preds = %2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(23) %1, i8* align 1 dereferenceable(23) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i64 23, i1 false)
br label %27
24: ; preds = %2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(26) %1, i8* align 1 dereferenceable(26) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i64 26, i1 false)
br label %27
25: ; preds = %2
%26 = bitcast i8* %1 to i64*
store i64 31093567915781749, i64* %26
br label %27
27: ; preds = %25, %24, %23, %22, %21
ret void
}