#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 */
typedef struct TYPE_12__ TYPE_6__;
typedef struct TYPE_11__ TYPE_5__;
typedef struct TYPE_10__ TYPE_4__;
typedef struct TYPE_9__ TYPE_3__;
typedef struct TYPE_8__ TYPE_2__;
typedef struct TYPE_7__ TYPE_1__;

/* Type definitions */
struct TYPE_11__ {
  int /*<<< orphan*/ dataformat;
};
struct TYPE_10__ {
  int /*<<< orphan*/ sample_format;
};
struct TYPE_9__ {
  int /*<<< orphan*/ pixelformat;
};
struct TYPE_8__ {
  int /*<<< orphan*/ pixelformat;
};
struct TYPE_7__ {
  int /*<<< orphan*/ pixelformat;
};
struct TYPE_12__ {
  TYPE_5__ meta;
  TYPE_4__ vbi;
  TYPE_3__ sdr;
  TYPE_2__ pix_mp;
  TYPE_1__ pix;
};
struct v4l2_format {
  int type;
  TYPE_6__ fmt;
};
typedef int /*<<< orphan*/ __u32;

/* Variables and functions */
#define V4L2_BUF_TYPE_META_CAPTURE 137
#define V4L2_BUF_TYPE_META_OUTPUT 136
#define V4L2_BUF_TYPE_SDR_CAPTURE 135
#define V4L2_BUF_TYPE_SDR_OUTPUT 134
#define V4L2_BUF_TYPE_VBI_CAPTURE 133
#define V4L2_BUF_TYPE_VBI_OUTPUT 132
#define V4L2_BUF_TYPE_VIDEO_CAPTURE 131
#define V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE 130
#define V4L2_BUF_TYPE_VIDEO_OUTPUT 129
#define V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE 128
__u32 v4l_format_g_pixelformat(const struct v4l2_format *fmt) {
  switch (fmt->type) {
  case V4L2_BUF_TYPE_VIDEO_CAPTURE:
  case V4L2_BUF_TYPE_VIDEO_OUTPUT:
    return fmt->fmt.pix.pixelformat;
  case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
  case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
    return fmt->fmt.pix_mp.pixelformat;
  case V4L2_BUF_TYPE_SDR_CAPTURE:
  case V4L2_BUF_TYPE_SDR_OUTPUT:
    return fmt->fmt.sdr.pixelformat;
  case V4L2_BUF_TYPE_VBI_CAPTURE:
  case V4L2_BUF_TYPE_VBI_OUTPUT:
    return fmt->fmt.vbi.sample_format;
  case V4L2_BUF_TYPE_META_CAPTURE:
  case V4L2_BUF_TYPE_META_OUTPUT:
    return fmt->fmt.meta.dataformat;
  default:
    return 0;
  }
}


