int half_stereo_bond_action(int nParity, int bUnknown, int bIsotopic,
                            int vABParityUnknown) {
  int nAction;
  if (nParity == 0)
    return 0;
  if (nParity == vABParityUnknown)
    nParity = 1 | 0x20;
  if (nParity == -vABParityUnknown)
    nParity = 1 | 0x20 | 0x10;
  if (nParity < 0)
    nParity = ((nParity == -2) ? 1 : (-nParity)) | 0x10;
  else if (nParity == 2)
    nParity = 1;
  if (bUnknown)
    nParity |= 0x20;
  if (bIsotopic) {
    switch (nParity) {
    case 1:
    case 1 | 0x10:
      nAction = 6;
      break;
    case 1 | 0x20:
    case 4 | 0x20:
    case 1 | 0x20 | 0x10:
    case 4 | 0x20 | 0x10:
      nAction = vABParityUnknown;
      break;
    case 5:
    case 5 | 0x20:
      nAction = 0;
      break;
    case 4:
    case 4 | 0x10:
      nAction = 4;
      break;
    default:
      nAction = -1;
    }
  } else {
    switch (nParity) {
    case 1:
      nAction = 6;
      break;
    case 1 | 0x20:
    case 4 | 0x20:
      nAction = vABParityUnknown;
      break;
    case 4:
      nAction = 4;
      break;
    case 1 | 0x20 | 0x10:
    case 1 | 0x10:
    case 5:
    case 5 | 0x20:
    case 4 | 0x10:
    case 4 | 0x20 | 0x10:
      nAction = 0;
      break;
    default:
      nAction = -1;
    }
  }
  return nAction;
}


