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

/* 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
__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 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;
  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
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x3,%eax
ja     115c <v4l_format_g_bytesperline+0x5c>
mov    -0x20(%rbp),%rax
lea    0xed2(%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    1163 <v4l_format_g_bytesperline+0x63>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x14(%rbp),%ecx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x4(%rbp)
jmp    1163 <v4l_format_g_bytesperline+0x63>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

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

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

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