#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 */

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ wigxjpf_fill_factors(int);
void wig_table_init(int max_two_j, int wigner_type) {
  int max_factorial;
  if (max_two_j < 0) {
    fprintf(stderr, "Negative max_two_j in wig_table_init.  Abort.\n");
    exit(1);
  }
  switch (wigner_type) {
  case 0:
    max_factorial = max_two_j;
    break;
  case 3:
    max_factorial = (3 * max_two_j) / 2 + 1;
    break;
  case 6:
    max_factorial = (4 * max_two_j) / 2 + 1;
    break;
  case 9:
    max_factorial = (5 * max_two_j) / 2 + 1;
    break;
  default:
    fprintf(stderr, "Bad wigner_type (%d) in wig_table_init.  Abort.\n",
            wigner_type);
    exit(1);
  }
  wigxjpf_fill_factors(max_factorial);
}


x86 assembly (clang, -O0):
<wig_table_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    1169 <wig_table_init+0x39>
mov    0x2e91(%rip),%rax
mov    (%rax),%edi
lea    0xed0(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    -0x8(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0x9,%rax
ja     11e0 <wig_table_init+0xb0>
mov    -0x18(%rbp),%rax
lea    0xe7b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    1204 <wig_table_init+0xd4>
imul   $0x3,-0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1204 <wig_table_init+0xd4>
mov    -0x4(%rbp),%eax
shl    $0x2,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1204 <wig_table_init+0xd4>
imul   $0x5,-0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1204 <wig_table_init+0xd4>
mov    0x2df9(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%edx
lea    0xe64(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    -0xc(%rbp),%edi
call   1040 <wigxjpf_fill_factors@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wig_table_init>:
push   %rax
test   %edi,%edi
js     1173 <wig_table_init+0x43>
mov    %esi,%edx
cmp    $0x9,%esi
ja     1194 <wig_table_init+0x64>
mov    %edx,%eax
lea    0xebb(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    (%rdi,%rdi,2),%eax
jmp    1161 <wig_table_init+0x31>
add    %edi,%edi
add    $0x1,%edi
pop    %rax
jmp    1040 <wigxjpf_fill_factors@plt>
lea    (%rdi,%rdi,4),%eax
mov    %eax,%edi
shr    $0x1f,%edi
add    %eax,%edi
sar    %edi
add    $0x1,%edi
pop    %rax
jmp    1040 <wigxjpf_fill_factors@plt>
mov    0x2e66(%rip),%rax
mov    (%rax),%edi
lea    0xea5(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    0x2e45(%rip),%rax
mov    (%rax),%edi
lea    0xeb3(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [47 x i8] c"Negative max_two_j in wig_table_init. Abort.\0A\00"
@.str.1 = [49 x i8] c"Bad wigner_type (%d) in wig_table_init. Abort.\0A\00"
define void @wig_table_init(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @exit(i32 1)
unreachable
12: ; preds = %2
%13 = load i32, i32* %4
switch i32 %13, label %31 [
i32 0, label %14
i32 3, label %16
i32 6, label %21
i32 9, label %26
]
14: ; preds = %12
%15 = load i32, i32* %3
store i32 %15, i32* %5
br label %36
16: ; preds = %12
%17 = load i32, i32* %3
%18 = mul nsw i32 3, %17
%19 = sdiv i32 %18, 2
%20 = add nsw i32 %19, 1
store i32 %20, i32* %5
br label %36
21: ; preds = %12
%22 = load i32, i32* %3
%23 = mul nsw i32 4, %22
%24 = sdiv i32 %23, 2
%25 = add nsw i32 %24, 1
store i32 %25, i32* %5
br label %36
26: ; preds = %12
%27 = load i32, i32* %3
%28 = mul nsw i32 5, %27
%29 = sdiv i32 %28, 2
%30 = add nsw i32 %29, 1
store i32 %30, i32* %5
br label %36
31: ; preds = %12
%32 = load i32, i32* @stderr
%33 = load i32, i32* %4
%34 = call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), i32 %33)
%35 = call i32 @exit(i32 1)
unreachable
36: ; preds = %26, %21, %16, %14
%37 = load i32, i32* %5
%38 = call i32 @wigxjpf_fill_factors(i32 %37)
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [47 x i8] c"Negative max_two_j in wig_table_init. Abort.\0A\00"
@.str.1 = [49 x i8] c"Bad wigner_type (%d) in wig_table_init. Abort.\0A\00"
define void @wig_table_init(i32 %0, i32 %1) {
%3 = icmp slt i32 %0, 0
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %2
switch i32 %1, label %20 [
i32 0, label %24
i32 3, label %9
i32 6, label %13
i32 9, label %16
]
9: ; preds = %8
%10 = mul nsw i32 %0, 3
%11 = sdiv i32 %10, 2
%12 = add nsw i32 %11, 1
br label %24
13: ; preds = %8
%14 = shl nuw nsw i32 %0, 1
%15 = or i32 %14, 1
br label %24
16: ; preds = %8
%17 = mul nsw i32 %0, 5
%18 = sdiv i32 %17, 2
%19 = add nsw i32 %18, 1
br label %24
20: ; preds = %8
%21 = load i32, i32* @stderr
%22 = tail call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), i32 %1)
%23 = tail call i32 @exit(i32 1)
unreachable
24: ; preds = %8, %16, %13, %9
%25 = phi i32 [ %19, %16 ], [ %15, %13 ], [ %12, %9 ], [ %0, %8 ]
%26 = tail call i32 @wigxjpf_fill_factors(i32 %25)
ret void
}