#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int uint32_t;

/* Variables and functions */
extern int getshiftamount(uint32_t num_links, uint32_t capacity, uint32_t bsize,
                          uint32_t *shiftamt) {
  if (num_links == 4) {
    if (capacity == 2) {
      switch (bsize) {
      case 32:
        *shiftamt = 5;
        break;
      case 64:
        *shiftamt = 6;
        break;
      case 128:
        *shiftamt = 7;
        break;
      default:
        return -1;
        break;
      }
    } else if (capacity == 4) {
      switch (bsize) {
      case 32:
        *shiftamt = 5;
        break;
      case 64:
        *shiftamt = 6;
        break;
      case 128:
        *shiftamt = 7;
        break;
      default:
        return -1;
        break;
      }
    } else {
      return -1;
    }
  } else if (num_links == 8) {
    if (capacity == 4) {
      switch (bsize) {
      case 32:
        *shiftamt = 5;
        break;
      case 64:
        *shiftamt = 6;
        break;
      case 128:
        *shiftamt = 7;
        break;
      default:
        return -1;
        break;
      }
    } else if (capacity == 8) {
      switch (bsize) {
      case 32:
        *shiftamt = 5;
        break;
      case 64:
        *shiftamt = 6;
        break;
      case 128:
        *shiftamt = 7;
        break;
      default:
        return -1;
        break;
      }
    } else {
      return -1;
    }
  } else {
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<getshiftamount>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
cmpl   $0x4,-0x8(%rbp)
jne    1231 <getshiftamount+0x131>
cmpl   $0x2,-0xc(%rbp)
jne    119b <getshiftamount+0x9b>
mov    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x20,%eax
je     115d <getshiftamount+0x5d>
jmp    1139 <getshiftamount+0x39>
mov    -0x1c(%rbp),%eax
sub    $0x40,%eax
je     116c <getshiftamount+0x6c>
jmp    114a <getshiftamount+0x4a>
mov    -0x1c(%rbp),%eax
sub    $0x80,%eax
je     117b <getshiftamount+0x7b>
jmp    118a <getshiftamount+0x8a>
mov    -0x18(%rbp),%rax
movl   $0x5,(%rax)
jmp    1196 <getshiftamount+0x96>
mov    -0x18(%rbp),%rax
movl   $0x6,(%rax)
jmp    1196 <getshiftamount+0x96>
mov    -0x18(%rbp),%rax
movl   $0x7,(%rax)
jmp    1196 <getshiftamount+0x96>
movl   $0xffffffff,-0x4(%rbp)
jmp    1369 <getshiftamount+0x269>
jmp    122c <getshiftamount+0x12c>
cmpl   $0x4,-0xc(%rbp)
jne    121b <getshiftamount+0x11b>
mov    -0x10(%rbp),%eax
mov    %eax,-0x20(%rbp)
sub    $0x20,%eax
je     11dd <getshiftamount+0xdd>
jmp    11b9 <getshiftamount+0xb9>
mov    -0x20(%rbp),%eax
sub    $0x40,%eax
je     11ec <getshiftamount+0xec>
jmp    11ca <getshiftamount+0xca>
mov    -0x20(%rbp),%eax
sub    $0x80,%eax
je     11fb <getshiftamount+0xfb>
jmp    120a <getshiftamount+0x10a>
mov    -0x18(%rbp),%rax
movl   $0x5,(%rax)
jmp    1216 <getshiftamount+0x116>
mov    -0x18(%rbp),%rax
movl   $0x6,(%rax)
jmp    1216 <getshiftamount+0x116>
mov    -0x18(%rbp),%rax
movl   $0x7,(%rax)
jmp    1216 <getshiftamount+0x116>
movl   $0xffffffff,-0x4(%rbp)
jmp    1369 <getshiftamount+0x269>
jmp    1227 <getshiftamount+0x127>
movl   $0xffffffff,-0x4(%rbp)
jmp    1369 <getshiftamount+0x269>
jmp    122c <getshiftamount+0x12c>
jmp    1362 <getshiftamount+0x262>
cmpl   $0x8,-0x8(%rbp)
jne    1351 <getshiftamount+0x251>
cmpl   $0x4,-0xc(%rbp)
jne    12bb <getshiftamount+0x1bb>
mov    -0x10(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x20,%eax
je     127d <getshiftamount+0x17d>
jmp    1259 <getshiftamount+0x159>
mov    -0x24(%rbp),%eax
sub    $0x40,%eax
je     128c <getshiftamount+0x18c>
jmp    126a <getshiftamount+0x16a>
mov    -0x24(%rbp),%eax
sub    $0x80,%eax
je     129b <getshiftamount+0x19b>
jmp    12aa <getshiftamount+0x1aa>
mov    -0x18(%rbp),%rax
movl   $0x5,(%rax)
jmp    12b6 <getshiftamount+0x1b6>
mov    -0x18(%rbp),%rax
movl   $0x6,(%rax)
jmp    12b6 <getshiftamount+0x1b6>
mov    -0x18(%rbp),%rax
movl   $0x7,(%rax)
jmp    12b6 <getshiftamount+0x1b6>
movl   $0xffffffff,-0x4(%rbp)
jmp    1369 <getshiftamount+0x269>
jmp    134c <getshiftamount+0x24c>
cmpl   $0x8,-0xc(%rbp)
jne    133b <getshiftamount+0x23b>
mov    -0x10(%rbp),%eax
mov    %eax,-0x28(%rbp)
sub    $0x20,%eax
je     12fd <getshiftamount+0x1fd>
jmp    12d9 <getshiftamount+0x1d9>
mov    -0x28(%rbp),%eax
sub    $0x40,%eax
je     130c <getshiftamount+0x20c>
jmp    12ea <getshiftamount+0x1ea>
mov    -0x28(%rbp),%eax
sub    $0x80,%eax
je     131b <getshiftamount+0x21b>
jmp    132a <getshiftamount+0x22a>
mov    -0x18(%rbp),%rax
movl   $0x5,(%rax)
jmp    1336 <getshiftamount+0x236>
mov    -0x18(%rbp),%rax
movl   $0x6,(%rax)
jmp    1336 <getshiftamount+0x236>
mov    -0x18(%rbp),%rax
movl   $0x7,(%rax)
jmp    1336 <getshiftamount+0x236>
movl   $0xffffffff,-0x4(%rbp)
jmp    1369 <getshiftamount+0x269>
jmp    1347 <getshiftamount+0x247>
movl   $0xffffffff,-0x4(%rbp)
jmp    1369 <getshiftamount+0x269>
jmp    134c <getshiftamount+0x24c>
jmp    135d <getshiftamount+0x25d>
movl   $0xffffffff,-0x4(%rbp)
jmp    1369 <getshiftamount+0x269>
jmp    1362 <getshiftamount+0x262>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<getshiftamount>:
mov    $0xffffffff,%eax
cmp    $0x8,%edi
je     111a <getshiftamount+0x1a>
cmp    $0x4,%edi
jne    1119 <getshiftamount+0x19>
cmp    $0x4,%esi
je     1124 <getshiftamount+0x24>
cmp    $0x2,%esi
je     1124 <getshiftamount+0x24>
ret
cmp    $0x8,%esi
je     1124 <getshiftamount+0x24>
cmp    $0x4,%esi
jne    1119 <getshiftamount+0x19>
cmp    $0x20,%edx
je     113d <getshiftamount+0x3d>
cmp    $0x80,%edx
je     1144 <getshiftamount+0x44>
cmp    $0x40,%edx
jne    1119 <getshiftamount+0x19>
mov    $0x6,%eax
jmp    1149 <getshiftamount+0x49>
mov    $0x5,%eax
jmp    1149 <getshiftamount+0x49>
mov    $0x7,%eax
mov    %eax,(%rcx)
xor    %eax,%eax
ret

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

LLVM IR (-O2):
define i32 @getshiftamount(i32 %0, i32 %1, i32 %2, i32* nocapture writeonly %3) {
switch i32 %0, label %21 [
i32 4, label %5
i32 8, label %12
]
5: ; preds = %4
switch i32 %1, label %21 [
i32 2, label %6
i32 4, label %9
]
6: ; preds = %5
switch i32 %2, label %21 [
i32 32, label %19
i32 64, label %7
i32 128, label %8
]
7: ; preds = %6
br label %19
8: ; preds = %6
br label %19
9: ; preds = %5
switch i32 %2, label %21 [
i32 32, label %19
i32 64, label %10
i32 128, label %11
]
10: ; preds = %9
br label %19
11: ; preds = %9
br label %19
12: ; preds = %4
switch i32 %1, label %21 [
i32 4, label %13
i32 8, label %16
]
13: ; preds = %12
switch i32 %2, label %21 [
i32 32, label %19
i32 64, label %14
i32 128, label %15
]
14: ; preds = %13
br label %19
15: ; preds = %13
br label %19
16: ; preds = %12
switch i32 %2, label %21 [
i32 32, label %19
i32 64, label %17
i32 128, label %18
]
17: ; preds = %16
br label %19
18: ; preds = %16
br label %19
19: ; preds = %16, %13, %9, %6, %18, %17, %14, %15, %8, %7, %10, %11
%20 = phi i32 [ 7, %11 ], [ 6, %10 ], [ 6, %7 ], [ 7, %8 ], [ 7, %15 ], [ 6, %14 ], [ 6, %17 ], [ 7, %18 ], [ 5, %6 ], [ 5, %9 ], [ 5, %13 ], [ 5, %16 ]
store i32 %20, i32* %3
br label %21
21: ; preds = %19, %4, %12, %16, %13, %5, %9, %6
%22 = phi i32 [ -1, %6 ], [ -1, %9 ], [ -1, %5 ], [ -1, %13 ], [ -1, %16 ], [ -1, %12 ], [ -1, %4 ], [ 0, %19 ]
ret i32 %22
}