#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 */

/* Type definitions */
struct v4l_fd {
  int dummy;
};
typedef int /*<<< orphan*/ __u32;

/* Variables and functions */
int /*<<< orphan*/ V4L2_BUF_TYPE_META_CAPTURE;
int /*<<< orphan*/ V4L2_BUF_TYPE_META_OUTPUT;
int /*<<< orphan*/ V4L2_BUF_TYPE_SDR_CAPTURE;
int /*<<< orphan*/ V4L2_BUF_TYPE_SDR_OUTPUT;
int /*<<< orphan*/ V4L2_BUF_TYPE_SLICED_VBI_CAPTURE;
int /*<<< orphan*/ V4L2_BUF_TYPE_SLICED_VBI_OUTPUT;
int /*<<< orphan*/ V4L2_BUF_TYPE_VBI_CAPTURE;
int /*<<< orphan*/ V4L2_BUF_TYPE_VBI_OUTPUT;
int /*<<< orphan*/ V4L2_BUF_TYPE_VIDEO_CAPTURE;
int /*<<< orphan*/ V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
int /*<<< orphan*/ V4L2_BUF_TYPE_VIDEO_OUTPUT;
int /*<<< orphan*/ V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
scalar_t__ v4l_has_meta_cap(struct v4l_fd const *);
scalar_t__ v4l_has_meta_out(struct v4l_fd const *);
scalar_t__ v4l_has_raw_vbi_cap(struct v4l_fd const *);
scalar_t__ v4l_has_raw_vbi_out(struct v4l_fd const *);
scalar_t__ v4l_has_sdr_cap(struct v4l_fd const *);
scalar_t__ v4l_has_sdr_out(struct v4l_fd const *);
scalar_t__ v4l_has_sliced_vbi_cap(struct v4l_fd const *);
scalar_t__ v4l_has_sliced_vbi_out(struct v4l_fd const *);
scalar_t__ v4l_has_vid_cap(struct v4l_fd const *);
scalar_t__ v4l_has_vid_mplane(struct v4l_fd const *);
scalar_t__ v4l_has_vid_out(struct v4l_fd const *);
__u32 v4l_determine_type(const struct v4l_fd *f) {
  if (v4l_has_vid_mplane(f))
    return v4l_has_vid_cap(f) ? V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE
                              : V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
  if (v4l_has_vid_cap(f))
    return V4L2_BUF_TYPE_VIDEO_CAPTURE;
  if (v4l_has_vid_out(f))
    return V4L2_BUF_TYPE_VIDEO_OUTPUT;
  if (v4l_has_raw_vbi_cap(f))
    return V4L2_BUF_TYPE_VBI_CAPTURE;
  if (v4l_has_sliced_vbi_cap(f))
    return V4L2_BUF_TYPE_SLICED_VBI_CAPTURE;
  if (v4l_has_raw_vbi_out(f))
    return V4L2_BUF_TYPE_VBI_OUTPUT;
  if (v4l_has_sliced_vbi_out(f))
    return V4L2_BUF_TYPE_SLICED_VBI_OUTPUT;
  if (v4l_has_sdr_cap(f))
    return V4L2_BUF_TYPE_SDR_CAPTURE;
  if (v4l_has_sdr_out(f))
    return V4L2_BUF_TYPE_SDR_OUTPUT;
  if (v4l_has_meta_cap(f))
    return V4L2_BUF_TYPE_META_CAPTURE;
  if (v4l_has_meta_out(f))
    return V4L2_BUF_TYPE_META_OUTPUT;
  return 0;
}


