int NextStereoParity2Test(int *stereo_bond_parity, int *sb_parity_calc,
                          int nNumBest, int nNumWorse, int nNumUnkn,
                          int nNumUndf, int nNumCalc, int vABParityUnknown) {
get_next_parity:
  switch (*stereo_bond_parity) {
  case 1:
    switch (*sb_parity_calc) {
    case 0:
      *stereo_bond_parity = 2;
      if (!nNumWorse) {
        goto get_next_parity;
      }
      break;
    case 1:
      *sb_parity_calc = 2;
      if (!nNumBest) {
        goto get_next_parity;
      }
      break;
    case 2:
      *stereo_bond_parity = 2;
      if (!nNumCalc) {
        goto get_next_parity;
      }
      break;
    }
    break;
  case 2:
    switch (*sb_parity_calc) {
    case 0:
      *stereo_bond_parity = vABParityUnknown;
      if (!nNumUnkn) {
        goto get_next_parity;
      }
      break;
    case 1:
      return ((-30000) - 10);
    case 2:
      *sb_parity_calc = 0;
      if (!nNumWorse) {
        goto get_next_parity;
      }
      break;
    }
    break;
  case 3:
    if (*sb_parity_calc) {
      return ((-30000) - 10);
    }
    *stereo_bond_parity = 4;
    if (!nNumUndf) {
      return 1;
    }
    break;
  case 4:
    if (*sb_parity_calc) {
      return ((-30000) - 10);
    }
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<NextStereoParity2Test>:
push   %rbp
mov    %rsp,%rbp
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9d,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0x3,%eax
ja     12ca <NextStereoParity2Test+0x1ca>
mov    -0x30(%rbp),%rax
lea    0xebd(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
test   %eax,%eax
je     1184 <NextStereoParity2Test+0x84>
jmp    1162 <NextStereoParity2Test+0x62>
mov    -0x34(%rbp),%eax
sub    $0x1,%eax
je     11a2 <NextStereoParity2Test+0xa2>
jmp    1173 <NextStereoParity2Test+0x73>
mov    -0x34(%rbp),%eax
sub    $0x2,%eax
je     11c0 <NextStereoParity2Test+0xc0>
jmp    11de <NextStereoParity2Test+0xde>
mov    -0x10(%rbp),%rax
movl   $0x2,(%rax)
cmpl   $0x0,-0x20(%rbp)
jne    119d <NextStereoParity2Test+0x9d>
jmp    1120 <NextStereoParity2Test+0x20>
jmp    11de <NextStereoParity2Test+0xde>
mov    -0x18(%rbp),%rax
movl   $0x2,(%rax)
cmpl   $0x0,-0x1c(%rbp)
jne    11bb <NextStereoParity2Test+0xbb>
jmp    1120 <NextStereoParity2Test+0x20>
jmp    11de <NextStereoParity2Test+0xde>
mov    -0x10(%rbp),%rax
movl   $0x2,(%rax)
cmpl   $0x0,0x10(%rbp)
jne    11d9 <NextStereoParity2Test+0xd9>
jmp    1120 <NextStereoParity2Test+0x20>
jmp    11de <NextStereoParity2Test+0xde>
jmp    12ca <NextStereoParity2Test+0x1ca>
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
test   %eax,%eax
je     121b <NextStereoParity2Test+0x11b>
jmp    11f9 <NextStereoParity2Test+0xf9>
mov    -0x38(%rbp),%eax
sub    $0x1,%eax
je     1238 <NextStereoParity2Test+0x138>
jmp    120a <NextStereoParity2Test+0x10a>
mov    -0x38(%rbp),%eax
sub    $0x2,%eax
je     1244 <NextStereoParity2Test+0x144>
jmp    1262 <NextStereoParity2Test+0x162>
mov    0x18(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
cmpl   $0x0,-0x24(%rbp)
jne    1233 <NextStereoParity2Test+0x133>
jmp    1120 <NextStereoParity2Test+0x20>
jmp    1262 <NextStereoParity2Test+0x162>
movl   $0xffff8ac6,-0x4(%rbp)
jmp    12d1 <NextStereoParity2Test+0x1d1>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
cmpl   $0x0,-0x20(%rbp)
jne    125d <NextStereoParity2Test+0x15d>
jmp    1120 <NextStereoParity2Test+0x20>
jmp    1262 <NextStereoParity2Test+0x162>
jmp    12ca <NextStereoParity2Test+0x1ca>
mov    -0x18(%rbp),%rax
cmpl   $0x0,(%rax)
je     1280 <NextStereoParity2Test+0x180>
movl   $0xffff8ac6,-0x4(%rbp)
jmp    12d1 <NextStereoParity2Test+0x1d1>
mov    -0x10(%rbp),%rax
movl   $0x4,(%rax)
cmpl   $0x0,-0x28(%rbp)
jne    12a0 <NextStereoParity2Test+0x1a0>
movl   $0x1,-0x4(%rbp)
jmp    12d1 <NextStereoParity2Test+0x1d1>
jmp    12ca <NextStereoParity2Test+0x1ca>
mov    -0x18(%rbp),%rax
cmpl   $0x0,(%rax)
je     12be <NextStereoParity2Test+0x1be>
movl   $0xffff8ac6,-0x4(%rbp)
jmp    12d1 <NextStereoParity2Test+0x1d1>
movl   $0x1,-0x4(%rbp)
jmp    12d1 <NextStereoParity2Test+0x1d1>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<NextStereoParity2Test>:
push   %rbx
mov    0x18(%rsp),%r11d
mov    0x10(%rsp),%r10d
lea    0xeee(%rip),%rax
mov    (%rdi),%ebx
jmp    1133 <NextStereoParity2Test+0x33>
cs nopw 0x0(%rax,%rax,1)
movl   $0x2,(%rdi)
mov    $0x2,%ebx
test   %ecx,%ecx
jne    11ef <NextStereoParity2Test+0xef>
add    $0xffffffff,%ebx
cmp    $0x3,%ebx
ja     11ef <NextStereoParity2Test+0xef>
movslq (%rax,%rbx,4),%rbx
add    %rax,%rbx
jmp    *%rbx
mov    (%rsi),%ebx
test   %ebx,%ebx
je     1120 <NextStereoParity2Test+0x20>
cmp    $0x2,%ebx
jne    11aa <NextStereoParity2Test+0xaa>
movl   $0x2,(%rdi)
mov    $0x2,%ebx
test   %r10d,%r10d
je     1133 <NextStereoParity2Test+0x33>
jmp    11ef <NextStereoParity2Test+0xef>
nopl   0x0(%rax,%rax,1)
mov    (%rsi),%ebx
test   %ebx,%ebx
jne    1190 <NextStereoParity2Test+0x90>
mov    %r11d,(%rdi)
mov    %r11d,%ebx
test   %r8d,%r8d
je     1133 <NextStereoParity2Test+0x33>
jmp    11ef <NextStereoParity2Test+0xef>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmp    $0x1,%ebx
je     11dd <NextStereoParity2Test+0xdd>
cmp    $0x2,%ebx
jne    11ef <NextStereoParity2Test+0xef>
movl   $0x0,(%rsi)
test   %ecx,%ecx
je     1112 <NextStereoParity2Test+0x12>
jmp    11ef <NextStereoParity2Test+0xef>
cmp    $0x1,%ebx
jne    11ef <NextStereoParity2Test+0xef>
movl   $0x2,(%rsi)
test   %edx,%edx
je     1112 <NextStereoParity2Test+0x12>
jmp    11ef <NextStereoParity2Test+0xef>
mov    $0xffff8ac6,%eax
cmpl   $0x0,(%rsi)
je     11e4 <NextStereoParity2Test+0xe4>
pop    %rbx
ret
cmpl   $0x0,(%rsi)
mov    $0x1,%ecx
mov    $0xffff8ac6,%eax
cmove  %ecx,%eax
pop    %rbx
ret
mov    $0xffff8ac6,%eax
pop    %rbx
ret
movl   $0x4,(%rdi)
test   %r9d,%r9d
je     11f3 <NextStereoParity2Test+0xf3>
xor    %eax,%eax
pop    %rbx
ret
mov    $0x1,%eax
pop    %rbx
ret

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

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