#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 */
typedef int /*<<< orphan*/ uint32_t;

/* Variables and functions */
int /*<<< orphan*/ O_WRONLY;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ close(int);
int lseek(int, int, int /*<<< orphan*/);
int open(char *, int /*<<< orphan*/);
int write(int, int /*<<< orphan*/ *, int);
void write_pci_conf(char *path, int off, uint32_t newV) {
  int fd = open(path, O_WRONLY);
  assert(fd >= 0);
  assert(lseek(fd, off, SEEK_SET) == 0x150);
  assert(write(fd, &newV, 4) == 4);
  close(fd);
}


x86 assembly (clang, -O0):
<write_pci_conf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2e63(%rip),%rax
mov    (%rax),%esi
call   1070 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
setge  %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x14(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    0x2e4b(%rip),%rax
mov    (%rax),%edx
call   1040 <lseek@plt>
cmp    $0x150,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x14(%rbp),%edi
lea    -0x10(%rbp),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
cmp    $0x4,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x14(%rbp),%edi
call   1050 <close@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_pci_conf>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %edx,0x4(%rsp)
mov    0x2e70(%rip),%rax
mov    (%rax),%esi
call   1070 <open@plt>
mov    %eax,%ebx
mov    %eax,%edi
not    %edi
shr    $0x1f,%edi
call   1060 <assert@plt>
mov    0x2e64(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
mov    %ebp,%esi
call   1040 <lseek@plt>
xor    %edi,%edi
cmp    $0x150,%eax
sete   %dil
call   1060 <assert@plt>
lea    0x4(%rsp),%rsi
mov    %ebx,%edi
mov    $0x4,%edx
call   1030 <write@plt>
xor    %edi,%edi
cmp    $0x4,%eax
sete   %dil
call   1060 <assert@plt>
mov    %ebx,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <close@plt>

LLVM IR (-O0):
@O_WRONLY = global i32 0
@SEEK_SET = global i32 0
define void @write_pci_conf(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i8*, i8** %4
%9 = load i32, i32* @O_WRONLY
%10 = call i32 @open(i8* %8, i32 %9)
store i32 %10, i32* %7
%11 = load i32, i32* %7
%12 = icmp sge i32 %11, 0
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = load i32, i32* %7
%16 = load i32, i32* %5
%17 = load i32, i32* @SEEK_SET
%18 = call i32 @lseek(i32 %15, i32 %16, i32 %17)
%19 = icmp eq i32 %18, 336
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
%22 = load i32, i32* %7
%23 = call i32 @write(i32 %22, i32* %6, i32 4)
%24 = icmp eq i32 %23, 4
%25 = zext i1 %24 to i32
%26 = call i32 @assert(i32 %25)
%27 = load i32, i32* %7
%28 = call i32 @close(i32 %27)
ret void
}

LLVM IR (-O2):
@O_WRONLY = global i32 0
@SEEK_SET = global i32 0
define void @write_pci_conf(i8* nocapture %0, i32 %1, i32 %2) {
%4 = alloca i32
store i32 %2, i32* %4
%5 = load i32, i32* @O_WRONLY
%6 = tail call i32 @open(i8* %0, i32 %5)
%7 = xor i32 %6, -1
%8 = lshr i32 %7, 31
%9 = tail call i32 @assert(i32 %8)
%10 = load i32, i32* @SEEK_SET
%11 = tail call i32 @lseek(i32 %6, i32 %1, i32 %10)
%12 = icmp eq i32 %11, 336
%13 = zext i1 %12 to i32
%14 = tail call i32 @assert(i32 %13)
%15 = call i32 @write(i32 %6, i32* %4, i32 4)
%16 = icmp eq i32 %15, 4
%17 = zext i1 %16 to i32
%18 = tail call i32 @assert(i32 %17)
%19 = tail call i32 @close(i32 %6)
ret void
}