#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_14__ TYPE_7__;
typedef struct TYPE_13__ TYPE_6__;
typedef struct TYPE_12__ TYPE_5__;
typedef struct TYPE_11__ TYPE_4__;
typedef struct TYPE_10__ TYPE_3__;
typedef struct TYPE_9__ TYPE_2__;
typedef struct TYPE_8__ TYPE_1__;

/* Type definitions */
struct TYPE_11__ {
  int buffersize;
};
struct TYPE_10__ {
  int io_size;
};
struct TYPE_9__ {
  int samples_per_line;
  int *count;
};
struct TYPE_8__ {
  TYPE_7__ *plane_fmt;
};
struct TYPE_12__ {
  int sizeimage;
};
struct TYPE_13__ {
  TYPE_4__ sdr;
  TYPE_3__ sliced;
  TYPE_2__ vbi;
  TYPE_1__ pix_mp;
  TYPE_5__ pix;
};
struct v4l2_format {
  int type;
  TYPE_6__ fmt;
};
typedef int __u32;
struct TYPE_14__ {
  int sizeimage;
};

/* Variables and functions */
#define V4L2_BUF_TYPE_SDR_CAPTURE 136
#define V4L2_BUF_TYPE_SLICED_VBI_CAPTURE 135
#define V4L2_BUF_TYPE_SLICED_VBI_OUTPUT 134
#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_sizeimage(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.sizeimage;
  case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
  case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
    return fmt->fmt.pix_mp.plane_fmt[plane].sizeimage;
  case V4L2_BUF_TYPE_VBI_CAPTURE:
  case V4L2_BUF_TYPE_VBI_OUTPUT:
    return plane ? 0
                 : fmt->fmt.vbi.samples_per_line *
                       (fmt->fmt.vbi.count[0] + fmt->fmt.vbi.count[1]);
  case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
  case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT:
    return plane ? 0 : fmt->fmt.sliced.io_size;
  case V4L2_BUF_TYPE_SDR_CAPTURE:
    return plane ? 0 : fmt->fmt.sdr.buffersize;
  default:
    return 0;
  }
}


