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

/* Variables and functions */
int /*<<< orphan*/ drm_intel_decode(struct drm_intel_decode *);
int /*<<< orphan*/ drm_intel_decode_set_batch_pointer(struct drm_intel_decode *,
                                                      void *, int, size_t);
int /*<<< orphan*/ drm_intel_decode_set_output_file(struct drm_intel_decode *,
                                                    int /*<<< orphan*/);
int /*<<< orphan*/ read_file(char const *, void **, size_t *);
int /*<<< orphan*/ stdout;
void dump_batch(struct drm_intel_decode *ctx, const char *batch_filename) {
  void *batch_ptr;
  size_t batch_size;
  read_file(batch_filename, &batch_ptr, &batch_size);
  drm_intel_decode_set_batch_pointer(ctx, batch_ptr, 0x12300000,
                                     batch_size / 4);
  drm_intel_decode_set_output_file(ctx, stdout);
  drm_intel_decode(ctx);
}


x86 assembly (clang, -O0):
<dump_batch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   1040 <read_file@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rcx
shr    $0x2,%rcx
mov    $0x12300000,%edx
call   1050 <drm_intel_decode_set_batch_pointer@plt>
mov    -0x8(%rbp),%rdi
mov    0x2e5a(%rip),%rax
mov    (%rax),%esi
call   1060 <drm_intel_decode_set_output_file@plt>
mov    -0x8(%rbp),%rdi
call   1030 <drm_intel_decode@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_batch>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rax
mov    %rdi,%rbx
lea    0x8(%rsp),%rsi
mov    %rsp,%rdx
mov    %rax,%rdi
call   1040 <read_file@plt>
mov    0x8(%rsp),%rsi
mov    (%rsp),%rcx
shr    $0x2,%rcx
mov    %rbx,%rdi
mov    $0x12300000,%edx
call   1050 <drm_intel_decode_set_batch_pointer@plt>
mov    0x2e64(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1060 <drm_intel_decode_set_output_file@plt>
mov    %rbx,%rdi
call   1030 <drm_intel_decode@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.drm_intel_decode = type { i32 }
@stdout = global i32 0
define void @dump_batch(%struct.drm_intel_decode* %0, i8* %1) {
%3 = alloca %struct.drm_intel_decode*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
store %struct.drm_intel_decode* %0, %struct.drm_intel_decode** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %4
%8 = call i32 @read_file(i8* %7, i8** %5, i64* %6)
%9 = load %struct.drm_intel_decode*, %struct.drm_intel_decode** %3
%10 = load i8*, i8** %5
%11 = load i64, i64* %6
%12 = udiv i64 %11, 4
%13 = call i32 @drm_intel_decode_set_batch_pointer(%struct.drm_intel_decode* %9, i8* %10, i32 305135616, i64 %12)
%14 = load %struct.drm_intel_decode*, %struct.drm_intel_decode** %3
%15 = load i32, i32* @stdout
%16 = call i32 @drm_intel_decode_set_output_file(%struct.drm_intel_decode* %14, i32 %15)
%17 = load %struct.drm_intel_decode*, %struct.drm_intel_decode** %3
%18 = call i32 @drm_intel_decode(%struct.drm_intel_decode* %17)
ret void
}

LLVM IR (-O2):
%struct.drm_intel_decode = type { i32 }
@stdout = global i32 0
define void @dump_batch(%struct.drm_intel_decode* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = bitcast i8** %3 to i8*
%6 = bitcast i64* %4 to i8*
%7 = call i32 @read_file(i8* %1, i8** %3, i64* %4)
%8 = load i8*, i8** %3
%9 = load i64, i64* %4
%10 = lshr i64 %9, 2
%11 = call i32 @drm_intel_decode_set_batch_pointer(%struct.drm_intel_decode* %0, i8* %8, i32 305135616, i64 %10)
%12 = load i32, i32* @stdout
%13 = call i32 @drm_intel_decode_set_output_file(%struct.drm_intel_decode* %0, i32 %12)
%14 = call i32 @drm_intel_decode(%struct.drm_intel_decode* %0)
ret void
}