#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 host1x_pushbuf {
  int dummy;
};
struct host1x_bo {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *, int, int);
int host1x_pushbuf_relocate(struct host1x_pushbuf *, struct host1x_bo *,
                            unsigned long, unsigned long);
int /*<<< orphan*/ stderr;
int host1x_pushbuf_relocate_helper(struct host1x_pushbuf *pb,
                                   struct host1x_bo *target,
                                   unsigned long offset, unsigned long shift,
                                   const char *file, int line) {
  int err = host1x_pushbuf_relocate(pb, target, offset, shift);
  if (err)
    fprintf(stderr, "ERROR: %s:%d: host1x_pushbuf_relocate() failed %d\n", file,
            line, err);
  return err;
}


x86 assembly (clang, -O0):
<host1x_pushbuf_relocate_helper>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1040 <host1x_pushbuf_relocate@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
je     1182 <host1x_pushbuf_relocate_helper+0x62>
mov    0x2e77(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rdx
mov    -0x2c(%rbp),%ecx
mov    -0x30(%rbp),%r8d
lea    0xe83(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x30(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<host1x_pushbuf_relocate_helper>:
push   %rbp
push   %r14
push   %rbx
mov    %r9d,%r14d
mov    %r8,%rbx
call   1040 <host1x_pushbuf_relocate@plt>
mov    %eax,%ebp
test   %eax,%eax
je     1153 <host1x_pushbuf_relocate_helper+0x33>
mov    0x2ea4(%rip),%rax
mov    (%rax),%edi
lea    0xebb(%rip),%rsi
mov    %rbx,%rdx
mov    %r14d,%ecx
mov    %ebp,%r8d
call   1030 <fprintf@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.host1x_pushbuf = type { i32 }
%struct.host1x_bo = type { i32 }
@stderr = global i32 0
@.str = [51 x i8] c"ERROR: %s:%d: host1x_pushbuf_relocate() failed %d\0A\00"
define i32 @host1x_pushbuf_relocate_helper(%struct.host1x_pushbuf* %0, %struct.host1x_bo* %1, i64 %2, i64 %3, i8* %4, i32 %5) {
%7 = alloca %struct.host1x_pushbuf*
%8 = alloca %struct.host1x_bo*
%9 = alloca i64
%10 = alloca i64
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
store %struct.host1x_pushbuf* %0, %struct.host1x_pushbuf** %7
store %struct.host1x_bo* %1, %struct.host1x_bo** %8
store i64 %2, i64* %9
store i64 %3, i64* %10
store i8* %4, i8** %11
store i32 %5, i32* %12
%14 = load %struct.host1x_pushbuf*, %struct.host1x_pushbuf** %7
%15 = load %struct.host1x_bo*, %struct.host1x_bo** %8
%16 = load i64, i64* %9
%17 = load i64, i64* %10
%18 = call i32 @host1x_pushbuf_relocate(%struct.host1x_pushbuf* %14, %struct.host1x_bo* %15, i64 %16, i64 %17)
store i32 %18, i32* %13
%19 = load i32, i32* %13
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %27
21: ; preds = %6
%22 = load i32, i32* @stderr
%23 = load i8*, i8** %11
%24 = load i32, i32* %12
%25 = load i32, i32* %13
%26 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i8* %23, i32 %24, i32 %25)
br label %27
27: ; preds = %21, %6
%28 = load i32, i32* %13
ret i32 %28
}

LLVM IR (-O2):
%struct.host1x_pushbuf = type { i32 }
%struct.host1x_bo = type { i32 }
@stderr = global i32 0
@.str = [51 x i8] c"ERROR: %s:%d: host1x_pushbuf_relocate() failed %d\0A\00"
define i32 @host1x_pushbuf_relocate_helper(%struct.host1x_pushbuf* %0, %struct.host1x_bo* %1, i64 %2, i64 %3, i8* %4, i32 %5) {
%7 = tail call i32 @host1x_pushbuf_relocate(%struct.host1x_pushbuf* %0, %struct.host1x_bo* %1, i64 %2, i64 %3)
%8 = icmp eq i32 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %6
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i8* %4, i32 %5, i32 %7)
br label %12
12: ; preds = %9, %6
ret i32 %7
}