#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__ {
  void *sizeimage;
};
struct TYPE_8__ {
  TYPE_3__ pix_mp;
  TYPE_1__ pix;
};
struct v4l2_format {
  int type;
  TYPE_4__ fmt;
};
typedef void *__u32;
struct TYPE_6__ {
  void *sizeimage;
};

/* 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
void v4l_format_s_sizeimage(struct v4l2_format *fmt, unsigned plane,
                            __u32 sizeimage) {
  switch (fmt->type) {
  case V4L2_BUF_TYPE_VIDEO_CAPTURE:
  case V4L2_BUF_TYPE_VIDEO_OUTPUT:
    if (plane == 0)
      fmt->fmt.pix.sizeimage = sizeimage;
    break;
  case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
  case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
    fmt->fmt.pix_mp.plane_fmt[plane].sizeimage = sizeimage;
    break;
  }
}


x86 assembly (clang, -O0):
<v4l_format_s_sizeimage>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x3,%eax
ja     1169 <v4l_format_s_sizeimage+0x69>
mov    -0x20(%rbp),%rax
lea    0xece(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
cmpl   $0x0,-0xc(%rbp)
jne    1151 <v4l_format_s_sizeimage+0x51>
mov    -0x18(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x10(%rax)
jmp    1169 <v4l_format_s_sizeimage+0x69>
mov    -0x18(%rbp),%rdx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0xc(%rbp),%ecx
mov    %rdx,(%rax,%rcx,8)
pop    %rbp
ret

x86 assembly (clang, -O2):
<v4l_format_s_sizeimage>:
mov    (%rdi),%eax
add    $0xffffff80,%eax
cmp    $0x3,%eax
ja     112d <v4l_format_s_sizeimage+0x2d>
lea    0xeef(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    %esi,%eax
shl    $0x3,%rax
add    0x8(%rdi),%rax
mov    %rax,%rdi
jmp    1132 <v4l_format_s_sizeimage+0x32>
test   %esi,%esi
je     112e <v4l_format_s_sizeimage+0x2e>
ret
add    $0x10,%rdi
mov    %rdx,(%rdi)
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 { i8* }
%struct.TYPE_5__ = type { i8* }
define void @v4l_format_s_sizeimage(%struct.v4l2_format* %0, i32 %1, i8* %2) {
%4 = alloca %struct.v4l2_format*
%5 = alloca i32
%6 = alloca i8*
store %struct.v4l2_format* %0, %struct.v4l2_format** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%7 = load %struct.v4l2_format*, %struct.v4l2_format** %4
%8 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %7, i32 0, i32 0
%9 = load i32, i32* %8
switch i32 %9, label %31 [
i32 131, label %10
i32 129, label %10
i32 130, label %20
i32 128, label %20
]
10: ; preds = %3, %3
%11 = load i32, i32* %5
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %19
13: ; preds = %10
%14 = load i8*, i8** %6
%15 = load %struct.v4l2_format*, %struct.v4l2_format** %4
%16 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %15, i32 0, i32 1
%17 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %16, i32 0, i32 1
%18 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %17, i32 0, i32 0
store i8* %14, i8** %18
br label %19
19: ; preds = %13, %10
br label %31
20: ; preds = %3, %3
%21 = load i8*, i8** %6
%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_8__, %struct.TYPE_8__* %23, i32 0, i32 0
%25 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %24, i32 0, i32 0
%26 = load %struct.TYPE_6__*, %struct.TYPE_6__** %25
%27 = load i32, i32* %5
%28 = zext i32 %27 to i64
%29 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %26, i64 %28
%30 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %29, i32 0, i32 0
store i8* %21, i8** %30
br label %31
31: ; preds = %3, %20, %19
ret void
}

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 { i8* }
%struct.TYPE_5__ = type { i8* }
define void @v4l_format_s_sizeimage(%struct.v4l2_format* nocapture %0, i32 %1, i8* %2) {
%4 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %0, i64 0, i32 0
%5 = load i32, i32* %4
switch i32 %5, label %17 [
i32 131, label %6
i32 129, label %6
i32 130, label %10
i32 128, label %10
]
6: ; preds = %3, %3
%7 = icmp eq i32 %1, 0
br i1 %7, label %8, label %17
8: ; preds = %6
%9 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %0, i64 0, i32 1, i32 1, i32 0
br label %15
10: ; preds = %3, %3
%11 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %0, i64 0, i32 1, i32 0, i32 0
%12 = load %struct.TYPE_6__*, %struct.TYPE_6__** %11
%13 = zext i32 %1 to i64
%14 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %12, i64 %13, i32 0
br label %15
15: ; preds = %10, %8
%16 = phi i8** [ %9, %8 ], [ %14, %10 ]
store i8* %2, i8** %16
br label %17
17: ; preds = %15, %6, %3
ret void
}