#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*/ pci_write_config_dword(struct pci_dev *, int, int);
void nonll_dma_config(struct pci_dev *pdev, unsigned int chn_num,
                      unsigned int w_r, unsigned int sz_byte, unsigned int sar,
                      unsigned int dar) {
  if (w_r) {
    pci_write_config_dword(pdev, ((0x0 + 0x700) + 0x29c), 0x1);
    pci_write_config_dword(pdev, ((0x0 + 0x700) + 0x36c),
                           ((w_r << 31) + chn_num));
    pci_write_config_dword(pdev, ((0x0 + 0x700) + 0x2a8), 0x8421);
    pci_write_config_dword(pdev, ((0x0 + 0x700) + 0x318), 0x0);
    pci_write_config_dword(pdev, ((0x0 + 0x700) + 0x370),
                           ((0x1 << 4) + (0x1 << 3)));
    pci_write_config_dword(pdev, ((0x0 + 0x700) + 0x378), sz_byte);
    pci_write_config_dword(pdev, ((0x0 + 0x700) + 0x37c), sar);
    pci_write_config_dword(pdev, ((0x0 + 0x700) + 0x380), 0x0);
    pci_write_config_dword(pdev, ((0x0 + 0x700) + 0x384), dar);
    pci_write_config_dword(pdev, ((0x0 + 0x700) + 0x388), 0x0);
  } else {
    pci_write_config_dword(pdev, ((0x0 + 0x700) + 0x27c), 0x1);
    pci_write_config_dword(pdev, ((0x0 + 0x700) + 0x36c),
                           ((w_r << 31) + chn_num));
    pci_write_config_dword(pdev, ((0x0 + 0x700) + 0x288), 0x8421);
    pci_write_config_dword(pdev, ((0x0 + 0x700) + 0x2c4), 0x0);
    pci_write_config_dword(pdev, ((0x0 + 0x700) + 0x370),
                           ((0x1 << 4) + (0x1 << 3)));
    pci_write_config_dword(pdev, ((0x0 + 0x700) + 0x378), sz_byte);
    pci_write_config_dword(pdev, ((0x0 + 0x700) + 0x37c), sar);
    pci_write_config_dword(pdev, ((0x0 + 0x700) + 0x380), 0x0);
    pci_write_config_dword(pdev, ((0x0 + 0x700) + 0x384), dar);
    pci_write_config_dword(pdev, ((0x0 + 0x700) + 0x388), 0x0);
  }
}


