#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 */

/* Variables and functions */
int /*<<< orphan*/ OS_disable_interrupts(unsigned long *);
int /*<<< orphan*/ OS_enable_interrupts(unsigned long);
int dma_start(unsigned long, unsigned long, int, int);
int blender_block_read_start(unsigned long address, unsigned long length,
                             int transfer_size_8bit) {
  int err;
  unsigned long ie;
  if (length > (4096 * 16))
    return 0x1000;
  OS_disable_interrupts(&ie);
  err = dma_start(address, length, 1, transfer_size_8bit);
  OS_enable_interrupts(ie);
  return err;
}


x86 assembly (clang, -O0):
<blender_block_read_start>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
cmpq   $0x10000,-0x18(%rbp)
jbe    115d <blender_block_read_start+0x2d>
movl   $0x1000,-0x4(%rbp)
jmp    118d <blender_block_read_start+0x5d>
lea    -0x28(%rbp),%rdi
call   1050 <OS_disable_interrupts@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%ecx
mov    $0x1,%edx
call   1040 <dma_start@plt>
mov    %eax,-0x20(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <OS_enable_interrupts@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<blender_block_read_start>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x1000,%ebp
cmp    $0x10000,%rsi
ja     1174 <blender_block_read_start+0x44>
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %rdi,%r15
mov    %rsp,%rdi
call   1050 <OS_disable_interrupts@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
mov    %r14d,%ecx
call   1040 <dma_start@plt>
mov    %eax,%ebp
mov    (%rsp),%rdi
call   1030 <OS_enable_interrupts@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @blender_block_read_start(i64 %0, i64 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i64
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
%9 = alloca i64
store i64 %0, i64* %5
store i64 %1, i64* %6
store i32 %2, i32* %7
%10 = load i64, i64* %6
%11 = icmp ugt i64 %10, 65536
br i1 %11, label %12, label %13
12: ; preds = %3
store i32 4096, i32* %4
br label %22
13: ; preds = %3
%14 = call i32 @OS_disable_interrupts(i64* %9)
%15 = load i64, i64* %5
%16 = load i64, i64* %6
%17 = load i32, i32* %7
%18 = call i32 @dma_start(i64 %15, i64 %16, i32 1, i32 %17)
store i32 %18, i32* %8
%19 = load i64, i64* %9
%20 = call i32 @OS_enable_interrupts(i64 %19)
%21 = load i32, i32* %8
store i32 %21, i32* %4
br label %22
22: ; preds = %13, %12
%23 = load i32, i32* %4
ret i32 %23
}

LLVM IR (-O2):
define i32 @blender_block_read_start(i64 %0, i64 %1, i32 %2) {
%4 = alloca i64
%5 = bitcast i64* %4 to i8*
%6 = icmp ugt i64 %1, 65536
br i1 %6, label %12, label %7
7: ; preds = %3
%8 = call i32 @OS_disable_interrupts(i64* %4)
%9 = call i32 @dma_start(i64 %0, i64 %1, i32 1, i32 %2)
%10 = load i64, i64* %4
%11 = call i32 @OS_enable_interrupts(i64 %10)
br label %12
12: ; preds = %3, %7
%13 = phi i32 [ %9, %7 ], [ 4096, %3 ]
ret i32 %13
}