#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_4__ TYPE_2__;
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  int num_planes;
};
struct TYPE_4__ {
  TYPE_1__ pix_mp;
};
struct v4l2_format {
  int type;
  TYPE_2__ fmt;
};
typedef int __u8;

/* Variables and functions */
#define V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE 129
#define V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE 128
__u8 v4l_format_g_num_planes(const struct v4l2_format *fmt) {
  switch (fmt->type) {
  case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
  case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
    return fmt->fmt.pix_mp.num_planes;
  default:
    return 1;
  }
}


x86 assembly (clang, -O0):
<v4l_format_g_num_planes>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
add    $0xffffff80,%eax
sub    $0x1,%eax
ja     112e <v4l_format_g_num_planes+0x2e>
jmp    111f <v4l_format_g_num_planes+0x1f>
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1135 <v4l_format_g_num_planes+0x35>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<v4l_format_g_num_planes>:
mov    (%rdi),%ecx
and    $0xfffffffe,%ecx
mov    $0x1,%eax
cmp    $0x80,%ecx
jne    1115 <v4l_format_g_num_planes+0x15>
mov    0x4(%rdi),%eax
ret

LLVM IR (-O0):
%struct.v4l2_format = type { i32, %struct.TYPE_4__ }
%struct.TYPE_4__ = type { %struct.TYPE_3__ }
%struct.TYPE_3__ = type { i32 }
define i32 @v4l_format_g_num_planes(%struct.v4l2_format* %0) {
%2 = alloca i32
%3 = alloca %struct.v4l2_format*
store %struct.v4l2_format* %0, %struct.v4l2_format** %3
%4 = load %struct.v4l2_format*, %struct.v4l2_format** %3
%5 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %4, i32 0, i32 0
%6 = load i32, i32* %5
switch i32 %6, label %13 [
i32 129, label %7
i32 128, label %7
]
7: ; preds = %1, %1
%8 = load %struct.v4l2_format*, %struct.v4l2_format** %3
%9 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %8, i32 0, i32 1
%10 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %9, i32 0, i32 0
%11 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %10, i32 0, i32 0
%12 = load i32, i32* %11
store i32 %12, i32* %2
br label %14
13: ; preds = %1
store i32 1, i32* %2
br label %14
14: ; preds = %13, %7
%15 = load i32, i32* %2
ret i32 %15
}

LLVM IR (-O2):
%struct.v4l2_format = type { i32, %struct.TYPE_4__ }
%struct.TYPE_4__ = type { %struct.TYPE_3__ }
%struct.TYPE_3__ = type { i32 }
define i32 @v4l_format_g_num_planes(%struct.v4l2_format* nocapture %0) {
%2 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %0, i64 0, i32 0
%3 = load i32, i32* %2
%4 = and i32 %3, -2
%5 = icmp eq i32 %4, 128
br i1 %5, label %6, label %9
6: ; preds = %1
%7 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %0, i64 0, i32 1, i32 0, i32 0
%8 = load i32, i32* %7
br label %9
9: ; preds = %1, %6
%10 = phi i32 [ %8, %6 ], [ 1, %1 ]
ret i32 %10
}