#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);
void *malloc(int);
char **TranspositionCreateTable(int letters, int key_columns, int *rows) {
  if ((letters % key_columns) != 0)
    *rows = (letters / key_columns) + 1;
  else
    *rows = letters / key_columns;
  char **enc_table = malloc((*rows) * sizeof(char *));
  if (!enc_table)
    exit(1);
  int i;
  for (i = 0; i < *rows; i++) {
    enc_table[i] = malloc(key_columns * sizeof(char));
    if (!enc_table[i])
      exit(1);
  }
  return (enc_table);
}


x86 assembly (clang, -O0):
<TranspositionCreateTable>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
cmp    $0x0,%edx
je     1159 <TranspositionCreateTable+0x39>
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %eax,%ecx
add    $0x1,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    1168 <TranspositionCreateTable+0x48>
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
movslq (%rax),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1193 <TranspositionCreateTable+0x73>
mov    $0x1,%edi
call   1040 <exit@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%eax
jge    11f7 <TranspositionCreateTable+0xd7>
movslq -0x8(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jne    11e4 <TranspositionCreateTable+0xc4>
mov    $0x1,%edi
call   1040 <exit@plt>
jmp    11e9 <TranspositionCreateTable+0xc9>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    119a <TranspositionCreateTable+0x7a>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TranspositionCreateTable>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%rcx
mov    %esi,%r15d
mov    %edi,%eax
cltd
idiv   %esi
mov    %eax,%r14d
cmp    $0x1,%edx
sbb    $0xffffffff,%r14d
mov    %r14d,(%rcx)
lea    0x0(,%r14,8),%edi
call   1030 <malloc@plt>
test   %rax,%rax
je     1186 <TranspositionCreateTable+0x66>
mov    %rax,%r12
test   %r14d,%r14d
jle    117a <TranspositionCreateTable+0x5a>
mov    %r14d,%ebp
xor    %ebx,%ebx
nop
mov    %r15d,%edi
call   1030 <malloc@plt>
mov    %rax,(%r12,%rbx,8)
test   %rax,%rax
je     1186 <TranspositionCreateTable+0x66>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1160 <TranspositionCreateTable+0x40>
mov    %r12,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
define i8** @TranspositionCreateTable(i32 %0, i32 %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i8**
%8 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32* %2, i32** %6
%9 = load i32, i32* %4
%10 = load i32, i32* %5
%11 = srem i32 %9, %10
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %19
13: ; preds = %3
%14 = load i32, i32* %4
%15 = load i32, i32* %5
%16 = sdiv i32 %14, %15
%17 = add nsw i32 %16, 1
%18 = load i32*, i32** %6
store i32 %17, i32* %18
br label %24
19: ; preds = %3
%20 = load i32, i32* %4
%21 = load i32, i32* %5
%22 = sdiv i32 %20, %21
%23 = load i32*, i32** %6
store i32 %22, i32* %23
br label %24
24: ; preds = %19, %13
%25 = load i32*, i32** %6
%26 = load i32, i32* %25
%27 = sext i32 %26 to i64
%28 = mul i64 %27, 8
%29 = trunc i64 %28 to i32
%30 = call i8* @malloc(i32 %29)
%31 = bitcast i8* %30 to i8**
store i8** %31, i8*** %7
%32 = load i8**, i8*** %7
%33 = icmp ne i8** %32, null
br i1 %33, label %36, label %34
34: ; preds = %24
%35 = call i32 @exit(i32 1)
unreachable
36: ; preds = %24
store i32 0, i32* %8
br label %37
37: ; preds = %61, %36
%38 = load i32, i32* %8
%39 = load i32*, i32** %6
%40 = load i32, i32* %39
%41 = icmp slt i32 %38, %40
br i1 %41, label %42, label %64
42: ; preds = %37
%43 = load i32, i32* %5
%44 = sext i32 %43 to i64
%45 = mul i64 %44, 1
%46 = trunc i64 %45 to i32
%47 = call i8* @malloc(i32 %46)
%48 = load i8**, i8*** %7
%49 = load i32, i32* %8
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8*, i8** %48, i64 %50
store i8* %47, i8** %51
%52 = load i8**, i8*** %7
%53 = load i32, i32* %8
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i8*, i8** %52, i64 %54
%56 = load i8*, i8** %55
%57 = icmp ne i8* %56, null
br i1 %57, label %60, label %58
58: ; preds = %42
%59 = call i32 @exit(i32 1)
unreachable
60: ; preds = %42
br label %61
61: ; preds = %60
%62 = load i32, i32* %8
%63 = add nsw i32 %62, 1
store i32 %63, i32* %8
br label %37
64: ; preds = %37
%65 = load i8**, i8*** %7
ret i8** %65
}

LLVM IR (-O2):
define noalias i8** @TranspositionCreateTable(i32 %0, i32 %1, i32* nocapture %2) {
%4 = srem i32 %0, %1
%5 = icmp ne i32 %4, 0
%6 = sdiv i32 %0, %1
%7 = zext i1 %5 to i32
%8 = add nsw i32 %6, %7
store i32 %8, i32* %2
%9 = shl i32 %8, 3
%10 = tail call i8* @malloc(i32 %9)
%11 = bitcast i8* %10 to i8**
%12 = icmp eq i8* %10, null
br i1 %12, label %17, label %13
13: ; preds = %3
%14 = icmp sgt i32 %8, 0
br i1 %14, label %15, label %29
15: ; preds = %13
%16 = zext i32 %8 to i64
br label %21
17: ; preds = %3
%18 = tail call i32 @exit(i32 1)
unreachable
19: ; preds = %21
%20 = icmp eq i64 %26, %16
br i1 %20, label %29, label %21
21: ; preds = %15, %19
%22 = phi i64 [ 0, %15 ], [ %26, %19 ]
%23 = tail call i8* @malloc(i32 %1)
%24 = getelementptr inbounds i8*, i8** %11, i64 %22
store i8* %23, i8** %24
%25 = icmp eq i8* %23, null
%26 = add nuw nsw i64 %22, 1
br i1 %25, label %27, label %19
27: ; preds = %21
%28 = tail call i32 @exit(i32 1)
unreachable
29: ; preds = %19, %13
ret i8** %11
}