#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 *CharCountArray(char *);
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ printf(char *, int, int);
void PrintDup(char *str) {
  int i;
  int *count;
  count = CharCountArray(str);
  for (i = 0; i < 256; i++) {
    if (count[i] > 1) {
      printf("%c is repeated %d extra times\n", i, (count[i] - 1));
    }
  }
  free(count);
}


x86 assembly (clang, -O0):
<PrintDup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <CharCountArray@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x100,-0xc(%rbp)
jge    119f <PrintDup+0x6f>
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
cmpl   $0x1,(%rax,%rcx,4)
jle    118c <PrintDup+0x5c>
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
sub    $0x1,%edx
lea    0xe79(%rip),%rdi
call   1050 <printf@plt>
jmp    1191 <PrintDup+0x61>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1150 <PrintDup+0x20>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PrintDup>:
push   %r15
push   %r14
push   %rbx
call   1040 <CharCountArray@plt>
mov    %rax,%r14
xor    %ebx,%ebx
lea    0xeba(%rip),%r15
jmp    115d <PrintDup+0x2d>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    $0x100,%rbx
je     1175 <PrintDup+0x45>
mov    (%r14,%rbx,4),%edx
cmp    $0x2,%edx
jl     1150 <PrintDup+0x20>
add    $0xffffffff,%edx
mov    %r15,%rdi
mov    %ebx,%esi
call   1050 <printf@plt>
jmp    1150 <PrintDup+0x20>
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <free@plt>

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

LLVM IR (-O2):
@.str = [31 x i8] c"%c is repeated %d extra times\0A\00"
define void @PrintDup(i8* %0) {
%2 = tail call i32* @CharCountArray(i8* %0)
br label %3
3: ; preds = %1, %12
%4 = phi i64 [ 0, %1 ], [ %13, %12 ]
%5 = getelementptr inbounds i32, i32* %2, i64 %4
%6 = load i32, i32* %5
%7 = icmp sgt i32 %6, 1
br i1 %7, label %8, label %12
8: ; preds = %3
%9 = add nsw i32 %6, -1
%10 = trunc i64 %4 to i32
%11 = tail call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %9)
br label %12
12: ; preds = %3, %8
%13 = add nuw nsw i64 %4, 1
%14 = icmp eq i64 %13, 256
br i1 %14, label %15, label %3
15: ; preds = %12
%16 = tail call i32 @free(i32* %2)
ret void
}