#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 */
typedef int /*<<< orphan*/ a;

/* Variables and functions */
int /*<<< orphan*/ free(int *);
int *histogram(int *, int, int *);
int /*<<< orphan*/ printf(char *, int);
int main(void) {
  int a[] = {1, 2, 3, 3, 3, 2, 1, 4, 5, 6, 0, -100};
  int *h, m, i;
  h = histogram(a, sizeof(a) / sizeof(a[0]), &m);
  if (h) {
    for (i = 0; i < m; i++)
      printf("%d\n", h[i]);
    free(h);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xea6(%rip),%rsi
mov    $0x30,%edx
call   1060 <memcpy@plt>
lea    -0x40(%rbp),%rdi
mov    $0xc,%esi
lea    -0x4c(%rbp),%rdx
call   1040 <histogram@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
je     11c6 <main+0x86>
movl   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%eax
cmp    -0x4c(%rbp),%eax
jge    11bd <main+0x7d>
mov    -0x48(%rbp),%rax
movslq -0x50(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe86(%rip),%rdi
call   1050 <printf@plt>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    118c <main+0x4c>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
movaps 0xee0(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xec4(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xea8(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rdx
mov    $0xc,%esi
call   1040 <histogram@plt>
test   %rax,%rax
je     11b2 <main+0x82>
mov    %rax,%r15
cmpl   $0x0,0xc(%rsp)
jle    11aa <main+0x7a>
xor    %ebx,%ebx
lea    0xea7(%rip),%r14
nopl   0x0(%rax)
mov    (%r15,%rbx,4),%esi
mov    %r14,%rdi
call   1050 <printf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     1190 <main+0x60>
mov    %r15,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.a = [12 x i32] [i32 1, i32 2, i32 3, i32 3, i32 3, i32 2, i32 1, i32 4, i32 5, i32 6, i32 0, i32 -100]
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [12 x i32]
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = bitcast [12 x i32]* %2 to i8*
%7 = getelementptr inbounds [12 x i32], [12 x i32]* %2, i64 0, i64 0
%8 = call i32* @histogram(i32* %7, i32 12, i32* %4)
store i32* %8, i32** %3
%9 = load i32*, i32** %3
%10 = icmp ne i32* %9, null
br i1 %10, label %11, label %29
11: ; preds = %0
store i32 0, i32* %5
br label %12
12: ; preds = %23, %11
%13 = load i32, i32* %5
%14 = load i32, i32* %4
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %26
16: ; preds = %12
%17 = load i32*, i32** %3
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %17, i64 %19
%21 = load i32, i32* %20
%22 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %21)
br label %23
23: ; preds = %16
%24 = load i32, i32* %5
%25 = add nsw i32 %24, 1
store i32 %25, i32* %5
br label %12
26: ; preds = %12
%27 = load i32*, i32** %3
%28 = call i32 @free(i32* %27)
br label %29
29: ; preds = %26, %0
ret i32 0
}

LLVM IR (-O2):
@__const.main.a = [12 x i32] [i32 1, i32 2, i32 3, i32 3, i32 3, i32 2, i32 1, i32 4, i32 5, i32 6, i32 0, i32 -100]
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [12 x i32]
%2 = alloca i32
%3 = bitcast [12 x i32]* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = getelementptr inbounds [12 x i32], [12 x i32]* %1, i64 0, i64 0
%6 = call i32* @histogram(i32* %5, i32 12, i32* %2)
%7 = icmp eq i32* %6, null
br i1 %7, label %22, label %8
8: ; preds = %0
%9 = load i32, i32* %2
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %20
11: ; preds = %8, %11
%12 = phi i64 [ %16, %11 ], [ 0, %8 ]
%13 = getelementptr inbounds i32, i32* %6, i64 %12
%14 = load i32, i32* %13
%15 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = add nuw nsw i64 %12, 1
%17 = load i32, i32* %2
%18 = sext i32 %17 to i64
%19 = icmp slt i64 %16, %18
br i1 %19, label %11, label %20
20: ; preds = %11, %8
%21 = call i32 @free(i32* %6)
br label %22
22: ; preds = %20, %0
ret i32 0
}