#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*/ free_perm_table(int ***, int);
int /*<<< orphan*/ generate_perm_table(int *, int, int /*<<< orphan*/, int **);
int **new_perm_table(int);
int *generate_operation_order(int op_count, int seq_num) {
  static int **perm_table = NULL;
  if (seq_num == 0) {
    int elements[12];
    int i;
    if (perm_table)
      free_perm_table(&perm_table, op_count);
    perm_table = new_perm_table(op_count);
    for (i = 0; i < op_count; i++)
      elements[i] = i;
    generate_perm_table(elements, op_count, 0, perm_table);
  }
  return perm_table[seq_num];
}


x86 assembly (clang, -O0):
<generate_operation_order>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    11b5 <generate_operation_order+0x85>
cmpq   $0x0,0x2ef0(%rip)
je     1165 <generate_operation_order+0x35>
mov    -0x4(%rbp),%esi
lea    0x2ee0(%rip),%rdi
call   1030 <free_perm_table@plt>
mov    -0x4(%rbp),%edi
call   1040 <new_perm_table@plt>
mov    %rax,0x2ecc(%rip)
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11a0 <generate_operation_order+0x70>
mov    -0x44(%rbp),%ecx
movslq -0x44(%rbp),%rax
mov    %ecx,-0x40(%rbp,%rax,4)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    117b <generate_operation_order+0x4b>
lea    -0x40(%rbp),%rdi
mov    -0x4(%rbp),%esi
mov    0x2e92(%rip),%rcx
xor    %edx,%edx
call   1050 <generate_perm_table@plt>
mov    0x2e84(%rip),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate_operation_order>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    %esi,%ebx
test   %esi,%esi
jne    12fc <generate_operation_order+0x1cc>
mov    %edi,%r14d
cmpq   $0x0,0x2ef3(%rip)
je     115e <generate_operation_order+0x2e>
lea    0x2eea(%rip),%rdi
mov    %r14d,%esi
call   1030 <free_perm_table@plt>
mov    %r14d,%edi
call   1040 <new_perm_table@plt>
mov    %rax,0x2ed3(%rip)
test   %r14d,%r14d
jle    12ec <generate_operation_order+0x1bc>
mov    %r14d,%ecx
cmp    $0x8,%r14d
jae    1186 <generate_operation_order+0x56>
xor    %edx,%edx
jmp    12e0 <generate_operation_order+0x1b0>
mov    %ecx,%edx
and    $0xfffffff8,%edx
lea    -0x8(%rdx),%rbp
mov    %rbp,%rdi
shr    $0x3,%rdi
add    $0x1,%rdi
mov    %edi,%esi
and    $0x3,%esi
cmp    $0x18,%rbp
jae    11b4 <generate_operation_order+0x84>
movdqa 0xe53(%rip),%xmm0
xor    %ebp,%ebp
jmp    1288 <generate_operation_order+0x158>
and    $0xfffffffffffffffc,%rdi
movdqa 0xe40(%rip),%xmm0
xor    %ebp,%ebp
movdqa 0xe45(%rip),%xmm8
movdqa 0xe4c(%rip),%xmm9
movdqa 0xe53(%rip),%xmm10
movdqa 0xe5b(%rip),%xmm4
movdqa 0xe63(%rip),%xmm5
movdqa 0xe6b(%rip),%xmm6
movdqa 0xe73(%rip),%xmm7
movdqa 0xe7b(%rip),%xmm1
cs nopw 0x0(%rax,%rax,1)
nop
movdqa %xmm0,%xmm2
paddd  %xmm8,%xmm2
movdqa %xmm0,(%rsp,%rbp,4)
movdqa %xmm2,0x10(%rsp,%rbp,4)
movdqa %xmm0,%xmm2
paddd  %xmm9,%xmm2
movdqa %xmm0,%xmm3
paddd  %xmm10,%xmm3
movdqa %xmm2,0x20(%rsp,%rbp,4)
movdqa %xmm3,0x30(%rsp,%rbp,4)
movdqa %xmm0,%xmm2
paddd  %xmm4,%xmm2
movdqa %xmm0,%xmm3
paddd  %xmm5,%xmm3
movdqa %xmm2,0x40(%rsp,%rbp,4)
movdqa %xmm3,0x50(%rsp,%rbp,4)
movdqa %xmm0,%xmm2
paddd  %xmm6,%xmm2
movdqa %xmm0,%xmm3
paddd  %xmm7,%xmm3
movdqa %xmm2,0x60(%rsp,%rbp,4)
movdqa %xmm3,0x70(%rsp,%rbp,4)
add    $0x20,%rbp
paddd  %xmm1,%xmm0
add    $0xfffffffffffffffc,%rdi
jne    1210 <generate_operation_order+0xe0>
test   %rsi,%rsi
je     12d0 <generate_operation_order+0x1a0>
lea    (%rsp,%rbp,4),%rdi
add    $0x10,%rdi
shl    $0x5,%rsi
xor    %ebp,%ebp
movdqa 0xd6d(%rip),%xmm1
movdqa 0xd75(%rip),%xmm2
nopl   0x0(%rax,%rax,1)
movdqa %xmm0,%xmm3
paddd  %xmm1,%xmm3
movdqa %xmm0,-0x10(%rdi,%rbp,1)
movdqa %xmm3,(%rdi,%rbp,1)
paddd  %xmm2,%xmm0
add    $0x20,%rbp
cmp    %rbp,%rsi
jne    12b0 <generate_operation_order+0x180>
cmp    %rcx,%rdx
je     12ec <generate_operation_order+0x1bc>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %edx,(%rsp,%rdx,4)
add    $0x1,%rdx
cmp    %rdx,%rcx
jne    12e0 <generate_operation_order+0x1b0>
mov    %rsp,%rdi
mov    %r14d,%esi
xor    %edx,%edx
mov    %rax,%rcx
call   1050 <generate_perm_table@plt>
mov    0x2d3d(%rip),%rax
movslq %ebx,%rcx
mov    (%rax,%rcx,8),%rax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@generate_operation_order.perm_table = internal global i32** null
define i32* @generate_operation_order(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [12 x i32]
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %35
9: ; preds = %2
%10 = load i32**, i32*** @generate_operation_order.perm_table
%11 = icmp ne i32** %10, null
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = load i32, i32* %3
%14 = call i32 @free_perm_table(i32*** @generate_operation_order.perm_table, i32 %13)
br label %15
15: ; preds = %12, %9
%16 = load i32, i32* %3
%17 = call i32** @new_perm_table(i32 %16)
store i32** %17, i32*** @generate_operation_order.perm_table
store i32 0, i32* %6
br label %18
18: ; preds = %27, %15
%19 = load i32, i32* %6
%20 = load i32, i32* %3
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %30
22: ; preds = %18
%23 = load i32, i32* %6
%24 = load i32, i32* %6
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [12 x i32], [12 x i32]* %5, i64 0, i64 %25
store i32 %23, i32* %26
br label %27
27: ; preds = %22
%28 = load i32, i32* %6
%29 = add nsw i32 %28, 1
store i32 %29, i32* %6
br label %18
30: ; preds = %18
%31 = getelementptr inbounds [12 x i32], [12 x i32]* %5, i64 0, i64 0
%32 = load i32, i32* %3
%33 = load i32**, i32*** @generate_operation_order.perm_table
%34 = call i32 @generate_perm_table(i32* %31, i32 %32, i32 0, i32** %33)
br label %35
35: ; preds = %30, %2
%36 = load i32**, i32*** @generate_operation_order.perm_table
%37 = load i32, i32* %4
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i32*, i32** %36, i64 %38
%40 = load i32*, i32** %39
ret i32* %40
}

