#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*/ decode_quad(int, char *);
int /*<<< orphan*/ printf(char *, ...);
void print_csv(unsigned int counts[]) {
  char text[4 + 1];
  int i;
  printf("Prefix, Count\n");
  for (i = 0; i < 65536; ++i) {
    decode_quad(i, text);
    if (counts[i] > 0) {
      printf("%s, %u\n", text, counts[i]);
    }
  }
}


x86 assembly (clang, -O0):
<print_csv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x10000,-0x14(%rbp)
jge    119c <print_csv+0x7c>
mov    -0x14(%rbp),%edi
lea    -0xd(%rbp),%rsi
call   1040 <decode_quad@plt>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jbe    1189 <print_csv+0x69>
lea    -0xd(%rbp),%rsi
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    118e <print_csv+0x6e>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1141 <print_csv+0x21>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_csv>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r12
lea    0xec6(%rip),%rdi
call   1030 <puts@plt>
lea    0x3(%rsp),%r14
lea    0xead(%rip),%r15
xor    %ebx,%ebx
jmp    116d <print_csv+0x3d>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    $0x10000,%rbx
je     118e <print_csv+0x5e>
mov    %ebx,%edi
mov    %r14,%rsi
call   1050 <decode_quad@plt>
mov    (%r12,%rbx,4),%edx
test   %edx,%edx
je     1160 <print_csv+0x30>
mov    %r15,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1160 <print_csv+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [15 x i8] c"Prefix, Count\0A\00"
@.str.1 = [8 x i8] c"%s, %u\0A\00"
define void @print_csv(i32* %0) {
%2 = alloca i32*
%3 = alloca [5 x i8]
%4 = alloca i32
store i32* %0, i32** %2
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %4
br label %6
6: ; preds = %28, %1
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 65536
br i1 %8, label %9, label %31
9: ; preds = %6
%10 = load i32, i32* %4
%11 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%12 = call i32 @decode_quad(i32 %10, i8* %11)
%13 = load i32*, i32** %2
%14 = load i32, i32* %4
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i32, i32* %13, i64 %15
%17 = load i32, i32* %16
%18 = icmp ugt i32 %17, 0
br i1 %18, label %19, label %27
19: ; preds = %9
%20 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%21 = load i32*, i32** %2
%22 = load i32, i32* %4
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %21, i64 %23
%25 = load i32, i32* %24
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %20, i32 %25)
br label %27
27: ; preds = %19, %9
br label %28
28: ; preds = %27
%29 = load i32, i32* %4
%30 = add nsw i32 %29, 1
store i32 %30, i32* %4
br label %6
31: ; preds = %6
ret void
}

LLVM IR (-O2):
@.str.1 = [8 x i8] c"%s, %u\0A\00"
@str = [14 x i8] c"Prefix, Count\00"
define void @print_csv(i32* nocapture %0) {
%2 = alloca [5 x i8]
%3 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
br label %5
5: ; preds = %1, %14
%6 = phi i64 [ 0, %1 ], [ %15, %14 ]
%7 = trunc i64 %6 to i32
%8 = call i32 @decode_quad(i32 %7, i8* %3)
%9 = getelementptr inbounds i32, i32* %0, i64 %6
%10 = load i32, i32* %9
%11 = icmp eq i32 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %5
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %3, i32 %10)
br label %14
14: ; preds = %5, %12
%15 = add nuw nsw i64 %6, 1
%16 = icmp eq i64 %15, 65536
br i1 %16, label %17, label %5
17: ; preds = %14
ret void
}