#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 v4l2_format {
  int dummy;
};

/* Variables and functions */
unsigned int V4L2_FIELD_ALTERNATE;
unsigned int V4L2_FIELD_BOTTOM;
unsigned int V4L2_FIELD_TOP;
unsigned int v4l_format_g_field(struct v4l2_format const *);
unsigned v4l_format_g_flds_per_frm(const struct v4l2_format *fmt) {
  unsigned field = v4l_format_g_field(fmt);
  if (field == V4L2_FIELD_ALTERNATE || field == V4L2_FIELD_TOP ||
      field == V4L2_FIELD_BOTTOM)
    return 2;
  return 1;
}


x86 assembly (clang, -O0):
<v4l_format_g_flds_per_frm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <v4l_format_g_field@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2e9e(%rip),%rcx
cmp    (%rcx),%eax
je     115e <v4l_format_g_flds_per_frm+0x4e>
mov    -0x14(%rbp),%eax
mov    0x2ea4(%rip),%rcx
cmp    (%rcx),%eax
je     115e <v4l_format_g_flds_per_frm+0x4e>
mov    -0x14(%rbp),%eax
mov    0x2e8a(%rip),%rcx
cmp    (%rcx),%eax
jne    116a <v4l_format_g_flds_per_frm+0x5a>
movl   $0x2,-0x4(%rbp)
jmp    1171 <v4l_format_g_flds_per_frm+0x61>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<v4l_format_g_flds_per_frm>:
push   %rax
call   1030 <v4l_format_g_field@plt>
mov    0x2eb3(%rip),%rcx
cmp    (%rcx),%eax
sete   %cl
mov    0x2ebf(%rip),%rdx
cmp    (%rdx),%eax
sete   %dl
or     %cl,%dl
mov    0x2ea9(%rip),%rcx
cmp    (%rcx),%eax
sete   %al
or     %dl,%al
movzbl %al,%eax
add    $0x1,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.v4l2_format = type { i32 }
@V4L2_FIELD_ALTERNATE = global i32 0
@V4L2_FIELD_TOP = global i32 0
@V4L2_FIELD_BOTTOM = global i32 0
define i32 @v4l_format_g_flds_per_frm(%struct.v4l2_format* %0) {
%2 = alloca i32
%3 = alloca %struct.v4l2_format*
%4 = alloca i32
store %struct.v4l2_format* %0, %struct.v4l2_format** %3
%5 = load %struct.v4l2_format*, %struct.v4l2_format** %3
%6 = call i32 @v4l_format_g_field(%struct.v4l2_format* %5)
store i32 %6, i32* %4
%7 = load i32, i32* %4
%8 = load i32, i32* @V4L2_FIELD_ALTERNATE
%9 = icmp eq i32 %7, %8
br i1 %9, label %18, label %10
10: ; preds = %1
%11 = load i32, i32* %4
%12 = load i32, i32* @V4L2_FIELD_TOP
%13 = icmp eq i32 %11, %12
br i1 %13, label %18, label %14
14: ; preds = %10
%15 = load i32, i32* %4
%16 = load i32, i32* @V4L2_FIELD_BOTTOM
%17 = icmp eq i32 %15, %16
br i1 %17, label %18, label %19
18: ; preds = %14, %10, %1
store i32 2, i32* %2
br label %20
19: ; preds = %14
store i32 1, i32* %2
br label %20
20: ; preds = %19, %18
%21 = load i32, i32* %2
ret i32 %21
}

LLVM IR (-O2):
%struct.v4l2_format = type { i32 }
@V4L2_FIELD_ALTERNATE = global i32 0
@V4L2_FIELD_TOP = global i32 0
@V4L2_FIELD_BOTTOM = global i32 0
define i32 @v4l_format_g_flds_per_frm(%struct.v4l2_format* %0) {
%2 = tail call i32 @v4l_format_g_field(%struct.v4l2_format* %0)
%3 = load i32, i32* @V4L2_FIELD_ALTERNATE
%4 = icmp eq i32 %2, %3
%5 = load i32, i32* @V4L2_FIELD_TOP
%6 = icmp eq i32 %2, %5
%7 = select i1 %4, i1 true, i1 %6
%8 = load i32, i32* @V4L2_FIELD_BOTTOM
%9 = icmp eq i32 %2, %8
%10 = select i1 %7, i1 true, i1 %9
%11 = select i1 %10, i32 2, i32 1
ret i32 %11
}