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

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

/* Variables and functions */
#define V4L2_BUF_TYPE_VIDEO_CAPTURE 133
#define V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE 132
#define V4L2_BUF_TYPE_VIDEO_OUTPUT 131
#define V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE 130
#define V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY 129
#define V4L2_BUF_TYPE_VIDEO_OVERLAY 128
int V4L2_FIELD_NONE;
unsigned v4l_format_g_field(const struct v4l2_format *fmt) {
  switch (fmt->type) {
  case V4L2_BUF_TYPE_VIDEO_CAPTURE:
  case V4L2_BUF_TYPE_VIDEO_OUTPUT:
    return fmt->fmt.pix.field;
  case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
  case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
    return fmt->fmt.pix_mp.field;
  case V4L2_BUF_TYPE_VIDEO_OVERLAY:
  case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY:
    return fmt->fmt.win.field;
  default:
    return V4L2_FIELD_NONE;
  }
}


x86 assembly (clang, -O0):
<v4l_format_g_field>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
add    $0xffffff80,%eax
sub    $0x2,%eax
jb     118c <v4l_format_g_field+0x8c>
jmp    1122 <v4l_format_g_field+0x22>
mov    -0x14(%rbp),%eax
sub    $0x82,%eax
je     117d <v4l_format_g_field+0x7d>
jmp    1135 <v4l_format_g_field+0x35>
mov    -0x14(%rbp),%eax
sub    $0x83,%eax
je     116e <v4l_format_g_field+0x6e>
jmp    1148 <v4l_format_g_field+0x48>
mov    -0x14(%rbp),%eax
sub    $0x84,%eax
je     117d <v4l_format_g_field+0x7d>
jmp    115b <v4l_format_g_field+0x5b>
mov    -0x14(%rbp),%eax
sub    $0x85,%eax
jne    119b <v4l_format_g_field+0x9b>
jmp    116e <v4l_format_g_field+0x6e>
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11a7 <v4l_format_g_field+0xa7>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11a7 <v4l_format_g_field+0xa7>
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11a7 <v4l_format_g_field+0xa7>
mov    0x2e46(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<v4l_format_g_field>:
mov    (%rdi),%eax
add    $0xffffff80,%eax
cmp    $0x5,%eax
ja     1133 <v4l_format_g_field+0x33>
mov    $0x3,%ecx
bt     %eax,%ecx
jb     1125 <v4l_format_g_field+0x25>
mov    $0x14,%ecx
bt     %eax,%ecx
jae    112c <v4l_format_g_field+0x2c>
add    $0x8,%rdi
mov    (%rdi),%eax
ret
add    $0x4,%rdi
mov    (%rdi),%eax
ret
add    $0xc,%rdi
mov    (%rdi),%eax
ret
mov    0x2eae(%rip),%rdi
mov    (%rdi),%eax
ret

LLVM IR (-O0):
%struct.v4l2_format = type { i32, %struct.TYPE_8__ }
%struct.TYPE_8__ = type { %struct.TYPE_7__, %struct.TYPE_6__, %struct.TYPE_5__ }
%struct.TYPE_7__ = type { i32 }
%struct.TYPE_6__ = type { i32 }
%struct.TYPE_5__ = type { i32 }
@V4L2_FIELD_NONE = global i32 0
define i32 @v4l_format_g_field(%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 %25 [
i32 133, label %7
i32 131, label %7
i32 132, label %13
i32 130, label %13
i32 128, label %19
i32 129, label %19
]
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_8__, %struct.TYPE_8__* %9, i32 0, i32 2
%11 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %10, i32 0, i32 0
%12 = load i32, i32* %11
store i32 %12, i32* %2
br label %27
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_8__, %struct.TYPE_8__* %15, i32 0, i32 1
%17 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %16, i32 0, i32 0
%18 = load i32, i32* %17
store i32 %18, i32* %2
br label %27
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_8__, %struct.TYPE_8__* %21, i32 0, i32 0
%23 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %22, i32 0, i32 0
%24 = load i32, i32* %23
store i32 %24, i32* %2
br label %27
25: ; preds = %1
%26 = load i32, i32* @V4L2_FIELD_NONE
store i32 %26, i32* %2
br label %27
27: ; preds = %25, %19, %13, %7
%28 = load i32, i32* %2
ret i32 %28
}

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