x86 assembly (clang, -O0):
<nonll_dma_config>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    %r9d,-0x1c(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     11ef <nonll_dma_config+0xdf>
mov    -0x8(%rbp),%rdi
mov    $0x99c,%esi
mov    $0x1,%edx
call   1030 <pci_write_config_dword@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%edx
shl    $0x1f,%edx
add    -0xc(%rbp),%edx
mov    $0xa6c,%esi
call   1030 <pci_write_config_dword@plt>
mov    -0x8(%rbp),%rdi
mov    $0x9a8,%esi
mov    $0x8421,%edx
call   1030 <pci_write_config_dword@plt>
mov    -0x8(%rbp),%rdi
mov    $0xa18,%esi
xor    %edx,%edx
call   1030 <pci_write_config_dword@plt>
mov    -0x8(%rbp),%rdi
mov    $0xa70,%esi
mov    $0x18,%edx
call   1030 <pci_write_config_dword@plt>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    $0xa78,%esi
call   1030 <pci_write_config_dword@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%edx
mov    $0xa7c,%esi
call   1030 <pci_write_config_dword@plt>
mov    -0x8(%rbp),%rdi
mov    $0xa80,%esi
xor    %edx,%edx
call   1030 <pci_write_config_dword@plt>
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%edx
mov    $0xa84,%esi
call   1030 <pci_write_config_dword@plt>
mov    -0x8(%rbp),%rdi
mov    $0xa88,%esi
xor    %edx,%edx
call   1030 <pci_write_config_dword@plt>
jmp    12a2 <nonll_dma_config+0x192>
mov    -0x8(%rbp),%rdi
mov    $0x97c,%esi
mov    $0x1,%edx
call   1030 <pci_write_config_dword@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%edx
shl    $0x1f,%edx
add    -0xc(%rbp),%edx
mov    $0xa6c,%esi
call   1030 <pci_write_config_dword@plt>
mov    -0x8(%rbp),%rdi
mov    $0x988,%esi
mov    $0x8421,%edx
call   1030 <pci_write_config_dword@plt>
mov    -0x8(%rbp),%rdi
mov    $0x9c4,%esi
xor    %edx,%edx
call   1030 <pci_write_config_dword@plt>
mov    -0x8(%rbp),%rdi
mov    $0xa70,%esi
mov    $0x18,%edx
call   1030 <pci_write_config_dword@plt>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    $0xa78,%esi
call   1030 <pci_write_config_dword@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%edx
mov    $0xa7c,%esi
call   1030 <pci_write_config_dword@plt>
mov    -0x8(%rbp),%rdi
mov    $0xa80,%esi
xor    %edx,%edx
call   1030 <pci_write_config_dword@plt>
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%edx
mov    $0xa84,%esi
call   1030 <pci_write_config_dword@plt>
mov    -0x8(%rbp),%rdi
mov    $0xa88,%esi
xor    %edx,%edx
call   1030 <pci_write_config_dword@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nonll_dma_config>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,0x4(%rsp)
mov    %r8d,(%rsp)
mov    %ecx,%r12d
mov    %esi,%r15d
mov    %rdi,%rbx
test   %edx,%edx
je     1159 <nonll_dma_config+0x49>
mov    %edx,%ebp
mov    %rbx,%rdi
mov    $0x99c,%esi
mov    $0x1,%edx
call   1030 <pci_write_config_dword@plt>
shl    $0x1f,%ebp
add    %ebp,%r15d
mov    $0xa18,%r13d
mov    $0x9a8,%r14d
jmp    1177 <nonll_dma_config+0x67>
mov    %rbx,%rdi
mov    $0x97c,%esi
mov    $0x1,%edx
call   1030 <pci_write_config_dword@plt>
mov    $0x9c4,%r13d
mov    $0x988,%r14d
mov    %rbx,%rdi
mov    $0xa6c,%esi
mov    %r15d,%edx
call   1030 <pci_write_config_dword@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
mov    $0x8421,%edx
call   1030 <pci_write_config_dword@plt>
mov    %rbx,%rdi
mov    %r13d,%esi
xor    %edx,%edx
call   1030 <pci_write_config_dword@plt>
mov    %rbx,%rdi
mov    $0xa70,%esi
mov    $0x18,%edx
call   1030 <pci_write_config_dword@plt>
mov    %rbx,%rdi
mov    $0xa78,%esi
mov    %r12d,%edx
call   1030 <pci_write_config_dword@plt>
mov    %rbx,%rdi
mov    $0xa7c,%esi
mov    (%rsp),%edx
call   1030 <pci_write_config_dword@plt>
mov    %rbx,%rdi
mov    $0xa80,%esi
xor    %edx,%edx
call   1030 <pci_write_config_dword@plt>
mov    %rbx,%rdi
mov    $0xa84,%esi
mov    0x4(%rsp),%edx
call   1030 <pci_write_config_dword@plt>
mov    %rbx,%rdi
mov    $0xa88,%esi
xor    %edx,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <pci_write_config_dword@plt>

LLVM IR (-O0):
%struct.pci_dev = type { i32 }
define void @nonll_dma_config(%struct.pci_dev* %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca %struct.pci_dev*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store %struct.pci_dev* %0, %struct.pci_dev** %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i32 %5, i32* %12
%13 = load i32, i32* %9
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %43
15: ; preds = %6
%16 = load %struct.pci_dev*, %struct.pci_dev** %7
%17 = call i32 @pci_write_config_dword(%struct.pci_dev* %16, i32 2460, i32 1)
%18 = load %struct.pci_dev*, %struct.pci_dev** %7
%19 = load i32, i32* %9
%20 = shl i32 %19, 31
%21 = load i32, i32* %8
%22 = add i32 %20, %21
%23 = call i32 @pci_write_config_dword(%struct.pci_dev* %18, i32 2668, i32 %22)
%24 = load %struct.pci_dev*, %struct.pci_dev** %7
%25 = call i32 @pci_write_config_dword(%struct.pci_dev* %24, i32 2472, i32 33825)
%26 = load %struct.pci_dev*, %struct.pci_dev** %7
%27 = call i32 @pci_write_config_dword(%struct.pci_dev* %26, i32 2584, i32 0)
%28 = load %struct.pci_dev*, %struct.pci_dev** %7
%29 = call i32 @pci_write_config_dword(%struct.pci_dev* %28, i32 2672, i32 24)
%30 = load %struct.pci_dev*, %struct.pci_dev** %7
%31 = load i32, i32* %10
%32 = call i32 @pci_write_config_dword(%struct.pci_dev* %30, i32 2680, i32 %31)
%33 = load %struct.pci_dev*, %struct.pci_dev** %7
%34 = load i32, i32* %11
%35 = call i32 @pci_write_config_dword(%struct.pci_dev* %33, i32 2684, i32 %34)
%36 = load %struct.pci_dev*, %struct.pci_dev** %7
%37 = call i32 @pci_write_config_dword(%struct.pci_dev* %36, i32 2688, i32 0)
%38 = load %struct.pci_dev*, %struct.pci_dev** %7
%39 = load i32, i32* %12
%40 = call i32 @pci_write_config_dword(%struct.pci_dev* %38, i32 2692, i32 %39)
%41 = load %struct.pci_dev*, %struct.pci_dev** %7
%42 = call i32 @pci_write_config_dword(%struct.pci_dev* %41, i32 2696, i32 0)
br label %71
43: ; preds = %6
%44 = load %struct.pci_dev*, %struct.pci_dev** %7
%45 = call i32 @pci_write_config_dword(%struct.pci_dev* %44, i32 2428, i32 1)
%46 = load %struct.pci_dev*, %struct.pci_dev** %7
%47 = load i32, i32* %9
%48 = shl i32 %47, 31
%49 = load i32, i32* %8
%50 = add i32 %48, %49
%51 = call i32 @pci_write_config_dword(%struct.pci_dev* %46, i32 2668, i32 %50)
%52 = load %struct.pci_dev*, %struct.pci_dev** %7
%53 = call i32 @pci_write_config_dword(%struct.pci_dev* %52, i32 2440, i32 33825)
%54 = load %struct.pci_dev*, %struct.pci_dev** %7
%55 = call i32 @pci_write_config_dword(%struct.pci_dev* %54, i32 2500, i32 0)
%56 = load %struct.pci_dev*, %struct.pci_dev** %7
%57 = call i32 @pci_write_config_dword(%struct.pci_dev* %56, i32 2672, i32 24)
%58 = load %struct.pci_dev*, %struct.pci_dev** %7
%59 = load i32, i32* %10
%60 = call i32 @pci_write_config_dword(%struct.pci_dev* %58, i32 2680, i32 %59)
%61 = load %struct.pci_dev*, %struct.pci_dev** %7
%62 = load i32, i32* %11
%63 = call i32 @pci_write_config_dword(%struct.pci_dev* %61, i32 2684, i32 %62)
%64 = load %struct.pci_dev*, %struct.pci_dev** %7
%65 = call i32 @pci_write_config_dword(%struct.pci_dev* %64, i32 2688, i32 0)
%66 = load %struct.pci_dev*, %struct.pci_dev** %7
%67 = load i32, i32* %12
%68 = call i32 @pci_write_config_dword(%struct.pci_dev* %66, i32 2692, i32 %67)
%69 = load %struct.pci_dev*, %struct.pci_dev** %7
%70 = call i32 @pci_write_config_dword(%struct.pci_dev* %69, i32 2696, i32 0)
br label %71
71: ; preds = %43, %15
ret void
}

LLVM IR (-O2):
%struct.pci_dev = type { i32 }
define void @nonll_dma_config(%struct.pci_dev* %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = icmp eq i32 %2, 0
br i1 %7, label %12, label %8
8: ; preds = %6
%9 = tail call i32 @pci_write_config_dword(%struct.pci_dev* %0, i32 2460, i32 1)
%10 = shl i32 %2, 31
%11 = add i32 %10, %1
br label %14
12: ; preds = %6
%13 = tail call i32 @pci_write_config_dword(%struct.pci_dev* %0, i32 2428, i32 1)
br label %14
14: ; preds = %12, %8
%15 = phi i32 [ %1, %12 ], [ %11, %8 ]
%16 = phi i32 [ 2440, %12 ], [ 2472, %8 ]
%17 = phi i32 [ 2500, %12 ], [ 2584, %8 ]
%18 = tail call i32 @pci_write_config_dword(%struct.pci_dev* %0, i32 2668, i32 %15)
%19 = tail call i32 @pci_write_config_dword(%struct.pci_dev* %0, i32 %16, i32 33825)
%20 = tail call i32 @pci_write_config_dword(%struct.pci_dev* %0, i32 %17, i32 0)
%21 = tail call i32 @pci_write_config_dword(%struct.pci_dev* %0, i32 2672, i32 24)
%22 = tail call i32 @pci_write_config_dword(%struct.pci_dev* %0, i32 2680, i32 %3)
%23 = tail call i32 @pci_write_config_dword(%struct.pci_dev* %0, i32 2684, i32 %4)
%24 = tail call i32 @pci_write_config_dword(%struct.pci_dev* %0, i32 2688, i32 0)
%25 = tail call i32 @pci_write_config_dword(%struct.pci_dev* %0, i32 2692, i32 %5)
%26 = tail call i32 @pci_write_config_dword(%struct.pci_dev* %0, i32 2696, i32 0)
ret void
}