#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*/ types;
typedef int __u32;

/* Variables and functions */
#define V4L2_DV_BT_656_1120 128
int /*<<< orphan*/ sprintf(char *, char *, int);
const char *v4l2_dv_type_to_string(unsigned int type) {
  static const struct {
    __u32 type;
    const char *name;
  } types[] = {
      {V4L2_DV_BT_656_1120, "BT.656/1120"},
  };
  static char unknown[20];
  unsigned int i;
  for (i = 0; i < (sizeof(types) / sizeof((types)[0])); i++) {
    if (types[i].type == type)
      return types[i].name;
  }
  sprintf(unknown, "Unknown (%u)", type);
  return unknown;
}


x86 assembly (clang, -O0):
<v4l2_dv_type_to_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    $0x1,%rax
jae    1180 <v4l2_dv_type_to_string+0x70>
mov    -0x10(%rbp),%eax
mov    %eax,%ecx
lea    0x2cd5(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%eax
cmp    -0xc(%rbp),%eax
jne    116d <v4l2_dv_type_to_string+0x5d>
mov    -0x10(%rbp),%eax
mov    %eax,%ecx
lea    0x2cb7(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    0x8(%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    11a1 <v4l2_dv_type_to_string+0x91>
jmp    1172 <v4l2_dv_type_to_string+0x62>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1122 <v4l2_dv_type_to_string+0x12>
mov    -0xc(%rbp),%edx
lea    0x2eb6(%rip),%rdi
lea    0xe7b(%rip),%rsi
call   1030 <sprintf@plt>
lea    0x2ea3(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<v4l2_dv_type_to_string>:
push   %rbx
cmp    $0x80,%edi
jne    1122 <v4l2_dv_type_to_string+0x12>
lea    0xee0(%rip),%rbx
jmp    113a <v4l2_dv_type_to_string+0x2a>
mov    %edi,%edx
lea    0x2f15(%rip),%rbx
lea    0xeda(%rip),%rsi
mov    %rbx,%rdi
call   1030 <sprintf@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
%struct.anon = type { i32, i8* }
@v4l2_dv_type_to_string.types = internal constant [1 x %struct.anon] [%struct.anon { i32 128, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i32 0, i32 0) }]
@.str = [12 x i8] c"BT.656/1120\00"
@v4l2_dv_type_to_string.unknown = internal global [20 x i8] zeroinitializer
@.str.1 = [13 x i8] c"Unknown (%u)\00"
define i8* @v4l2_dv_type_to_string(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, 1
br i1 %8, label %9, label %27
9: ; preds = %5
%10 = load i32, i32* %4
%11 = zext i32 %10 to i64
%12 = getelementptr inbounds [1 x %struct.anon], [1 x %struct.anon]* @v4l2_dv_type_to_string.types, 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 [1 x %struct.anon], [1 x %struct.anon]* @v4l2_dv_type_to_string.types, 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 %30
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 = call i32 @sprintf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @v4l2_dv_type_to_string.unknown, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %28)
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @v4l2_dv_type_to_string.unknown, i64 0, i64 0), i8** %2
br label %30
30: ; preds = %27, %17
%31 = load i8*, i8** %2
ret i8* %31
}

LLVM IR (-O2):
@.str = [12 x i8] c"BT.656/1120\00"
@v4l2_dv_type_to_string.unknown = internal global [20 x i8] zeroinitializer
@.str.1 = [13 x i8] c"Unknown (%u)\00"
define i8* @v4l2_dv_type_to_string(i32 %0) {
%2 = icmp eq i32 %0, 128
br i1 %2, label %5, label %3
3: ; preds = %1
%4 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @v4l2_dv_type_to_string.unknown, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %0)
br label %5
5: ; preds = %1, %3
%6 = phi i8* [ getelementptr inbounds ([20 x i8], [20 x i8]* @v4l2_dv_type_to_string.unknown, i64 0, i64 0), %3 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %6
}