#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 trace_seq {
  int dummy;
};
struct pevent_record {
  int dummy;
};
struct format_field {
  int dummy;
};
struct event_format {
  int dummy;
};

/* Variables and functions */
int get_field_val(struct trace_seq *, struct format_field *, char const *,
                  struct pevent_record *, unsigned long long *, int);
struct format_field *pevent_find_field(struct event_format *, char const *);
int pevent_get_field_val(struct trace_seq *s, struct event_format *event,
                         const char *name, struct pevent_record *record,
                         unsigned long long *val, int err) {
  struct format_field *field;
  if (!event) {
    return -1;
  }
  field = pevent_find_field(event, name);
  return get_field_val(s, field, name, record, val, err);
}


x86 assembly (clang, -O0):
<pevent_get_field_val>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9d,-0x34(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1157 <pevent_get_field_val+0x37>
movl   $0xffffffff,-0x4(%rbp)
jmp    1188 <pevent_get_field_val+0x68>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <pevent_find_field@plt>
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    -0x34(%rbp),%r9d
call   1040 <get_field_val@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pevent_get_field_val>:
test   %rsi,%rsi
je     1166 <pevent_get_field_val+0x46>
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r9d,%r14d
mov    %r8,%r15
mov    %rcx,%r12
mov    %rdx,%rbx
mov    %rdi,%rbp
mov    %rsi,%rdi
mov    %rdx,%rsi
call   1030 <pevent_find_field@plt>
mov    %rbp,%rdi
mov    %rax,%rsi
mov    %rbx,%rdx
mov    %r12,%rcx
mov    %r15,%r8
mov    %r14d,%r9d
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <get_field_val@plt>
mov    $0xffffffff,%eax
ret

LLVM IR (-O0):
%struct.trace_seq = type { i32 }
%struct.event_format = type { i32 }
%struct.pevent_record = type { i32 }
%struct.format_field = type { i32 }
define i32 @pevent_get_field_val(%struct.trace_seq* %0, %struct.event_format* %1, i8* %2, %struct.pevent_record* %3, i64* %4, i32 %5) {
%7 = alloca i32
%8 = alloca %struct.trace_seq*
%9 = alloca %struct.event_format*
%10 = alloca i8*
%11 = alloca %struct.pevent_record*
%12 = alloca i64*
%13 = alloca i32
%14 = alloca %struct.format_field*
store %struct.trace_seq* %0, %struct.trace_seq** %8
store %struct.event_format* %1, %struct.event_format** %9
store i8* %2, i8** %10
store %struct.pevent_record* %3, %struct.pevent_record** %11
store i64* %4, i64** %12
store i32 %5, i32* %13
%15 = load %struct.event_format*, %struct.event_format** %9
%16 = icmp ne %struct.event_format* %15, null
br i1 %16, label %18, label %17
17: ; preds = %6
store i32 -1, i32* %7
br label %29
18: ; preds = %6
%19 = load %struct.event_format*, %struct.event_format** %9
%20 = load i8*, i8** %10
%21 = call %struct.format_field* @pevent_find_field(%struct.event_format* %19, i8* %20)
store %struct.format_field* %21, %struct.format_field** %14
%22 = load %struct.trace_seq*, %struct.trace_seq** %8
%23 = load %struct.format_field*, %struct.format_field** %14
%24 = load i8*, i8** %10
%25 = load %struct.pevent_record*, %struct.pevent_record** %11
%26 = load i64*, i64** %12
%27 = load i32, i32* %13
%28 = call i32 @get_field_val(%struct.trace_seq* %22, %struct.format_field* %23, i8* %24, %struct.pevent_record* %25, i64* %26, i32 %27)
store i32 %28, i32* %7
br label %29
29: ; preds = %18, %17
%30 = load i32, i32* %7
ret i32 %30
}

LLVM IR (-O2):
%struct.trace_seq = type { i32 }
%struct.event_format = type { i32 }
%struct.pevent_record = type { i32 }
%struct.format_field = type { i32 }
define i32 @pevent_get_field_val(%struct.trace_seq* %0, %struct.event_format* %1, i8* %2, %struct.pevent_record* %3, i64* %4, i32 %5) {
%7 = icmp eq %struct.event_format* %1, null
br i1 %7, label %11, label %8
8: ; preds = %6
%9 = tail call %struct.format_field* @pevent_find_field(%struct.event_format* %1, i8* %2)
%10 = tail call i32 @get_field_val(%struct.trace_seq* %0, %struct.format_field* %9, i8* %2, %struct.pevent_record* %3, i64* %4, i32 %5)
br label %11
11: ; preds = %6, %8
%12 = phi i32 [ %10, %8 ], [ -1, %6 ]
ret i32 %12
}