#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*/ getCount(int *, int *, int, int);
int *malloc(int);
int nElementsInArray(int *, int);
int /*<<< orphan*/ outputCount(int *, int *, int, int);
int /*<<< orphan*/ sortIntegerArray(int *, int);
void tabluate(int *s, int n) {
  int elements, *ip;
  sortIntegerArray(s, n);
  elements = nElementsInArray(s, n);
  ip = malloc(elements * sizeof(int));
  if (ip == NULL)
    exit(-1);
  getCount(s, ip, n, elements);
  outputCount(s, ip, n, elements);
}


x86 assembly (clang, -O0):
<tabluate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <sortIntegerArray@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1040 <nElementsInArray@plt>
mov    %eax,-0x10(%rbp)
movslq -0x10(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11b2 <tabluate+0x52>
mov    $0xffffffff,%edi
call   1070 <exit@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
call   1050 <getCount@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
call   1080 <outputCount@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tabluate>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r15d
mov    %rdi,%rbx
call   1030 <sortIntegerArray@plt>
mov    %rbx,%rdi
mov    %r15d,%esi
call   1040 <nElementsInArray@plt>
mov    %eax,%r14d
lea    0x0(,%r14,4),%edi
call   1060 <malloc@plt>
test   %rax,%rax
je     11c1 <tabluate+0x61>
mov    %rax,%rbp
mov    %rbx,%rdi
mov    %rax,%rsi
mov    %r15d,%edx
mov    %r14d,%ecx
call   1050 <getCount@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r15d,%edx
mov    %r14d,%ecx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1080 <outputCount@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
define void @tabluate(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
store i32* %0, i32** %3
store i32 %1, i32* %4
%7 = load i32*, i32** %3
%8 = load i32, i32* %4
%9 = call i32 @sortIntegerArray(i32* %7, i32 %8)
%10 = load i32*, i32** %3
%11 = load i32, i32* %4
%12 = call i32 @nElementsInArray(i32* %10, i32 %11)
store i32 %12, i32* %5
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = mul i64 %14, 4
%16 = trunc i64 %15 to i32
%17 = call i32* @malloc(i32 %16)
store i32* %17, i32** %6
%18 = load i32*, i32** %6
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %22
20: ; preds = %2
%21 = call i32 @exit(i32 -1)
unreachable
22: ; preds = %2
%23 = load i32*, i32** %3
%24 = load i32*, i32** %6
%25 = load i32, i32* %4
%26 = load i32, i32* %5
%27 = call i32 @getCount(i32* %23, i32* %24, i32 %25, i32 %26)
%28 = load i32*, i32** %3
%29 = load i32*, i32** %6
%30 = load i32, i32* %4
%31 = load i32, i32* %5
%32 = call i32 @outputCount(i32* %28, i32* %29, i32 %30, i32 %31)
ret void
}

LLVM IR (-O2):
define void @tabluate(i32* %0, i32 %1) {
%3 = tail call i32 @sortIntegerArray(i32* %0, i32 %1)
%4 = tail call i32 @nElementsInArray(i32* %0, i32 %1)
%5 = shl i32 %4, 2
%6 = tail call i32* @malloc(i32 %5)
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = tail call i32 @exit(i32 -1)
unreachable
10: ; preds = %2
%11 = tail call i32 @getCount(i32* %0, i32* %6, i32 %1, i32 %4)
%12 = tail call i32 @outputCount(i32* %0, i32* %6, i32 %1, i32 %4)
ret void
}