#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 */
typedef int /*<<< orphan*/ uint32_t;
struct host1x_client {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *, int, int);
int host1x_client_wait(struct host1x_client *, int /*<<< orphan*/,
                       int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int host1x_client_wait_helper(struct host1x_client *client, uint32_t fence,
                              uint32_t timeout, const char *file, int line) {
  int err = host1x_client_wait(client, fence, timeout);
  if (err)
    fprintf(stderr, "ERROR: %s:%d: host1x_client_wait() failed %d\n", file,
            line, err);
  return err;
}


x86 assembly (clang, -O0):
<host1x_client_wait_helper>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1040 <host1x_client_wait@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     1176 <host1x_client_wait_helper+0x56>
mov    0x2e83(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
lea    0xe8f(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x20(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<host1x_client_wait_helper>:
push   %rbp
push   %r14
push   %rbx
mov    %r8d,%r14d
mov    %rcx,%rbx
call   1040 <host1x_client_wait@plt>
mov    %eax,%ebp
test   %eax,%eax
je     1153 <host1x_client_wait_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_client = type { i32 }
@stderr = global i32 0
@.str = [46 x i8] c"ERROR: %s:%d: host1x_client_wait() failed %d\0A\00"
define i32 @host1x_client_wait_helper(%struct.host1x_client* %0, i32 %1, i32 %2, i8* %3, i32 %4) {
%6 = alloca %struct.host1x_client*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
store %struct.host1x_client* %0, %struct.host1x_client** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i8* %3, i8** %9
store i32 %4, i32* %10
%12 = load %struct.host1x_client*, %struct.host1x_client** %6
%13 = load i32, i32* %7
%14 = load i32, i32* %8
%15 = call i32 @host1x_client_wait(%struct.host1x_client* %12, i32 %13, i32 %14)
store i32 %15, i32* %11
%16 = load i32, i32* %11
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %24
18: ; preds = %5
%19 = load i32, i32* @stderr
%20 = load i8*, i8** %9
%21 = load i32, i32* %10
%22 = load i32, i32* %11
%23 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i8* %20, i32 %21, i32 %22)
br label %24
24: ; preds = %18, %5
%25 = load i32, i32* %11
ret i32 %25
}

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