#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 */
typedef int /*<<< orphan*/ names;
typedef enum v4l2_buf_type { ____Placeholder_v4l2_buf_type } v4l2_buf_type;

/* Variables and functions */
int V4L2_BUF_TYPE_PRIVATE;
#define V4L2_BUF_TYPE_VIDEO_CAPTURE 130
#define V4L2_BUF_TYPE_VIDEO_OUTPUT 129
#define V4L2_BUF_TYPE_VIDEO_OVERLAY 128
const char *v4l2_buf_type_name(enum v4l2_buf_type type) {
  static struct {
    enum v4l2_buf_type type;
    const char *name;
  } names[] = {
      {V4L2_BUF_TYPE_VIDEO_CAPTURE, "Video capture"},
      {V4L2_BUF_TYPE_VIDEO_OUTPUT, "Video output"},
      {V4L2_BUF_TYPE_VIDEO_OVERLAY, "Video overlay"},
  };
  unsigned int i;
  for (i = 0; i < (sizeof(names) / sizeof((names)[0])); ++i) {
    if (names[i].type == type)
      return names[i].name;
  }
  if (type & V4L2_BUF_TYPE_PRIVATE)
    return "Private";
  else
    return "Unknown";
}


x86 assembly (clang, -O0):
<v4l2_buf_type_name>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    $0x3,%rax
jae    116c <v4l2_buf_type_name+0x6c>
mov    -0x10(%rbp),%eax
mov    %eax,%ecx
lea    0x2f09(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%eax
cmp    -0xc(%rbp),%eax
jne    1159 <v4l2_buf_type_name+0x59>
mov    -0x10(%rbp),%eax
mov    %eax,%ecx
lea    0x2eeb(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    0x8(%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    119c <v4l2_buf_type_name+0x9c>
jmp    115e <v4l2_buf_type_name+0x5e>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    110e <v4l2_buf_type_name+0xe>
mov    -0xc(%rbp),%eax
mov    0x2e6a(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1191 <v4l2_buf_type_name+0x91>
lea    0xea1(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    119c <v4l2_buf_type_name+0x9c>
lea    0xe99(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<v4l2_buf_type_name>:
lea    -0x80(%rdi),%eax
cmp    $0x2,%eax
ja     1123 <v4l2_buf_type_name+0x23>
mov    %eax,%eax
mov    $0x2,%ecx
sub    %rax,%rcx
shl    $0x4,%rcx
lea    0x2cf3(%rip),%rax
mov    0x8(%rcx,%rax,1),%rax
ret
mov    0x2eae(%rip),%rax
test   %edi,(%rax)
lea    0xefe(%rip),%rcx
lea    0xeef(%rip),%rax
cmove  %rcx,%rax
ret

LLVM IR (-O0):
%struct.anon = type { i32, i8* }
@v4l2_buf_type_name.names = internal global [3 x %struct.anon] [%struct.anon { i32 130, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i32 0, i32 0) }, %struct.anon { i32 129, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i32 0, i32 0) }, %struct.anon { i32 128, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i32 0, i32 0) }]
@.str = [14 x i8] c"Video capture\00"
@.str.1 = [13 x i8] c"Video output\00"
@.str.2 = [14 x i8] c"Video overlay\00"
@V4L2_BUF_TYPE_PRIVATE = global i32 0
@.str.3 = [8 x i8] c"Private\00"
@.str.4 = [8 x i8] c"Unknown\00"
define i8* @v4l2_buf_type_name(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 0, i32* %4
br label %5
5: ; preds = %24, %1
%6 = load i32, i32* %4
%7 = zext i32 %6 to i64
%8 = icmp ult i64 %7, 3
br i1 %8, label %9, label %27
9: ; preds = %5
%10 = load i32, i32* %4
%11 = zext i32 %10 to i64
%12 = getelementptr inbounds [3 x %struct.anon], [3 x %struct.anon]* @v4l2_buf_type_name.names, i64 0, i64 %11
%13 = getelementptr inbounds %struct.anon, %struct.anon* %12, i32 0, i32 0
%14 = load i32, i32* %13
%15 = load i32, i32* %3
%16 = icmp eq i32 %14, %15
br i1 %16, label %17, label %23
17: ; preds = %9
%18 = load i32, i32* %4
%19 = zext i32 %18 to i64
%20 = getelementptr inbounds [3 x %struct.anon], [3 x %struct.anon]* @v4l2_buf_type_name.names, i64 0, i64 %19
%21 = getelementptr inbounds %struct.anon, %struct.anon* %20, i32 0, i32 1
%22 = load i8*, i8** %21
store i8* %22, i8** %2
br label %34
23: ; preds = %9
br label %24
24: ; preds = %23
%25 = load i32, i32* %4
%26 = add i32 %25, 1
store i32 %26, i32* %4
br label %5
27: ; preds = %5
%28 = load i32, i32* %3
%29 = load i32, i32* @V4L2_BUF_TYPE_PRIVATE
%30 = and i32 %28, %29
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %27
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %34
33: ; preds = %27
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %34
34: ; preds = %33, %32, %17
%35 = load i8*, i8** %2
ret i8* %35
}

LLVM IR (-O2):
%struct.anon = type { i32, i8* }
@v4l2_buf_type_name.names = internal unnamed_addr constant [3 x %struct.anon] [%struct.anon { i32 130, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i32 0, i32 0) }, %struct.anon { i32 129, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i32 0, i32 0) }, %struct.anon { i32 128, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i32 0, i32 0) }]
@.str = [14 x i8] c"Video capture\00"
@.str.1 = [13 x i8] c"Video output\00"
@.str.2 = [14 x i8] c"Video overlay\00"
@V4L2_BUF_TYPE_PRIVATE = global i32 0
@.str.3 = [8 x i8] c"Private\00"
@.str.4 = [8 x i8] c"Unknown\00"
define i8* @v4l2_buf_type_name(i32 %0) {
%2 = add i32 %0, -128
%3 = icmp ult i32 %2, 3
br i1 %3, label %4, label %9
4: ; preds = %1
%5 = zext i32 %2 to i64
%6 = sub nsw i64 2, %5
%7 = getelementptr inbounds [3 x %struct.anon], [3 x %struct.anon]* @v4l2_buf_type_name.names, i64 0, i64 %6, i32 1
%8 = load i8*, i8** %7
br label %14
9: ; preds = %1
%10 = load i32, i32* @V4L2_BUF_TYPE_PRIVATE
%11 = and i32 %10, %0
%12 = icmp eq i32 %11, 0
%13 = select i1 %12, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0)
br label %14
14: ; preds = %9, %4
%15 = phi i8* [ %8, %4 ], [ %13, %9 ]
ret i8* %15
}