int NextStereoParity2Test(int *stereo_bond_parity, int *sb_parity_calc,
                          int nNumBest, int nNumWorse, int nNumUnkn,
                          int nNumUndf, int nNumCalc) {
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 = 4;
      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 4:
    if (*sb_parity_calc) {
      return ((-30000) - 10);
    }
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<NextStereoParity2Test>:
push   %rbp
mov    %rsp,%rbp
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
mov    %eax,-0x2c(%rbp)
sub    $0x1,%eax
je     1156 <NextStereoParity2Test+0x56>
jmp    1134 <NextStereoParity2Test+0x34>
mov    -0x2c(%rbp),%eax
sub    $0x2,%eax
je     11ed <NextStereoParity2Test+0xed>
jmp    1145 <NextStereoParity2Test+0x45>
mov    -0x2c(%rbp),%eax
sub    $0x4,%eax
je     1272 <NextStereoParity2Test+0x172>
jmp    1297 <NextStereoParity2Test+0x197>
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
test   %eax,%eax
je     118e <NextStereoParity2Test+0x8e>
jmp    116c <NextStereoParity2Test+0x6c>
mov    -0x30(%rbp),%eax
sub    $0x1,%eax
je     11ac <NextStereoParity2Test+0xac>
jmp    117d <NextStereoParity2Test+0x7d>
mov    -0x30(%rbp),%eax
sub    $0x2,%eax
je     11ca <NextStereoParity2Test+0xca>
jmp    11e8 <NextStereoParity2Test+0xe8>
mov    -0x10(%rbp),%rax
movl   $0x2,(%rax)
cmpl   $0x0,-0x20(%rbp)
jne    11a7 <NextStereoParity2Test+0xa7>
jmp    111d <NextStereoParity2Test+0x1d>
jmp    11e8 <NextStereoParity2Test+0xe8>
mov    -0x18(%rbp),%rax
movl   $0x2,(%rax)
cmpl   $0x0,-0x1c(%rbp)
jne    11c5 <NextStereoParity2Test+0xc5>
jmp    111d <NextStereoParity2Test+0x1d>
jmp    11e8 <NextStereoParity2Test+0xe8>
mov    -0x10(%rbp),%rax
movl   $0x2,(%rax)
cmpl   $0x0,0x10(%rbp)
jne    11e3 <NextStereoParity2Test+0xe3>
jmp    111d <NextStereoParity2Test+0x1d>
jmp    11e8 <NextStereoParity2Test+0xe8>
jmp    1297 <NextStereoParity2Test+0x197>
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
test   %eax,%eax
je     1225 <NextStereoParity2Test+0x125>
jmp    1203 <NextStereoParity2Test+0x103>
mov    -0x34(%rbp),%eax
sub    $0x1,%eax
je     1243 <NextStereoParity2Test+0x143>
jmp    1214 <NextStereoParity2Test+0x114>
mov    -0x34(%rbp),%eax
sub    $0x2,%eax
je     124f <NextStereoParity2Test+0x14f>
jmp    126d <NextStereoParity2Test+0x16d>
mov    -0x10(%rbp),%rax
movl   $0x4,(%rax)
cmpl   $0x0,-0x24(%rbp)
jne    123e <NextStereoParity2Test+0x13e>
jmp    111d <NextStereoParity2Test+0x1d>
jmp    126d <NextStereoParity2Test+0x16d>
movl   $0xffff8ac6,-0x4(%rbp)
jmp    129e <NextStereoParity2Test+0x19e>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
cmpl   $0x0,-0x20(%rbp)
jne    1268 <NextStereoParity2Test+0x168>
jmp    111d <NextStereoParity2Test+0x1d>
jmp    126d <NextStereoParity2Test+0x16d>
jmp    1297 <NextStereoParity2Test+0x197>
mov    -0x18(%rbp),%rax
cmpl   $0x0,(%rax)
je     128b <NextStereoParity2Test+0x18b>
movl   $0xffff8ac6,-0x4(%rbp)
jmp    129e <NextStereoParity2Test+0x19e>
movl   $0x1,-0x4(%rbp)
jmp    129e <NextStereoParity2Test+0x19e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<NextStereoParity2Test>:
mov    0x8(%rsp),%r9d
xor    %eax,%eax
mov    (%rdi),%r10d
jmp    1124 <NextStereoParity2Test+0x24>
nopl   0x0(%rax)
movl   $0x2,(%rdi)
mov    $0x2,%r10d
test   %ecx,%ecx
jne    11de <NextStereoParity2Test+0xde>
cmp    $0x1,%r10d
je     1160 <NextStereoParity2Test+0x60>
cmp    $0x2,%r10d
jne    11c2 <NextStereoParity2Test+0xc2>
mov    (%rsi),%r10d
test   %r10d,%r10d
jne    1190 <NextStereoParity2Test+0x90>
movl   $0x4,(%rdi)
mov    $0x4,%r10d
test   %r8d,%r8d
je     1124 <NextStereoParity2Test+0x24>
jmp    11de <NextStereoParity2Test+0xde>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%rsi),%r10d
test   %r10d,%r10d
je     1110 <NextStereoParity2Test+0x10>
cmp    $0x2,%r10d
jne    11ac <NextStereoParity2Test+0xac>
movl   $0x2,(%rdi)
mov    $0x2,%r10d
test   %r9d,%r9d
je     1124 <NextStereoParity2Test+0x24>
jmp    11de <NextStereoParity2Test+0xde>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmp    $0x1,%r10d
je     11d9 <NextStereoParity2Test+0xd9>
cmp    $0x2,%r10d
jne    11de <NextStereoParity2Test+0xde>
movl   $0x0,(%rsi)
test   %ecx,%ecx
je     1107 <NextStereoParity2Test+0x7>
jmp    11de <NextStereoParity2Test+0xde>
cmp    $0x1,%r10d
jne    11de <NextStereoParity2Test+0xde>
movl   $0x2,(%rsi)
test   %edx,%edx
je     1107 <NextStereoParity2Test+0x7>
jmp    11de <NextStereoParity2Test+0xde>
cmp    $0x4,%r10d
jne    11de <NextStereoParity2Test+0xde>
cmpl   $0x0,(%rsi)
mov    $0x1,%ecx
mov    $0xffff8ac6,%eax
cmove  %ecx,%eax
ret
mov    $0xffff8ac6,%eax
ret

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

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