#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_6__ TYPE_3__;
typedef struct TYPE_5__ TYPE_2__;
typedef struct TYPE_4__ TYPE_1__;

/* Type definitions */
struct TYPE_5__ {
  int flags;
};
struct TYPE_4__ {
  int flags;
};
struct TYPE_6__ {
  TYPE_2__ pix_mp;
  TYPE_1__ pix;
};
struct v4l2_format {
  int type;
  TYPE_3__ fmt;
};

/* Variables and functions */
#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
unsigned v4l_format_g_flags(const struct v4l2_format *fmt) {
  switch (fmt->type) {
  case V4L2_BUF_TYPE_VIDEO_CAPTURE:
  case V4L2_BUF_TYPE_VIDEO_OUTPUT:
    return fmt->fmt.pix.flags;
  case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
  case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
    return fmt->fmt.pix_mp.flags;
  default:
    return 0;
  }
}


x86 assembly (clang, -O0):
<v4l_format_g_flags>:
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    $0x3,%eax
ja     1152 <v4l_format_g_flags+0x52>
mov    -0x18(%rbp),%rax
lea    0xed5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1159 <v4l_format_g_flags+0x59>
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1159 <v4l_format_g_flags+0x59>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<v4l_format_g_flags>:
mov    (%rdi),%eax
add    $0xffffff80,%eax
cmp    $0x3,%eax
ja     1128 <v4l_format_g_flags+0x28>
lea    0xeef(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
add    $0x4,%rdi
mov    (%rdi),%eax
ret
add    $0x8,%rdi
mov    (%rdi),%eax
ret
xor    %eax,%eax
ret

LLVM IR (-O0):
%struct.v4l2_format = type { i32, %struct.TYPE_6__ }
%struct.TYPE_6__ = type { %struct.TYPE_5__, %struct.TYPE_4__ }
%struct.TYPE_5__ = type { i32 }
%struct.TYPE_4__ = type { i32 }
define i32 @v4l_format_g_flags(%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 %19 [
i32 131, label %7
i32 129, label %7
i32 130, label %13
i32 128, label %13
]
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_6__, %struct.TYPE_6__* %9, i32 0, i32 1
%11 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %10, i32 0, i32 0
%12 = load i32, i32* %11
store i32 %12, i32* %2
br label %20
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_6__, %struct.TYPE_6__* %15, i32 0, i32 0
%17 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %16, i32 0, i32 0
%18 = load i32, i32* %17
store i32 %18, i32* %2
br label %20
19: ; preds = %1
store i32 0, i32* %2
br label %20
20: ; preds = %19, %13, %7
%21 = load i32, i32* %2
ret i32 %21
}

LLVM IR (-O2):
%struct.v4l2_format = type { i32, %struct.TYPE_6__ }
%struct.TYPE_6__ = type { %struct.TYPE_5__, %struct.TYPE_4__ }
%struct.TYPE_5__ = type { i32 }
%struct.TYPE_4__ = type { i32 }
define i32 @v4l_format_g_flags(%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 %11 [
i32 131, label %4
i32 129, label %4
i32 130, label %6
i32 128, label %6
]
4: ; preds = %1, %1
%5 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %0, i64 0, i32 1, i32 1, i32 0
br label %8
6: ; preds = %1, %1
%7 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %0, i64 0, i32 1, i32 0, i32 0
br label %8
8: ; preds = %4, %6
%9 = phi i32* [ %7, %6 ], [ %5, %4 ]
%10 = load i32, i32* %9
br label %11
11: ; preds = %8, %1
%12 = phi i32 [ 0, %1 ], [ %10, %8 ]
ret i32 %12
}