x86 assembly (clang, -O0):
<v4l_format_g_sizeimage>:
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    $0x8,%eax
ja     1209 <v4l_format_g_sizeimage+0x109>
mov    -0x20(%rbp),%rax
lea    0xed2(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
cmpl   $0x0,-0x14(%rbp)
je     114b <v4l_format_g_sizeimage+0x4b>
xor    %eax,%eax
mov    %eax,-0x24(%rbp)
jmp    1155 <v4l_format_g_sizeimage+0x55>
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1210 <v4l_format_g_sizeimage+0x110>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
mov    -0x14(%rbp),%ecx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x4(%rbp)
jmp    1210 <v4l_format_g_sizeimage+0x110>
cmpl   $0x0,-0x14(%rbp)
je     118a <v4l_format_g_sizeimage+0x8a>
xor    %eax,%eax
mov    %eax,-0x28(%rbp)
jmp    11ac <v4l_format_g_sizeimage+0xac>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%eax
mov    -0x10(%rbp),%rcx
mov    0x18(%rcx),%rcx
mov    (%rcx),%ecx
mov    -0x10(%rbp),%rdx
mov    0x18(%rdx),%rdx
add    0x4(%rdx),%ecx
imul   %ecx,%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1210 <v4l_format_g_sizeimage+0x110>
cmpl   $0x0,-0x14(%rbp)
je     11cb <v4l_format_g_sizeimage+0xcb>
xor    %eax,%eax
mov    %eax,-0x2c(%rbp)
jmp    11d5 <v4l_format_g_sizeimage+0xd5>
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1210 <v4l_format_g_sizeimage+0x110>
cmpl   $0x0,-0x14(%rbp)
je     11f4 <v4l_format_g_sizeimage+0xf4>
xor    %eax,%eax
mov    %eax,-0x30(%rbp)
jmp    11fe <v4l_format_g_sizeimage+0xfe>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1210 <v4l_format_g_sizeimage+0x110>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<v4l_format_g_sizeimage>:
mov    (%rdi),%ecx
xor    %eax,%eax
add    $0xffffff80,%ecx
cmp    $0x8,%ecx
ja     112a <v4l_format_g_sizeimage+0x2a>
lea    0xeed(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
mov    0x20(%rdi),%rax
mov    %esi,%ecx
mov    (%rax,%rcx,4),%eax
ret
test   %esi,%esi
je     114d <v4l_format_g_sizeimage+0x4d>
ret
test   %esi,%esi
jne    112a <v4l_format_g_sizeimage+0x2a>
mov    0x18(%rdi),%rcx
mov    0x4(%rcx),%eax
add    (%rcx),%eax
imul   0x10(%rdi),%eax
ret
test   %esi,%esi
jne    112a <v4l_format_g_sizeimage+0x2a>
mov    0xc(%rdi),%eax
ret
test   %esi,%esi
jne    112a <v4l_format_g_sizeimage+0x2a>
mov    0x8(%rdi),%eax
ret
mov    0x28(%rdi),%eax
ret

LLVM IR (-O0):
%struct.v4l2_format = type { i32, %struct.TYPE_13__ }
%struct.TYPE_13__ = type { %struct.TYPE_11__, %struct.TYPE_10__, %struct.TYPE_9__, %struct.TYPE_8__, %struct.TYPE_12__ }
%struct.TYPE_11__ = type { i32 }
%struct.TYPE_10__ = type { i32 }
%struct.TYPE_9__ = type { i32, i32* }
%struct.TYPE_8__ = type { %struct.TYPE_14__* }
%struct.TYPE_14__ = type { i32 }
%struct.TYPE_12__ = type { i32 }
define i32 @v4l_format_g_sizeimage(%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 %84 [
i32 131, label %9
i32 129, label %9
i32 130, label %21
i32 128, label %21
i32 133, label %32
i32 132, label %32
i32 135, label %60
i32 134, label %60
i32 136, label %72
]
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_13__, %struct.TYPE_13__* %15, i32 0, i32 4
%17 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %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 %85
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_13__, %struct.TYPE_13__* %23, i32 0, i32 3
%25 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %24, i32 0, i32 0
%26 = load %struct.TYPE_14__*, %struct.TYPE_14__** %25
%27 = load i32, i32* %5
%28 = zext i32 %27 to i64
%29 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %26, i64 %28
%30 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %29, i32 0, i32 0
%31 = load i32, i32* %30
store i32 %31, i32* %3
br label %85
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 %58
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_13__, %struct.TYPE_13__* %38, i32 0, i32 2
%40 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %39, i32 0, i32 0
%41 = load i32, i32* %40
%42 = load %struct.v4l2_format*, %struct.v4l2_format** %4
%43 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %42, i32 0, i32 1
%44 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %43, i32 0, i32 2
%45 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %44, i32 0, i32 1
%46 = load i32*, i32** %45
%47 = getelementptr inbounds i32, i32* %46, i64 0
%48 = load i32, i32* %47
%49 = load %struct.v4l2_format*, %struct.v4l2_format** %4
%50 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %49, i32 0, i32 1
%51 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %50, i32 0, i32 2
%52 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %51, i32 0, i32 1
%53 = load i32*, i32** %52
%54 = getelementptr inbounds i32, i32* %53, i64 1
%55 = load i32, i32* %54
%56 = add nsw i32 %48, %55
%57 = mul nsw i32 %41, %56
br label %58
58: ; preds = %36, %35
%59 = phi i32 [ 0, %35 ], [ %57, %36 ]
store i32 %59, i32* %3
br label %85
60: ; preds = %2, %2
%61 = load i32, i32* %5
%62 = icmp ne i32 %61, 0
br i1 %62, label %63, label %64
63: ; preds = %60
br label %70
64: ; preds = %60
%65 = load %struct.v4l2_format*, %struct.v4l2_format** %4
%66 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %65, i32 0, i32 1
%67 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %66, i32 0, i32 1
%68 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %67, i32 0, i32 0
%69 = load i32, i32* %68
br label %70
70: ; preds = %64, %63
%71 = phi i32 [ 0, %63 ], [ %69, %64 ]
store i32 %71, i32* %3
br label %85
72: ; preds = %2
%73 = load i32, i32* %5
%74 = icmp ne i32 %73, 0
br i1 %74, label %75, label %76
75: ; preds = %72
br label %82
76: ; preds = %72
%77 = load %struct.v4l2_format*, %struct.v4l2_format** %4
%78 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %77, i32 0, i32 1
%79 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %78, i32 0, i32 0
%80 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %79, i32 0, i32 0
%81 = load i32, i32* %80
br label %82
82: ; preds = %76, %75
%83 = phi i32 [ 0, %75 ], [ %81, %76 ]
store i32 %83, i32* %3
br label %85
84: ; preds = %2
store i32 0, i32* %3
br label %85
85: ; preds = %84, %82, %70, %58, %21, %19
%86 = load i32, i32* %3
ret i32 %86
}

LLVM IR (-O2):
%struct.v4l2_format = type { i32, %struct.TYPE_13__ }
%struct.TYPE_13__ = type { %struct.TYPE_11__, %struct.TYPE_10__, %struct.TYPE_9__, %struct.TYPE_8__, %struct.TYPE_12__ }
%struct.TYPE_11__ = type { i32 }
%struct.TYPE_10__ = type { i32 }
%struct.TYPE_9__ = type { i32, i32* }
%struct.TYPE_8__ = type { %struct.TYPE_14__* }
%struct.TYPE_14__ = type { i32 }
%struct.TYPE_12__ = type { i32 }
define i32 @v4l_format_g_sizeimage(%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 %38 [
i32 131, label %5
i32 129, label %5
i32 130, label %10
i32 128, label %10
i32 133, label %16
i32 132, label %16
i32 135, label %28
i32 134, label %28
i32 136, label %33
]
5: ; preds = %2, %2
%6 = icmp eq i32 %1, 0
br i1 %6, label %7, label %38
7: ; preds = %5
%8 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %0, i64 0, i32 1, i32 4, i32 0
%9 = load i32, i32* %8
br label %38
10: ; preds = %2, %2
%11 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %0, i64 0, i32 1, i32 3, i32 0
%12 = load %struct.TYPE_14__*, %struct.TYPE_14__** %11
%13 = zext i32 %1 to i64
%14 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %12, i64 %13, i32 0
%15 = load i32, i32* %14
br label %38
16: ; preds = %2, %2
%17 = icmp eq i32 %1, 0
br i1 %17, label %18, label %38
18: ; preds = %16
%19 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %0, i64 0, i32 1, i32 2, i32 0
%20 = load i32, i32* %19
%21 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %0, i64 0, i32 1, i32 2, i32 1
%22 = load i32*, i32** %21
%23 = load i32, i32* %22
%24 = getelementptr inbounds i32, i32* %22, i64 1
%25 = load i32, i32* %24
%26 = add nsw i32 %25, %23
%27 = mul nsw i32 %26, %20
br label %38
28: ; preds = %2, %2
%29 = icmp eq i32 %1, 0
br i1 %29, label %30, label %38
30: ; preds = %28
%31 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %0, i64 0, i32 1, i32 1, i32 0
%32 = load i32, i32* %31
br label %38
33: ; preds = %2
%34 = icmp eq i32 %1, 0
br i1 %34, label %35, label %38
35: ; preds = %33
%36 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %0, i64 0, i32 1, i32 0, i32 0
%37 = load i32, i32* %36
br label %38
38: ; preds = %2, %35, %33, %30, %28, %18, %16, %7, %5, %10
%39 = phi i32 [ %15, %10 ], [ %9, %7 ], [ 0, %5 ], [ %27, %18 ], [ 0, %16 ], [ %32, %30 ], [ 0, %28 ], [ %37, %35 ], [ 0, %33 ], [ 0, %2 ]
ret i32 %39
}