#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 get_perm_count(int);
scalar_t__ malloc(int);
int **new_perm_table(int op_count) {
  int i;
  int **perm_table;
  int perm_count = get_perm_count(op_count);
  perm_table = (int **)malloc(perm_count * sizeof(int *));
  for (i = 0; i < perm_count; i++)
    perm_table[i] = (int *)malloc(op_count * sizeof(int));
  return perm_table;
}


x86 assembly (clang, -O0):
<new_perm_table>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <get_perm_count@plt>
mov    %eax,-0x14(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1188 <new_perm_table+0x68>
movslq -0x4(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1150 <new_perm_table+0x30>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<new_perm_table>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edi,%r15d
call   1030 <get_perm_count@plt>
mov    %eax,%r14d
lea    0x0(,%r14,8),%edi
call   1040 <malloc@plt>
mov    %rax,%r12
test   %r14d,%r14d
jle    1175 <new_perm_table+0x55>
shl    $0x2,%r15d
mov    %r14d,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15d,%edi
call   1040 <malloc@plt>
mov    %rax,(%r12,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1160 <new_perm_table+0x40>
mov    %r12,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32** @new_perm_table(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32**
%5 = alloca i32
store i32 %0, i32* %2
%6 = load i32, i32* %2
%7 = call i32 @get_perm_count(i32 %6)
store i32 %7, i32* %5
%8 = load i32, i32* %5
%9 = sext i32 %8 to i64
%10 = mul i64 %9, 8
%11 = trunc i64 %10 to i32
%12 = call i64 @malloc(i32 %11)
%13 = inttoptr i64 %12 to i32**
store i32** %13, i32*** %4
store i32 0, i32* %3
br label %14
14: ; preds = %29, %1
%15 = load i32, i32* %3
%16 = load i32, i32* %5
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %32
18: ; preds = %14
%19 = load i32, i32* %2
%20 = sext i32 %19 to i64
%21 = mul i64 %20, 4
%22 = trunc i64 %21 to i32
%23 = call i64 @malloc(i32 %22)
%24 = inttoptr i64 %23 to i32*
%25 = load i32**, i32*** %4
%26 = load i32, i32* %3
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i32*, i32** %25, i64 %27
store i32* %24, i32** %28
br label %29
29: ; preds = %18
%30 = load i32, i32* %3
%31 = add nsw i32 %30, 1
store i32 %31, i32* %3
br label %14
32: ; preds = %14
%33 = load i32**, i32*** %4
ret i32** %33
}

LLVM IR (-O2):
define i32** @new_perm_table(i32 %0) {
%2 = tail call i32 @get_perm_count(i32 %0)
%3 = shl i32 %2, 3
%4 = tail call i64 @malloc(i32 %3)
%5 = inttoptr i64 %4 to i32**
%6 = icmp sgt i32 %2, 0
br i1 %6, label %7, label %17
7: ; preds = %1
%8 = shl i32 %0, 2
%9 = zext i32 %2 to i64
br label %10
10: ; preds = %7, %10
%11 = phi i64 [ 0, %7 ], [ %15, %10 ]
%12 = tail call i64 @malloc(i32 %8)
%13 = inttoptr i64 %12 to i32*
%14 = getelementptr inbounds i32*, i32** %5, i64 %11
store i32* %13, i32** %14
%15 = add nuw nsw i64 %11, 1
%16 = icmp eq i64 %15, %9
br i1 %16, label %17, label %10
17: ; preds = %10, %1
ret i32** %5
}