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

/* Variables and functions */
int /*<<< orphan*/ dma_com(struct pci_dev *, int /*<<< orphan*/, int);
int /*<<< orphan*/ dma_doorbell(struct pci_dev *, int /*<<< orphan*/, int);
int /*<<< orphan*/ dma_imwr(struct pci_dev *, int /*<<< orphan*/, int, int,
                            int /*<<< orphan*/, int);
int /*<<< orphan*/ nonll_dma_config(struct pci_dev *, int /*<<< orphan*/, int,
                                    int, int, int);
int /*<<< orphan*/ pci_write_config_dword(struct pci_dev *, int, int);
void pcie_dma_rw(struct pci_dev *pdev) {
  pci_write_config_dword(pdev, ((0x0 + 0x700) + 0x10c), 0x00100000);
  pci_write_config_dword(pdev, ((0x0 + 0x700) + 0x10), 0x80);
  pci_write_config_dword(pdev, ((0x0 + 0x70) + 0x8), (0x1 << 5));
  nonll_dma_config(pdev, 0, 1, 0x200, 0x8e6ff000, 0x00070000 + 0x200);
  dma_imwr(pdev, 0, 1, 0x8e6ff000, 0, 0x0);
  dma_doorbell(pdev, 0, 1);
  nonll_dma_config(pdev, 0, 0, 0x200, 0x00070000 + 0x200, 0x8e6ff000);
  dma_imwr(pdev, 0, 0, 0x8e6ff000, 0, 0x1);
  dma_doorbell(pdev, 0, 0);
  dma_com(pdev, 0, 1);
  dma_com(pdev, 0, 0);
}


x86 assembly (clang, -O0):
<pcie_dma_rw>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x80c,%esi
mov    $0x100000,%edx
call   1050 <pci_write_config_dword@plt>
mov    -0x8(%rbp),%rdi
mov    $0x710,%esi
mov    $0x80,%edx
call   1050 <pci_write_config_dword@plt>
mov    -0x8(%rbp),%rdi
mov    $0x78,%esi
mov    $0x20,%edx
call   1050 <pci_write_config_dword@plt>
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
mov    $0x200,%ecx
mov    $0x8e6ff000,%r8d
mov    $0x70200,%r9d
call   1070 <nonll_dma_config@plt>
mov    -0x8(%rbp),%rdi
xor    %r9d,%r9d
mov    $0x1,%edx
mov    $0x8e6ff000,%ecx
mov    %r9d,%esi
mov    %r9d,%r8d
call   1030 <dma_imwr@plt>
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1060 <dma_doorbell@plt>
mov    -0x8(%rbp),%rdi
xor    %edx,%edx
mov    $0x200,%ecx
mov    $0x70200,%r8d
mov    $0x8e6ff000,%r9d
mov    %edx,%esi
call   1070 <nonll_dma_config@plt>
mov    -0x8(%rbp),%rdi
xor    %r8d,%r8d
mov    $0x8e6ff000,%ecx
mov    $0x1,%r9d
mov    %r8d,%esi
mov    %r8d,%edx
call   1030 <dma_imwr@plt>
mov    -0x8(%rbp),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   1060 <dma_doorbell@plt>
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1040 <dma_com@plt>
mov    -0x8(%rbp),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   1040 <dma_com@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pcie_dma_rw>:
push   %rbx
mov    %rdi,%rbx
mov    $0x80c,%esi
mov    $0x100000,%edx
call   1050 <pci_write_config_dword@plt>
mov    %rbx,%rdi
mov    $0x710,%esi
mov    $0x80,%edx
call   1050 <pci_write_config_dword@plt>
mov    %rbx,%rdi
mov    $0x78,%esi
mov    $0x20,%edx
call   1050 <pci_write_config_dword@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x1,%edx
mov    $0x200,%ecx
mov    $0x8e6ff000,%r8d
mov    $0x70200,%r9d
call   1070 <nonll_dma_config@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x1,%edx
mov    $0x8e6ff000,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1030 <dma_imwr@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1060 <dma_doorbell@plt>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
mov    $0x200,%ecx
mov    $0x70200,%r8d
mov    $0x8e6ff000,%r9d
call   1070 <nonll_dma_config@plt>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
mov    $0x8e6ff000,%ecx
xor    %r8d,%r8d
mov    $0x1,%r9d
call   1030 <dma_imwr@plt>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1060 <dma_doorbell@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1040 <dma_com@plt>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
pop    %rbx
jmp    1040 <dma_com@plt>

