#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 atoi(char *);
int /*<<< orphan*/ print(int, int, char, int);
int /*<<< orphan*/ printf(char *);
int sortints(int, int);
void chart(int argc, char *argv[]) {
  int counts[16] = {0};
  int i;
  printf("\n");
  for (i = 1; i < argc; i++) {
    int temp = atoi(argv[i]);
    int index = sortints(temp, 16);
    counts[index] = counts[index] + 1;
  }
  for (i = 0; i < 16; i++) {
    char in = counts[i];
    print(i * 16, (i + 1) * 16 - 1, in, argc - 1);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<chart>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1040 <memset@plt>
lea    0xe8a(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11d3 <chart+0x83>
mov    -0x10(%rbp),%rax
movslq -0x54(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x58(%rbp)
mov    -0x58(%rbp),%edi
mov    $0x10,%esi
call   1070 <sortints@plt>
mov    %eax,-0x5c(%rbp)
movslq -0x5c(%rbp),%rax
mov    -0x50(%rbp,%rax,4),%ecx
add    $0x1,%ecx
movslq -0x5c(%rbp),%rax
mov    %ecx,-0x50(%rbp,%rax,4)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1182 <chart+0x32>
movl   $0x0,-0x54(%rbp)
cmpl   $0x10,-0x54(%rbp)
jge    1220 <chart+0xd0>
movslq -0x54(%rbp),%rax
mov    -0x50(%rbp,%rax,4),%eax
mov    %al,-0x5d(%rbp)
mov    -0x54(%rbp),%edi
shl    $0x4,%edi
mov    -0x54(%rbp),%esi
add    $0x1,%esi
shl    $0x4,%esi
sub    $0x1,%esi
mov    -0x5d(%rbp),%al
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
movsbl %al,%edx
call   1050 <print@plt>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    11da <chart+0x8a>
lea    0xdd9(%rip),%rdi
call   1030 <printf@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chart>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x48,%rsp
mov    %rsi,%r14
mov    %edi,%r15d
xorps  %xmm0,%xmm0
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
mov    $0xa,%edi
call   1030 <putchar@plt>
cmp    $0x2,%r15d
jl     11a4 <chart+0x64>
mov    %r15d,%ebx
mov    $0x1,%ebp
xchg   %ax,%ax
mov    (%r14,%rbp,8),%rdi
call   1050 <atoi@plt>
mov    %eax,%edi
mov    $0x10,%esi
call   1060 <sortints@plt>
cltq
addl   $0x1,(%rsp,%rax,4)
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1180 <chart+0x40>
add    $0xffffffff,%r15d
mov    %rsp,%rbp
xor    %ebx,%ebx
nopl   (%rax)
movsbl 0x0(%rbp),%edx
lea    0xf(%rbx),%esi
mov    %ebx,%edi
mov    %r15d,%ecx
call   1040 <print@plt>
add    $0x10,%rbx
add    $0x4,%rbp
cmp    $0x100,%rbx
jne    11b0 <chart+0x70>
mov    $0xa,%edi
add    $0x48,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
define void @chart(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca [16 x i32]
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8
store i32 %0, i32* %3
store i8** %1, i8*** %4
%10 = bitcast [16 x i32]* %5 to i8*
%11 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %6
br label %12
12: ; preds = %33, %2
%13 = load i32, i32* %6
%14 = load i32, i32* %3
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %36
16: ; preds = %12
%17 = load i8**, i8*** %4
%18 = load i32, i32* %6
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8*, i8** %17, i64 %19
%21 = load i8*, i8** %20
%22 = call i32 @atoi(i8* %21)
store i32 %22, i32* %7
%23 = load i32, i32* %7
%24 = call i32 @sortints(i32 %23, i32 16)
store i32 %24, i32* %8
%25 = load i32, i32* %8
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [16 x i32], [16 x i32]* %5, i64 0, i64 %26
%28 = load i32, i32* %27
%29 = add nsw i32 %28, 1
%30 = load i32, i32* %8
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [16 x i32], [16 x i32]* %5, i64 0, i64 %31
store i32 %29, i32* %32
br label %33
33: ; preds = %16
%34 = load i32, i32* %6
%35 = add nsw i32 %34, 1
store i32 %35, i32* %6
br label %12
36: ; preds = %12
store i32 0, i32* %6
br label %37
37: ; preds = %56, %36
%38 = load i32, i32* %6
%39 = icmp slt i32 %38, 16
br i1 %39, label %40, label %59
40: ; preds = %37
%41 = load i32, i32* %6
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [16 x i32], [16 x i32]* %5, i64 0, i64 %42
%44 = load i32, i32* %43
%45 = trunc i32 %44 to i8
store i8 %45, i8* %9
%46 = load i32, i32* %6
%47 = mul nsw i32 %46, 16
%48 = load i32, i32* %6
%49 = add nsw i32 %48, 1
%50 = mul nsw i32 %49, 16
%51 = sub nsw i32 %50, 1
%52 = load i8, i8* %9
%53 = load i32, i32* %3
%54 = sub nsw i32 %53, 1
%55 = call i32 @print(i32 %47, i32 %51, i8 signext %52, i32 %54)
br label %56
56: ; preds = %40
%57 = load i32, i32* %6
%58 = add nsw i32 %57, 1
store i32 %58, i32* %6
br label %37
59: ; preds = %37
%60 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
define void @chart(i32 %0, i8** nocapture %1) {
%3 = alloca [16 x i32]
%4 = bitcast [16 x i32]* %3 to i8*
%5 = tail call i32 @putchar(i32 10)
%6 = icmp sgt i32 %0, 1
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = zext i32 %0 to i64
br label %11
9: ; preds = %11, %2
%10 = add nsw i32 %0, -1
br label %23
11: ; preds = %7, %11
%12 = phi i64 [ 1, %7 ], [ %21, %11 ]
%13 = getelementptr inbounds i8*, i8** %1, i64 %12
%14 = load i8*, i8** %13
%15 = tail call i32 @atoi(i8* %14)
%16 = tail call i32 @sortints(i32 %15, i32 16)
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 %17
%19 = load i32, i32* %18
%20 = add nsw i32 %19, 1
store i32 %20, i32* %18
%21 = add nuw nsw i64 %12, 1
%22 = icmp eq i64 %21, %8
br i1 %22, label %9, label %11
23: ; preds = %9, %23
%24 = phi i64 [ 0, %9 ], [ %28, %23 ]
%25 = getelementptr inbounds [16 x i32], [16 x i32]* %3, i64 0, i64 %24
%26 = load i32, i32* %25
%27 = trunc i32 %26 to i8
%28 = add nuw nsw i64 %24, 1
%29 = trunc i64 %28 to i32
%30 = shl nuw nsw i32 %29, 4
%31 = add nsw i32 %30, -1
%32 = trunc i64 %24 to i32
%33 = shl i32 %32, 4
%34 = tail call i32 @print(i32 %33, i32 %31, i8 signext %27, i32 %10)
%35 = icmp eq i64 %28, 16
br i1 %35, label %36, label %23
36: ; preds = %23
%37 = tail call i32 @putchar(i32 10)
ret void
}