#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 */
int atoi(int /*<<< orphan*/);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int posmod(int, int);
int /*<<< orphan*/ print_display(char *);
int /*<<< orphan*/ printf(char *, ...);
char *strstr(char *, char *);
int /*<<< orphan*/ strtok(char *, char *);
int sum_pixels(char *);
void decrypt(char *fname) {
  FILE *fp = fopen(fname, "r");
  char instr[100];
  char display[50 * 6] = {0};
  while (fgets(instr, 100, fp) != NULL) {
    if (strstr(instr, "rect")) {
      char *num_seg = strstr(instr, " ") + 1;
      int x = atoi(strtok(num_seg, "x"));
      int y = atoi(strtok(NULL, "x"));
      for (int i = 0; i < x; i++) {
        for (int j = 0; j < y; j++) {
          display[i + 50 * j] = 1;
        }
      }
    } else {
      char rc = strstr(instr, "column") == NULL;
      strtok(instr, "=");
      int loc = atoi(strtok(NULL, " "));
      strtok(NULL, " ");
      int amt = atoi(strtok(NULL, " "));
      if (rc) {
        char temp[50];
        for (int i = 0; i < 50; i++)
          temp[i] = display[loc * 50 + posmod(i - amt, 50)];
        for (int i = 0; i < 50; i++)
          display[loc * 50 + i] = temp[i];
      } else {
        char temp[6];
        for (int i = 0; i < 6; i++)
          temp[i] = display[loc + 50 * posmod(i - amt, 6)];
        for (int i = 0; i < 6; i++)
          display[loc + 50 * i] = temp[i];
      }
    }
  }
  printf("Part 1: %d\n", sum_pixels(display));
  printf("Part 2:\n");
  print_display(display);
}


