#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 tracecmd_input {
  int dummy;
};
struct record {
  int dummy;
};

/* Variables and functions */
struct record *tracecmd_read_data(struct tracecmd_input *, int);
struct record *tracecmd_read_next_data(struct tracecmd_input *, int *);
struct record *read_record(struct tracecmd_input *handle, int percpu,
                           int *cpu) {
  if (percpu)
    return tracecmd_read_data(handle, *cpu);
  return tracecmd_read_next_data(handle, cpu);
}


x86 assembly (clang, -O0):
<read_record>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1155 <read_record+0x35>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    (%rax),%esi
call   1040 <tracecmd_read_data@plt>
mov    %rax,-0x8(%rbp)
jmp    1166 <read_record+0x46>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <tracecmd_read_next_data@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_record>:
test   %esi,%esi
je     112b <read_record+0xb>
mov    (%rdx),%esi
jmp    1040 <tracecmd_read_data@plt>
mov    %rdx,%rsi
jmp    1030 <tracecmd_read_next_data@plt>

LLVM IR (-O0):
%struct.record = type { i32 }
%struct.tracecmd_input = type { i32 }
define %struct.record* @read_record(%struct.tracecmd_input* %0, i32 %1, i32* %2) {
%4 = alloca %struct.record*
%5 = alloca %struct.tracecmd_input*
%6 = alloca i32
%7 = alloca i32*
store %struct.tracecmd_input* %0, %struct.tracecmd_input** %5
store i32 %1, i32* %6
store i32* %2, i32** %7
%8 = load i32, i32* %6
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %3
%11 = load %struct.tracecmd_input*, %struct.tracecmd_input** %5
%12 = load i32*, i32** %7
%13 = load i32, i32* %12
%14 = call %struct.record* @tracecmd_read_data(%struct.tracecmd_input* %11, i32 %13)
store %struct.record* %14, %struct.record** %4
br label %19
15: ; preds = %3
%16 = load %struct.tracecmd_input*, %struct.tracecmd_input** %5
%17 = load i32*, i32** %7
%18 = call %struct.record* @tracecmd_read_next_data(%struct.tracecmd_input* %16, i32* %17)
store %struct.record* %18, %struct.record** %4
br label %19
19: ; preds = %15, %10
%20 = load %struct.record*, %struct.record** %4
ret %struct.record* %20
}

LLVM IR (-O2):
%struct.record = type { i32 }
%struct.tracecmd_input = type { i32 }
define %struct.record* @read_record(%struct.tracecmd_input* %0, i32 %1, i32* %2) {
%4 = icmp eq i32 %1, 0
br i1 %4, label %8, label %5
5: ; preds = %3
%6 = load i32, i32* %2
%7 = tail call %struct.record* @tracecmd_read_data(%struct.tracecmd_input* %0, i32 %6)
br label %10
8: ; preds = %3
%9 = tail call %struct.record* @tracecmd_read_next_data(%struct.tracecmd_input* %0, i32* %2)
br label %10
10: ; preds = %8, %5
%11 = phi %struct.record* [ %7, %5 ], [ %9, %8 ]
ret %struct.record* %11
}