#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*/ samples_per_line;
};
struct TYPE_8__ {
  TYPE_2__ *plane_fmt;
};
struct TYPE_6__ {
  int /*<<< orphan*/ bytesperline;
};
struct TYPE_10__ {
  TYPE_4__ vbi;
  TYPE_3__ pix_mp;
  TYPE_1__ pix;
};
struct v4l2_format {
  int type;
  TYPE_5__ fmt;
};
typedef int /*<<< orphan*/ __u32;
struct TYPE_7__ {
  int /*<<< orphan*/ bytesperline;
};

/* Variables and functions */
#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_bytesperline(const struct v4l2_format *fmt, unsigned plane) {
  switch (fmt->type) {
  case V4L2_BUF_TYPE_VIDEO_CAPTURE:
  case V4L2_BUF_TYPE_VIDEO_OUTPUT:
    return plane ? 0 : fmt->fmt.pix.bytesperline;
  case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
  case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
    return fmt->fmt.pix_mp.plane_fmt[plane].bytesperline;
  case V4L2_BUF_TYPE_VBI_CAPTURE:
  case V4L2_BUF_TYPE_VBI_OUTPUT:
    return plane ? 0 : fmt->fmt.vbi.samples_per_line;
  default:
    return 0;
  }
}


x86 assembly (clang, -O0):
<v4l_format_g_bytesperline>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
sub    $0x80,%eax
je     119c <v4l_format_g_bytesperline+0x9c>
jmp    1124 <v4l_format_g_bytesperline+0x24>
mov    -0x18(%rbp),%eax
sub    $0x81,%eax
je     1173 <v4l_format_g_bytesperline+0x73>
jmp    1137 <v4l_format_g_bytesperline+0x37>
mov    -0x18(%rbp),%eax
sub    $0x82,%eax
je     119c <v4l_format_g_bytesperline+0x9c>
jmp    114a <v4l_format_g_bytesperline+0x4a>
mov    -0x18(%rbp),%eax
sub    $0x83,%eax
je     1173 <v4l_format_g_bytesperline+0x73>
jmp    115d <v4l_format_g_bytesperline+0x5d>
mov    -0x18(%rbp),%eax
add    $0xffffff7c,%eax
sub    $0x2,%eax
jb     11b2 <v4l_format_g_bytesperline+0xb2>
jmp    11db <v4l_format_g_bytesperline+0xdb>
cmpl   $0x0,-0x14(%rbp)
je     1187 <v4l_format_g_bytesperline+0x87>
xor    %eax,%eax
mov    %eax,-0x1c(%rbp)
jmp    1191 <v4l_format_g_bytesperline+0x91>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11e2 <v4l_format_g_bytesperline+0xe2>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    -0x14(%rbp),%ecx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x4(%rbp)
jmp    11e2 <v4l_format_g_bytesperline+0xe2>
cmpl   $0x0,-0x14(%rbp)
je     11c6 <v4l_format_g_bytesperline+0xc6>
xor    %eax,%eax
mov    %eax,-0x20(%rbp)
jmp    11d0 <v4l_format_g_bytesperline+0xd0>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11e2 <v4l_format_g_bytesperline+0xe2>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<v4l_format_g_bytesperline>:
mov    (%rdi),%ecx
xor    %eax,%eax
add    $0xffffff80,%ecx
cmp    $0x5,%ecx
ja     1124 <v4l_format_g_bytesperline+0x24>
mov    $0x5,%edx
bt     %ecx,%edx
jb     1125 <v4l_format_g_bytesperline+0x25>
mov    $0xa,%edx
bt     %ecx,%edx
jae    112f <v4l_format_g_bytesperline+0x2f>
test   %esi,%esi
je     1137 <v4l_format_g_bytesperline+0x37>
ret
mov    0x10(%rdi),%rax
mov    %esi,%ecx
mov    (%rax,%rcx,4),%eax
ret
test   %esi,%esi
jne    1124 <v4l_format_g_bytesperline+0x24>
mov    0x8(%rdi),%eax
ret
mov    0x18(%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_6__ }
%struct.TYPE_9__ = type { i32 }
%struct.TYPE_8__ = type { %struct.TYPE_7__* }
%struct.TYPE_7__ = type { i32 }
%struct.TYPE_6__ = type { i32 }
define i32 @v4l_format_g_bytesperline(%struct.v4l2_format* %0, i32 %1) {
%3 = alloca i32
%4 = alloca %struct.v4l2_format*
%5 = alloca i32
store %struct.v4l2_format* %0, %struct.v4l2_format** %4
store i32 %1, i32* %5
%6 = load %struct.v4l2_format*, %struct.v4l2_format** %4
%7 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %6, i32 0, i32 0
%8 = load i32, i32* %7
switch i32 %8, label %44 [
i32 131, label %9
i32 129, label %9
i32 130, label %21
i32 128, label %21
i32 133, label %32
i32 132, label %32
]
9: ; preds = %2, %2
%10 = load i32, i32* %5
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %9
br label %19
13: ; preds = %9
%14 = load %struct.v4l2_format*, %struct.v4l2_format** %4
%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_6__, %struct.TYPE_6__* %16, i32 0, i32 0
%18 = load i32, i32* %17
br label %19
19: ; preds = %13, %12
%20 = phi i32 [ 0, %12 ], [ %18, %13 ]
store i32 %20, i32* %3
br label %45
21: ; preds = %2, %2
%22 = load %struct.v4l2_format*, %struct.v4l2_format** %4
%23 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %22, i32 0, i32 1
%24 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %23, i32 0, i32 1
%25 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %24, i32 0, i32 0
%26 = load %struct.TYPE_7__*, %struct.TYPE_7__** %25
%27 = load i32, i32* %5
%28 = zext i32 %27 to i64
%29 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %26, i64 %28
%30 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %29, i32 0, i32 0
%31 = load i32, i32* %30
store i32 %31, i32* %3
br label %45
32: ; preds = %2, %2
%33 = load i32, i32* %5
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %32
br label %42
36: ; preds = %32
%37 = load %struct.v4l2_format*, %struct.v4l2_format** %4
%38 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %37, i32 0, i32 1
%39 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %38, i32 0, i32 0
%40 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %39, i32 0, i32 0
%41 = load i32, i32* %40
br label %42
42: ; preds = %36, %35
%43 = phi i32 [ 0, %35 ], [ %41, %36 ]
store i32 %43, i32* %3
br label %45
44: ; preds = %2
store i32 0, i32* %3
br label %45
45: ; preds = %44, %42, %21, %19
%46 = load i32, i32* %3
ret i32 %46
}

