#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 */
size_t HighestCounterFrequency(int *, int);
int /*<<< orphan*/ IsolateUniqueChar(char *, char *, int, int *);
int NumberOfOccurence(char *, char, int);
char HighestFrequency(char arr[], int size) {
  int i;
  int counterfrequency[size];
  char Uniqueletters[size];
  int CounterUniqueCharacters = 0;
  IsolateUniqueChar(arr, Uniqueletters, size, &CounterUniqueCharacters);
  for (i = 0; i < CounterUniqueCharacters; i++)
    counterfrequency[i] = NumberOfOccurence(arr, Uniqueletters[i], size);
  return Uniqueletters[HighestCounterFrequency(counterfrequency,
                                               CounterUniqueCharacters)];
}


x86 assembly (clang, -O0):
<HighestFrequency>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
mov    -0xc(%rbp),%eax
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rsi
sub    %rcx,%rsi
mov    %rsi,-0x38(%rbp)
mov    %rsi,%rsp
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    -0x2c(%rbp),%rcx
call   1050 <IsolateUniqueChar@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    11e4 <HighestFrequency+0xb4>
mov    -0x38(%rbp),%rax
mov    -0x8(%rbp),%rdi
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    -0xc(%rbp),%edx
movsbl %al,%esi
call   1030 <NumberOfOccurence@plt>
mov    %eax,%edx
mov    -0x40(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11a3 <HighestFrequency+0x73>
mov    -0x40(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   1040 <HighestCounterFrequency@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
mov    (%rax,%rcx,1),%al
mov    -0x18(%rbp),%rcx
mov    %rcx,%rsp
movsbl %al,%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HighestFrequency>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r15d
mov    %rdi,%r14
mov    %esi,%eax
mov    %rsp,%r12
lea    0xf(,%rax,4),%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%r12
mov    %r12,%rsp
mov    %rsp,%r13
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
movl   $0x0,-0x2c(%rbp)
lea    -0x2c(%rbp),%rcx
mov    %r13,%rsi
mov    %r15d,%edx
call   1050 <IsolateUniqueChar@plt>
mov    -0x2c(%rbp),%esi
test   %esi,%esi
jle    11b2 <HighestFrequency+0x82>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movsbl 0x0(%r13,%rbx,1),%esi
mov    %r14,%rdi
mov    %r15d,%edx
call   1030 <NumberOfOccurence@plt>
mov    %eax,(%r12,%rbx,4)
add    $0x1,%rbx
movslq -0x2c(%rbp),%rsi
cmp    %rsi,%rbx
jl     1190 <HighestFrequency+0x60>
mov    %r12,%rdi
call   1040 <HighestCounterFrequency@plt>
mov    0x0(%r13,%rax,1),%al
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define signext i8 @HighestFrequency(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%10 = load i32, i32* %4
%11 = zext i32 %10 to i64
%12 = call i8* @llvm.stacksave()
store i8* %12, i8** %6
%13 = alloca i32, i64 %11
store i64 %11, i64* %7
%14 = load i32, i32* %4
%15 = zext i32 %14 to i64
%16 = alloca i8, i64 %15
store i64 %15, i64* %8
store i32 0, i32* %9
%17 = load i8*, i8** %3
%18 = load i32, i32* %4
%19 = call i32 @IsolateUniqueChar(i8* %17, i8* %16, i32 %18, i32* %9)
store i32 0, i32* %5
br label %20
20: ; preds = %35, %2
%21 = load i32, i32* %5
%22 = load i32, i32* %9
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %38
24: ; preds = %20
%25 = load i8*, i8** %3
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %16, i64 %27
%29 = load i8, i8* %28
%30 = load i32, i32* %4
%31 = call i32 @NumberOfOccurence(i8* %25, i8 signext %29, i32 %30)
%32 = load i32, i32* %5
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i32, i32* %13, i64 %33
store i32 %31, i32* %34
br label %35
35: ; preds = %24
%36 = load i32, i32* %5
%37 = add nsw i32 %36, 1
store i32 %37, i32* %5
br label %20
38: ; preds = %20
%39 = load i32, i32* %9
%40 = call i64 @HighestCounterFrequency(i32* %13, i32 %39)
%41 = getelementptr inbounds i8, i8* %16, i64 %40
%42 = load i8, i8* %41
%43 = load i8*, i8** %6
ret i8 %42
}

LLVM IR (-O2):
define signext i8 @HighestFrequency(i8* %0, i32 %1) {
%3 = alloca i32
%4 = zext i32 %1 to i64
%5 = alloca i32, i64 %4
%6 = alloca i8, i64 %4
%7 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%8 = call i32 @IsolateUniqueChar(i8* %0, i8* %6, i32 %1, i32* %3)
%9 = load i32, i32* %3
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %21
11: ; preds = %2, %11
%12 = phi i64 [ %17, %11 ], [ 0, %2 ]
%13 = getelementptr inbounds i8, i8* %6, i64 %12
%14 = load i8, i8* %13
%15 = call i32 @NumberOfOccurence(i8* %0, i8 signext %14, i32 %1)
%16 = getelementptr inbounds i32, i32* %5, i64 %12
store i32 %15, i32* %16
%17 = add nuw nsw i64 %12, 1
%18 = load i32, i32* %3
%19 = sext i32 %18 to i64
%20 = icmp slt i64 %17, %19
br i1 %20, label %11, label %21
21: ; preds = %11, %2
%22 = phi i32 [ %9, %2 ], [ %18, %11 ]
%23 = call i64 @HighestCounterFrequency(i32* %5, i32 %22)
%24 = getelementptr inbounds i8, i8* %6, i64 %23
%25 = load i8, i8* %24
ret i8 %25
}