void pnx833x_gpio_write(unsigned int val, unsigned int pin) {
  if (pin < 32) {
    if (val)
      do {
        ((*((volatile unsigned long *)((0xa0000000ul + 0x17E00000ul) +
                                       0xF004))) |= (1 << (pin)));
      } while (0);
    else
      do {
        ((*((volatile unsigned long *)((0xa0000000ul + 0x17E00000ul) +
                                       0xF004))) &= ~(1 << (pin)));
      } while (0);
  } else {
    if (val)
      do {
        ((*((volatile unsigned long *)((0xa0000000ul + 0x17E00000ul) +
                                       0xF060))) |= (1 << (pin & 31)));
      } while (0);
    else
      do {
        ((*((volatile unsigned long *)((0xa0000000ul + 0x17E00000ul) +
                                       0xF060))) &= ~(1 << (pin & 31)));
      } while (0);
  }
}


x86 assembly (clang, -O0):
<pnx833x_gpio_write>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0x20,-0x8(%rbp)
jae    1178 <pnx833x_gpio_write+0x78>
cmpl   $0x0,-0x4(%rbp)
je     1147 <pnx833x_gpio_write+0x47>
jmp    1123 <pnx833x_gpio_write+0x23>
mov    -0x8(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
cltq
mov    $0xb7e0f004,%ecx
mov    (%rcx),%rcx
or     %rax,%rcx
mov    $0xb7e0f004,%eax
mov    %rcx,(%rax)
jmp    1173 <pnx833x_gpio_write+0x73>
jmp    114c <pnx833x_gpio_write+0x4c>
mov    -0x8(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
xor    $0xffffffff,%eax
cltq
mov    $0xb7e0f004,%ecx
mov    (%rcx),%rcx
and    %rax,%rcx
mov    $0xb7e0f004,%eax
mov    %rcx,(%rax)
jmp    1173 <pnx833x_gpio_write+0x73>
jmp    11e2 <pnx833x_gpio_write+0xe2>
cmpl   $0x0,-0x4(%rbp)
je     11ae <pnx833x_gpio_write+0xae>
jmp    1187 <pnx833x_gpio_write+0x87>
mov    -0x8(%rbp),%ecx
and    $0x1f,%ecx
mov    $0x1,%eax
shl    %cl,%eax
cltq
mov    $0xb7e0f060,%ecx
mov    (%rcx),%rcx
or     %rax,%rcx
mov    $0xb7e0f060,%eax
mov    %rcx,(%rax)
jmp    11dd <pnx833x_gpio_write+0xdd>
jmp    11b3 <pnx833x_gpio_write+0xb3>
mov    -0x8(%rbp),%ecx
and    $0x1f,%ecx
mov    $0x1,%eax
shl    %cl,%eax
xor    $0xffffffff,%eax
cltq
mov    $0xb7e0f060,%ecx
mov    (%rcx),%rcx
and    %rax,%rcx
mov    $0xb7e0f060,%eax
mov    %rcx,(%rax)
jmp    11dd <pnx833x_gpio_write+0xdd>
jmp    11e2 <pnx833x_gpio_write+0xe2>
pop    %rbp
ret

x86 assembly (clang, -O2):
<pnx833x_gpio_write>:
mov    %esi,%ecx
mov    $0xb7e0f004,%eax
mov    $0x1,%edx
shl    %cl,%edx
cmp    $0x1f,%esi
ja     111e <pnx833x_gpio_write+0x1e>
test   %edi,%edi
je     112a <pnx833x_gpio_write+0x2a>
movslq %edx,%rcx
or     %rcx,(%rax)
ret
test   %edi,%edi
je     1133 <pnx833x_gpio_write+0x33>
movslq %edx,%rcx
or     %rcx,0x5c(%rax)
ret
not    %edx
movslq %edx,%rcx
and    %rcx,(%rax)
ret
not    %edx
movslq %edx,%rcx
and    %rcx,0x5c(%rax)
ret

LLVM IR (-O0):
define void @pnx833x_gpio_write(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = icmp ult i32 %5, 32
br i1 %6, label %7, label %28
7: ; preds = %2
%8 = load i32, i32* %3
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %18
10: ; preds = %7
br label %11
11: ; preds = %10
%12 = load i32, i32* %4
%13 = shl i32 1, %12
%14 = sext i32 %13 to i64
%15 = load volatile i64, i64* inttoptr (i64 3084972036 to i64*)
%16 = or i64 %15, %14
store volatile i64 %16, i64* inttoptr (i64 3084972036 to i64*)
br label %17
17: ; preds = %11
br label %27
18: ; preds = %7
br label %19
19: ; preds = %18
%20 = load i32, i32* %4
%21 = shl i32 1, %20
%22 = xor i32 %21, -1
%23 = sext i32 %22 to i64
%24 = load volatile i64, i64* inttoptr (i64 3084972036 to i64*)
%25 = and i64 %24, %23
store volatile i64 %25, i64* inttoptr (i64 3084972036 to i64*)
br label %26
26: ; preds = %19
br label %27
27: ; preds = %26, %17
br label %51
28: ; preds = %2
%29 = load i32, i32* %3
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %40
31: ; preds = %28
br label %32
32: ; preds = %31
%33 = load i32, i32* %4
%34 = and i32 %33, 31
%35 = shl i32 1, %34
%36 = sext i32 %35 to i64
%37 = load volatile i64, i64* inttoptr (i64 3084972128 to i64*)
%38 = or i64 %37, %36
store volatile i64 %38, i64* inttoptr (i64 3084972128 to i64*)
br label %39
39: ; preds = %32
br label %50
40: ; preds = %28
br label %41
41: ; preds = %40
%42 = load i32, i32* %4
%43 = and i32 %42, 31
%44 = shl i32 1, %43
%45 = xor i32 %44, -1
%46 = sext i32 %45 to i64
%47 = load volatile i64, i64* inttoptr (i64 3084972128 to i64*)
%48 = and i64 %47, %46
store volatile i64 %48, i64* inttoptr (i64 3084972128 to i64*)
br label %49
49: ; preds = %41
br label %50
50: ; preds = %49, %39
br label %51
51: ; preds = %50, %27
ret void
}

LLVM IR (-O2):
define void @pnx833x_gpio_write(i32 %0, i32 %1) {
%3 = icmp ult i32 %1, 32
%4 = icmp eq i32 %0, 0
br i1 %3, label %5, label %16
5: ; preds = %2
%6 = shl nuw i32 1, %1
br i1 %4, label %11, label %7
7: ; preds = %5
%8 = sext i32 %6 to i64
%9 = load volatile i64, i64* inttoptr (i64 3084972036 to i64*)
%10 = or i64 %9, %8
store volatile i64 %10, i64* inttoptr (i64 3084972036 to i64*)
br label %28
11: ; preds = %5
%12 = xor i32 %6, -1
%13 = sext i32 %12 to i64
%14 = load volatile i64, i64* inttoptr (i64 3084972036 to i64*)
%15 = and i64 %14, %13
store volatile i64 %15, i64* inttoptr (i64 3084972036 to i64*)
br label %28
16: ; preds = %2
%17 = and i32 %1, 31
%18 = shl nuw i32 1, %17
br i1 %4, label %23, label %19
19: ; preds = %16
%20 = sext i32 %18 to i64
%21 = load volatile i64, i64* inttoptr (i64 3084972128 to i64*)
%22 = or i64 %21, %20
store volatile i64 %22, i64* inttoptr (i64 3084972128 to i64*)
br label %28
23: ; preds = %16
%24 = xor i32 %18, -1
%25 = sext i32 %24 to i64
%26 = load volatile i64, i64* inttoptr (i64 3084972128 to i64*)
%27 = and i64 %26, %25
store volatile i64 %27, i64* inttoptr (i64 3084972128 to i64*)
br label %28
28: ; preds = %19, %23, %7, %11
ret void
}