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

/* Variables and functions */
int /*<<< orphan*/ __pushbuf_print(struct pushbuf_decode_state *,
                                   int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                                   int /*<<< orphan*/, int);
int /*<<< orphan*/ *gpu_mapping_get_data(struct gpu_mapping *,
                                         int /*<<< orphan*/, int);
uint64_t pushbuf_print(struct pushbuf_decode_state *pstate,
                       struct gpu_mapping *gpu_mapping, uint64_t gpu_address,
                       int commands) {
  uint32_t *start =
      gpu_mapping_get_data(gpu_mapping, gpu_address, commands * 4);
  return __pushbuf_print(pstate, start, start + commands, gpu_address,
                         commands);
}


x86 assembly (clang, -O0):
<pushbuf_print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
shl    $0x2,%edx
call   1040 <gpu_mapping_get_data@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x20(%rbp),%rdx
movslq -0x18(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
call   1030 <__pushbuf_print@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pushbuf_print>:
push   %rbp
push   %r14
push   %rbx
mov    %ecx,%ebx
mov    %edx,%ebp
mov    %rdi,%r14
lea    0x0(,%rbx,4),%edx
mov    %rsi,%rdi
mov    %ebp,%esi
call   1040 <gpu_mapping_get_data@plt>
movslq %ebx,%r8
lea    (%rax,%r8,4),%rdx
mov    %r14,%rdi
mov    %rax,%rsi
mov    %ebp,%ecx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <__pushbuf_print@plt>

LLVM IR (-O0):
%struct.pushbuf_decode_state = type { i32 }
%struct.gpu_mapping = type { i32 }
define i32 @pushbuf_print(%struct.pushbuf_decode_state* %0, %struct.gpu_mapping* %1, i32 %2, i32 %3) {
%5 = alloca %struct.pushbuf_decode_state*
%6 = alloca %struct.gpu_mapping*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
store %struct.pushbuf_decode_state* %0, %struct.pushbuf_decode_state** %5
store %struct.gpu_mapping* %1, %struct.gpu_mapping** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = load %struct.gpu_mapping*, %struct.gpu_mapping** %6
%11 = load i32, i32* %7
%12 = load i32, i32* %8
%13 = mul nsw i32 %12, 4
%14 = call i32* @gpu_mapping_get_data(%struct.gpu_mapping* %10, i32 %11, i32 %13)
store i32* %14, i32** %9
%15 = load %struct.pushbuf_decode_state*, %struct.pushbuf_decode_state** %5
%16 = load i32*, i32** %9
%17 = load i32*, i32** %9
%18 = load i32, i32* %8
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %17, i64 %19
%21 = load i32, i32* %7
%22 = load i32, i32* %8
%23 = call i32 @__pushbuf_print(%struct.pushbuf_decode_state* %15, i32* %16, i32* %20, i32 %21, i32 %22)
ret i32 %23
}

LLVM IR (-O2):
%struct.pushbuf_decode_state = type { i32 }
%struct.gpu_mapping = type { i32 }
define i32 @pushbuf_print(%struct.pushbuf_decode_state* %0, %struct.gpu_mapping* %1, i32 %2, i32 %3) {
%5 = shl nsw i32 %3, 2
%6 = tail call i32* @gpu_mapping_get_data(%struct.gpu_mapping* %1, i32 %2, i32 %5)
%7 = sext i32 %3 to i64
%8 = getelementptr inbounds i32, i32* %6, i64 %7
%9 = tail call i32 @__pushbuf_print(%struct.pushbuf_decode_state* %0, i32* %6, i32* %8, i32 %2, i32 %3)
ret i32 %9
}