LLVM IR (-O2):
%struct.v4l2_format = type { i32, %struct.TYPE_10__ }
%struct.TYPE_10__ = type { %struct.TYPE_9__, %struct.TYPE_8__, %struct.TYPE_6__ }
%struct.TYPE_9__ = type { i32 }
%struct.TYPE_8__ = type { %struct.TYPE_7__* }
%struct.TYPE_7__ = type { i32 }
%struct.TYPE_6__ = type { i32 }
define i32 @v4l_format_g_bytesperline(%struct.v4l2_format* nocapture %0, i32 %1) {
%3 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %0, i64 0, i32 0
%4 = load i32, i32* %3
switch i32 %4, label %21 [
i32 131, label %5
i32 129, label %5
i32 130, label %10
i32 128, label %10
i32 133, label %16
i32 132, label %16
]
5: ; preds = %2, %2
%6 = icmp eq i32 %1, 0
br i1 %6, label %7, label %21
7: ; preds = %5
%8 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %0, i64 0, i32 1, i32 2, i32 0
%9 = load i32, i32* %8
br label %21
10: ; preds = %2, %2
%11 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %0, i64 0, i32 1, i32 1, i32 0
%12 = load %struct.TYPE_7__*, %struct.TYPE_7__** %11
%13 = zext i32 %1 to i64
%14 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %12, i64 %13, i32 0
%15 = load i32, i32* %14
br label %21
16: ; preds = %2, %2
%17 = icmp eq i32 %1, 0
br i1 %17, label %18, label %21
18: ; preds = %16
%19 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %0, i64 0, i32 1, i32 0, i32 0
%20 = load i32, i32* %19
br label %21
21: ; preds = %2, %18, %16, %7, %5, %10
%22 = phi i32 [ %15, %10 ], [ %9, %7 ], [ 0, %5 ], [ %20, %18 ], [ 0, %16 ], [ 0, %2 ]
ret i32 %22
}