#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, char *);
int pick_heatmap(int *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  FILE *fp = fopen("input", "r");
  char data[16];
  int heatmaps[8][26] = {{0}}, i;
  if (fp == NULL) {
    printf("could not open input file\n");
    return -1;
  }
  while (fscanf(fp, "%s", data) != EOF) {
    for (i = 0; i < 8; i++) {
      heatmaps[i][(int)data[i] - 'a']++;
    }
  }
  for (i = 0; i < 8; i++) {
    printf("%c", pick_heatmap(heatmaps[i]) + 'a');
  }
  printf("\n");
  fclose(fp);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x370,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe87(%rip),%rdi
lea    0xe86(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    -0x360(%rbp),%rdi
xor    %esi,%esi
mov    $0x340,%edx
call   1060 <memset@plt>
cmpq   $0x0,-0x10(%rbp)
jne    11c1 <main+0x61>
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12c0 <main+0x160>
jmp    11c6 <main+0x66>
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rdx
lea    0xe4e(%rip),%rsi
call   1070 <fscanf@plt>
mov    0x2e07(%rip),%rcx
cmp    (%rcx),%rax
je     124a <main+0xea>
movl   $0x0,-0x364(%rbp)
cmpl   $0x8,-0x364(%rbp)
jge    1245 <main+0xe5>
movslq -0x364(%rbp),%rcx
lea    -0x360(%rbp),%rax
imul   $0x68,%rcx,%rcx
add    %rcx,%rax
movslq -0x364(%rbp),%rcx
movsbl -0x20(%rbp,%rcx,1),%ecx
sub    $0x61,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edx
add    $0x1,%edx
mov    %edx,(%rax,%rcx,4)
mov    -0x364(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x364(%rbp)
jmp    11f4 <main+0x94>
jmp    11c6 <main+0x66>
movl   $0x0,-0x364(%rbp)
cmpl   $0x8,-0x364(%rbp)
jge    12a2 <main+0x142>
movslq -0x364(%rbp),%rax
lea    -0x360(%rbp),%rdi
imul   $0x68,%rax,%rax
add    %rax,%rdi
call   1030 <pick_heatmap@plt>
mov    %eax,%esi
add    $0x61,%esi
lea    0xd9f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x364(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x364(%rbp)
jmp    1254 <main+0xf4>
lea    0xd78(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x370,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x358,%rsp
lea    0xe7b(%rip),%rdi
lea    0xe7a(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%r14
lea    0x10(%rsp),%rdi
mov    $0x340,%edx
xor    %esi,%esi
call   1070 <memset@plt>
test   %r14,%r14
je     1315 <main+0x1a5>
lea    0xe53(%rip),%rsi
mov    %rsp,%rdx
mov    %r14,%rdi
call   1080 <fscanf@plt>
mov    0x2e21(%rip),%r12
cmp    (%r12),%rax
je     125d <main+0xed>
lea    0xe30(%rip),%r15
mov    %rsp,%rbx
nopl   0x0(%rax,%rax,1)
movsbq (%rsp),%rax
addl   $0x1,-0x174(%rsp,%rax,4)
01
movsbq 0x1(%rsp),%rax
addl   $0x1,-0x10c(%rsp,%rax,4)
01
movsbq 0x2(%rsp),%rax
addl   $0x1,-0xa4(%rsp,%rax,4)
01
movsbq 0x3(%rsp),%rax
addl   $0x1,-0x3c(%rsp,%rax,4)
movsbq 0x4(%rsp),%rax
addl   $0x1,0x2c(%rsp,%rax,4)
movsbq 0x5(%rsp),%rax
addl   $0x1,0x94(%rsp,%rax,4)
01
movsbq 0x6(%rsp),%rax
addl   $0x1,0xfc(%rsp,%rax,4)
01
movsbq 0x7(%rsp),%rax
addl   $0x1,0x164(%rsp,%rax,4)
01
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1080 <fscanf@plt>
cmp    (%r12),%rax
jne    11e0 <main+0x70>
lea    0x10(%rsp),%rdi
call   1030 <pick_heatmap@plt>
lea    0x61(%rax),%edi
call   1040 <putchar@plt>
lea    0x78(%rsp),%rdi
call   1030 <pick_heatmap@plt>
lea    0x61(%rax),%edi
call   1040 <putchar@plt>
lea    0xe0(%rsp),%rdi
call   1030 <pick_heatmap@plt>
lea    0x61(%rax),%edi
call   1040 <putchar@plt>
lea    0x148(%rsp),%rdi
call   1030 <pick_heatmap@plt>
lea    0x61(%rax),%edi
call   1040 <putchar@plt>
lea    0x1b0(%rsp),%rdi
call   1030 <pick_heatmap@plt>
lea    0x61(%rax),%edi
call   1040 <putchar@plt>
lea    0x218(%rsp),%rdi
call   1030 <pick_heatmap@plt>
lea    0x61(%rax),%edi
call   1040 <putchar@plt>
lea    0x280(%rsp),%rdi
call   1030 <pick_heatmap@plt>
lea    0x61(%rax),%edi
call   1040 <putchar@plt>
lea    0x2e8(%rsp),%rdi
call   1030 <pick_heatmap@plt>
lea    0x61(%rax),%edi
call   1040 <putchar@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %r14,%rdi
call   1060 <fclose@plt>
xor    %eax,%eax
jmp    1326 <main+0x1b6>
lea    0xcef(%rip),%rdi
call   1050 <puts@plt>
mov    $0xffffffff,%eax
add    $0x358,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [6 x i8] c"input\00"
@.str.1 = [2 x i8] c"r\00"
@.str.3 = [3 x i8] c"%s\00"
@EOF = global i64 0
@str = [26 x i8] c"could not open input file\00"
define i32 @main() {
%1 = alloca [16 x i8]
%2 = alloca [8 x [26 x i32]]
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
%5 = bitcast [8 x [26 x i32]]* %2 to i8*
%6 = icmp eq i32* %3, null
br i1 %6, label %19, label %7
7: ; preds = %0
%8 = call i64 @fscanf(i32* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%9 = load i64, i64* @EOF
%10 = icmp eq i64 %8, %9
br i1 %10, label %73, label %11
11: ; preds = %7
%12 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 1
%13 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 2
%14 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 3
%15 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 4
%16 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 5
%17 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 6
%18 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 7
br label %21
19: ; preds = %0
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
br label %108
21: ; preds = %11, %21
%22 = load i8, i8* %4
%23 = sext i8 %22 to i64
%24 = add nsw i64 %23, -97
%25 = getelementptr inbounds [8 x [26 x i32]], [8 x [26 x i32]]* %2, i64 0, i64 0, i64 %24
%26 = load i32, i32* %25
%27 = add nsw i32 %26, 1
store i32 %27, i32* %25
%28 = load i8, i8* %12
%29 = sext i8 %28 to i64
%30 = add nsw i64 %29, -97
%31 = getelementptr inbounds [8 x [26 x i32]], [8 x [26 x i32]]* %2, i64 0, i64 1, i64 %30
%32 = load i32, i32* %31
%33 = add nsw i32 %32, 1
store i32 %33, i32* %31
%34 = load i8, i8* %13
%35 = sext i8 %34 to i64
%36 = add nsw i64 %35, -97
%37 = getelementptr inbounds [8 x [26 x i32]], [8 x [26 x i32]]* %2, i64 0, i64 2, i64 %36
%38 = load i32, i32* %37
%39 = add nsw i32 %38, 1
store i32 %39, i32* %37
%40 = load i8, i8* %14
%41 = sext i8 %40 to i64
%42 = add nsw i64 %41, -97
%43 = getelementptr inbounds [8 x [26 x i32]], [8 x [26 x i32]]* %2, i64 0, i64 3, i64 %42
%44 = load i32, i32* %43
%45 = add nsw i32 %44, 1
store i32 %45, i32* %43
%46 = load i8, i8* %15
%47 = sext i8 %46 to i64
%48 = add nsw i64 %47, -97
%49 = getelementptr inbounds [8 x [26 x i32]], [8 x [26 x i32]]* %2, i64 0, i64 4, i64 %48
%50 = load i32, i32* %49
%51 = add nsw i32 %50, 1
store i32 %51, i32* %49
%52 = load i8, i8* %16
%53 = sext i8 %52 to i64
%54 = add nsw i64 %53, -97
%55 = getelementptr inbounds [8 x [26 x i32]], [8 x [26 x i32]]* %2, i64 0, i64 5, i64 %54
%56 = load i32, i32* %55
%57 = add nsw i32 %56, 1
store i32 %57, i32* %55
%58 = load i8, i8* %17
%59 = sext i8 %58 to i64
%60 = add nsw i64 %59, -97
%61 = getelementptr inbounds [8 x [26 x i32]], [8 x [26 x i32]]* %2, i64 0, i64 6, i64 %60
%62 = load i32, i32* %61
%63 = add nsw i32 %62, 1
store i32 %63, i32* %61
%64 = load i8, i8* %18
%65 = sext i8 %64 to i64
%66 = add nsw i64 %65, -97
%67 = getelementptr inbounds [8 x [26 x i32]], [8 x [26 x i32]]* %2, i64 0, i64 7, i64 %66
%68 = load i32, i32* %67
%69 = add nsw i32 %68, 1
store i32 %69, i32* %67
%70 = call i64 @fscanf(i32* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%71 = load i64, i64* @EOF
%72 = icmp eq i64 %70, %71
br i1 %72, label %73, label %21
73: ; preds = %21, %7
%74 = getelementptr inbounds [8 x [26 x i32]], [8 x [26 x i32]]* %2, i64 0, i64 0, i64 0
%75 = call i32 @pick_heatmap(i32* %74)
%76 = add nsw i32 %75, 97
%77 = call i32 @putchar(i32 %76)
%78 = getelementptr inbounds [8 x [26 x i32]], [8 x [26 x i32]]* %2, i64 0, i64 1, i64 0
%79 = call i32 @pick_heatmap(i32* %78)
%80 = add nsw i32 %79, 97
%81 = call i32 @putchar(i32 %80)
%82 = getelementptr inbounds [8 x [26 x i32]], [8 x [26 x i32]]* %2, i64 0, i64 2, i64 0
%83 = call i32 @pick_heatmap(i32* %82)
%84 = add nsw i32 %83, 97
%85 = call i32 @putchar(i32 %84)
%86 = getelementptr inbounds [8 x [26 x i32]], [8 x [26 x i32]]* %2, i64 0, i64 3, i64 0
%87 = call i32 @pick_heatmap(i32* %86)
%88 = add nsw i32 %87, 97
%89 = call i32 @putchar(i32 %88)
%90 = getelementptr inbounds [8 x [26 x i32]], [8 x [26 x i32]]* %2, i64 0, i64 4, i64 0
%91 = call i32 @pick_heatmap(i32* %90)
%92 = add nsw i32 %91, 97
%93 = call i32 @putchar(i32 %92)
%94 = getelementptr inbounds [8 x [26 x i32]], [8 x [26 x i32]]* %2, i64 0, i64 5, i64 0
%95 = call i32 @pick_heatmap(i32* %94)
%96 = add nsw i32 %95, 97
%97 = call i32 @putchar(i32 %96)
%98 = getelementptr inbounds [8 x [26 x i32]], [8 x [26 x i32]]* %2, i64 0, i64 6, i64 0
%99 = call i32 @pick_heatmap(i32* %98)
%100 = add nsw i32 %99, 97
%101 = call i32 @putchar(i32 %100)
%102 = getelementptr inbounds [8 x [26 x i32]], [8 x [26 x i32]]* %2, i64 0, i64 7, i64 0
%103 = call i32 @pick_heatmap(i32* %102)
%104 = add nsw i32 %103, 97
%105 = call i32 @putchar(i32 %104)
%106 = call i32 @putchar(i32 10)
%107 = call i32 @fclose(i32* %3)
br label %108
108: ; preds = %73, %19
%109 = phi i32 [ -1, %19 ], [ 0, %73 ]
ret i32 %109
}