#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*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
void mode(unsigned int freq[], const unsigned int answer[]) {
  size_t rating;
  size_t j;
  unsigned int h;
  unsigned int largest = 0;
  unsigned int secondlargest = 0;
  unsigned int modeValue = 0;
  unsigned int modeValue2 = 0;
  printf("\n%s\n%s\n%s\n", "********", " Mode", "*********");
  for (rating = 1; rating <= 9; ++rating) {
    freq[rating] = 0;
  }
  for (j = 0; j < 100; ++j) {
    ++freq[answer[j]];
  }
  printf("%s%11s%19s\n\n%54s\n%54s\n\n", "Response", "Frequency", "Histogram",
         "1    1   2     2", "5    0    5    0     5");
  for (rating = 1; rating <= 9; ++rating) {
    printf("%8u%11u        ", rating, freq[rating]);
    if (freq[rating] >= largest) {
      secondlargest = largest;
      largest = freq[rating];
      modeValue2 = modeValue;
      modeValue = rating;
    }
    for (h = 1; h <= freq[rating]; ++h) {
      printf("%s", "*");
    }
    puts("");
  }
  if (largest == secondlargest) {
    printf("\nThe mode is the most frequent value.\n"
           "For this run the mode is %u and %u wich occurred"
           " %u times each.\n",
           modeValue, modeValue2, largest);
  } else {
    printf("\nThe mode is the most frequent value.\n"
           "For this run the mode is %u wich occurred"
           " %u times.\n",
           modeValue, largest);
  }
  return;
}


