#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_6__ TYPE_3__;
typedef struct TYPE_5__ TYPE_2__;
typedef struct TYPE_4__ TYPE_1__;

/* Type definitions */
struct TYPE_5__ {
  unsigned int colorspace;
};
struct TYPE_4__ {
  unsigned int colorspace;
};
struct TYPE_6__ {
  TYPE_2__ pix_mp;
  TYPE_1__ pix;
};
struct v4l2_format {
  int type;
  TYPE_3__ fmt;
};

/* 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_pix_colorspace(struct v4l2_format *fmt, unsigned colorspace) {
  switch (fmt->type) {
  case V4L2_BUF_TYPE_VIDEO_CAPTURE:
  case V4L2_BUF_TYPE_VIDEO_OUTPUT:
    fmt->fmt.pix.colorspace = colorspace;
    break;
  case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
  case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
    fmt->fmt.pix_mp.colorspace = colorspace;
    break;
  }
}


x86 assembly (clang, -O0):
<v4l_format_s_pix_colorspace>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x3,%eax
ja     1150 <v4l_format_s_pix_colorspace+0x50>
mov    -0x18(%rbp),%rax
lea    0xed2(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x8(%rax)
jmp    1150 <v4l_format_s_pix_colorspace+0x50>
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x4(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<v4l_format_s_pix_colorspace>:
mov    (%rdi),%eax
add    $0xffffff80,%eax
cmp    $0x3,%eax
ja     1126 <v4l_format_s_pix_colorspace+0x26>
lea    0xeef(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
add    $0x4,%rdi
jmp    1124 <v4l_format_s_pix_colorspace+0x24>
add    $0x8,%rdi
mov    %esi,(%rdi)
ret

LLVM IR (-O0):
%struct.v4l2_format = type { i32, %struct.TYPE_6__ }
%struct.TYPE_6__ = type { %struct.TYPE_5__, %struct.TYPE_4__ }
%struct.TYPE_5__ = type { i32 }
%struct.TYPE_4__ = type { i32 }
define void @v4l_format_s_pix_colorspace(%struct.v4l2_format* %0, i32 %1) {
%3 = alloca %struct.v4l2_format*
%4 = alloca i32
store %struct.v4l2_format* %0, %struct.v4l2_format** %3
store i32 %1, i32* %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 %20 [
i32 131, label %8
i32 129, label %8
i32 130, label %14
i32 128, label %14
]
8: ; preds = %2, %2
%9 = load i32, i32* %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_6__, %struct.TYPE_6__* %11, i32 0, i32 1
%13 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %12, i32 0, i32 0
store i32 %9, i32* %13
br label %20
14: ; preds = %2, %2
%15 = load i32, i32* %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_6__, %struct.TYPE_6__* %17, i32 0, i32 0
%19 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %18, i32 0, i32 0
store i32 %15, i32* %19
br label %20
20: ; preds = %2, %14, %8
ret void
}

LLVM IR (-O2):
%struct.v4l2_format = type { i32, %struct.TYPE_6__ }
%struct.TYPE_6__ = type { %struct.TYPE_5__, %struct.TYPE_4__ }
%struct.TYPE_5__ = type { i32 }
%struct.TYPE_4__ = type { i32 }
define void @v4l_format_s_pix_colorspace(%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 %11 [
i32 131, label %5
i32 129, label %5
i32 130, label %7
i32 128, label %7
]
5: ; preds = %2, %2
%6 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %0, i64 0, i32 1, i32 1, i32 0
br label %9
7: ; preds = %2, %2
%8 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %0, i64 0, i32 1, i32 0, i32 0
br label %9
9: ; preds = %5, %7
%10 = phi i32* [ %8, %7 ], [ %6, %5 ]
store i32 %1, i32* %10
br label %11
11: ; preds = %9, %2
ret void
}