#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__ {
  void *sample_format;
};
struct TYPE_8__ {
  void *pixelformat;
};
struct TYPE_7__ {
  void *pixelformat;
};
struct TYPE_6__ {
  void *pixelformat;
};
struct TYPE_10__ {
  TYPE_4__ vbi;
  TYPE_3__ sdr;
  TYPE_2__ pix_mp;
  TYPE_1__ pix;
};
struct v4l2_format {
  int type;
  TYPE_5__ fmt;
};
typedef void *__u32;

/* Variables and functions */
#define V4L2_BUF_TYPE_SDR_CAPTURE 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
void v4l_format_s_pixelformat(struct v4l2_format *fmt, __u32 pixelformat) {
  switch (fmt->type) {
  case V4L2_BUF_TYPE_VIDEO_CAPTURE:
  case V4L2_BUF_TYPE_VIDEO_OUTPUT:
    fmt->fmt.pix.pixelformat = pixelformat;
    break;
  case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
  case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
    fmt->fmt.pix_mp.pixelformat = pixelformat;
    break;
  case V4L2_BUF_TYPE_SDR_CAPTURE:
    fmt->fmt.sdr.pixelformat = pixelformat;
    break;
  case V4L2_BUF_TYPE_VBI_CAPTURE:
  case V4L2_BUF_TYPE_VBI_OUTPUT:
    fmt->fmt.vbi.sample_format = pixelformat;
    break;
  }
}


x86 assembly (clang, -O0):
<v4l_format_s_pixelformat>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x6,%eax
ja     1177 <v4l_format_s_pixelformat+0x77>
mov    -0x18(%rbp),%rax
lea    0xed1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x20(%rax)
jmp    1177 <v4l_format_s_pixelformat+0x77>
mov    -0x10(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x18(%rax)
jmp    1177 <v4l_format_s_pixelformat+0x77>
mov    -0x10(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x10(%rax)
jmp    1177 <v4l_format_s_pixelformat+0x77>
mov    -0x10(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x8(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<v4l_format_s_pixelformat>:
mov    (%rdi),%eax
add    $0xffffff80,%eax
cmp    $0x6,%eax
ja     1133 <v4l_format_s_pixelformat+0x33>
lea    0xeef(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
add    $0x18,%rdi
jmp    1130 <v4l_format_s_pixelformat+0x30>
add    $0x20,%rdi
jmp    1130 <v4l_format_s_pixelformat+0x30>
add    $0x8,%rdi
jmp    1130 <v4l_format_s_pixelformat+0x30>
add    $0x10,%rdi
mov    %rsi,(%rdi)
ret

LLVM IR (-O0):
%struct.v4l2_format = type { i32, %struct.TYPE_10__ }
%struct.TYPE_10__ = type { %struct.TYPE_9__, %struct.TYPE_8__, %struct.TYPE_7__, %struct.TYPE_6__ }
%struct.TYPE_9__ = type { i8* }
%struct.TYPE_8__ = type { i8* }
%struct.TYPE_7__ = type { i8* }
%struct.TYPE_6__ = type { i8* }
define void @v4l_format_s_pixelformat(%struct.v4l2_format* %0, i8* %1) {
%3 = alloca %struct.v4l2_format*
%4 = alloca i8*
store %struct.v4l2_format* %0, %struct.v4l2_format** %3
store i8* %1, i8** %4
%5 = load %struct.v4l2_format*, %struct.v4l2_format** %3
%6 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %5, i32 0, i32 0
%7 = load i32, i32* %6
switch i32 %7, label %32 [
i32 131, label %8
i32 129, label %8
i32 130, label %14
i32 128, label %14
i32 134, label %20
i32 133, label %26
i32 132, label %26
]
8: ; preds = %2, %2
%9 = load i8*, i8** %4
%10 = load %struct.v4l2_format*, %struct.v4l2_format** %3
%11 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %10, i32 0, i32 1
%12 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %11, i32 0, i32 3
%13 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %12, i32 0, i32 0
store i8* %9, i8** %13
br label %32
14: ; preds = %2, %2
%15 = load i8*, i8** %4
%16 = load %struct.v4l2_format*, %struct.v4l2_format** %3
%17 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %16, i32 0, i32 1
%18 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %17, i32 0, i32 2
%19 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %18, i32 0, i32 0
store i8* %15, i8** %19
br label %32
20: ; preds = %2
%21 = load i8*, i8** %4
%22 = load %struct.v4l2_format*, %struct.v4l2_format** %3
%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
store i8* %21, i8** %25
br label %32
26: ; preds = %2, %2
%27 = load i8*, i8** %4
%28 = load %struct.v4l2_format*, %struct.v4l2_format** %3
%29 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %28, i32 0, i32 1
%30 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %29, i32 0, i32 0
%31 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %30, i32 0, i32 0
store i8* %27, i8** %31
br label %32
32: ; preds = %2, %26, %20, %14, %8
ret void
}

LLVM IR (-O2):
%struct.v4l2_format = type { i32, %struct.TYPE_10__ }
%struct.TYPE_10__ = type { %struct.TYPE_9__, %struct.TYPE_8__, %struct.TYPE_7__, %struct.TYPE_6__ }
%struct.TYPE_9__ = type { i8* }
%struct.TYPE_8__ = type { i8* }
%struct.TYPE_7__ = type { i8* }
%struct.TYPE_6__ = type { i8* }
define void @v4l_format_s_pixelformat(%struct.v4l2_format* nocapture %0, i8* %1) {
%3 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %0, i64 0, i32 0
%4 = load i32, i32* %3
switch i32 %4, label %15 [
i32 131, label %5
i32 129, label %5
i32 130, label %7
i32 128, label %7
i32 134, label %9
i32 133, label %11
i32 132, label %11
]
5: ; preds = %2, %2
%6 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %0, i64 0, i32 1, i32 3, i32 0
br label %13
7: ; preds = %2, %2
%8 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %0, i64 0, i32 1, i32 2, i32 0
br label %13
9: ; preds = %2
%10 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %0, i64 0, i32 1, i32 1, i32 0
br label %13
11: ; preds = %2, %2
%12 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %0, i64 0, i32 1, i32 0, i32 0
br label %13
13: ; preds = %5, %7, %9, %11
%14 = phi i8** [ %12, %11 ], [ %10, %9 ], [ %8, %7 ], [ %6, %5 ]
store i8* %1, i8** %14
br label %15
15: ; preds = %13, %2
ret void
}