#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 */
typedef int v4l2_std_id;
struct v4l2_format {
  int dummy;
};

/* Variables and functions */
unsigned int V4L2_FIELD_ALTERNATE;
int V4L2_FIELD_BOTTOM;
int V4L2_FIELD_TOP;
int V4L2_STD_525_60;
unsigned int v4l_format_g_field(struct v4l2_format const *);
unsigned v4l_format_g_first_field(const struct v4l2_format *fmt,
                                  v4l2_std_id std) {
  unsigned field = v4l_format_g_field(fmt);
  if (field != V4L2_FIELD_ALTERNATE)
    return field;
  if (std & V4L2_STD_525_60)
    return V4L2_FIELD_BOTTOM;
  return V4L2_FIELD_TOP;
}


x86 assembly (clang, -O0):
<v4l_format_g_first_field>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <v4l_format_g_field@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    0x2e93(%rip),%rcx
cmp    (%rcx),%eax
je     1148 <v4l_format_g_first_field+0x38>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    117a <v4l_format_g_first_field+0x6a>
mov    -0x14(%rbp),%eax
mov    0x2e86(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     116e <v4l_format_g_first_field+0x5e>
mov    0x2e7c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    117a <v4l_format_g_first_field+0x6a>
mov    0x2e73(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<v4l_format_g_first_field>:
push   %rbx
mov    %esi,%ebx
call   1030 <v4l_format_g_field@plt>
mov    0x2ea9(%rip),%rcx
cmp    (%rcx),%eax
jne    1140 <v4l_format_g_first_field+0x30>
mov    0x2eae(%rip),%rax
test   %ebx,(%rax)
je     1137 <v4l_format_g_first_field+0x27>
mov    0x2eab(%rip),%rax
jmp    113e <v4l_format_g_first_field+0x2e>
mov    0x2eaa(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret

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

LLVM IR (-O2):
%struct.v4l2_format = type { i32 }
@V4L2_FIELD_ALTERNATE = global i32 0
@V4L2_STD_525_60 = global i32 0
@V4L2_FIELD_BOTTOM = global i32 0
@V4L2_FIELD_TOP = global i32 0
define i32 @v4l_format_g_first_field(%struct.v4l2_format* %0, i32 %1) {
%3 = tail call i32 @v4l_format_g_field(%struct.v4l2_format* %0)
%4 = load i32, i32* @V4L2_FIELD_ALTERNATE
%5 = icmp eq i32 %3, %4
br i1 %5, label %6, label %14
6: ; preds = %2
%7 = load i32, i32* @V4L2_STD_525_60
%8 = and i32 %7, %1
%9 = icmp eq i32 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %6
%11 = load i32, i32* @V4L2_FIELD_BOTTOM
br label %14
12: ; preds = %6
%13 = load i32, i32* @V4L2_FIELD_TOP
br label %14
14: ; preds = %2, %12, %10
%15 = phi i32 [ %11, %10 ], [ %13, %12 ], [ %3, %2 ]
ret i32 %15
}