LLVM IR (-O0):
%struct.pci_dev = type { i32 }
define void @pcie_dma_rw(%struct.pci_dev* %0) {
%2 = alloca %struct.pci_dev*
store %struct.pci_dev* %0, %struct.pci_dev** %2
%3 = load %struct.pci_dev*, %struct.pci_dev** %2
%4 = call i32 @pci_write_config_dword(%struct.pci_dev* %3, i32 2060, i32 1048576)
%5 = load %struct.pci_dev*, %struct.pci_dev** %2
%6 = call i32 @pci_write_config_dword(%struct.pci_dev* %5, i32 1808, i32 128)
%7 = load %struct.pci_dev*, %struct.pci_dev** %2
%8 = call i32 @pci_write_config_dword(%struct.pci_dev* %7, i32 120, i32 32)
%9 = load %struct.pci_dev*, %struct.pci_dev** %2
%10 = call i32 @nonll_dma_config(%struct.pci_dev* %9, i32 0, i32 1, i32 512, i32 -1905266688, i32 459264)
%11 = load %struct.pci_dev*, %struct.pci_dev** %2
%12 = call i32 @dma_imwr(%struct.pci_dev* %11, i32 0, i32 1, i32 -1905266688, i32 0, i32 0)
%13 = load %struct.pci_dev*, %struct.pci_dev** %2
%14 = call i32 @dma_doorbell(%struct.pci_dev* %13, i32 0, i32 1)
%15 = load %struct.pci_dev*, %struct.pci_dev** %2
%16 = call i32 @nonll_dma_config(%struct.pci_dev* %15, i32 0, i32 0, i32 512, i32 459264, i32 -1905266688)
%17 = load %struct.pci_dev*, %struct.pci_dev** %2
%18 = call i32 @dma_imwr(%struct.pci_dev* %17, i32 0, i32 0, i32 -1905266688, i32 0, i32 1)
%19 = load %struct.pci_dev*, %struct.pci_dev** %2
%20 = call i32 @dma_doorbell(%struct.pci_dev* %19, i32 0, i32 0)
%21 = load %struct.pci_dev*, %struct.pci_dev** %2
%22 = call i32 @dma_com(%struct.pci_dev* %21, i32 0, i32 1)
%23 = load %struct.pci_dev*, %struct.pci_dev** %2
%24 = call i32 @dma_com(%struct.pci_dev* %23, i32 0, i32 0)
ret void
}

LLVM IR (-O2):
%struct.pci_dev = type { i32 }
define void @pcie_dma_rw(%struct.pci_dev* %0) {
%2 = tail call i32 @pci_write_config_dword(%struct.pci_dev* %0, i32 2060, i32 1048576)
%3 = tail call i32 @pci_write_config_dword(%struct.pci_dev* %0, i32 1808, i32 128)
%4 = tail call i32 @pci_write_config_dword(%struct.pci_dev* %0, i32 120, i32 32)
%5 = tail call i32 @nonll_dma_config(%struct.pci_dev* %0, i32 0, i32 1, i32 512, i32 -1905266688, i32 459264)
%6 = tail call i32 @dma_imwr(%struct.pci_dev* %0, i32 0, i32 1, i32 -1905266688, i32 0, i32 0)
%7 = tail call i32 @dma_doorbell(%struct.pci_dev* %0, i32 0, i32 1)
%8 = tail call i32 @nonll_dma_config(%struct.pci_dev* %0, i32 0, i32 0, i32 512, i32 459264, i32 -1905266688)
%9 = tail call i32 @dma_imwr(%struct.pci_dev* %0, i32 0, i32 0, i32 -1905266688, i32 0, i32 1)
%10 = tail call i32 @dma_doorbell(%struct.pci_dev* %0, i32 0, i32 0)
%11 = tail call i32 @dma_com(%struct.pci_dev* %0, i32 0, i32 1)
%12 = tail call i32 @dma_com(%struct.pci_dev* %0, i32 0, i32 0)
ret void
}