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

/* Variables and functions */
int /*<<< orphan*/ pevent_print_num_field(struct trace_seq *, char *,
                                          struct event_format *, char *,
                                          struct pevent_record *, int);
scalar_t__ print_exit_reason(struct trace_seq *, struct pevent_record *,
                             struct event_format *, char *);
int kvm_nested_vmexit_inject_handler(struct trace_seq *s,
                                     struct pevent_record *record,
                                     struct event_format *event,
                                     void *context) {
  if (print_exit_reason(s, record, event, "exit_code") < 0)
    return -1;
  pevent_print_num_field(s, " info1 %llx", event, "exit_info1", record, 1);
  pevent_print_num_field(s, " info2 %llx", event, "exit_info2", record, 1);
  pevent_print_num_field(s, " int_info %llx", event, "exit_int_info", record,
                         1);
  pevent_print_num_field(s, " int_info_err %llx", event, "exit_int_info_err",
                         record, 1);
  return 0;
}


x86 assembly (clang, -O0):
<kvm_nested_vmexit_inject_handler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xeb5(%rip),%rcx
call   1040 <print_exit_reason@plt>
cmp    $0x0,%rax
jge    1166 <kvm_nested_vmexit_inject_handler+0x46>
movl   $0xffffffff,-0x4(%rbp)
jmp    1201 <kvm_nested_vmexit_inject_handler+0xe1>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x18(%rbp),%r8
lea    0xe91(%rip),%rsi
lea    0xe96(%rip),%rcx
mov    $0x1,%r9d
call   1030 <pevent_print_num_field@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x18(%rbp),%r8
lea    0xe83(%rip),%rsi
lea    0xe88(%rip),%rcx
mov    $0x1,%r9d
call   1030 <pevent_print_num_field@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x18(%rbp),%r8
lea    0xe75(%rip),%rsi
lea    0xe7d(%rip),%rcx
mov    $0x1,%r9d
call   1030 <pevent_print_num_field@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x18(%rbp),%r8
lea    0xe6d(%rip),%rsi
lea    0xe79(%rip),%rcx
mov    $0x1,%r9d
call   1030 <pevent_print_num_field@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kvm_nested_vmexit_inject_handler>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xecb(%rip),%rcx
call   1040 <print_exit_reason@plt>
test   %rax,%rax
js     11cf <kvm_nested_vmexit_inject_handler+0xaf>
lea    0xec0(%rip),%rsi
lea    0xec5(%rip),%rcx
mov    %rbx,%rdi
mov    %r15,%rdx
mov    %r14,%r8
mov    $0x1,%r9d
call   1030 <pevent_print_num_field@plt>
lea    0xeb5(%rip),%rsi
lea    0xeba(%rip),%rcx
mov    %rbx,%rdi
mov    %r15,%rdx
mov    %r14,%r8
mov    $0x1,%r9d
call   1030 <pevent_print_num_field@plt>
lea    0xeaa(%rip),%rsi
lea    0xeb2(%rip),%rcx
mov    %rbx,%rdi
mov    %r15,%rdx
mov    %r14,%r8
mov    $0x1,%r9d
call   1030 <pevent_print_num_field@plt>
lea    0xea5(%rip),%rsi
lea    0xeb1(%rip),%rcx
mov    %rbx,%rdi
mov    %r15,%rdx
mov    %r14,%r8
mov    $0x1,%r9d
call   1030 <pevent_print_num_field@plt>
xor    %eax,%eax
jmp    11d4 <kvm_nested_vmexit_inject_handler+0xb4>
mov    $0xffffffff,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.trace_seq = type { i32 }
%struct.pevent_record = type { i32 }
%struct.event_format = type { i32 }
@.str = [10 x i8] c"exit_code\00"
@.str.1 = [12 x i8] c" info1 %llx\00"
@.str.2 = [11 x i8] c"exit_info1\00"
@.str.3 = [12 x i8] c" info2 %llx\00"
@.str.4 = [11 x i8] c"exit_info2\00"
@.str.5 = [15 x i8] c" int_info %llx\00"
@.str.6 = [14 x i8] c"exit_int_info\00"
@.str.7 = [19 x i8] c" int_info_err %llx\00"
@.str.8 = [18 x i8] c"exit_int_info_err\00"
define i32 @kvm_nested_vmexit_inject_handler(%struct.trace_seq* %0, %struct.pevent_record* %1, %struct.event_format* %2, i8* %3) {
%5 = alloca i32
%6 = alloca %struct.trace_seq*
%7 = alloca %struct.pevent_record*
%8 = alloca %struct.event_format*
%9 = alloca i8*
store %struct.trace_seq* %0, %struct.trace_seq** %6
store %struct.pevent_record* %1, %struct.pevent_record** %7
store %struct.event_format* %2, %struct.event_format** %8
store i8* %3, i8** %9
%10 = load %struct.trace_seq*, %struct.trace_seq** %6
%11 = load %struct.pevent_record*, %struct.pevent_record** %7
%12 = load %struct.event_format*, %struct.event_format** %8
%13 = call i64 @print_exit_reason(%struct.trace_seq* %10, %struct.pevent_record* %11, %struct.event_format* %12, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %4
store i32 -1, i32* %5
br label %33
16: ; preds = %4
%17 = load %struct.trace_seq*, %struct.trace_seq** %6
%18 = load %struct.event_format*, %struct.event_format** %8
%19 = load %struct.pevent_record*, %struct.pevent_record** %7
%20 = call i32 @pevent_print_num_field(%struct.trace_seq* %17, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), %struct.event_format* %18, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), %struct.pevent_record* %19, i32 1)
%21 = load %struct.trace_seq*, %struct.trace_seq** %6
%22 = load %struct.event_format*, %struct.event_format** %8
%23 = load %struct.pevent_record*, %struct.pevent_record** %7
%24 = call i32 @pevent_print_num_field(%struct.trace_seq* %21, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), %struct.event_format* %22, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), %struct.pevent_record* %23, i32 1)
%25 = load %struct.trace_seq*, %struct.trace_seq** %6
%26 = load %struct.event_format*, %struct.event_format** %8
%27 = load %struct.pevent_record*, %struct.pevent_record** %7
%28 = call i32 @pevent_print_num_field(%struct.trace_seq* %25, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), %struct.event_format* %26, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), %struct.pevent_record* %27, i32 1)
%29 = load %struct.trace_seq*, %struct.trace_seq** %6
%30 = load %struct.event_format*, %struct.event_format** %8
%31 = load %struct.pevent_record*, %struct.pevent_record** %7
%32 = call i32 @pevent_print_num_field(%struct.trace_seq* %29, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), %struct.event_format* %30, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0), %struct.pevent_record* %31, i32 1)
store i32 0, i32* %5
br label %33
33: ; preds = %16, %15
%34 = load i32, i32* %5
ret i32 %34
}

