#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*/ flashrom_program_byte_z180dma(int /*<<< orphan*/,
                                                 int /*<<< orphan*/);
void flashrom_block_write_z180dma(unsigned long address, unsigned char *buffer,
                                  unsigned int length) {
  unsigned long offset = address;
  while (length--) {
    flashrom_program_byte_z180dma(offset++, *(buffer++));
  }
}


x86 assembly (clang, -O0):
<flashrom_block_write_z180dma>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x14(%rbp)
cmp    $0x0,%eax
je     116c <flashrom_block_write_z180dma+0x5c>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
mov    %eax,%edi
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movzbl (%rax),%esi
call   1030 <flashrom_program_byte_z180dma@plt>
jmp    112b <flashrom_block_write_z180dma+0x1b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<flashrom_block_write_z180dma>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %edx,%edx
je     1147 <flashrom_block_write_z180dma+0x37>
mov    %rsi,%r14
mov    %rdi,%r15
mov    %edx,%r12d
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
lea    (%r15,%rbx,1),%edi
movzbl (%r14,%rbx,1),%esi
call   1030 <flashrom_program_byte_z180dma@plt>
add    $0x1,%rbx
cmp    %ebx,%r12d
jne    1130 <flashrom_block_write_z180dma+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @flashrom_block_write_z180dma(i64 %0, i8* %1, i32 %2) {
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i64
store i64 %0, i64* %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%8 = load i64, i64* %4
store i64 %8, i64* %7
br label %9
9: ; preds = %13, %3
%10 = load i32, i32* %6
%11 = add i32 %10, -1
store i32 %11, i32* %6
%12 = icmp ne i32 %10, 0
br i1 %12, label %13, label %22
13: ; preds = %9
%14 = load i64, i64* %7
%15 = add i64 %14, 1
store i64 %15, i64* %7
%16 = trunc i64 %14 to i32
%17 = load i8*, i8** %5
%18 = getelementptr inbounds i8, i8* %17, i32 1
store i8* %18, i8** %5
%19 = load i8, i8* %17
%20 = zext i8 %19 to i32
%21 = call i32 @flashrom_program_byte_z180dma(i32 %16, i32 %20)
br label %9
22: ; preds = %9
ret void
}

LLVM IR (-O2):
define void @flashrom_block_write_z180dma(i64 %0, i8* nocapture %1, i32 %2) {
%4 = icmp eq i32 %2, 0
br i1 %4, label %17, label %5
5: ; preds = %3, %5
%6 = phi i64 [ %10, %5 ], [ %0, %3 ]
%7 = phi i32 [ %9, %5 ], [ %2, %3 ]
%8 = phi i8* [ %12, %5 ], [ %1, %3 ]
%9 = add i32 %7, -1
%10 = add i64 %6, 1
%11 = trunc i64 %6 to i32
%12 = getelementptr inbounds i8, i8* %8, i64 1
%13 = load i8, i8* %8
%14 = zext i8 %13 to i32
%15 = tail call i32 @flashrom_program_byte_z180dma(i32 %11, i32 %14)
%16 = icmp eq i32 %9, 0
br i1 %16, label %17, label %5
17: ; preds = %5, %3
ret void
}