x86 assembly (clang, -O0):
<v4l_determine_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <v4l_has_vid_mplane@plt>
cmp    $0x0,%rax
je     120a <v4l_determine_type+0x5a>
mov    -0x10(%rbp),%rdi
call   1090 <v4l_has_vid_cap@plt>
cmp    $0x0,%rax
je     11f3 <v4l_determine_type+0x43>
mov    0x2dc7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
jmp    11ff <v4l_determine_type+0x4f>
mov    0x2dfe(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1379 <v4l_determine_type+0x1c9>
mov    -0x10(%rbp),%rdi
call   1090 <v4l_has_vid_cap@plt>
cmp    $0x0,%rax
je     122e <v4l_determine_type+0x7e>
mov    0x2dbc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1379 <v4l_determine_type+0x1c9>
mov    -0x10(%rbp),%rdi
call   10c0 <v4l_has_vid_out@plt>
cmp    $0x0,%rax
je     1252 <v4l_determine_type+0xa2>
mov    0x2d80(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1379 <v4l_determine_type+0x1c9>
mov    -0x10(%rbp),%rdi
call   1060 <v4l_has_raw_vbi_cap@plt>
cmp    $0x0,%rax
je     1276 <v4l_determine_type+0xc6>
mov    0x2d3c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1379 <v4l_determine_type+0x1c9>
mov    -0x10(%rbp),%rdi
call   10a0 <v4l_has_sliced_vbi_cap@plt>
cmp    $0x0,%rax
je     129a <v4l_determine_type+0xea>
mov    0x2cf8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1379 <v4l_determine_type+0x1c9>
mov    -0x10(%rbp),%rdi
call   10d0 <v4l_has_raw_vbi_out@plt>
cmp    $0x0,%rax
je     12be <v4l_determine_type+0x10e>
mov    0x2cdc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1379 <v4l_determine_type+0x1c9>
mov    -0x10(%rbp),%rdi
call   1030 <v4l_has_sliced_vbi_out@plt>
cmp    $0x0,%rax
je     12e2 <v4l_determine_type+0x132>
mov    0x2ce0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1379 <v4l_determine_type+0x1c9>
mov    -0x10(%rbp),%rdi
call   10b0 <v4l_has_sdr_cap@plt>
cmp    $0x0,%rax
je     1306 <v4l_determine_type+0x156>
mov    0x2ca4(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1379 <v4l_determine_type+0x1c9>
mov    -0x10(%rbp),%rdi
call   1080 <v4l_has_sdr_out@plt>
cmp    $0x0,%rax
je     132a <v4l_determine_type+0x17a>
mov    0x2cb8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1379 <v4l_determine_type+0x1c9>
mov    -0x10(%rbp),%rdi
call   1050 <v4l_has_meta_cap@plt>
cmp    $0x0,%rax
je     134e <v4l_determine_type+0x19e>
mov    0x2ca4(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1379 <v4l_determine_type+0x1c9>
mov    -0x10(%rbp),%rdi
call   1070 <v4l_has_meta_out@plt>
cmp    $0x0,%rax
je     1372 <v4l_determine_type+0x1c2>
mov    0x2c58(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1379 <v4l_determine_type+0x1c9>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<v4l_determine_type>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1040 <v4l_has_vid_mplane@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1090 <v4l_has_vid_cap@plt>
test   %rbx,%rbx
je     11dd <v4l_determine_type+0x2d>
test   %rax,%rax
jne    11ee <v4l_determine_type+0x3e>
mov    0x2e20(%rip),%rax
jmp    12cc <v4l_determine_type+0x11c>
test   %rax,%rax
je     11fa <v4l_determine_type+0x4a>
mov    0x2df7(%rip),%rax
jmp    12cc <v4l_determine_type+0x11c>
mov    0x2dbb(%rip),%rax
jmp    12cc <v4l_determine_type+0x11c>
mov    %r14,%rdi
call   10c0 <v4l_has_vid_out@plt>
test   %rax,%rax
je     1213 <v4l_determine_type+0x63>
mov    0x2dba(%rip),%rax
jmp    12cc <v4l_determine_type+0x11c>
mov    %r14,%rdi
call   1060 <v4l_has_raw_vbi_cap@plt>
test   %rax,%rax
je     122c <v4l_determine_type+0x7c>
mov    0x2d81(%rip),%rax
jmp    12cc <v4l_determine_type+0x11c>
mov    %r14,%rdi
call   10a0 <v4l_has_sliced_vbi_cap@plt>
test   %rax,%rax
je     1245 <v4l_determine_type+0x95>
mov    0x2d48(%rip),%rax
jmp    12cc <v4l_determine_type+0x11c>
mov    %r14,%rdi
call   10d0 <v4l_has_raw_vbi_out@plt>
test   %rax,%rax
je     125b <v4l_determine_type+0xab>
mov    0x2d37(%rip),%rax
jmp    12cc <v4l_determine_type+0x11c>
mov    %r14,%rdi
call   1030 <v4l_has_sliced_vbi_out@plt>
test   %rax,%rax
je     1271 <v4l_determine_type+0xc1>
mov    0x2d49(%rip),%rax
jmp    12cc <v4l_determine_type+0x11c>
mov    %r14,%rdi
call   10b0 <v4l_has_sdr_cap@plt>
test   %rax,%rax
je     1287 <v4l_determine_type+0xd7>
mov    0x2d1b(%rip),%rax
jmp    12cc <v4l_determine_type+0x11c>
mov    %r14,%rdi
call   1080 <v4l_has_sdr_out@plt>
test   %rax,%rax
je     129d <v4l_determine_type+0xed>
mov    0x2d3d(%rip),%rax
jmp    12cc <v4l_determine_type+0x11c>
mov    %r14,%rdi
call   1050 <v4l_has_meta_cap@plt>
test   %rax,%rax
je     12b3 <v4l_determine_type+0x103>
mov    0x2d37(%rip),%rax
jmp    12cc <v4l_determine_type+0x11c>
mov    %r14,%rdi
call   1070 <v4l_has_meta_out@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
je     12ce <v4l_determine_type+0x11e>
mov    0x2cf4(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.v4l_fd = type { i32 }
@V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE = global i32 0
@V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE = global i32 0
@V4L2_BUF_TYPE_VIDEO_CAPTURE = global i32 0
@V4L2_BUF_TYPE_VIDEO_OUTPUT = global i32 0
@V4L2_BUF_TYPE_VBI_CAPTURE = global i32 0
@V4L2_BUF_TYPE_SLICED_VBI_CAPTURE = global i32 0
@V4L2_BUF_TYPE_VBI_OUTPUT = global i32 0
@V4L2_BUF_TYPE_SLICED_VBI_OUTPUT = global i32 0
@V4L2_BUF_TYPE_SDR_CAPTURE = global i32 0
@V4L2_BUF_TYPE_SDR_OUTPUT = global i32 0
@V4L2_BUF_TYPE_META_CAPTURE = global i32 0
@V4L2_BUF_TYPE_META_OUTPUT = global i32 0
define i32 @v4l_determine_type(%struct.v4l_fd* %0) {
%2 = alloca i32
%3 = alloca %struct.v4l_fd*
store %struct.v4l_fd* %0, %struct.v4l_fd** %3
%4 = load %struct.v4l_fd*, %struct.v4l_fd** %3
%5 = call i64 @v4l_has_vid_mplane(%struct.v4l_fd* %4)
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %17
7: ; preds = %1
%8 = load %struct.v4l_fd*, %struct.v4l_fd** %3
%9 = call i64 @v4l_has_vid_cap(%struct.v4l_fd* %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = load i32, i32* @V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE
br label %15
13: ; preds = %7
%14 = load i32, i32* @V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE
br label %15
15: ; preds = %13, %11
%16 = phi i32 [ %12, %11 ], [ %14, %13 ]
store i32 %16, i32* %2
br label %78
17: ; preds = %1
%18 = load %struct.v4l_fd*, %struct.v4l_fd** %3
%19 = call i64 @v4l_has_vid_cap(%struct.v4l_fd* %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = load i32, i32* @V4L2_BUF_TYPE_VIDEO_CAPTURE
store i32 %22, i32* %2
br label %78
23: ; preds = %17
%24 = load %struct.v4l_fd*, %struct.v4l_fd** %3
%25 = call i64 @v4l_has_vid_out(%struct.v4l_fd* %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %23
%28 = load i32, i32* @V4L2_BUF_TYPE_VIDEO_OUTPUT
store i32 %28, i32* %2
br label %78
29: ; preds = %23
%30 = load %struct.v4l_fd*, %struct.v4l_fd** %3
%31 = call i64 @v4l_has_raw_vbi_cap(%struct.v4l_fd* %30)
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %29
%34 = load i32, i32* @V4L2_BUF_TYPE_VBI_CAPTURE
store i32 %34, i32* %2
br label %78
35: ; preds = %29
%36 = load %struct.v4l_fd*, %struct.v4l_fd** %3
%37 = call i64 @v4l_has_sliced_vbi_cap(%struct.v4l_fd* %36)
%38 = icmp ne i64 %37, 0
br i1 %38, label %39, label %41
39: ; preds = %35
%40 = load i32, i32* @V4L2_BUF_TYPE_SLICED_VBI_CAPTURE
store i32 %40, i32* %2
br label %78
41: ; preds = %35
%42 = load %struct.v4l_fd*, %struct.v4l_fd** %3
%43 = call i64 @v4l_has_raw_vbi_out(%struct.v4l_fd* %42)
%44 = icmp ne i64 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %41
%46 = load i32, i32* @V4L2_BUF_TYPE_VBI_OUTPUT
store i32 %46, i32* %2
br label %78
47: ; preds = %41
%48 = load %struct.v4l_fd*, %struct.v4l_fd** %3
%49 = call i64 @v4l_has_sliced_vbi_out(%struct.v4l_fd* %48)
%50 = icmp ne i64 %49, 0
br i1 %50, label %51, label %53
51: ; preds = %47
%52 = load i32, i32* @V4L2_BUF_TYPE_SLICED_VBI_OUTPUT
store i32 %52, i32* %2
br label %78
53: ; preds = %47
%54 = load %struct.v4l_fd*, %struct.v4l_fd** %3
%55 = call i64 @v4l_has_sdr_cap(%struct.v4l_fd* %54)
%56 = icmp ne i64 %55, 0
br i1 %56, label %57, label %59
57: ; preds = %53
%58 = load i32, i32* @V4L2_BUF_TYPE_SDR_CAPTURE
store i32 %58, i32* %2
br label %78
59: ; preds = %53
%60 = load %struct.v4l_fd*, %struct.v4l_fd** %3
%61 = call i64 @v4l_has_sdr_out(%struct.v4l_fd* %60)
%62 = icmp ne i64 %61, 0
br i1 %62, label %63, label %65
63: ; preds = %59
%64 = load i32, i32* @V4L2_BUF_TYPE_SDR_OUTPUT
store i32 %64, i32* %2
br label %78
65: ; preds = %59
%66 = load %struct.v4l_fd*, %struct.v4l_fd** %3
%67 = call i64 @v4l_has_meta_cap(%struct.v4l_fd* %66)
%68 = icmp ne i64 %67, 0
br i1 %68, label %69, label %71
69: ; preds = %65
%70 = load i32, i32* @V4L2_BUF_TYPE_META_CAPTURE
store i32 %70, i32* %2
br label %78
71: ; preds = %65
%72 = load %struct.v4l_fd*, %struct.v4l_fd** %3
%73 = call i64 @v4l_has_meta_out(%struct.v4l_fd* %72)
%74 = icmp ne i64 %73, 0
br i1 %74, label %75, label %77
75: ; preds = %71
%76 = load i32, i32* @V4L2_BUF_TYPE_META_OUTPUT
store i32 %76, i32* %2
br label %78
77: ; preds = %71
store i32 0, i32* %2
br label %78
78: ; preds = %77, %75, %69, %63, %57, %51, %45, %39, %33, %27, %21, %15
%79 = load i32, i32* %2
ret i32 %79
}

LLVM IR (-O2):
%struct.v4l_fd = type { i32 }
@V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE = global i32 0
@V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE = global i32 0
@V4L2_BUF_TYPE_VIDEO_CAPTURE = global i32 0
@V4L2_BUF_TYPE_VIDEO_OUTPUT = global i32 0
@V4L2_BUF_TYPE_VBI_CAPTURE = global i32 0
@V4L2_BUF_TYPE_SLICED_VBI_CAPTURE = global i32 0
@V4L2_BUF_TYPE_VBI_OUTPUT = global i32 0
@V4L2_BUF_TYPE_SLICED_VBI_OUTPUT = global i32 0
@V4L2_BUF_TYPE_SDR_CAPTURE = global i32 0
@V4L2_BUF_TYPE_SDR_OUTPUT = global i32 0
@V4L2_BUF_TYPE_META_CAPTURE = global i32 0
@V4L2_BUF_TYPE_META_OUTPUT = global i32 0
define i32 @v4l_determine_type(%struct.v4l_fd* %0) {
%2 = tail call i64 @v4l_has_vid_mplane(%struct.v4l_fd* %0)
%3 = icmp eq i64 %2, 0
%4 = tail call i64 @v4l_has_vid_cap(%struct.v4l_fd* %0)
%5 = icmp eq i64 %4, 0
br i1 %3, label %10, label %6
6: ; preds = %1
%7 = load i32, i32* @V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE
%8 = load i32, i32* @V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE
%9 = select i1 %5, i32 %8, i32 %7
br label %58
10: ; preds = %1
br i1 %5, label %13, label %11
11: ; preds = %10
%12 = load i32, i32* @V4L2_BUF_TYPE_VIDEO_CAPTURE
br label %58
13: ; preds = %10
%14 = tail call i64 @v4l_has_vid_out(%struct.v4l_fd* %0)
%15 = icmp eq i64 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %13
%17 = load i32, i32* @V4L2_BUF_TYPE_VIDEO_OUTPUT
br label %58
18: ; preds = %13
%19 = tail call i64 @v4l_has_raw_vbi_cap(%struct.v4l_fd* %0)
%20 = icmp eq i64 %19, 0
br i1 %20, label %23, label %21
21: ; preds = %18
%22 = load i32, i32* @V4L2_BUF_TYPE_VBI_CAPTURE
br label %58
23: ; preds = %18
%24 = tail call i64 @v4l_has_sliced_vbi_cap(%struct.v4l_fd* %0)
%25 = icmp eq i64 %24, 0
br i1 %25, label %28, label %26
26: ; preds = %23
%27 = load i32, i32* @V4L2_BUF_TYPE_SLICED_VBI_CAPTURE
br label %58
28: ; preds = %23
%29 = tail call i64 @v4l_has_raw_vbi_out(%struct.v4l_fd* %0)
%30 = icmp eq i64 %29, 0
br i1 %30, label %33, label %31
31: ; preds = %28
%32 = load i32, i32* @V4L2_BUF_TYPE_VBI_OUTPUT
br label %58
33: ; preds = %28
%34 = tail call i64 @v4l_has_sliced_vbi_out(%struct.v4l_fd* %0)
%35 = icmp eq i64 %34, 0
br i1 %35, label %38, label %36
36: ; preds = %33
%37 = load i32, i32* @V4L2_BUF_TYPE_SLICED_VBI_OUTPUT
br label %58
38: ; preds = %33
%39 = tail call i64 @v4l_has_sdr_cap(%struct.v4l_fd* %0)
%40 = icmp eq i64 %39, 0
br i1 %40, label %43, label %41
41: ; preds = %38
%42 = load i32, i32* @V4L2_BUF_TYPE_SDR_CAPTURE
br label %58
43: ; preds = %38
%44 = tail call i64 @v4l_has_sdr_out(%struct.v4l_fd* %0)
%45 = icmp eq i64 %44, 0
br i1 %45, label %48, label %46
46: ; preds = %43
%47 = load i32, i32* @V4L2_BUF_TYPE_SDR_OUTPUT
br label %58
48: ; preds = %43
%49 = tail call i64 @v4l_has_meta_cap(%struct.v4l_fd* %0)
%50 = icmp eq i64 %49, 0
br i1 %50, label %53, label %51
51: ; preds = %48
%52 = load i32, i32* @V4L2_BUF_TYPE_META_CAPTURE
br label %58
53: ; preds = %48
%54 = tail call i64 @v4l_has_meta_out(%struct.v4l_fd* %0)
%55 = icmp eq i64 %54, 0
%56 = load i32, i32* @V4L2_BUF_TYPE_META_OUTPUT
%57 = select i1 %55, i32 0, i32 %56
br label %58
58: ; preds = %53, %51, %46, %41, %36, %31, %26, %21, %16, %11, %6
%59 = phi i32 [ %9, %6 ], [ %12, %11 ], [ %17, %16 ], [ %22, %21 ], [ %27, %26 ], [ %32, %31 ], [ %37, %36 ], [ %42, %41 ], [ %47, %46 ], [ %52, %51 ], [ %57, %53 ]
ret i32 %59
}