x86 assembly (clang, -O0):
<decrypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe46(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    -0x1b0(%rbp),%rdi
xor    %esi,%esi
mov    $0x12c,%edx
call   1050 <memset@plt>
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x64,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     1504 <decrypt+0x364>
lea    -0x80(%rbp),%rdi
lea    0xe05(%rip),%rsi
call   10c0 <strstr@plt>
cmp    $0x0,%rax
je     12e7 <decrypt+0x147>
lea    -0x80(%rbp),%rdi
lea    0xdf0(%rip),%rsi
call   10c0 <strstr@plt>
add    $0x1,%rax
mov    %rax,-0x1b8(%rbp)
mov    -0x1b8(%rbp),%rdi
lea    0xdd4(%rip),%rsi
call   1080 <strtok@plt>
mov    %eax,%edi
call   1090 <atoi@plt>
mov    %eax,-0x1bc(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xdb7(%rip),%rsi
call   1080 <strtok@plt>
mov    %eax,%edi
call   1090 <atoi@plt>
mov    %eax,-0x1c0(%rbp)
movl   $0x0,-0x1c4(%rbp)
mov    -0x1c4(%rbp),%eax
cmp    -0x1bc(%rbp),%eax
jge    12e2 <decrypt+0x142>
movl   $0x0,-0x1c8(%rbp)
mov    -0x1c8(%rbp),%eax
cmp    -0x1c0(%rbp),%eax
jge    12c9 <decrypt+0x129>
mov    -0x1c4(%rbp),%eax
imul   $0x32,-0x1c8(%rbp),%ecx
add    %ecx,%eax
cltq
movb   $0x1,-0x1b0(%rbp,%rax,1)
01
mov    -0x1c8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c8(%rbp)
jmp    128a <decrypt+0xea>
jmp    12ce <decrypt+0x12e>
mov    -0x1c4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c4(%rbp)
jmp    126e <decrypt+0xce>
jmp    14ff <decrypt+0x35f>
lea    -0x80(%rbp),%rdi
lea    0xd19(%rip),%rsi
call   10c0 <strstr@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %al,-0x1c9(%rbp)
lea    -0x80(%rbp),%rdi
lea    0xcfe(%rip),%rsi
call   1080 <strtok@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xce3(%rip),%rsi
call   1080 <strtok@plt>
mov    %eax,%edi
call   1090 <atoi@plt>
mov    %eax,-0x1d0(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xcc6(%rip),%rsi
call   1080 <strtok@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xcb6(%rip),%rsi
call   1080 <strtok@plt>
mov    %eax,%edi
call   1090 <atoi@plt>
mov    %eax,-0x1d4(%rbp)
cmpb   $0x0,-0x1c9(%rbp)
je     1433 <decrypt+0x293>
movl   $0x0,-0x214(%rbp)
cmpl   $0x32,-0x214(%rbp)
jge    13df <decrypt+0x23f>
imul   $0x32,-0x1d0(%rbp),%eax
mov    %eax,-0x22c(%rbp)
mov    -0x214(%rbp),%edi
sub    -0x1d4(%rbp),%edi
mov    $0x32,%esi
call   10a0 <posmod@plt>
mov    %eax,%ecx
mov    -0x22c(%rbp),%eax
add    %ecx,%eax
cltq
mov    -0x1b0(%rbp,%rax,1),%cl
movslq -0x214(%rbp),%rax
mov    %cl,-0x210(%rbp,%rax,1)
mov    -0x214(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x214(%rbp)
jmp    137a <decrypt+0x1da>
movl   $0x0,-0x218(%rbp)
cmpl   $0x32,-0x218(%rbp)
jge    142e <decrypt+0x28e>
movslq -0x218(%rbp),%rax
mov    -0x210(%rbp,%rax,1),%cl
imul   $0x32,-0x1d0(%rbp),%eax
add    -0x218(%rbp),%eax
cltq
mov    %cl,-0x1b0(%rbp,%rax,1)
mov    -0x218(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x218(%rbp)
jmp    13e9 <decrypt+0x249>
jmp    14fa <decrypt+0x35a>
movl   $0x0,-0x224(%rbp)
cmpl   $0x6,-0x224(%rbp)
jge    14a4 <decrypt+0x304>
mov    -0x1d0(%rbp),%eax
mov    %eax,-0x230(%rbp)
mov    -0x224(%rbp),%edi
sub    -0x1d4(%rbp),%edi
mov    $0x6,%esi
call   10a0 <posmod@plt>
mov    %eax,%ecx
mov    -0x230(%rbp),%eax
imul   $0x32,%ecx,%ecx
add    %ecx,%eax
cltq
mov    -0x1b0(%rbp,%rax,1),%cl
movslq -0x224(%rbp),%rax
mov    %cl,-0x21e(%rbp,%rax,1)
mov    -0x224(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x224(%rbp)
jmp    143d <decrypt+0x29d>
movl   $0x0,-0x228(%rbp)
cmpl   $0x6,-0x228(%rbp)
jge    14f5 <decrypt+0x355>
movslq -0x228(%rbp),%rax
mov    -0x21e(%rbp,%rax,1),%cl
mov    -0x1d0(%rbp),%eax
imul   $0x32,-0x228(%rbp),%edx
add    %edx,%eax
cltq
mov    %cl,-0x1b0(%rbp,%rax,1)
mov    -0x228(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x228(%rbp)
jmp    14ae <decrypt+0x30e>
jmp    14fa <decrypt+0x35a>
jmp    14ff <decrypt+0x35f>
jmp    11d6 <decrypt+0x36>
lea    -0x1b0(%rbp),%rdi
call   10b0 <sum_pixels@plt>
mov    %eax,%esi
lea    0xafb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xaf9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x1b0(%rbp),%rdi
call   1030 <print_display@plt>
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decrypt>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1e8,%rsp
lea    0xe28(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%r12
lea    0x50(%rsp),%rdi
mov    $0x12c,%edx
xor    %esi,%esi
call   1070 <memset@plt>
lea    0x180(%rsp),%rdi
mov    $0x64,%esi
mov    %r12,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     14f8 <decrypt+0x338>
lea    0xdec(%rip),%r14
lea    0x180(%rsp),%r15
jmp    13ad <decrypt+0x1ed>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0xdd4(%rip),%rsi
call   10e0 <strstr@plt>
mov    %rax,%r13
mov    %r15,%rdi
lea    0xdc9(%rip),%rsi
call   10a0 <strtok@plt>
xor    %edi,%edi
lea    0xdb0(%rip),%rbx
mov    %rbx,%rsi
call   10a0 <strtok@plt>
mov    %eax,%edi
call   10b0 <atoi@plt>
mov    %eax,%r15d
xor    %edi,%edi
mov    %rbx,%rsi
call   10a0 <strtok@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   10a0 <strtok@plt>
mov    %eax,%edi
call   10b0 <atoi@plt>
mov    %eax,%r14d
test   %r13,%r13
je     148f <decrypt+0x2cf>
mov    %r14d,%edi
neg    %edi
mov    $0x6,%esi
call   10c0 <posmod@plt>
imul   $0x32,%eax,%eax
add    %r15d,%eax
cltq
mov    0x50(%rsp,%rax,1),%al
mov    %al,0xf(%rsp)
mov    $0x1,%edi
sub    %r14d,%edi
mov    $0x6,%esi
call   10c0 <posmod@plt>
imul   $0x32,%eax,%eax
add    %r15d,%eax
cltq
mov    0x50(%rsp,%rax,1),%al
mov    %al,0xe(%rsp)
mov    $0x2,%edi
sub    %r14d,%edi
mov    $0x6,%esi
call   10c0 <posmod@plt>
imul   $0x32,%eax,%eax
add    %r15d,%eax
cltq
mov    0x50(%rsp,%rax,1),%bl
mov    $0x3,%edi
sub    %r14d,%edi
mov    $0x6,%esi
call   10c0 <posmod@plt>
imul   $0x32,%eax,%eax
add    %r15d,%eax
cltq
mov    %r12,%r13
mov    0x50(%rsp,%rax,1),%r12b
mov    $0x4,%edi
sub    %r14d,%edi
mov    $0x6,%esi
call   10c0 <posmod@plt>
imul   $0x32,%eax,%eax
add    %r15d,%eax
cltq
mov    0x50(%rsp,%rax,1),%bpl
mov    $0x5,%edi
sub    %r14d,%edi
mov    $0x6,%esi
call   10c0 <posmod@plt>
imul   $0x32,%eax,%eax
add    %r15d,%eax
cltq
mov    0x50(%rsp,%rax,1),%al
movslq %r15d,%rcx
mov    0xf(%rsp),%dl
mov    %dl,0x50(%rsp,%rcx,1)
mov    0xe(%rsp),%dl
mov    %dl,0x82(%rsp,%rcx,1)
mov    %bl,0xb4(%rsp,%rcx,1)
mov    %r12b,0xe6(%rsp,%rcx,1)
mov    %r13,%r12
mov    %bpl,0x118(%rsp,%rcx,1)
mov    %al,0x14a(%rsp,%rcx,1)
lea    0xc76(%rip),%r14
lea    0x180(%rsp),%r15
mov    %r15,%rdi
mov    $0x64,%esi
mov    %r12,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     14f8 <decrypt+0x338>
mov    %r15,%rdi
mov    %r14,%rsi
call   10e0 <strstr@plt>
mov    %r15,%rdi
test   %rax,%rax
je     1230 <decrypt+0x70>
mov    $0x20,%esi
call   1050 <strchr@plt>
lea    0x1(%rax),%rdi
lea    0xc30(%rip),%rbx
mov    %rbx,%rsi
call   10a0 <strtok@plt>
mov    %eax,%edi
call   10b0 <atoi@plt>
mov    %eax,%ebp
xor    %edi,%edi
mov    %rbx,%rsi
call   10a0 <strtok@plt>
mov    %eax,%edi
call   10b0 <atoi@plt>
test   %ebp,%ebp
jle    1394 <decrypt+0x1d4>
mov    %ebp,%r10d
mov    %eax,%edx
lea    -0x1(%rdx),%r8
mov    %edx,%r9d
and    $0x3,%r9d
and    $0xfffffffc,%edx
imul   $0x32,%r9,%rbp
lea    0x50(%rsp),%rcx
xor    %esi,%esi
jmp    1431 <decrypt+0x271>
nop
add    $0x1,%rsi
add    $0x1,%rcx
cmp    %r10,%rsi
je     1394 <decrypt+0x1d4>
test   %eax,%eax
jle    1420 <decrypt+0x260>
cmp    $0x3,%r8
jae    1440 <decrypt+0x280>
xor    %edi,%edi
jmp    1472 <decrypt+0x2b2>
nop
mov    %rcx,%rbx
xor    %edi,%edi
cs nopw 0x0(%rax,%rax,1)
nop
movb   $0x1,(%rbx)
movb   $0x1,0x32(%rbx)
movb   $0x1,0x64(%rbx)
movb   $0x1,0x96(%rbx)
add    $0x4,%rdi
add    $0xc8,%rbx
cmp    %rdi,%rdx
jne    1450 <decrypt+0x290>
test   %r9,%r9
je     1420 <decrypt+0x260>
imul   $0x32,%rdi,%rdi
add    %rcx,%rdi
xor    %ebx,%ebx
movb   $0x1,(%rdi,%rbx,1)
add    $0x32,%rbx
cmp    %rbx,%rbp
jne    1480 <decrypt+0x2c0>
jmp    1420 <decrypt+0x260>
imul   $0x32,%r15d,%ebx
neg    %r14d
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
lea    (%r14,%rbp,1),%edi
mov    $0x32,%esi
call   10c0 <posmod@plt>
add    %ebx,%eax
cltq
movzbl 0x50(%rsp,%rax,1),%eax
mov    %al,0x10(%rsp,%rbp,1)
add    $0x1,%rbp
cmp    $0x32,%rbp
jne    14a0 <decrypt+0x2e0>
movslq %ebx,%rax
movzwl 0x40(%rsp),%ecx
mov    %cx,0x80(%rsp,%rax,1)
movaps 0x10(%rsp),%xmm0
movaps 0x20(%rsp),%xmm1
movaps 0x30(%rsp),%xmm2
movups %xmm2,0x70(%rsp,%rax,1)
movups %xmm1,0x60(%rsp,%rax,1)
movups %xmm0,0x50(%rsp,%rax,1)
jmp    1385 <decrypt+0x1c5>
lea    0x50(%rsp),%rbx
mov    %rbx,%rdi
call   10d0 <sum_pixels@plt>
lea    0xb08(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xb04(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1040 <print_display@plt>
add    $0x1e8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [5 x i8] c"rect\00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [2 x i8] c"x\00"
@.str.4 = [7 x i8] c"column\00"
@.str.5 = [2 x i8] c"=\00"
@.str.6 = [12 x i8] c"Part 1: %d\0A\00"
@.str.7 = [9 x i8] c"Part 2:\0A\00"
define void @decrypt(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca [100 x i8]
%5 = alloca [300 x i8]
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8
%12 = alloca i32
%13 = alloca i32
%14 = alloca [50 x i8]
%15 = alloca i32
%16 = alloca i32
%17 = alloca [6 x i8]
%18 = alloca i32
%19 = alloca i32
store i8* %0, i8** %2
%20 = load i8*, i8** %2
%21 = call i32* @fopen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %21, i32** %3
%22 = bitcast [300 x i8]* %5 to i8*
br label %23
23: ; preds = %161, %1
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%25 = load i32*, i32** %3
%26 = call i32* @fgets(i8* %24, i32 100, i32* %25)
%27 = icmp ne i32* %26, null
br i1 %27, label %28, label %162
28: ; preds = %23
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%30 = call i8* @strstr(i8* %29, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%31 = icmp ne i8* %30, null
br i1 %31, label %32, label %65
32: ; preds = %28
%33 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%34 = call i8* @strstr(i8* %33, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%35 = getelementptr inbounds i8, i8* %34, i64 1
store i8* %35, i8** %6
%36 = load i8*, i8** %6
%37 = call i32 @strtok(i8* %36, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%38 = call i32 @atoi(i32 %37)
store i32 %38, i32* %7
%39 = call i32 @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%40 = call i32 @atoi(i32 %39)
store i32 %40, i32* %8
store i32 0, i32* %9
br label %41
41: ; preds = %61, %32
%42 = load i32, i32* %9
%43 = load i32, i32* %7
%44 = icmp slt i32 %42, %43
br i1 %44, label %45, label %64
45: ; preds = %41
store i32 0, i32* %10
br label %46
46: ; preds = %57, %45
%47 = load i32, i32* %10
%48 = load i32, i32* %8
%49 = icmp slt i32 %47, %48
br i1 %49, label %50, label %60
50: ; preds = %46
%51 = load i32, i32* %9
%52 = load i32, i32* %10
%53 = mul nsw i32 50, %52
%54 = add nsw i32 %51, %53
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [300 x i8], [300 x i8]* %5, i64 0, i64 %55
store i8 1, i8* %56
br label %57
57: ; preds = %50
%58 = load i32, i32* %10
%59 = add nsw i32 %58, 1
store i32 %59, i32* %10
br label %46
60: ; preds = %46
br label %61
61: ; preds = %60
%62 = load i32, i32* %9
%63 = add nsw i32 %62, 1
store i32 %63, i32* %9
br label %41
64: ; preds = %41
br label %161
65: ; preds = %28
%66 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%67 = call i8* @strstr(i8* %66, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%68 = icmp eq i8* %67, null
%69 = zext i1 %68 to i32
%70 = trunc i32 %69 to i8
store i8 %70, i8* %11
%71 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%72 = call i32 @strtok(i8* %71, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%73 = call i32 @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%74 = call i32 @atoi(i32 %73)
store i32 %74, i32* %12
%75 = call i32 @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%76 = call i32 @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%77 = call i32 @atoi(i32 %76)
store i32 %77, i32* %13
%78 = load i8, i8* %11
%79 = icmp ne i8 %78, 0
br i1 %79, label %80, label %120
80: ; preds = %65
store i32 0, i32* %15
br label %81
81: ; preds = %98, %80
%82 = load i32, i32* %15
%83 = icmp slt i32 %82, 50
br i1 %83, label %84, label %101
84: ; preds = %81
%85 = load i32, i32* %12
%86 = mul nsw i32 %85, 50
%87 = load i32, i32* %15
%88 = load i32, i32* %13
%89 = sub nsw i32 %87, %88
%90 = call i32 @posmod(i32 %89, i32 50)
%91 = add nsw i32 %86, %90
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds [300 x i8], [300 x i8]* %5, i64 0, i64 %92
%94 = load i8, i8* %93
%95 = load i32, i32* %15
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds [50 x i8], [50 x i8]* %14, i64 0, i64 %96
store i8 %94, i8* %97
br label %98
98: ; preds = %84
%99 = load i32, i32* %15
%100 = add nsw i32 %99, 1
store i32 %100, i32* %15
br label %81
101: ; preds = %81
store i32 0, i32* %16
br label %102
102: ; preds = %116, %101
%103 = load i32, i32* %16
%104 = icmp slt i32 %103, 50
br i1 %104, label %105, label %119
105: ; preds = %102
%106 = load i32, i32* %16
%107 = sext i32 %106 to i64
%108 = getelementptr inbounds [50 x i8], [50 x i8]* %14, i64 0, i64 %107
%109 = load i8, i8* %108
%110 = load i32, i32* %12
%111 = mul nsw i32 %110, 50
%112 = load i32, i32* %16
%113 = add nsw i32 %111, %112
%114 = sext i32 %113 to i64
%115 = getelementptr inbounds [300 x i8], [300 x i8]* %5, i64 0, i64 %114
store i8 %109, i8* %115
br label %116
116: ; preds = %105
%117 = load i32, i32* %16
%118 = add nsw i32 %117, 1
store i32 %118, i32* %16
br label %102
119: ; preds = %102
br label %160
120: ; preds = %65
store i32 0, i32* %18
br label %121
121: ; preds = %138, %120
%122 = load i32, i32* %18
%123 = icmp slt i32 %122, 6
br i1 %123, label %124, label %141
124: ; preds = %121
%125 = load i32, i32* %12
%126 = load i32, i32* %18
%127 = load i32, i32* %13
%128 = sub nsw i32 %126, %127
%129 = call i32 @posmod(i32 %128, i32 6)
%130 = mul nsw i32 50, %129
%131 = add nsw i32 %125, %130
%132 = sext i32 %131 to i64
%133 = getelementptr inbounds [300 x i8], [300 x i8]* %5, i64 0, i64 %132
%134 = load i8, i8* %133
%135 = load i32, i32* %18
%136 = sext i32 %135 to i64
%137 = getelementptr inbounds [6 x i8], [6 x i8]* %17, i64 0, i64 %136
store i8 %134, i8* %137
br label %138
138: ; preds = %124
%139 = load i32, i32* %18
%140 = add nsw i32 %139, 1
store i32 %140, i32* %18
br label %121
141: ; preds = %121
store i32 0, i32* %19
br label %142
142: ; preds = %156, %141
%143 = load i32, i32* %19
%144 = icmp slt i32 %143, 6
br i1 %144, label %145, label %159
145: ; preds = %142
%146 = load i32, i32* %19
%147 = sext i32 %146 to i64
%148 = getelementptr inbounds [6 x i8], [6 x i8]* %17, i64 0, i64 %147
%149 = load i8, i8* %148
%150 = load i32, i32* %12
%151 = load i32, i32* %19
%152 = mul nsw i32 50, %151
%153 = add nsw i32 %150, %152
%154 = sext i32 %153 to i64
%155 = getelementptr inbounds [300 x i8], [300 x i8]* %5, i64 0, i64 %154
store i8 %149, i8* %155
br label %156
156: ; preds = %145
%157 = load i32, i32* %19
%158 = add nsw i32 %157, 1
store i32 %158, i32* %19
br label %142
159: ; preds = %142
br label %160
160: ; preds = %159, %119
br label %161
161: ; preds = %160, %64
br label %23
162: ; preds = %23
%163 = getelementptr inbounds [300 x i8], [300 x i8]* %5, i64 0, i64 0
%164 = call i32 @sum_pixels(i8* %163)
%165 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i32 %164)
%166 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%167 = getelementptr inbounds [300 x i8], [300 x i8]* %5, i64 0, i64 0
%168 = call i32 @print_display(i8* %167)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [5 x i8] c"rect\00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [2 x i8] c"x\00"
@.str.4 = [7 x i8] c"column\00"
@.str.5 = [2 x i8] c"=\00"
@.str.6 = [12 x i8] c"Part 1: %d\0A\00"
@str = [8 x i8] c"Part 2:\00"
define void @decrypt(i8* nocapture %0) {
%2 = alloca [100 x i8]
%3 = alloca [300 x i8]
%4 = alloca [50 x i8]
%5 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%6 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%8 = getelementptr inbounds [300 x i8], [300 x i8]* %3, i64 0, i64 0
%9 = call i32* @fgets(i8* %7, i32 100, i32* %6)
%10 = icmp eq i32* %9, null
br i1 %10, label %155, label %11
11: ; preds = %1
%12 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
br label %13
13: ; preds = %11, %152
%14 = call i8* @strstr(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i8* %14, null
br i1 %15, label %71, label %16
16: ; preds = %13
%17 = call i8* @strchr(i8* %7, i32 32)
%18 = getelementptr inbounds i8, i8* %17, i64 1
%19 = call i32 @strtok(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%20 = call i32 @atoi(i32 %19)
%21 = call i32 @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%22 = call i32 @atoi(i32 %21)
%23 = icmp sgt i32 %20, 0
br i1 %23, label %24, label %152
24: ; preds = %16
%25 = icmp sgt i32 %22, 0
%26 = zext i32 %20 to i64
%27 = zext i32 %22 to i64
%28 = add nsw i64 %27, -1
%29 = and i64 %27, 3
%30 = icmp ult i64 %28, 3
%31 = and i64 %27, 4294967292
%32 = icmp eq i64 %29, 0
br label %33
33: ; preds = %24, %47
%34 = phi i64 [ 0, %24 ], [ %48, %47 ]
br i1 %25, label %35, label %47
35: ; preds = %33
br i1 %30, label %36, label %50
36: ; preds = %50, %35
%37 = phi i64 [ 0, %35 ], [ %68, %50 ]
br i1 %32, label %47, label %38
38: ; preds = %36, %38
%39 = phi i64 [ %44, %38 ], [ %37, %36 ]
%40 = phi i64 [ %45, %38 ], [ 0, %36 ]
%41 = mul nuw nsw i64 %39, 50
%42 = add nuw nsw i64 %41, %34
%43 = getelementptr inbounds [300 x i8], [300 x i8]* %3, i64 0, i64 %42
store i8 1, i8* %43
%44 = add nuw nsw i64 %39, 1
%45 = add i64 %40, 1
%46 = icmp eq i64 %45, %29
br i1 %46, label %47, label %38
47: ; preds = %36, %38, %33
%48 = add nuw nsw i64 %34, 1
%49 = icmp eq i64 %48, %26
br i1 %49, label %152, label %33
50: ; preds = %35, %50
%51 = phi i64 [ %68, %50 ], [ 0, %35 ]
%52 = phi i64 [ %69, %50 ], [ 0, %35 ]
%53 = mul nuw nsw i64 %51, 50
%54 = add nuw nsw i64 %53, %34
%55 = getelementptr inbounds [300 x i8], [300 x i8]* %3, i64 0, i64 %54
store i8 1, i8* %55
%56 = or i64 %51, 1
%57 = mul nuw nsw i64 %56, 50
%58 = add nuw nsw i64 %57, %34
%59 = getelementptr inbounds [300 x i8], [300 x i8]* %3, i64 0, i64 %58
store i8 1, i8* %59
%60 = or i64 %51, 2
%61 = mul nuw nsw i64 %60, 50
%62 = add nuw nsw i64 %61, %34
%63 = getelementptr inbounds [300 x i8], [300 x i8]* %3, i64 0, i64 %62
store i8 1, i8* %63
%64 = or i64 %51, 3
%65 = mul nuw nsw i64 %64, 50
%66 = add nuw nsw i64 %65, %34
%67 = getelementptr inbounds [300 x i8], [300 x i8]* %3, i64 0, i64 %66
store i8 1, i8* %67
%68 = add nuw nsw i64 %51, 4
%69 = add i64 %52, 4
%70 = icmp eq i64 %69, %31
br i1 %70, label %36, label %50
71: ; preds = %13
%72 = call i8* @strstr(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%73 = icmp eq i8* %72, null
%74 = call i32 @strtok(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%75 = call i32 @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%76 = call i32 @atoi(i32 %75)
%77 = call i32 @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%78 = call i32 @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%79 = call i32 @atoi(i32 %78)
br i1 %73, label %80, label %97
80: ; preds = %71
%81 = mul nsw i32 %76, 50
br label %85
82: ; preds = %85
%83 = sext i32 %81 to i64
%84 = getelementptr [300 x i8], [300 x i8]* %3, i64 0, i64 %83
br label %152
85: ; preds = %80, %85
%86 = phi i64 [ 0, %80 ], [ %95, %85 ]
%87 = trunc i64 %86 to i32
%88 = sub nsw i32 %87, %79
%89 = call i32 @posmod(i32 %88, i32 50)
%90 = add nsw i32 %89, %81
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds [300 x i8], [300 x i8]* %3, i64 0, i64 %91
%93 = load i8, i8* %92
%94 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 %86
store i8 %93, i8* %94
%95 = add nuw nsw i64 %86, 1
%96 = icmp eq i64 %95, 50
br i1 %96, label %82, label %85
97: ; preds = %71
%98 = sub nsw i32 0, %79
%99 = call i32 @posmod(i32 %98, i32 6)
%100 = mul nsw i32 %99, 50
%101 = add nsw i32 %100, %76
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds [300 x i8], [300 x i8]* %3, i64 0, i64 %102
%104 = load i8, i8* %103
%105 = sub nsw i32 1, %79
%106 = call i32 @posmod(i32 %105, i32 6)
%107 = mul nsw i32 %106, 50
%108 = add nsw i32 %107, %76
%109 = sext i32 %108 to i64
%110 = getelementptr inbounds [300 x i8], [300 x i8]* %3, i64 0, i64 %109
%111 = load i8, i8* %110
%112 = sub nsw i32 2, %79
%113 = call i32 @posmod(i32 %112, i32 6)
%114 = mul nsw i32 %113, 50
%115 = add nsw i32 %114, %76
%116 = sext i32 %115 to i64
%117 = getelementptr inbounds [300 x i8], [300 x i8]* %3, i64 0, i64 %116
%118 = load i8, i8* %117
%119 = sub nsw i32 3, %79
%120 = call i32 @posmod(i32 %119, i32 6)
%121 = mul nsw i32 %120, 50
%122 = add nsw i32 %121, %76
%123 = sext i32 %122 to i64
%124 = getelementptr inbounds [300 x i8], [300 x i8]* %3, i64 0, i64 %123
%125 = load i8, i8* %124
%126 = sub nsw i32 4, %79
%127 = call i32 @posmod(i32 %126, i32 6)
%128 = mul nsw i32 %127, 50
%129 = add nsw i32 %128, %76
%130 = sext i32 %129 to i64
%131 = getelementptr inbounds [300 x i8], [300 x i8]* %3, i64 0, i64 %130
%132 = load i8, i8* %131
%133 = sub nsw i32 5, %79
%134 = call i32 @posmod(i32 %133, i32 6)
%135 = mul nsw i32 %134, 50
%136 = add nsw i32 %135, %76
%137 = sext i32 %136 to i64
%138 = getelementptr inbounds [300 x i8], [300 x i8]* %3, i64 0, i64 %137
%139 = load i8, i8* %138
%140 = sext i32 %76 to i64
%141 = getelementptr inbounds [300 x i8], [300 x i8]* %3, i64 0, i64 %140
store i8 %104, i8* %141
%142 = add nsw i64 %140, 50
%143 = getelementptr inbounds [300 x i8], [300 x i8]* %3, i64 0, i64 %142
store i8 %111, i8* %143
%144 = add nsw i64 %140, 100
%145 = getelementptr inbounds [300 x i8], [300 x i8]* %3, i64 0, i64 %144
store i8 %118, i8* %145
%146 = add nsw i64 %140, 150
%147 = getelementptr inbounds [300 x i8], [300 x i8]* %3, i64 0, i64 %146
store i8 %125, i8* %147
%148 = add nsw i64 %140, 200
%149 = getelementptr inbounds [300 x i8], [300 x i8]* %3, i64 0, i64 %148
store i8 %132, i8* %149
%150 = add nsw i64 %140, 250
%151 = getelementptr inbounds [300 x i8], [300 x i8]* %3, i64 0, i64 %150
store i8 %139, i8* %151
br label %152
152: ; preds = %47, %16, %82, %97
%153 = call i32* @fgets(i8* %7, i32 100, i32* %6)
%154 = icmp eq i32* %153, null
br i1 %154, label %155, label %13
155: ; preds = %152, %1
%156 = call i32 @sum_pixels(i8* %8)
%157 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i32 %156)
%158 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
%159 = call i32 @print_display(i8* %8)
ret void
}