#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_8__ {
  int /*<<< orphan*/ height;
};
struct TYPE_9__ {
  TYPE_3__ w;
};
struct TYPE_7__ {
  int /*<<< orphan*/ height;
};
struct TYPE_6__ {
  int /*<<< orphan*/ height;
};
struct TYPE_10__ {
  TYPE_4__ win;
  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_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
__u32 v4l_format_g_height(const struct v4l2_format *fmt) {
  switch (fmt->type) {
  case V4L2_BUF_TYPE_VIDEO_CAPTURE:
  case V4L2_BUF_TYPE_VIDEO_OUTPUT:
    return fmt->fmt.pix.height;
  case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
  case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
    return fmt->fmt.pix_mp.height;
  case V4L2_BUF_TYPE_VIDEO_OVERLAY:
  case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY:
    return fmt->fmt.win.w.height;
  default:
    return 0;
  }
}


x86 assembly (clang, -O0):
<v4l_format_g_height>:
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_height+0x8c>
jmp    1122 <v4l_format_g_height+0x22>
mov    -0x14(%rbp),%eax
sub    $0x82,%eax
je     117d <v4l_format_g_height+0x7d>
jmp    1135 <v4l_format_g_height+0x35>
mov    -0x14(%rbp),%eax
sub    $0x83,%eax
je     116e <v4l_format_g_height+0x6e>
jmp    1148 <v4l_format_g_height+0x48>
mov    -0x14(%rbp),%eax
sub    $0x84,%eax
je     117d <v4l_format_g_height+0x7d>
jmp    115b <v4l_format_g_height+0x5b>
mov    -0x14(%rbp),%eax
sub    $0x85,%eax
jne    119b <v4l_format_g_height+0x9b>
jmp    116e <v4l_format_g_height+0x6e>
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11a2 <v4l_format_g_height+0xa2>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11a2 <v4l_format_g_height+0xa2>
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11a2 <v4l_format_g_height+0xa2>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

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

LLVM IR (-O0):
%struct.v4l2_format = type { i32, %struct.TYPE_10__ }
%struct.TYPE_10__ = type { %struct.TYPE_9__, %struct.TYPE_7__, %struct.TYPE_6__ }
%struct.TYPE_9__ = type { %struct.TYPE_8__ }
%struct.TYPE_8__ = type { i32 }
%struct.TYPE_7__ = type { i32 }
%struct.TYPE_6__ = type { i32 }
define i32 @v4l_format_g_height(%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 %26 [
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_10__, %struct.TYPE_10__* %9, i32 0, i32 2
%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 %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_10__, %struct.TYPE_10__* %15, i32 0, i32 1
%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 %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_10__, %struct.TYPE_10__* %21, i32 0, i32 0
%23 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %22, i32 0, i32 0
%24 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %23, i32 0, i32 0
%25 = load i32, i32* %24
store i32 %25, i32* %2
br label %27
26: ; preds = %1
store i32 0, i32* %2
br label %27
27: ; preds = %26, %19, %13, %7
%28 = load i32, i32* %2
ret i32 %28
}

LLVM IR (-O2):
%struct.v4l2_format = type { i32, %struct.TYPE_10__ }
%struct.TYPE_10__ = type { %struct.TYPE_9__, %struct.TYPE_7__, %struct.TYPE_6__ }
%struct.TYPE_9__ = type { %struct.TYPE_8__ }
%struct.TYPE_8__ = type { i32 }
%struct.TYPE_7__ = type { i32 }
%struct.TYPE_6__ = type { i32 }
define i32 @v4l_format_g_height(%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 %13 [
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, i32 0
br label %10
10: ; preds = %4, %6, %8
%11 = phi i32* [ %9, %8 ], [ %7, %6 ], [ %5, %4 ]
%12 = load i32, i32* %11
br label %13
13: ; preds = %10, %1
%14 = phi i32 [ 0, %1 ], [ %12, %10 ]
ret i32 %14
}