void GPMCWaitPinPolaritySelect(unsigned int baseAddr, unsigned int pin,
                               unsigned int polarity) {
  if (pin == (0)) {
    if (polarity == (1)) {
      (*((volatile unsigned int *)(baseAddr + (0x50)))) |= ((0x00000100u));
    } else if (polarity == (0)) {
      (*((volatile unsigned int *)(baseAddr + (0x50)))) &= (~(0x00000100u));
    }
  } else if (pin == (1)) {
    if (polarity == (1)) {
      (*((volatile unsigned int *)(baseAddr + (0x50)))) |= ((0x00000200u));
    } else if (polarity == (0)) {
      (*((volatile unsigned int *)(baseAddr + (0x50)))) &= (~(0x00000200u));
    }
  }
}


x86 assembly (clang, -O0):
<GPMCWaitPinPolaritySelect>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    115e <GPMCWaitPinPolaritySelect+0x5e>
cmpl   $0x1,-0xc(%rbp)
jne    1138 <GPMCWaitPinPolaritySelect+0x38>
mov    -0x4(%rbp),%eax
add    $0x50,%eax
mov    %eax,%eax
mov    (%rax),%ecx
or     $0x100,%ecx
mov    %ecx,(%rax)
jmp    1159 <GPMCWaitPinPolaritySelect+0x59>
cmpl   $0x0,-0xc(%rbp)
jne    1154 <GPMCWaitPinPolaritySelect+0x54>
mov    -0x4(%rbp),%eax
add    $0x50,%eax
mov    %eax,%eax
mov    (%rax),%ecx
and    $0xfffffeff,%ecx
mov    %ecx,(%rax)
jmp    1159 <GPMCWaitPinPolaritySelect+0x59>
jmp    11b4 <GPMCWaitPinPolaritySelect+0xb4>
cmpl   $0x1,-0x8(%rbp)
jne    11af <GPMCWaitPinPolaritySelect+0xaf>
cmpl   $0x1,-0xc(%rbp)
jne    1189 <GPMCWaitPinPolaritySelect+0x89>
mov    -0x4(%rbp),%eax
add    $0x50,%eax
mov    %eax,%eax
mov    (%rax),%ecx
or     $0x200,%ecx
mov    %ecx,(%rax)
jmp    11aa <GPMCWaitPinPolaritySelect+0xaa>
cmpl   $0x0,-0xc(%rbp)
jne    11a5 <GPMCWaitPinPolaritySelect+0xa5>
mov    -0x4(%rbp),%eax
add    $0x50,%eax
mov    %eax,%eax
mov    (%rax),%ecx
and    $0xfffffdff,%ecx
mov    %ecx,(%rax)
jmp    11aa <GPMCWaitPinPolaritySelect+0xaa>
jmp    11af <GPMCWaitPinPolaritySelect+0xaf>
jmp    11b4 <GPMCWaitPinPolaritySelect+0xb4>
pop    %rbp
ret

x86 assembly (clang, -O2):
<GPMCWaitPinPolaritySelect>:
cmp    $0x1,%esi
je     111c <GPMCWaitPinPolaritySelect+0x1c>
test   %esi,%esi
jne    1142 <GPMCWaitPinPolaritySelect+0x42>
test   %edx,%edx
je     112f <GPMCWaitPinPolaritySelect+0x2f>
cmp    $0x1,%edx
jne    1142 <GPMCWaitPinPolaritySelect+0x42>
add    $0x50,%edi
orl    $0x100,(%rdi)
ret
test   %edx,%edx
je     1139 <GPMCWaitPinPolaritySelect+0x39>
cmp    $0x1,%edx
jne    1142 <GPMCWaitPinPolaritySelect+0x42>
add    $0x50,%edi
orl    $0x200,(%rdi)
ret
add    $0x50,%edi
andl   $0xfffffeff,(%rdi)
ret
add    $0x50,%edi
andl   $0xfffffdff,(%rdi)
ret