x86 assembly (clang, -O0):
<v4l_format_g_pixelformat>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x9,%eax
ja     117f <v4l_format_g_pixelformat+0x7f>
mov    -0x18(%rbp),%rax
lea    0xed5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rax
mov    0x14(%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1186 <v4l_format_g_pixelformat+0x86>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1186 <v4l_format_g_pixelformat+0x86>
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1186 <v4l_format_g_pixelformat+0x86>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1186 <v4l_format_g_pixelformat+0x86>
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1186 <v4l_format_g_pixelformat+0x86>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<v4l_format_g_pixelformat>:
mov    (%rdi),%eax
add    $0xffffff80,%eax
cmp    $0x9,%eax
ja     113d <v4l_format_g_pixelformat+0x3d>
lea    0xeef(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
add    $0x10,%rdi
mov    (%rdi),%eax
ret
add    $0x14,%rdi
mov    (%rdi),%eax
ret
add    $0x8,%rdi
mov    (%rdi),%eax
ret
add    $0xc,%rdi
mov    (%rdi),%eax
ret
add    $0x4,%rdi
mov    (%rdi),%eax
ret
xor    %eax,%eax
ret

LLVM IR (-O0):
%struct.v4l2_format = type { i32, %struct.TYPE_12__ }
%struct.TYPE_12__ = type { %struct.TYPE_11__, %struct.TYPE_10__, %struct.TYPE_9__, %struct.TYPE_8__, %struct.TYPE_7__ }
%struct.TYPE_11__ = type { i32 }
%struct.TYPE_10__ = type { i32 }
%struct.TYPE_9__ = type { i32 }
%struct.TYPE_8__ = type { i32 }
%struct.TYPE_7__ = type { i32 }
define i32 @v4l_format_g_pixelformat(%struct.v4l2_format* %0) {
%2 = alloca i32
%3 = alloca %struct.v4l2_format*
store %struct.v4l2_format* %0, %struct.v4l2_format** %3
%4 = load %struct.v4l2_format*, %struct.v4l2_format** %3
%5 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %4, i32 0, i32 0
%6 = load i32, i32* %5
switch i32 %6, label %37 [
i32 131, label %7
i32 129, label %7
i32 130, label %13
i32 128, label %13
i32 135, label %19
i32 134, label %19
i32 133, label %25
i32 132, label %25
i32 137, label %31
i32 136, label %31
]
7: ; preds = %1, %1
%8 = load %struct.v4l2_format*, %struct.v4l2_format** %3
%9 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %8, i32 0, i32 1
%10 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %9, i32 0, i32 4
%11 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %10, i32 0, i32 0
%12 = load i32, i32* %11
store i32 %12, i32* %2
br label %38
13: ; preds = %1, %1
%14 = load %struct.v4l2_format*, %struct.v4l2_format** %3
%15 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %14, i32 0, i32 1
%16 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %15, i32 0, i32 3
%17 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %16, i32 0, i32 0
%18 = load i32, i32* %17
store i32 %18, i32* %2
br label %38
19: ; preds = %1, %1
%20 = load %struct.v4l2_format*, %struct.v4l2_format** %3
%21 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %20, i32 0, i32 1
%22 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %21, i32 0, i32 2
%23 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %22, i32 0, i32 0
%24 = load i32, i32* %23
store i32 %24, i32* %2
br label %38
25: ; preds = %1, %1
%26 = load %struct.v4l2_format*, %struct.v4l2_format** %3
%27 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %26, i32 0, i32 1
%28 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %27, i32 0, i32 1
%29 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %28, i32 0, i32 0
%30 = load i32, i32* %29
store i32 %30, i32* %2
br label %38
31: ; preds = %1, %1
%32 = load %struct.v4l2_format*, %struct.v4l2_format** %3
%33 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %32, i32 0, i32 1
%34 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %33, i32 0, i32 0
%35 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %34, i32 0, i32 0
%36 = load i32, i32* %35
store i32 %36, i32* %2
br label %38
37: ; preds = %1
store i32 0, i32* %2
br label %38
38: ; preds = %37, %31, %25, %19, %13, %7
%39 = load i32, i32* %2
ret i32 %39
}

LLVM IR (-O2):
%struct.v4l2_format = type { i32, %struct.TYPE_12__ }
%struct.TYPE_12__ = type { %struct.TYPE_11__, %struct.TYPE_10__, %struct.TYPE_9__, %struct.TYPE_8__, %struct.TYPE_7__ }
%struct.TYPE_11__ = type { i32 }
%struct.TYPE_10__ = type { i32 }
%struct.TYPE_9__ = type { i32 }
%struct.TYPE_8__ = type { i32 }
%struct.TYPE_7__ = type { i32 }
define i32 @v4l_format_g_pixelformat(%struct.v4l2_format* nocapture %0) {
%2 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %0, i64 0, i32 0
%3 = load i32, i32* %2
switch i32 %3, label %17 [
i32 131, label %4
i32 129, label %4
i32 130, label %6
i32 128, label %6
i32 135, label %8
i32 134, label %8
i32 133, label %10
i32 132, label %10
i32 137, label %12
i32 136, label %12
]
4: ; preds = %1, %1
%5 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %0, i64 0, i32 1, i32 4, i32 0
br label %14
6: ; preds = %1, %1
%7 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %0, i64 0, i32 1, i32 3, i32 0
br label %14
8: ; preds = %1, %1
%9 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %0, i64 0, i32 1, i32 2, i32 0
br label %14
10: ; preds = %1, %1
%11 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %0, i64 0, i32 1, i32 1, i32 0
br label %14
12: ; preds = %1, %1
%13 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %0, i64 0, i32 1, i32 0, i32 0
br label %14
14: ; preds = %4, %6, %8, %10, %12
%15 = phi i32* [ %13, %12 ], [ %11, %10 ], [ %9, %8 ], [ %7, %6 ], [ %5, %4 ]
%16 = load i32, i32* %15
br label %17
17: ; preds = %14, %1
%18 = phi i32 [ 0, %1 ], [ %16, %14 ]
ret i32 %18
}