#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 lowl_pci_handle {
  int dummy;
};
typedef int /*<<< orphan*/ off_t;

/* Variables and functions */
void *lowl_pci_get_words(struct lowl_pci_handle *const, void *const,
                         size_t const, int const, int /*<<< orphan*/ const);
int /*<<< orphan*/ memmove(void *const, void const *const, size_t const);
bool lowl_pci_read_words(struct lowl_pci_handle *const lph, void *const buf,
                         const size_t words, const int bar,
                         const off_t offset) {
  const void *const p = lowl_pci_get_words(lph, buf, words, bar, offset);
  if (!p)
    return false;
  if (buf != p)
    memmove(buf, p, words * 4);
  return true;
}


x86 assembly (clang, -O0):
<lowl_pci_read_words>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8d,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%r8d
call   1030 <lowl_pci_get_words@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    116e <lowl_pci_read_words+0x4e>
movl   $0x0,-0x4(%rbp)
jmp    1198 <lowl_pci_read_words+0x78>
mov    -0x18(%rbp),%rax
cmp    -0x30(%rbp),%rax
je     1191 <lowl_pci_read_words+0x71>
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x20(%rbp),%rdx
shl    $0x2,%rdx
call   1040 <memmove@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lowl_pci_read_words>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%rbx
call   1030 <lowl_pci_get_words@plt>
test   %rax,%rax
je     1152 <lowl_pci_read_words+0x32>
mov    $0x1,%ebp
cmp    %rbx,%rax
je     1154 <lowl_pci_read_words+0x34>
shl    $0x2,%r14
mov    %rbx,%rdi
mov    %rax,%rsi
mov    %r14,%rdx
call   1040 <memmove@plt>
jmp    1154 <lowl_pci_read_words+0x34>
xor    %ebp,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.lowl_pci_handle = type { i32 }
define i32 @lowl_pci_read_words(%struct.lowl_pci_handle* %0, i8* %1, i64 %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca %struct.lowl_pci_handle*
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
store %struct.lowl_pci_handle* %0, %struct.lowl_pci_handle** %7
store i8* %1, i8** %8
store i64 %2, i64* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
%13 = load %struct.lowl_pci_handle*, %struct.lowl_pci_handle** %7
%14 = load i8*, i8** %8
%15 = load i64, i64* %9
%16 = load i32, i32* %10
%17 = load i32, i32* %11
%18 = call i8* @lowl_pci_get_words(%struct.lowl_pci_handle* %13, i8* %14, i64 %15, i32 %16, i32 %17)
store i8* %18, i8** %12
%19 = load i8*, i8** %12
%20 = icmp ne i8* %19, null
br i1 %20, label %22, label %21
21: ; preds = %5
store i32 0, i32* %6
br label %33
22: ; preds = %5
%23 = load i8*, i8** %8
%24 = load i8*, i8** %12
%25 = icmp ne i8* %23, %24
br i1 %25, label %26, label %32
26: ; preds = %22
%27 = load i8*, i8** %8
%28 = load i8*, i8** %12
%29 = load i64, i64* %9
%30 = mul i64 %29, 4
%31 = call i32 @memmove(i8* %27, i8* %28, i64 %30)
br label %32
32: ; preds = %26, %22
store i32 1, i32* %6
br label %33
33: ; preds = %32, %21
%34 = load i32, i32* %6
ret i32 %34
}

LLVM IR (-O2):
%struct.lowl_pci_handle = type { i32 }
define i32 @lowl_pci_read_words(%struct.lowl_pci_handle* %0, i8* %1, i64 %2, i32 %3, i32 %4) {
%6 = tail call i8* @lowl_pci_get_words(%struct.lowl_pci_handle* %0, i8* %1, i64 %2, i32 %3, i32 %4)
%7 = icmp eq i8* %6, null
br i1 %7, label %13, label %8
8: ; preds = %5
%9 = icmp eq i8* %6, %1
br i1 %9, label %13, label %10
10: ; preds = %8
%11 = shl i64 %2, 2
%12 = tail call i32 @memmove(i8* %1, i8* %6, i64 %11)
br label %13
13: ; preds = %8, %10, %5
%14 = phi i32 [ 0, %5 ], [ 1, %10 ], [ 1, %8 ]
ret i32 %14
}