x86 assembly (clang, -O0):
<mode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
lea    0xead(%rip),%rdi
lea    0xeb8(%rip),%rsi
lea    0xeaa(%rip),%rdx
lea    0xea9(%rip),%rcx
mov    $0x0,%al
call   1040 <printf@plt>
movq   $0x1,-0x18(%rbp)
cmpq   $0x9,-0x18(%rbp)
ja     11a2 <mode+0x82>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1177 <mode+0x57>
movq   $0x0,-0x20(%rbp)
cmpq   $0x64,-0x20(%rbp)
jae    11de <mode+0xbe>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    -0x20(%rbp),%rdx
mov    (%rcx,%rdx,4),%ecx
mov    (%rax,%rcx,4),%edx
add    $0x1,%edx
mov    %edx,(%rax,%rcx,4)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    11aa <mode+0x8a>
lea    0xe36(%rip),%rdi
lea    0xe47(%rip),%rsi
lea    0xe49(%rip),%rdx
lea    0xe4c(%rip),%rcx
lea    0xe4f(%rip),%r8
lea    0xe59(%rip),%r9
mov    $0x0,%al
call   1040 <printf@plt>
movq   $0x1,-0x18(%rbp)
cmpq   $0x9,-0x18(%rbp)
ja     12cf <mode+0x1af>
mov    -0x18(%rbp),%rsi
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x28(%rbp),%eax
jb     1274 <mode+0x154>
mov    -0x28(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x28(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%rax
mov    %eax,-0x30(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x8(%rbp),%rcx
mov    -0x18(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
ja     12b2 <mode+0x192>
lea    0xdf2(%rip),%rdi
lea    0xd7c(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    127b <mode+0x15b>
lea    0xd79(%rip),%rdi
call   1030 <puts@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1217 <mode+0xf7>
mov    -0x28(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jne    12f7 <mode+0x1d7>
mov    -0x30(%rbp),%esi
mov    -0x34(%rbp),%edx
mov    -0x28(%rbp),%ecx
lea    0xda0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    130b <mode+0x1eb>
mov    -0x30(%rbp),%esi
mov    -0x28(%rbp),%edx
lea    0xdee(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mode>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbp
mov    %rdi,%r15
lea    0xec8(%rip),%rdi
lea    0xed3(%rip),%rsi
lea    0xec5(%rip),%rdx
lea    0xec4(%rip),%rcx
xor    %eax,%eax
call   1040 <printf@plt>
xorps  %xmm0,%xmm0
movups %xmm0,0x4(%r15)
movups %xmm0,0x14(%r15)
movl   $0x0,0x24(%r15)
mov    $0x3,%eax
xchg   %ax,%ax
mov    -0xc(%rbp,%rax,4),%ecx
addl   $0x1,(%r15,%rcx,4)
mov    -0x8(%rbp,%rax,4),%ecx
addl   $0x1,(%r15,%rcx,4)
mov    -0x4(%rbp,%rax,4),%ecx
addl   $0x1,(%r15,%rcx,4)
mov    0x0(%rbp,%rax,4),%ecx
addl   $0x1,(%r15,%rcx,4)
add    $0x4,%rax
cmp    $0x67,%rax
jne    1170 <mode+0x50>
lea    0xe76(%rip),%rdi
lea    0xe87(%rip),%rsi
lea    0xe89(%rip),%rdx
lea    0xe8c(%rip),%rcx
lea    0xe8f(%rip),%r8
lea    0xe99(%rip),%r9
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%ebp
movl   $0x0,(%rsp)
xor    %r13d,%r13d
movl   $0x0,0x4(%rsp)
xor    %r12d,%r12d
jmp    120d <mode+0xed>
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%rbp
mov    %r12d,%r13d
mov    %r12d,%esi
mov    %r14d,%r12d
cmp    $0xa,%rbp
je     1278 <mode+0x158>
mov    (%r15,%rbp,4),%edx
lea    0xe60(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%r15,%rbp,4),%eax
cmp    %r12d,%eax
jae    1240 <mode+0x120>
mov    %r12d,%r14d
mov    %r13d,%r12d
test   %eax,%eax
jne    1253 <mode+0x133>
jmp    11f0 <mode+0xd0>
nopw   0x0(%rax,%rax,1)
mov    %eax,%r14d
mov    %r12d,0x4(%rsp)
mov    %ebp,%r12d
mov    %r13d,(%rsp)
test   %eax,%eax
je     11f0 <mode+0xd0>
mov    $0x1,%ebx
nopl   0x0(%rax,%rax,1)
mov    $0x2a,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
cmp    (%r15,%rbp,4),%ebx
jbe    1260 <mode+0x140>
jmp    11f0 <mode+0xd0>
cmp    0x4(%rsp),%r14d
jne    12a1 <mode+0x181>
lea    0xe02(%rip),%rdi
mov    (%rsp),%edx
mov    %r14d,%ecx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>
lea    0xe47(%rip),%rdi
mov    %r14d,%edx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"\0A%s\0A%s\0A%s\0A\00"
@.str.1 = [9 x i8] c"********\00"
@.str.2 = [6 x i8] c" Mode\00"
@.str.3 = [10 x i8] c"*********\00"
@.str.4 = [24 x i8] c"%s%11s%19s\0A\0A%54s\0A%54s\0A\0A\00"
@.str.5 = [9 x i8] c"Response\00"
@.str.6 = [10 x i8] c"Frequency\00"
@.str.7 = [10 x i8] c"Histogram\00"
@.str.8 = [17 x i8] c"1 1 2 2\00"
@.str.9 = [23 x i8] c"5 0 5 0 5\00"
@.str.10 = [16 x i8] c"%8u%11u \00"
@.str.11 = [3 x i8] c"%s\00"
@.str.12 = [2 x i8] c"*\00"
@.str.13 = [1 x i8] zeroinitializer
@.str.14 = [103 x i8] c"\0AThe mode is the most frequent value.\0AFor this run the mode is %u and %u wich occurred %u times each.\0A\00"
@.str.15 = [91 x i8] c"\0AThe mode is the most frequent value.\0AFor this run the mode is %u wich occurred %u times.\0A\00"
define void @mode(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i64
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
store i32 0, i32* %11
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
store i64 1, i64* %5
br label %13
13: ; preds = %20, %2
%14 = load i64, i64* %5
%15 = icmp ule i64 %14, 9
br i1 %15, label %16, label %23
16: ; preds = %13
%17 = load i32*, i32** %3
%18 = load i64, i64* %5
%19 = getelementptr inbounds i32, i32* %17, i64 %18
store i32 0, i32* %19
br label %20
20: ; preds = %16
%21 = load i64, i64* %5
%22 = add i64 %21, 1
store i64 %22, i64* %5
br label %13
23: ; preds = %13
store i64 0, i64* %6
br label %24
24: ; preds = %37, %23
%25 = load i64, i64* %6
%26 = icmp ult i64 %25, 100
br i1 %26, label %27, label %40
27: ; preds = %24
%28 = load i32*, i32** %3
%29 = load i32*, i32** %4
%30 = load i64, i64* %6
%31 = getelementptr inbounds i32, i32* %29, i64 %30
%32 = load i32, i32* %31
%33 = zext i32 %32 to i64
%34 = getelementptr inbounds i32, i32* %28, i64 %33
%35 = load i32, i32* %34
%36 = add i32 %35, 1
store i32 %36, i32* %34
br label %37
37: ; preds = %27
%38 = load i64, i64* %6
%39 = add i64 %38, 1
store i64 %39, i64* %6
br label %24
40: ; preds = %24
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0))
store i64 1, i64* %5
br label %42
42: ; preds = %82, %40
%43 = load i64, i64* %5
%44 = icmp ule i64 %43, 9
br i1 %44, label %45, label %85
45: ; preds = %42
%46 = load i64, i64* %5
%47 = load i32*, i32** %3
%48 = load i64, i64* %5
%49 = getelementptr inbounds i32, i32* %47, i64 %48
%50 = load i32, i32* %49
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i64 %46, i32 %50)
%52 = load i32*, i32** %3
%53 = load i64, i64* %5
%54 = getelementptr inbounds i32, i32* %52, i64 %53
%55 = load i32, i32* %54
%56 = load i32, i32* %8
%57 = icmp uge i32 %55, %56
br i1 %57, label %58, label %67
58: ; preds = %45
%59 = load i32, i32* %8
store i32 %59, i32* %9
%60 = load i32*, i32** %3
%61 = load i64, i64* %5
%62 = getelementptr inbounds i32, i32* %60, i64 %61
%63 = load i32, i32* %62
store i32 %63, i32* %8
%64 = load i32, i32* %10
store i32 %64, i32* %11
%65 = load i64, i64* %5
%66 = trunc i64 %65 to i32
store i32 %66, i32* %10
br label %67
67: ; preds = %58, %45
store i32 1, i32* %7
br label %68
68: ; preds = %77, %67
%69 = load i32, i32* %7
%70 = load i32*, i32** %3
%71 = load i64, i64* %5
%72 = getelementptr inbounds i32, i32* %70, i64 %71
%73 = load i32, i32* %72
%74 = icmp ule i32 %69, %73
br i1 %74, label %75, label %80
75: ; preds = %68
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
br label %77
77: ; preds = %75
%78 = load i32, i32* %7
%79 = add i32 %78, 1
store i32 %79, i32* %7
br label %68
80: ; preds = %68
%81 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.13, i64 0, i64 0))
br label %82
82: ; preds = %80
%83 = load i64, i64* %5
%84 = add i64 %83, 1
store i64 %84, i64* %5
br label %42
85: ; preds = %42
%86 = load i32, i32* %8
%87 = load i32, i32* %9
%88 = icmp eq i32 %86, %87
br i1 %88, label %89, label %94
89: ; preds = %85
%90 = load i32, i32* %10
%91 = load i32, i32* %11
%92 = load i32, i32* %8
%93 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([103 x i8], [103 x i8]* @.str.14, i64 0, i64 0), i32 %90, i32 %91, i32 %92)
br label %98
94: ; preds = %85
%95 = load i32, i32* %10
%96 = load i32, i32* %8
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([91 x i8], [91 x i8]* @.str.15, i64 0, i64 0), i32 %95, i32 %96)
br label %98
98: ; preds = %94, %89
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"\0A%s\0A%s\0A%s\0A\00"
@.str.1 = [9 x i8] c"********\00"
@.str.2 = [6 x i8] c" Mode\00"
@.str.3 = [10 x i8] c"*********\00"
@.str.4 = [24 x i8] c"%s%11s%19s\0A\0A%54s\0A%54s\0A\0A\00"
@.str.5 = [9 x i8] c"Response\00"
@.str.6 = [10 x i8] c"Frequency\00"
@.str.7 = [10 x i8] c"Histogram\00"
@.str.8 = [17 x i8] c"1 1 2 2\00"
@.str.9 = [23 x i8] c"5 0 5 0 5\00"
@.str.10 = [16 x i8] c"%8u%11u \00"
@.str.14 = [103 x i8] c"\0AThe mode is the most frequent value.\0AFor this run the mode is %u and %u wich occurred %u times each.\0A\00"
@.str.15 = [91 x i8] c"\0AThe mode is the most frequent value.\0AFor this run the mode is %u wich occurred %u times.\0A\00"
define void @mode(i32* nocapture %0, i32* nocapture %1) {
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%4 = getelementptr i32, i32* %0, i64 1
%5 = bitcast i32* %4 to i8*
br label %6
6: ; preds = %6, %2
%7 = phi i64 [ 0, %2 ], [ %35, %6 ]
%8 = getelementptr inbounds i32, i32* %1, i64 %7
%9 = load i32, i32* %8
%10 = zext i32 %9 to i64
%11 = getelementptr inbounds i32, i32* %0, i64 %10
%12 = load i32, i32* %11
%13 = add i32 %12, 1
store i32 %13, i32* %11
%14 = or i64 %7, 1
%15 = getelementptr inbounds i32, i32* %1, i64 %14
%16 = load i32, i32* %15
%17 = zext i32 %16 to i64
%18 = getelementptr inbounds i32, i32* %0, i64 %17
%19 = load i32, i32* %18
%20 = add i32 %19, 1
store i32 %20, i32* %18
%21 = or i64 %7, 2
%22 = getelementptr inbounds i32, i32* %1, i64 %21
%23 = load i32, i32* %22
%24 = zext i32 %23 to i64
%25 = getelementptr inbounds i32, i32* %0, i64 %24
%26 = load i32, i32* %25
%27 = add i32 %26, 1
store i32 %27, i32* %25
%28 = or i64 %7, 3
%29 = getelementptr inbounds i32, i32* %1, i64 %28
%30 = load i32, i32* %29
%31 = zext i32 %30 to i64
%32 = getelementptr inbounds i32, i32* %0, i64 %31
%33 = load i32, i32* %32
%34 = add i32 %33, 1
store i32 %34, i32* %32
%35 = add nuw nsw i64 %7, 4
%36 = icmp eq i64 %35, 100
br i1 %36, label %37, label %6
37: ; preds = %6
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0))
br label %39
39: ; preds = %37, %64
%40 = phi i32 [ 0, %37 ], [ %56, %64 ]
%41 = phi i32 [ 0, %37 ], [ %55, %64 ]
%42 = phi i32 [ 0, %37 ], [ %54, %64 ]
%43 = phi i32 [ 0, %37 ], [ %53, %64 ]
%44 = phi i64 [ 1, %37 ], [ %66, %64 ]
%45 = getelementptr inbounds i32, i32* %0, i64 %44
%46 = load i32, i32* %45
%47 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i64 %44, i32 %46)
%48 = load i32, i32* %45
%49 = icmp ult i32 %48, %43
br i1 %49, label %52, label %50
50: ; preds = %39
%51 = trunc i64 %44 to i32
br label %52
52: ; preds = %50, %39
%53 = phi i32 [ %48, %50 ], [ %43, %39 ]
%54 = phi i32 [ %43, %50 ], [ %42, %39 ]
%55 = phi i32 [ %51, %50 ], [ %41, %39 ]
%56 = phi i32 [ %41, %50 ], [ %40, %39 ]
%57 = icmp eq i32 %48, 0
br i1 %57, label %64, label %58
58: ; preds = %52, %58
%59 = phi i32 [ %61, %58 ], [ 1, %52 ]
%60 = tail call i32 @putchar(i32 42)
%61 = add i32 %59, 1
%62 = load i32, i32* %45
%63 = icmp ugt i32 %61, %62
br i1 %63, label %64, label %58
64: ; preds = %58, %52
%65 = tail call i32 @putchar(i32 10)
%66 = add nuw nsw i64 %44, 1
%67 = icmp eq i64 %66, 10
br i1 %67, label %68, label %39
68: ; preds = %64
%69 = icmp eq i32 %53, %54
br i1 %69, label %70, label %72
70: ; preds = %68
%71 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([103 x i8], [103 x i8]* @.str.14, i64 0, i64 0), i32 %55, i32 %56, i32 %53)
br label %74
72: ; preds = %68
%73 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([91 x i8], [91 x i8]* @.str.15, i64 0, i64 0), i32 %55, i32 %53)
br label %74
74: ; preds = %72, %70
ret void
}