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

/* Variables and functions */
int berictl_c0regs(struct beri_debug *);
int berictl_c2regs(struct beri_debug *);
int berictl_regs(struct beri_debug *);
int berictl_test_report(struct beri_debug *bdp) {
  int ret;
  ret = berictl_regs(bdp);
  if (ret != 0)
    return (ret);
  ret = berictl_c2regs(bdp);
  if (ret != 0)
    return (ret);
  return (berictl_c0regs(bdp));
}


x86 assembly (clang, -O0):
<berictl_test_report>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <berictl_regs@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     115d <berictl_test_report+0x2d>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    118a <berictl_test_report+0x5a>
mov    -0x10(%rbp),%rdi
call   1030 <berictl_c2regs@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     117e <berictl_test_report+0x4e>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    118a <berictl_test_report+0x5a>
mov    -0x10(%rbp),%rdi
call   1040 <berictl_c0regs@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<berictl_test_report>:
push   %rbx
mov    %rdi,%rbx
call   1050 <berictl_regs@plt>
test   %eax,%eax
jne    1149 <berictl_test_report+0x19>
mov    %rbx,%rdi
call   1030 <berictl_c2regs@plt>
test   %eax,%eax
je     114b <berictl_test_report+0x1b>
pop    %rbx
ret
mov    %rbx,%rdi
pop    %rbx
jmp    1040 <berictl_c0regs@plt>

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

LLVM IR (-O2):
%struct.beri_debug = type { i32 }
define i32 @berictl_test_report(%struct.beri_debug* %0) {
%2 = tail call i32 @berictl_regs(%struct.beri_debug* %0)
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %9
4: ; preds = %1
%5 = tail call i32 @berictl_c2regs(%struct.beri_debug* %0)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = tail call i32 @berictl_c0regs(%struct.beri_debug* %0)
br label %9
9: ; preds = %4, %1, %7
%10 = phi i32 [ %8, %7 ], [ %2, %1 ], [ %5, %4 ]
ret i32 %10
}