#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 atoi(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, char *);
char pick_heatmap(int *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int main() {
  FILE *fp = fopen("input", "r");
  char data[64];
  int real_rooms = 0, sector_id_sum = 0;
  if (fp == NULL) {
    printf("could not open input file\n");
    return -1;
  }
  while (fscanf(fp, "%s", data) != EOF) {
    int i = -1, sector_id = 0, heatmap['z' - 'a' + 1] = {0};
    char checksum[6], calc[6] = {'\0'};
    while (data[++i] != ']') {
      if (!sector_id && data[i] >= 'a' && data[i] <= 'z') {
        heatmap[(int)data[i] - 'a']++;
      }
      if (!sector_id && data[i] >= '0' && data[i] <= '9') {
        sector_id = atoi(data + i);
      }
      if (data[i] == '[') {
        strncpy(checksum, data + (++i), 5);
      }
    }
    for (i = 0; i < 5; i++) {
      calc[i] = pick_heatmap(heatmap) + 'a';
    }
    if (strcmp(checksum, calc) == 0) {
      real_rooms++;
      sector_id_sum = sector_id_sum + sector_id;
      i = -1;
      int offset = sector_id % 26;
      while (data[++i] != '[') {
        int newchar = ' ';
        if (data[i] == '-') {
          newchar = ' ';
        }
        if (data[i] >= 'a' && data[i] <= 'z') {
          newchar = data[i] + offset;
          if (newchar > 'z') {
            newchar = newchar - 26;
          }
        }
        printf("%c", newchar);
      }
      printf(" (Sector ID %i)\n", sector_id);
    }
  }
  printf("There were %i valid rooms, with a sector id sum of %i\n", real_rooms,
         sector_id_sum);
  fclose(fp);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe57(%rip),%rdi
lea    0xe56(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x54(%rbp)
movl   $0x0,-0x58(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11ec <main+0x5c>
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    149b <main+0x30b>
jmp    11f1 <main+0x61>
mov    -0x10(%rbp),%rdi
lea    -0x50(%rbp),%rdx
lea    0xe23(%rip),%rsi
call   1080 <fscanf@plt>
mov    0x2ddc(%rip),%rcx
cmp    (%rcx),%rax
je     1477 <main+0x2e7>
movl   $0xffffffff,-0x5c(%rbp)
movl   $0x0,-0x60(%rbp)
lea    -0xd0(%rbp),%rdi
xor    %esi,%esi
mov    $0x68,%edx
call   1070 <memset@plt>
lea    -0xdc(%rbp),%rdi
xor    %esi,%esi
mov    $0x6,%edx
call   1070 <memset@plt>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
cltq
movsbl -0x50(%rbp,%rax,1),%eax
cmp    $0x5d,%eax
je     132a <main+0x19a>
cmpl   $0x0,-0x60(%rbp)
jne    12af <main+0x11f>
movslq -0x5c(%rbp),%rax
movsbl -0x50(%rbp,%rax,1),%eax
cmp    $0x61,%eax
jl     12af <main+0x11f>
movslq -0x5c(%rbp),%rax
movsbl -0x50(%rbp,%rax,1),%eax
cmp    $0x7a,%eax
jg     12af <main+0x11f>
movslq -0x5c(%rbp),%rax
movsbl -0x50(%rbp,%rax,1),%eax
sub    $0x61,%eax
cltq
mov    -0xd0(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0xd0(%rbp,%rax,4)
cmpl   $0x0,-0x60(%rbp)
jne    12f0 <main+0x160>
movslq -0x5c(%rbp),%rax
movsbl -0x50(%rbp,%rax,1),%eax
cmp    $0x30,%eax
jl     12f0 <main+0x160>
movslq -0x5c(%rbp),%rax
movsbl -0x50(%rbp,%rax,1),%eax
cmp    $0x39,%eax
jg     12f0 <main+0x160>
lea    -0x50(%rbp),%rdi
movslq -0x5c(%rbp),%rax
add    %rax,%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x60(%rbp)
movslq -0x5c(%rbp),%rax
movsbl -0x50(%rbp,%rax,1),%eax
cmp    $0x5b,%eax
jne    1325 <main+0x195>
lea    -0xd6(%rbp),%rdi
lea    -0x50(%rbp),%rsi
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
cltq
add    %rax,%rsi
mov    $0x5,%edx
call   1040 <strncpy@plt>
jmp    1249 <main+0xb9>
movl   $0x0,-0x5c(%rbp)
cmpl   $0x5,-0x5c(%rbp)
jge    1368 <main+0x1d8>
lea    -0xd0(%rbp),%rdi
call   1030 <pick_heatmap@plt>
movsbl %al,%eax
add    $0x61,%eax
mov    %al,%cl
movslq -0x5c(%rbp),%rax
mov    %cl,-0xdc(%rbp,%rax,1)
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    1331 <main+0x1a1>
lea    -0xd6(%rbp),%rdi
lea    -0xdc(%rbp),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    1472 <main+0x2e2>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
mov    -0x58(%rbp),%eax
add    -0x60(%rbp),%eax
mov    %eax,-0x58(%rbp)
movl   $0xffffffff,-0x5c(%rbp)
mov    -0x60(%rbp),%eax
mov    $0x1a,%ecx
cltd
idiv   %ecx
mov    %edx,-0xe0(%rbp)
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
cltq
movsbl -0x50(%rbp,%rax,1),%eax
cmp    $0x5b,%eax
je     1461 <main+0x2d1>
movl   $0x20,-0xe4(%rbp)
movslq -0x5c(%rbp),%rax
movsbl -0x50(%rbp,%rax,1),%eax
cmp    $0x2d,%eax
jne    13ee <main+0x25e>
movl   $0x20,-0xe4(%rbp)
movslq -0x5c(%rbp),%rax
movsbl -0x50(%rbp,%rax,1),%eax
cmp    $0x61,%eax
jl     1448 <main+0x2b8>
movslq -0x5c(%rbp),%rax
movsbl -0x50(%rbp,%rax,1),%eax
cmp    $0x7a,%eax
jg     1448 <main+0x2b8>
movslq -0x5c(%rbp),%rax
movsbl -0x50(%rbp,%rax,1),%eax
add    -0xe0(%rbp),%eax
mov    %eax,-0xe4(%rbp)
cmpl   $0x7a,-0xe4(%rbp)
jle    1443 <main+0x2b3>
mov    -0xe4(%rbp),%eax
sub    $0x1a,%eax
mov    %eax,-0xe4(%rbp)
jmp    1448 <main+0x2b8>
mov    -0xe4(%rbp),%esi
lea    0xbd1(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    13af <main+0x21f>
mov    -0x60(%rbp),%esi
lea    0xbbe(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    11f1 <main+0x61>
mov    -0x54(%rbp),%esi
mov    -0x58(%rbp),%edx
lea    0xbb6(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc8,%rsp
lea    0xe48(%rip),%rdi
lea    0xe47(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     1221 <main+0x81>
mov    %rax,%r12
lea    0xe35(%rip),%rsi
lea    0x20(%rsp),%rbp
mov    %rax,%rdi
mov    %rbp,%rdx
call   1090 <fscanf@plt>
mov    0x2dfe(%rip),%rcx
movl   $0x0,0x10(%rsp)
movl   $0x0,0x14(%rsp)
cmp    (%rcx),%rax
jne    1244 <main+0xa4>
lea    0xe16(%rip),%rdi
mov    0x10(%rsp),%esi
mov    0x14(%rsp),%edx
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r12,%rdi
call   1070 <fclose@plt>
xor    %eax,%eax
jmp    1232 <main+0x92>
lea    0xe2b(%rip),%rdi
call   1060 <puts@plt>
mov    $0xffffffff,%eax
add    $0xc8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
movl   $0x0,0x14(%rsp)
movl   $0x0,0x10(%rsp)
jmp    12a3 <main+0x103>
cs nopw 0x0(%rax,%rax,1)
addl   $0x1,0x10(%rsp)
add    %r15d,0x14(%rsp)
lea    0xd9a(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r14,%r12
mov    %r13,%rbp
mov    %r12,%rdi
lea    0xd7d(%rip),%rsi
mov    %rbp,%rdx
call   1090 <fscanf@plt>
mov    0x2d4e(%rip),%rcx
cmp    (%rcx),%rax
je     11ff <main+0x5f>
xorps  %xmm0,%xmm0
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movq   $0x0,0xc0(%rsp)
movw   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
mov    0x20(%rsp),%al
mov    $0x0,%r15d
cmp    $0x5d,%al
jne    13d0 <main+0x230>
lea    0x60(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <pick_heatmap@plt>
add    $0x61,%al
mov    %al,0x8(%rsp)
mov    %rbx,%rdi
call   1030 <pick_heatmap@plt>
add    $0x61,%al
mov    %al,0x9(%rsp)
mov    %rbx,%rdi
call   1030 <pick_heatmap@plt>
add    $0x61,%al
mov    %al,0xa(%rsp)
mov    %rbx,%rdi
call   1030 <pick_heatmap@plt>
add    $0x61,%al
mov    %al,0xb(%rsp)
mov    %rbx,%rdi
call   1030 <pick_heatmap@plt>
add    $0x61,%al
mov    %al,0xc(%rsp)
lea    0x1a(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   10a0 <strcmp@plt>
test   %rax,%rax
jne    1281 <main+0xe1>
mov    %rbp,%r13
mov    %r12,%r14
mov    0x20(%rsp),%al
cmp    $0x5b,%al
mov    $0x20,%r12d
je     1260 <main+0xc0>
movslq %r15d,%rbp
imul   $0x4ec4ec4f,%rbp,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x23,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
sub    %edx,%ebp
lea    0x21(%rsp),%rbx
xchg   %ax,%ax
movsbl %al,%eax
lea    (%rax,%rbp,1),%ecx
cmp    $0x7b,%ecx
lea    -0x1a(%rbp,%rax,1),%edi
cmovl  %ecx,%edi
add    $0xffffff9f,%eax
cmp    $0x1a,%al
cmovae %r12d,%edi
call   1040 <putchar@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
cmp    $0x5b,%al
jne    13a0 <main+0x200>
jmp    1260 <main+0xc0>
xchg   %ax,%ax
mov    $0xffffffff,%r14d
xor    %r13d,%r13d
mov    %rbp,%rdi
xor    %r15d,%r15d
jmp    141d <main+0x27d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl %al,%eax
add    $0xffffff9f,%eax
addl   $0x1,0x60(%rsp,%rax,4)
xor    %r15d,%r15d
mov    %r13d,%r14d
movslq %r13d,%rax
lea    0x1(%rax),%r13
lea    (%rsp,%rax,1),%rdi
add    $0x21,%rdi
movzbl 0x21(%rsp,%rax,1),%eax
cmp    $0x5d,%al
je     12fd <main+0x15d>
test   %r15d,%r15d
jne    142a <main+0x28a>
cmp    $0x61,%al
jl     142a <main+0x28a>
cmp    $0x7a,%al
jle    13f0 <main+0x250>
test   %r15d,%r15d
jne    1450 <main+0x2b0>
lea    -0x30(%rax),%ecx
cmp    $0x9,%cl
ja     1450 <main+0x2b0>
call   10c0 <atoi@plt>
mov    %eax,%r15d
jmp    13fe <main+0x25e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmp    $0x5b,%al
jne    13fe <main+0x25e>
movslq %r14d,%rax
add    $0x2,%r14d
lea    (%rax,%rbp,1),%rsi
add    $0x2,%rsi
lea    0x1a(%rsp),%rdi
mov    $0x5,%edx
call   1050 <strncpy@plt>
mov    %r14d,%r13d
jmp    13fe <main+0x25e>

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 = [17 x i8] c" (Sector ID %i)\0A\00"
@.str.6 = [55 x i8] c"There were %i valid rooms, with a sector id sum of %i\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca [64 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [26 x i32]
%9 = alloca [6 x i8]
%10 = alloca [6 x i8]
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %1
%13 = 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* %13, i32** %2
store i32 0, i32* %4
store i32 0, i32* %5
%14 = load i32*, i32** %2
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %18
16: ; preds = %0
%17 = 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 %189
18: ; preds = %0
br label %19
19: ; preds = %182, %18
%20 = load i32*, i32** %2
%21 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%22 = call i64 @fscanf(i32* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %21)
%23 = load i64, i64* @EOF
%24 = icmp ne i64 %22, %23
br i1 %24, label %25, label %183
25: ; preds = %19
store i32 -1, i32* %6
store i32 0, i32* %7
%26 = bitcast [26 x i32]* %8 to i8*
%27 = bitcast [6 x i8]* %10 to i8*
br label %28
28: ; preds = %102, %25
%29 = load i32, i32* %6
%30 = add nsw i32 %29, 1
store i32 %30, i32* %6
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp ne i32 %34, 93
br i1 %35, label %36, label %103
36: ; preds = %28
%37 = load i32, i32* %7
%38 = icmp ne i32 %37, 0
br i1 %38, label %64, label %39
39: ; preds = %36
%40 = load i32, i32* %6
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 %41
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp sge i32 %44, 97
br i1 %45, label %46, label %64
46: ; preds = %39
%47 = load i32, i32* %6
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 %48
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = icmp sle i32 %51, 122
br i1 %52, label %53, label %64
53: ; preds = %46
%54 = load i32, i32* %6
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 %55
%57 = load i8, i8* %56
%58 = sext i8 %57 to i32
%59 = sub nsw i32 %58, 97
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [26 x i32], [26 x i32]* %8, i64 0, i64 %60
%62 = load i32, i32* %61
%63 = add nsw i32 %62, 1
store i32 %63, i32* %61
br label %64
64: ; preds = %53, %46, %39, %36
%65 = load i32, i32* %7
%66 = icmp ne i32 %65, 0
br i1 %66, label %87, label %67
67: ; preds = %64
%68 = load i32, i32* %6
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 %69
%71 = load i8, i8* %70
%72 = sext i8 %71 to i32
%73 = icmp sge i32 %72, 48
br i1 %73, label %74, label %87
74: ; preds = %67
%75 = load i32, i32* %6
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 %76
%78 = load i8, i8* %77
%79 = sext i8 %78 to i32
%80 = icmp sle i32 %79, 57
br i1 %80, label %81, label %87
81: ; preds = %74
%82 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%83 = load i32, i32* %6
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds i8, i8* %82, i64 %84
%86 = call i32 @atoi(i8* %85)
store i32 %86, i32* %7
br label %87
87: ; preds = %81, %74, %67, %64
%88 = load i32, i32* %6
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 %89
%91 = load i8, i8* %90
%92 = sext i8 %91 to i32
%93 = icmp eq i32 %92, 91
br i1 %93, label %94, label %102
94: ; preds = %87
%95 = getelementptr inbounds [6 x i8], [6 x i8]* %9, i64 0, i64 0
%96 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%97 = load i32, i32* %6
%98 = add nsw i32 %97, 1
store i32 %98, i32* %6
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds i8, i8* %96, i64 %99
%101 = call i32 @strncpy(i8* %95, i8* %100, i32 5)
br label %102
102: ; preds = %94, %87
br label %28
103: ; preds = %28
store i32 0, i32* %6
br label %104
104: ; preds = %116, %103
%105 = load i32, i32* %6
%106 = icmp slt i32 %105, 5
br i1 %106, label %107, label %119
107: ; preds = %104
%108 = getelementptr inbounds [26 x i32], [26 x i32]* %8, i64 0, i64 0
%109 = call signext i8 @pick_heatmap(i32* %108)
%110 = sext i8 %109 to i32
%111 = add nsw i32 %110, 97
%112 = trunc i32 %111 to i8
%113 = load i32, i32* %6
%114 = sext i32 %113 to i64
%115 = getelementptr inbounds [6 x i8], [6 x i8]* %10, i64 0, i64 %114
store i8 %112, i8* %115
br label %116
116: ; preds = %107
%117 = load i32, i32* %6
%118 = add nsw i32 %117, 1
store i32 %118, i32* %6
br label %104
119: ; preds = %104
%120 = getelementptr inbounds [6 x i8], [6 x i8]* %9, i64 0, i64 0
%121 = getelementptr inbounds [6 x i8], [6 x i8]* %10, i64 0, i64 0
%122 = call i64 @strcmp(i8* %120, i8* %121)
%123 = icmp eq i64 %122, 0
br i1 %123, label %124, label %182
124: ; preds = %119
%125 = load i32, i32* %4
%126 = add nsw i32 %125, 1
store i32 %126, i32* %4
%127 = load i32, i32* %5
%128 = load i32, i32* %7
%129 = add nsw i32 %127, %128
store i32 %129, i32* %5
store i32 -1, i32* %6
%130 = load i32, i32* %7
%131 = srem i32 %130, 26
store i32 %131, i32* %11
br label %132
132: ; preds = %176, %124
%133 = load i32, i32* %6
%134 = add nsw i32 %133, 1
store i32 %134, i32* %6
%135 = sext i32 %134 to i64
%136 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 %135
%137 = load i8, i8* %136
%138 = sext i8 %137 to i32
%139 = icmp ne i32 %138, 91
br i1 %139, label %140, label %179
140: ; preds = %132
store i32 32, i32* %12
%141 = load i32, i32* %6
%142 = sext i32 %141 to i64
%143 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 %142
%144 = load i8, i8* %143
%145 = sext i8 %144 to i32
%146 = icmp eq i32 %145, 45
br i1 %146, label %147, label %148
147: ; preds = %140
store i32 32, i32* %12
br label %148
148: ; preds = %147, %140
%149 = load i32, i32* %6
%150 = sext i32 %149 to i64
%151 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 %150
%152 = load i8, i8* %151
%153 = sext i8 %152 to i32
%154 = icmp sge i32 %153, 97
br i1 %154, label %155, label %176
155: ; preds = %148
%156 = load i32, i32* %6
%157 = sext i32 %156 to i64
%158 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 %157
%159 = load i8, i8* %158
%160 = sext i8 %159 to i32
%161 = icmp sle i32 %160, 122
br i1 %161, label %162, label %176
162: ; preds = %155
%163 = load i32, i32* %6
%164 = sext i32 %163 to i64
%165 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 %164
%166 = load i8, i8* %165
%167 = sext i8 %166 to i32
%168 = load i32, i32* %11
%169 = add nsw i32 %167, %168
store i32 %169, i32* %12
%170 = load i32, i32* %12
%171 = icmp sgt i32 %170, 122
br i1 %171, label %172, label %175
172: ; preds = %162
%173 = load i32, i32* %12
%174 = sub nsw i32 %173, 26
store i32 %174, i32* %12
br label %175
175: ; preds = %172, %162
br label %176
176: ; preds = %175, %155, %148
%177 = load i32, i32* %12
%178 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %177)
br label %132
179: ; preds = %132
%180 = load i32, i32* %7
%181 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i32 %180)
br label %182
182: ; preds = %179, %119
br label %19
183: ; preds = %19
%184 = load i32, i32* %4
%185 = load i32, i32* %5
%186 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.6, i64 0, i64 0), i32 %184, i32 %185)
%187 = load i32*, i32** %2
%188 = call i32 @fclose(i32* %187)
store i32 0, i32* %1
br label %189
189: ; preds = %183, %16
%190 = load i32, i32* %1
ret i32 %190
}

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.5 = [17 x i8] c" (Sector ID %i)\0A\00"
@.str.6 = [55 x i8] c"There were %i valid rooms, with a sector id sum of %i\0A\00"
@str = [26 x i8] c"could not open input file\00"
define i32 @main() {
%1 = alloca [64 x i8]
%2 = alloca [26 x i32]
%3 = alloca [6 x i8]
%4 = alloca [6 x i8]
%5 = 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))
%6 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 0
%7 = icmp eq i32* %5, null
br i1 %7, label %21, label %8
8: ; preds = %0
%9 = call i64 @fscanf(i32* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %6)
%10 = load i64, i64* @EOF
%11 = icmp eq i64 %9, %10
br i1 %11, label %111, label %12
12: ; preds = %8
%13 = bitcast [26 x i32]* %2 to i8*
%14 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%15 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 0
%16 = getelementptr inbounds [26 x i32], [26 x i32]* %2, i64 0, i64 0
%17 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 1
%18 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 2
%19 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 3
%20 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 4
br label %23
21: ; preds = %0
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
br label %116
23: ; preds = %12, %105
%24 = phi i32 [ 0, %12 ], [ %107, %105 ]
%25 = phi i32 [ 0, %12 ], [ %106, %105 ]
%26 = load i8, i8* %6
%27 = icmp eq i8 %26, 93
br i1 %27, label %28, label %42
28: ; preds = %73, %23
%29 = phi i32 [ 0, %23 ], [ %74, %73 ]
%30 = call signext i8 @pick_heatmap(i32* %16)
%31 = add i8 %30, 97
store i8 %31, i8* %15
%32 = call signext i8 @pick_heatmap(i32* %16)
%33 = add i8 %32, 97
store i8 %33, i8* %17
%34 = call signext i8 @pick_heatmap(i32* %16)
%35 = add i8 %34, 97
store i8 %35, i8* %18
%36 = call signext i8 @pick_heatmap(i32* %16)
%37 = add i8 %36, 97
store i8 %37, i8* %19
%38 = call signext i8 @pick_heatmap(i32* %16)
%39 = add i8 %38, 97
store i8 %39, i8* %20
%40 = call i64 @strcmp(i8* %14, i8* %15)
%41 = icmp eq i64 %40, 0
br i1 %41, label %81, label %105
42: ; preds = %23, %73
%43 = phi i8 [ %79, %73 ], [ %26, %23 ]
%44 = phi i8* [ %78, %73 ], [ %6, %23 ]
%45 = phi i32 [ %76, %73 ], [ 0, %23 ]
%46 = phi i32 [ %74, %73 ], [ 0, %23 ]
%47 = phi i32 [ %75, %73 ], [ -1, %23 ]
%48 = icmp eq i32 %46, 0
%49 = icmp sgt i8 %43, 96
%50 = select i1 %48, i1 %49, i1 false
%51 = icmp slt i8 %43, 123
%52 = select i1 %50, i1 %51, i1 false
br i1 %52, label %53, label %60
53: ; preds = %42
%54 = zext i8 %43 to i64
%55 = add nuw nsw i64 %54, 4294967199
%56 = and i64 %55, 4294967295
%57 = getelementptr inbounds [26 x i32], [26 x i32]* %2, i64 0, i64 %56
%58 = load i32, i32* %57
%59 = add nsw i32 %58, 1
store i32 %59, i32* %57
br label %73
60: ; preds = %42
%61 = add i8 %43, -48
%62 = icmp ult i8 %61, 10
%63 = select i1 %48, i1 %62, i1 false
br i1 %63, label %64, label %66
64: ; preds = %60
%65 = call i32 @atoi(i8* %44)
br label %73
66: ; preds = %60
%67 = icmp eq i8 %43, 91
br i1 %67, label %68, label %73
68: ; preds = %66
%69 = add nsw i32 %47, 2
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 %70
%72 = call i32 @strncpy(i8* %14, i8* %71, i32 5)
br label %73
73: ; preds = %53, %64, %68, %66
%74 = phi i32 [ %46, %68 ], [ %46, %66 ], [ %65, %64 ], [ 0, %53 ]
%75 = phi i32 [ %69, %68 ], [ %45, %66 ], [ %45, %64 ], [ %45, %53 ]
%76 = add nsw i32 %75, 1
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 %77
%79 = load i8, i8* %78
%80 = icmp eq i8 %79, 93
br i1 %80, label %28, label %42
81: ; preds = %28
%82 = add nsw i32 %25, 1
%83 = add nsw i32 %29, %24
%84 = srem i32 %29, 26
%85 = load i8, i8* %6
%86 = icmp eq i8 %85, 91
br i1 %86, label %103, label %87
87: ; preds = %81, %87
%88 = phi i64 [ %99, %87 ], [ 0, %81 ]
%89 = phi i8 [ %101, %87 ], [ %85, %81 ]
%90 = sext i8 %89 to i32
%91 = add i8 %89, -97
%92 = icmp ult i8 %91, 26
%93 = add nsw i32 %84, %90
%94 = icmp sgt i32 %93, 122
%95 = add nsw i32 %93, -26
%96 = select i1 %94, i32 %95, i32 %93
%97 = select i1 %92, i32 %96, i32 32
%98 = call i32 @putchar(i32 %97)
%99 = add nuw i64 %88, 1
%100 = getelementptr inbounds [64 x i8], [64 x i8]* %1, i64 0, i64 %99
%101 = load i8, i8* %100
%102 = icmp eq i8 %101, 91
br i1 %102, label %103, label %87
103: ; preds = %87, %81
%104 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i32 %29)
br label %105
105: ; preds = %103, %28
%106 = phi i32 [ %82, %103 ], [ %25, %28 ]
%107 = phi i32 [ %83, %103 ], [ %24, %28 ]
%108 = call i64 @fscanf(i32* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %6)
%109 = load i64, i64* @EOF
%110 = icmp eq i64 %108, %109
br i1 %110, label %111, label %23
111: ; preds = %105, %8
%112 = phi i32 [ 0, %8 ], [ %106, %105 ]
%113 = phi i32 [ 0, %8 ], [ %107, %105 ]
%114 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.6, i64 0, i64 0), i32 %112, i32 %113)
%115 = call i32 @fclose(i32* %5)
br label %116
116: ; preds = %111, %21
%117 = phi i32 [ -1, %21 ], [ 0, %111 ]
ret i32 %117
}