LLVM IR (-O2):
@generate_operation_order.perm_table = internal global i32** null
define i32* @generate_operation_order(i32 %0, i32 %1) {
%3 = alloca [12 x i32]
%4 = icmp eq i32 %1, 0
br i1 %4, label %5, label %90
5: ; preds = %2
%6 = bitcast [12 x i32]* %3 to i8*
%7 = load i32**, i32*** @generate_operation_order.perm_table
%8 = icmp eq i32** %7, null
br i1 %8, label %11, label %9
9: ; preds = %5
%10 = tail call i32 @free_perm_table(i32*** @generate_operation_order.perm_table, i32 %0)
br label %11
11: ; preds = %9, %5
%12 = tail call i32** @new_perm_table(i32 %0)
store i32** %12, i32*** @generate_operation_order.perm_table
%13 = icmp sgt i32 %0, 0
br i1 %13, label %14, label %87
14: ; preds = %11
%15 = zext i32 %0 to i64
%16 = icmp ult i32 %0, 8
br i1 %16, label %79, label %17
17: ; preds = %14
%18 = and i64 %15, 4294967288
%19 = add nsw i64 %18, -8
%20 = lshr exact i64 %19, 3
%21 = add nuw nsw i64 %20, 1
%22 = and i64 %21, 3
%23 = icmp ult i64 %19, 24
br i1 %23, label %60, label %24
24: ; preds = %17
%25 = and i64 %21, 4611686018427387900
br label %26
26: ; preds = %26, %24
%27 = phi i64 [ 0, %24 ], [ %56, %26 ]
%28 = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %24 ], [ %57, %26 ]
%29 = phi i64 [ 0, %24 ], [ %58, %26 ]
%30 = add <4 x i32> %28, <i32 4, i32 4, i32 4, i32 4>
%31 = getelementptr inbounds [12 x i32], [12 x i32]* %3, i64 0, i64 %27
%32 = bitcast i32* %31 to <4 x i32>*
store <4 x i32> %28, <4 x i32>* %32
%33 = getelementptr inbounds i32, i32* %31, i64 4
%34 = bitcast i32* %33 to <4 x i32>*
store <4 x i32> %30, <4 x i32>* %34
%35 = or i64 %27, 8
%36 = add <4 x i32> %28, <i32 8, i32 8, i32 8, i32 8>
%37 = add <4 x i32> %28, <i32 12, i32 12, i32 12, i32 12>
%38 = getelementptr inbounds [12 x i32], [12 x i32]* %3, i64 0, i64 %35
%39 = bitcast i32* %38 to <4 x i32>*
store <4 x i32> %36, <4 x i32>* %39
%40 = getelementptr inbounds i32, i32* %38, i64 4
%41 = bitcast i32* %40 to <4 x i32>*
store <4 x i32> %37, <4 x i32>* %41
%42 = or i64 %27, 16
%43 = add <4 x i32> %28, <i32 16, i32 16, i32 16, i32 16>
%44 = add <4 x i32> %28, <i32 20, i32 20, i32 20, i32 20>
%45 = getelementptr inbounds [12 x i32], [12 x i32]* %3, i64 0, i64 %42
%46 = bitcast i32* %45 to <4 x i32>*
store <4 x i32> %43, <4 x i32>* %46
%47 = getelementptr inbounds i32, i32* %45, i64 4
%48 = bitcast i32* %47 to <4 x i32>*
store <4 x i32> %44, <4 x i32>* %48
%49 = or i64 %27, 24
%50 = add <4 x i32> %28, <i32 24, i32 24, i32 24, i32 24>
%51 = add <4 x i32> %28, <i32 28, i32 28, i32 28, i32 28>
%52 = getelementptr inbounds [12 x i32], [12 x i32]* %3, i64 0, i64 %49
%53 = bitcast i32* %52 to <4 x i32>*
store <4 x i32> %50, <4 x i32>* %53
%54 = getelementptr inbounds i32, i32* %52, i64 4
%55 = bitcast i32* %54 to <4 x i32>*
store <4 x i32> %51, <4 x i32>* %55
%56 = add nuw i64 %27, 32
%57 = add <4 x i32> %28, <i32 32, i32 32, i32 32, i32 32>
%58 = add i64 %29, 4
%59 = icmp eq i64 %58, %25
br i1 %59, label %60, label %26
60: ; preds = %26, %17
%61 = phi i64 [ 0, %17 ], [ %56, %26 ]
%62 = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %17 ], [ %57, %26 ]
%63 = icmp eq i64 %22, 0
br i1 %63, label %77, label %64
64: ; preds = %60, %64
%65 = phi i64 [ %73, %64 ], [ %61, %60 ]
%66 = phi <4 x i32> [ %74, %64 ], [ %62, %60 ]
%67 = phi i64 [ %75, %64 ], [ 0, %60 ]
%68 = add <4 x i32> %66, <i32 4, i32 4, i32 4, i32 4>
%69 = getelementptr inbounds [12 x i32], [12 x i32]* %3, i64 0, i64 %65
%70 = bitcast i32* %69 to <4 x i32>*
store <4 x i32> %66, <4 x i32>* %70
%71 = getelementptr inbounds i32, i32* %69, i64 4
%72 = bitcast i32* %71 to <4 x i32>*
store <4 x i32> %68, <4 x i32>* %72
%73 = add nuw i64 %65, 8
%74 = add <4 x i32> %66, <i32 8, i32 8, i32 8, i32 8>
%75 = add i64 %67, 1
%76 = icmp eq i64 %75, %22
br i1 %76, label %77, label %64
77: ; preds = %64, %60
%78 = icmp eq i64 %18, %15
br i1 %78, label %87, label %79
79: ; preds = %14, %77
%80 = phi i64 [ 0, %14 ], [ %18, %77 ]
br label %81
81: ; preds = %79, %81
%82 = phi i64 [ %85, %81 ], [ %80, %79 ]
%83 = getelementptr inbounds [12 x i32], [12 x i32]* %3, i64 0, i64 %82
%84 = trunc i64 %82 to i32
store i32 %84, i32* %83
%85 = add nuw nsw i64 %82, 1
%86 = icmp eq i64 %85, %15
br i1 %86, label %87, label %81
87: ; preds = %81, %77, %11
%88 = getelementptr inbounds [12 x i32], [12 x i32]* %3, i64 0, i64 0
%89 = call i32 @generate_perm_table(i32* %88, i32 %0, i32 0, i32** %12)
br label %90
90: ; preds = %87, %2
%91 = load i32**, i32*** @generate_operation_order.perm_table
%92 = sext i32 %1 to i64
%93 = getelementptr inbounds i32*, i32** %91, i64 %92
%94 = load i32*, i32** %93
ret i32* %94
}