x86 assembly (clang, -O0):
<half_stereo_bond_action>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1126 <half_stereo_bond_action+0x26>
movl   $0x0,-0x4(%rbp)
jmp    1288 <half_stereo_bond_action+0x188>
mov    -0x8(%rbp),%eax
cmp    -0x14(%rbp),%eax
jne    1139 <half_stereo_bond_action+0x39>
movl   $0x21,-0x8(%rbp)
mov    -0x8(%rbp),%eax
xor    %ecx,%ecx
sub    -0x14(%rbp),%ecx
cmp    %ecx,%eax
jne    1150 <half_stereo_bond_action+0x50>
movl   $0x31,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    1187 <half_stereo_bond_action+0x87>
cmpl   $0xfffffffe,-0x8(%rbp)
jne    1171 <half_stereo_bond_action+0x71>
mov    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1179 <half_stereo_bond_action+0x79>
xor    %eax,%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
or     $0x10,%eax
mov    %eax,-0x8(%rbp)
jmp    119d <half_stereo_bond_action+0x9d>
cmpl   $0x2,-0x8(%rbp)
jne    1198 <half_stereo_bond_action+0x98>
movl   $0x1,-0x8(%rbp)
jmp    119d <half_stereo_bond_action+0x9d>
cmpl   $0x0,-0xc(%rbp)
je     11b0 <half_stereo_bond_action+0xb0>
mov    -0x8(%rbp),%eax
or     $0x20,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     121e <half_stereo_bond_action+0x11e>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x33,%eax
ja     1212 <half_stereo_bond_action+0x112>
mov    -0x28(%rbp),%rax
lea    0xef6(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x6,-0x18(%rbp)
jmp    1219 <half_stereo_bond_action+0x119>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    1219 <half_stereo_bond_action+0x119>
movl   $0x0,-0x18(%rbp)
jmp    1219 <half_stereo_bond_action+0x119>
movl   $0x4,-0x18(%rbp)
jmp    1219 <half_stereo_bond_action+0x119>
movl   $0xffffffff,-0x18(%rbp)
jmp    1282 <half_stereo_bond_action+0x182>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0x33,%eax
ja     1276 <half_stereo_bond_action+0x176>
mov    -0x30(%rbp),%rax
lea    0xdc2(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x6,-0x18(%rbp)
jmp    127d <half_stereo_bond_action+0x17d>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    127d <half_stereo_bond_action+0x17d>
movl   $0x4,-0x18(%rbp)
jmp    127d <half_stereo_bond_action+0x17d>
movl   $0x0,-0x18(%rbp)
jmp    127d <half_stereo_bond_action+0x17d>
movl   $0xffffffff,-0x18(%rbp)
jmp    1282 <half_stereo_bond_action+0x182>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<half_stereo_bond_action>:
xor    %eax,%eax
test   %edi,%edi
je     1170 <half_stereo_bond_action+0x70>
cmp    %ecx,%edi
mov    $0x21,%eax
cmovne %edi,%eax
mov    %eax,%edi
add    %ecx,%edi
mov    $0x31,%edi
cmovne %eax,%edi
test   %edi,%edi
js     112f <half_stereo_bond_action+0x2f>
cmp    $0x2,%edi
mov    $0x1,%r8d
cmovne %edi,%r8d
jmp    1143 <half_stereo_bond_action+0x43>
mov    %edi,%eax
neg    %eax
or     $0x10,%eax
cmp    $0xfffffffe,%edi
mov    $0x11,%r8d
cmovne %eax,%r8d
mov    %r8d,%edi
or     $0x20,%edi
test   %esi,%esi
cmove  %r8d,%edi
add    $0xffffffff,%edi
test   %edx,%edx
je     1171 <half_stereo_bond_action+0x71>
cmp    $0x33,%edi
ja     1197 <half_stereo_bond_action+0x97>
mov    $0x6,%eax
lea    0xe99(%rip),%rdx
movslq (%rdx,%rdi,4),%rsi
add    %rdx,%rsi
jmp    *%rsi
ret
cmp    $0x33,%edi
ja     1197 <half_stereo_bond_action+0x97>
mov    $0x6,%eax
lea    0xf4e(%rip),%rdx
movslq (%rdx,%rdi,4),%rsi
add    %rdx,%rsi
jmp    *%rsi
xor    %eax,%eax
ret
mov    %ecx,%eax
ret
mov    $0x4,%eax
ret
mov    $0xffffffff,%eax
ret

LLVM IR (-O0):
define i32 @half_stereo_bond_action(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%11 = load i32, i32* %6
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %4
store i32 0, i32* %5
br label %72
14: ; preds = %4
%15 = load i32, i32* %6
%16 = load i32, i32* %9
%17 = icmp eq i32 %15, %16
br i1 %17, label %18, label %19
18: ; preds = %14
store i32 33, i32* %6
br label %19
19: ; preds = %18, %14
%20 = load i32, i32* %6
%21 = load i32, i32* %9
%22 = sub nsw i32 0, %21
%23 = icmp eq i32 %20, %22
br i1 %23, label %24, label %25
24: ; preds = %19
store i32 49, i32* %6
br label %25
25: ; preds = %24, %19
%26 = load i32, i32* %6
%27 = icmp slt i32 %26, 0
br i1 %27, label %28, label %38
28: ; preds = %25
%29 = load i32, i32* %6
%30 = icmp eq i32 %29, -2
br i1 %30, label %31, label %32
31: ; preds = %28
br label %35
32: ; preds = %28
%33 = load i32, i32* %6
%34 = sub nsw i32 0, %33
br label %35
35: ; preds = %32, %31
%36 = phi i32 [ 1, %31 ], [ %34, %32 ]
%37 = or i32 %36, 16
store i32 %37, i32* %6
br label %43
38: ; preds = %25
%39 = load i32, i32* %6
%40 = icmp eq i32 %39, 2
br i1 %40, label %41, label %42
41: ; preds = %38
store i32 1, i32* %6
br label %42
42: ; preds = %41, %38
br label %43
43: ; preds = %42, %35
%44 = load i32, i32* %7
%45 = icmp ne i32 %44, 0
br i1 %45, label %46, label %49
46: ; preds = %43
%47 = load i32, i32* %6
%48 = or i32 %47, 32
store i32 %48, i32* %6
br label %49
49: ; preds = %46, %43
%50 = load i32, i32* %8
%51 = icmp ne i32 %50, 0
br i1 %51, label %52, label %61
52: ; preds = %49
%53 = load i32, i32* %6
switch i32 %53, label %59 [
i32 1, label %54
i32 17, label %54
i32 33, label %55
i32 36, label %55
i32 49, label %55
i32 52, label %55
i32 5, label %57
i32 37, label %57
i32 4, label %58
i32 20, label %58
]
54: ; preds = %52, %52
store i32 6, i32* %10
br label %60
55: ; preds = %52, %52, %52, %52
%56 = load i32, i32* %9
store i32 %56, i32* %10
br label %60
57: ; preds = %52, %52
store i32 0, i32* %10
br label %60
58: ; preds = %52, %52
store i32 4, i32* %10
br label %60
59: ; preds = %52
store i32 -1, i32* %10
br label %60
60: ; preds = %59, %58, %57, %55, %54
br label %70
61: ; preds = %49
%62 = load i32, i32* %6
switch i32 %62, label %68 [
i32 1, label %63
i32 33, label %64
i32 36, label %64
i32 4, label %66
i32 49, label %67
i32 17, label %67
i32 5, label %67
i32 37, label %67
i32 20, label %67
i32 52, label %67
]
63: ; preds = %61
store i32 6, i32* %10
br label %69
64: ; preds = %61, %61
%65 = load i32, i32* %9
store i32 %65, i32* %10
br label %69
66: ; preds = %61
store i32 4, i32* %10
br label %69
67: ; preds = %61, %61, %61, %61, %61, %61
store i32 0, i32* %10
br label %69
68: ; preds = %61
store i32 -1, i32* %10
br label %69
69: ; preds = %68, %67, %66, %64, %63
br label %70
70: ; preds = %69, %60
%71 = load i32, i32* %10
store i32 %71, i32* %5
br label %72
72: ; preds = %70, %13
%73 = load i32, i32* %5
ret i32 %73
}

LLVM IR (-O2):
define i32 @half_stereo_bond_action(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = icmp eq i32 %0, 0
br i1 %5, label %37, label %6
6: ; preds = %4
%7 = icmp eq i32 %0, %3
%8 = select i1 %7, i32 33, i32 %0
%9 = sub nsw i32 0, %3
%10 = icmp eq i32 %8, %9
%11 = select i1 %10, i32 49, i32 %8
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %6
%14 = icmp eq i32 %11, -2
%15 = sub nsw i32 0, %11
%16 = or i32 %15, 16
%17 = select i1 %14, i32 17, i32 %16
br label %21
18: ; preds = %6
%19 = icmp eq i32 %11, 2
%20 = select i1 %19, i32 1, i32 %11
br label %21
21: ; preds = %18, %13
%22 = phi i32 [ %17, %13 ], [ %20, %18 ]
%23 = icmp eq i32 %1, 0
%24 = or i32 %22, 32
%25 = select i1 %23, i32 %22, i32 %24
%26 = icmp eq i32 %2, 0
br i1 %26, label %32, label %27
27: ; preds = %21
switch i32 %25, label %31 [
i32 1, label %37
i32 17, label %37
i32 33, label %28
i32 36, label %28
i32 49, label %28
i32 52, label %28
i32 5, label %29
i32 37, label %29
i32 4, label %30
i32 20, label %30
]
28: ; preds = %27, %27, %27, %27
br label %37
29: ; preds = %27, %27
br label %37
30: ; preds = %27, %27
br label %37
31: ; preds = %27
br label %37
32: ; preds = %21
switch i32 %25, label %36 [
i32 1, label %37
i32 33, label %33
i32 36, label %33
i32 4, label %34
i32 49, label %35
i32 17, label %35
i32 5, label %35
i32 37, label %35
i32 20, label %35
i32 52, label %35
]
33: ; preds = %32, %32
br label %37
34: ; preds = %32
br label %37
35: ; preds = %32, %32, %32, %32, %32, %32
br label %37
36: ; preds = %32
br label %37
37: ; preds = %31, %30, %29, %28, %36, %35, %34, %33, %27, %27, %32, %4
%38 = phi i32 [ 0, %4 ], [ -1, %31 ], [ 4, %30 ], [ 0, %29 ], [ %3, %28 ], [ -1, %36 ], [ 0, %35 ], [ 4, %34 ], [ %3, %33 ], [ 6, %27 ], [ 6, %27 ], [ 6, %32 ]
ret i32 %38
}