LLVM IR (-O2):
%struct.trace_seq = type { i32 }
%struct.pevent_record = type { i32 }
%struct.event_format = type { i32 }
@.str = [10 x i8] c"exit_code\00"
@.str.1 = [12 x i8] c" info1 %llx\00"
@.str.2 = [11 x i8] c"exit_info1\00"
@.str.3 = [12 x i8] c" info2 %llx\00"
@.str.4 = [11 x i8] c"exit_info2\00"
@.str.5 = [15 x i8] c" int_info %llx\00"
@.str.6 = [14 x i8] c"exit_int_info\00"
@.str.7 = [19 x i8] c" int_info_err %llx\00"
@.str.8 = [18 x i8] c"exit_int_info_err\00"
define i32 @kvm_nested_vmexit_inject_handler(%struct.trace_seq* %0, %struct.pevent_record* %1, %struct.event_format* %2, i8* nocapture readnone %3) {
%5 = tail call i64 @print_exit_reason(%struct.trace_seq* %0, %struct.pevent_record* %1, %struct.event_format* %2, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%6 = icmp slt i64 %5, 0
br i1 %6, label %12, label %7
7: ; preds = %4
%8 = tail call i32 @pevent_print_num_field(%struct.trace_seq* %0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), %struct.event_format* %2, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), %struct.pevent_record* %1, i32 1)
%9 = tail call i32 @pevent_print_num_field(%struct.trace_seq* %0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), %struct.event_format* %2, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), %struct.pevent_record* %1, i32 1)
%10 = tail call i32 @pevent_print_num_field(%struct.trace_seq* %0, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), %struct.event_format* %2, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), %struct.pevent_record* %1, i32 1)
%11 = tail call i32 @pevent_print_num_field(%struct.trace_seq* %0, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), %struct.event_format* %2, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0), %struct.pevent_record* %1, i32 1)
br label %12
12: ; preds = %4, %7
%13 = phi i32 [ 0, %7 ], [ -1, %4 ]
ret i32 %13
}