LLVM IR (-O0):
define void @GPMCWaitPinPolaritySelect(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i32, i32* %5
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %31
9: ; preds = %3
%10 = load i32, i32* %6
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %19
12: ; preds = %9
%13 = load i32, i32* %4
%14 = add i32 %13, 80
%15 = zext i32 %14 to i64
%16 = inttoptr i64 %15 to i32*
%17 = load volatile i32, i32* %16
%18 = or i32 %17, 256
store volatile i32 %18, i32* %16
br label %30
19: ; preds = %9
%20 = load i32, i32* %6
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %29
22: ; preds = %19
%23 = load i32, i32* %4
%24 = add i32 %23, 80
%25 = zext i32 %24 to i64
%26 = inttoptr i64 %25 to i32*
%27 = load volatile i32, i32* %26
%28 = and i32 %27, -257
store volatile i32 %28, i32* %26
br label %29
29: ; preds = %22, %19
br label %30
30: ; preds = %29, %12
br label %57
31: ; preds = %3
%32 = load i32, i32* %5
%33 = icmp eq i32 %32, 1
br i1 %33, label %34, label %56
34: ; preds = %31
%35 = load i32, i32* %6
%36 = icmp eq i32 %35, 1
br i1 %36, label %37, label %44
37: ; preds = %34
%38 = load i32, i32* %4
%39 = add i32 %38, 80
%40 = zext i32 %39 to i64
%41 = inttoptr i64 %40 to i32*
%42 = load volatile i32, i32* %41
%43 = or i32 %42, 512
store volatile i32 %43, i32* %41
br label %55
44: ; preds = %34
%45 = load i32, i32* %6
%46 = icmp eq i32 %45, 0
br i1 %46, label %47, label %54
47: ; preds = %44
%48 = load i32, i32* %4
%49 = add i32 %48, 80
%50 = zext i32 %49 to i64
%51 = inttoptr i64 %50 to i32*
%52 = load volatile i32, i32* %51
%53 = and i32 %52, -513
store volatile i32 %53, i32* %51
br label %54
54: ; preds = %47, %44
br label %55
55: ; preds = %54, %37
br label %56
56: ; preds = %55, %31
br label %57
57: ; preds = %56, %30
ret void
}

LLVM IR (-O2):
define void @GPMCWaitPinPolaritySelect(i32 %0, i32 %1, i32 %2) {
switch i32 %1, label %30 [
i32 0, label %4
i32 1, label %17
]
4: ; preds = %3
switch i32 %2, label %30 [
i32 1, label %5
i32 0, label %11
]
5: ; preds = %4
%6 = add i32 %0, 80
%7 = zext i32 %6 to i64
%8 = inttoptr i64 %7 to i32*
%9 = load volatile i32, i32* %8
%10 = or i32 %9, 256
store volatile i32 %10, i32* %8
br label %30
11: ; preds = %4
%12 = add i32 %0, 80
%13 = zext i32 %12 to i64
%14 = inttoptr i64 %13 to i32*
%15 = load volatile i32, i32* %14
%16 = and i32 %15, -257
store volatile i32 %16, i32* %14
br label %30
17: ; preds = %3
switch i32 %2, label %30 [
i32 1, label %18
i32 0, label %24
]
18: ; preds = %17
%19 = add i32 %0, 80
%20 = zext i32 %19 to i64
%21 = inttoptr i64 %20 to i32*
%22 = load volatile i32, i32* %21
%23 = or i32 %22, 512
store volatile i32 %23, i32* %21
br label %30
24: ; preds = %17
%25 = add i32 %0, 80
%26 = zext i32 %25 to i64
%27 = inttoptr i64 %26 to i32*
%28 = load volatile i32, i32* %27
%29 = and i32 %28, -513
store volatile i32 %29, i32* %27
br label %30
30: ; preds = %17, %3, %4, %24, %18, %5, %11
ret void
}