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

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

/* Variables and functions */
#define V4L2_BUF_TYPE_META_CAPTURE 139
#define V4L2_BUF_TYPE_META_OUTPUT 138
#define V4L2_BUF_TYPE_SDR_CAPTURE 137
#define V4L2_BUF_TYPE_SDR_OUTPUT 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:
  case V4L2_BUF_TYPE_SDR_OUTPUT:
    return plane ? 0 : fmt->fmt.sdr.buffersize;
  case V4L2_BUF_TYPE_META_CAPTURE:
  case V4L2_BUF_TYPE_META_OUTPUT:
    return plane ? 0 : fmt->fmt.meta.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    $0xb,%eax
ja     1232 <v4l_format_g_sizeimage+0x132>
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    0x30(%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1239 <v4l_format_g_sizeimage+0x139>
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rax
mov    -0x14(%rbp),%ecx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x4(%rbp)
jmp    1239 <v4l_format_g_sizeimage+0x139>
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    0x18(%rax),%eax
mov    -0x10(%rbp),%rcx
mov    0x20(%rcx),%rcx
mov    (%rcx),%ecx
mov    -0x10(%rbp),%rdx
mov    0x20(%rdx),%rdx
add    0x4(%rdx),%ecx
imul   %ecx,%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1239 <v4l_format_g_sizeimage+0x139>
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    0x10(%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1239 <v4l_format_g_sizeimage+0x139>
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    0xc(%rax),%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1239 <v4l_format_g_sizeimage+0x139>
cmpl   $0x0,-0x14(%rbp)
je     121d <v4l_format_g_sizeimage+0x11d>
xor    %eax,%eax
mov    %eax,-0x34(%rbp)
jmp    1227 <v4l_format_g_sizeimage+0x127>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1239 <v4l_format_g_sizeimage+0x139>
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    $0xb,%ecx
ja     112a <v4l_format_g_sizeimage+0x2a>
lea    0xeed(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
mov    0x28(%rdi),%rax
mov    %esi,%ecx
mov    (%rax,%rcx,4),%eax
ret
test   %esi,%esi
je     1155 <v4l_format_g_sizeimage+0x55>
ret
test   %esi,%esi
jne    112a <v4l_format_g_sizeimage+0x2a>
mov    0x20(%rdi),%rcx
mov    0x4(%rcx),%eax
add    (%rcx),%eax
imul   0x18(%rdi),%eax
ret
test   %esi,%esi
jne    112a <v4l_format_g_sizeimage+0x2a>
mov    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    0x30(%rdi),%eax
ret

LLVM IR (-O0):
%struct.v4l2_format = type { i32, %struct.TYPE_16__ }
%struct.TYPE_16__ = type { %struct.TYPE_15__, %struct.TYPE_14__, %struct.TYPE_13__, %struct.TYPE_12__, %struct.TYPE_11__, %struct.TYPE_9__ }
%struct.TYPE_15__ = type { i32 }
%struct.TYPE_14__ = type { i32 }
%struct.TYPE_13__ = type { i32 }
%struct.TYPE_12__ = type { i32, i32* }
%struct.TYPE_11__ = type { %struct.TYPE_10__* }
%struct.TYPE_10__ = type { i32 }
%struct.TYPE_9__ = 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 %96 [
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 137, label %72
i32 136, label %72
i32 139, label %84
i32 138, label %84
]
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_16__, %struct.TYPE_16__* %15, i32 0, i32 5
%17 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %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 %97
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_16__, %struct.TYPE_16__* %23, i32 0, i32 4
%25 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %24, i32 0, i32 0
%26 = load %struct.TYPE_10__*, %struct.TYPE_10__** %25
%27 = load i32, i32* %5
%28 = zext i32 %27 to i64
%29 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %26, i64 %28
%30 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %29, i32 0, i32 0
%31 = load i32, i32* %30
store i32 %31, i32* %3
br label %97
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_16__, %struct.TYPE_16__* %38, i32 0, i32 3
%40 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %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_16__, %struct.TYPE_16__* %43, i32 0, i32 3
%45 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %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_16__, %struct.TYPE_16__* %50, i32 0, i32 3
%52 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %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 %97
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_16__, %struct.TYPE_16__* %66, i32 0, i32 2
%68 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %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 %97
72: ; preds = %2, %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_16__, %struct.TYPE_16__* %78, i32 0, i32 1
%80 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %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 %97
84: ; preds = %2, %2
%85 = load i32, i32* %5
%86 = icmp ne i32 %85, 0
br i1 %86, label %87, label %88
87: ; preds = %84
br label %94
88: ; preds = %84
%89 = load %struct.v4l2_format*, %struct.v4l2_format** %4
%90 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %89, i32 0, i32 1
%91 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %90, i32 0, i32 0
%92 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %91, i32 0, i32 0
%93 = load i32, i32* %92
br label %94
94: ; preds = %88, %87
%95 = phi i32 [ 0, %87 ], [ %93, %88 ]
store i32 %95, i32* %3
br label %97
96: ; preds = %2
store i32 0, i32* %3
br label %97
97: ; preds = %96, %94, %82, %70, %58, %21, %19
%98 = load i32, i32* %3
ret i32 %98
}

LLVM IR (-O2):
%struct.v4l2_format = type { i32, %struct.TYPE_16__ }
%struct.TYPE_16__ = type { %struct.TYPE_15__, %struct.TYPE_14__, %struct.TYPE_13__, %struct.TYPE_12__, %struct.TYPE_11__, %struct.TYPE_9__ }
%struct.TYPE_15__ = type { i32 }
%struct.TYPE_14__ = type { i32 }
%struct.TYPE_13__ = type { i32 }
%struct.TYPE_12__ = type { i32, i32* }
%struct.TYPE_11__ = type { %struct.TYPE_10__* }
%struct.TYPE_10__ = type { i32 }
%struct.TYPE_9__ = 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 %43 [
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 137, label %33
i32 136, label %33
i32 139, label %38
i32 138, label %38
]
5: ; preds = %2, %2
%6 = icmp eq i32 %1, 0
br i1 %6, label %7, label %43
7: ; preds = %5
%8 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %0, i64 0, i32 1, i32 5, i32 0
%9 = load i32, i32* %8
br label %43
10: ; preds = %2, %2
%11 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %0, i64 0, i32 1, i32 4, i32 0
%12 = load %struct.TYPE_10__*, %struct.TYPE_10__** %11
%13 = zext i32 %1 to i64
%14 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %12, i64 %13, i32 0
%15 = load i32, i32* %14
br label %43
16: ; preds = %2, %2
%17 = icmp eq i32 %1, 0
br i1 %17, label %18, label %43
18: ; preds = %16
%19 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %0, i64 0, i32 1, i32 3, i32 0
%20 = load i32, i32* %19
%21 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %0, i64 0, i32 1, i32 3, 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 %43
28: ; preds = %2, %2
%29 = icmp eq i32 %1, 0
br i1 %29, label %30, label %43
30: ; preds = %28
%31 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %0, i64 0, i32 1, i32 2, i32 0
%32 = load i32, i32* %31
br label %43
33: ; preds = %2, %2
%34 = icmp eq i32 %1, 0
br i1 %34, label %35, label %43
35: ; preds = %33
%36 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %0, i64 0, i32 1, i32 1, i32 0
%37 = load i32, i32* %36
br label %43
38: ; preds = %2, %2
%39 = icmp eq i32 %1, 0
br i1 %39, label %40, label %43
40: ; preds = %38
%41 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %0, i64 0, i32 1, i32 0, i32 0
%42 = load i32, i32* %41
br label %43
43: ; preds = %2, %40, %38, %35, %33, %30, %28, %18, %16, %7, %5, %10
%44 = phi i32 [ %15, %10 ], [ %9, %7 ], [ 0, %5 ], [ %27, %18 ], [ 0, %16 ], [ %32, %30 ], [ 0, %28 ], [ %37, %35 ], [ 0, %33 ], [ %42, %40 ], [ 0, %38 ], [ 0, %2 ]
ret i32 %44
}