#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_10__ TYPE_5__;
typedef struct TYPE_9__ TYPE_4__;
typedef struct TYPE_8__ TYPE_3__;
typedef struct TYPE_7__ TYPE_2__;
typedef struct TYPE_6__ TYPE_1__;

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

/* Variables and functions */
#define V4L2_BUF_TYPE_SDR_CAPTURE 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:
    return fmt->fmt.sdr.pixelformat;
  case V4L2_BUF_TYPE_VBI_CAPTURE:
  case V4L2_BUF_TYPE_VBI_OUTPUT:
    return fmt->fmt.vbi.sample_format;
  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    $0x6,%eax
ja     1170 <v4l_format_g_pixelformat+0x70>
mov    -0x18(%rbp),%rax
lea    0xed5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1177 <v4l_format_g_pixelformat+0x77>
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1177 <v4l_format_g_pixelformat+0x77>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1177 <v4l_format_g_pixelformat+0x77>
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1177 <v4l_format_g_pixelformat+0x77>
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    $0x6,%eax
ja     112f <v4l_format_g_pixelformat+0x2f>
lea    0xeef(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
add    $0xc,%rdi
mov    (%rdi),%eax
ret
add    $0x10,%rdi
mov    (%rdi),%eax
ret
add    $0x4,%rdi
mov    (%rdi),%eax
ret
xor    %eax,%eax
ret
add    $0x8,%rdi
mov    (%rdi),%eax
ret

LLVM IR (-O0):
%struct.v4l2_format = type { i32, %struct.TYPE_10__ }
%struct.TYPE_10__ = type { %struct.TYPE_9__, %struct.TYPE_8__, %struct.TYPE_7__, %struct.TYPE_6__ }
%struct.TYPE_9__ = type { i32 }
%struct.TYPE_8__ = type { i32 }
%struct.TYPE_7__ = type { i32 }
%struct.TYPE_6__ = 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 %31 [
i32 131, label %7
i32 129, label %7
i32 130, label %13
i32 128, label %13
i32 134, label %19
i32 133, label %25
i32 132, label %25
]
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_10__, %struct.TYPE_10__* %9, i32 0, i32 3
%11 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %10, i32 0, i32 0
%12 = load i32, i32* %11
store i32 %12, i32* %2
br label %32
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_10__, %struct.TYPE_10__* %15, i32 0, i32 2
%17 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %16, i32 0, i32 0
%18 = load i32, i32* %17
store i32 %18, i32* %2
br label %32
19: ; preds = %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_10__, %struct.TYPE_10__* %21, i32 0, i32 1
%23 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %22, i32 0, i32 0
%24 = load i32, i32* %23
store i32 %24, i32* %2
br label %32
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_10__, %struct.TYPE_10__* %27, i32 0, i32 0
%29 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %28, i32 0, i32 0
%30 = load i32, i32* %29
store i32 %30, i32* %2
br label %32
31: ; preds = %1
store i32 0, i32* %2
br label %32
32: ; preds = %31, %25, %19, %13, %7
%33 = load i32, i32* %2
ret i32 %33
}

LLVM IR (-O2):
%struct.v4l2_format = type { i32, %struct.TYPE_10__ }
%struct.TYPE_10__ = type { %struct.TYPE_9__, %struct.TYPE_8__, %struct.TYPE_7__, %struct.TYPE_6__ }
%struct.TYPE_9__ = type { i32 }
%struct.TYPE_8__ = type { i32 }
%struct.TYPE_7__ = type { i32 }
%struct.TYPE_6__ = 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 %15 [
i32 131, label %4
i32 129, label %4
i32 130, label %6
i32 128, label %6
i32 134, label %8
i32 133, label %10
i32 132, label %10
]
4: ; preds = %1, %1
%5 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %0, i64 0, i32 1, i32 3, i32 0
br label %12
6: ; preds = %1, %1
%7 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %0, i64 0, i32 1, i32 2, i32 0
br label %12
8: ; preds = %1
%9 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %0, i64 0, i32 1, i32 1, i32 0
br label %12
10: ; preds = %1, %1
%11 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %0, i64 0, i32 1, i32 0, i32 0
br label %12
12: ; preds = %4, %6, %8, %10
%13 = phi i32* [ %11, %10 ], [ %9, %8 ], [ %7, %6 ], [ %5, %4 ]
%14 = load i32, i32* %13
br label %15
15: ; preds = %12, %1
%16 = phi i32 [ 0, %1 ], [ %14, %12 ]
ret i32 %16
}