#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 /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *, ...);
int /*<<< orphan*/ printf(char *, ...);
int score(int **, int, int, int, int, int);
int /*<<< orphan*/ setToZero(int **, int, int);
int main() {
  FILE *f1;
  int dx, dy, n, q;
  int x, y, m;
  int city[1001][1001];
  int query[21];
  int coffeecase;
  int scoreGrid[1001][1001];
  f1 = fopen("CoffeeData2.txt", "r");
  if (f1 == NULL) {
    printf("\nUnable to open CoffeeData.txt\n");
    exit(1);
  }
  coffeecase = 1;
  while (1) {
    fscanf(f1, "%d %d %d %d", &dx, &dy, &n, &q);
    if ((dx == 0) && (dy == 0) && (n == 0) && (q == 0)) {
      break;
    }
    if ((n > 500000) || (n < 0) || (q > 20) || (q < 1)) {
      printf("\n input error n = %d, q = %d\n", n, q);
      exit(1);
    }
    setToZero(city, dx, dy);
    for (int i = 1; i <= n; i++) {
      fscanf(f1, "%d %d", &x, &y);
      if ((x < 1) || (x > dx) || (y < 1) || (y > dy)) {
        printf("\n input error coffee shop location = %d x = %d, y = %d, dx = "
               "%d, dy = %d\n",
               i, x, y, dx, dy);
        exit(1);
      }
      city[x][y] = 1;
    }
    for (int i = 1; i <= q; i++) {
      fscanf(f1, "%d", &m);
      if ((m < 0) || (m > 1000000)) {
        printf("\n input error query distance i = %d m = %d\n", i, m);
        exit(1);
      }
      query[i] = m;
    }
    printf("\nCase %d:\n", coffeecase);
    for (int k = 1; k <= q; k++) {
      for (int i = 1; i <= dx; i++) {
        for (int j = 1; j <= dy; j++) {
          scoreGrid[i][j] = score(city, query[k], i, j, dx, dy);
        }
      }
      int winnerX = 0;
      int winnerY = 0;
      for (int i = 1; i <= dy; i++) {
        for (int j = 1; j <= dx; j++) {
          if (scoreGrid[winnerX][winnerY] < scoreGrid[j][i]) {
            winnerX = j;
            winnerY = i;
          }
        }
      }
      printf("%d: %d (%d, %d)\n", query[k], scoreGrid[winnerX][winnerY],
             winnerX, winnerY);
      setToZero(scoreGrid, dx, dy);
    }
    printf("\n");
    coffeecase++;
  }
  printf("\nAll cases are done\n");
  fclose(f1);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7a5150,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe77(%rip),%rdi
lea    0xe80(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11bc <main+0x4c>
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
movl   $0x1,-0x3d28d4(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe61(%rip),%rsi
lea    -0x14(%rbp),%rdx
lea    -0x18(%rbp),%rcx
lea    -0x1c(%rbp),%r8
lea    -0x20(%rbp),%r9
mov    $0x0,%al
call   1050 <fscanf@plt>
cmpl   $0x0,-0x14(%rbp)
jne    1215 <main+0xa5>
cmpl   $0x0,-0x18(%rbp)
jne    1215 <main+0xa5>
cmpl   $0x0,-0x1c(%rbp)
jne    1215 <main+0xa5>
cmpl   $0x0,-0x20(%rbp)
jne    1215 <main+0xa5>
jmp    1606 <main+0x496>
cmpl   $0x7a120,-0x1c(%rbp)
jg     1240 <main+0xd0>
cmpl   $0x0,-0x1c(%rbp)
jl     1240 <main+0xd0>
cmpl   $0x14,-0x20(%rbp)
jg     1240 <main+0xd0>
cmpl   $0x1,-0x20(%rbp)
jge    125e <main+0xee>
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
lea    0xdf1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
lea    -0x3d2870(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1090 <setToZero@plt>
movl   $0x1,-0x7a5124(%rbp)
mov    -0x7a5124(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jg     132f <main+0x1bf>
mov    -0x10(%rbp),%rdi
lea    0xda4(%rip),%rsi
lea    -0x24(%rbp),%rdx
lea    -0x28(%rbp),%rcx
mov    $0x0,%al
call   1050 <fscanf@plt>
cmpl   $0x1,-0x24(%rbp)
jl     12cf <main+0x15f>
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     12cf <main+0x15f>
cmpl   $0x1,-0x28(%rbp)
jl     12cf <main+0x15f>
mov    -0x28(%rbp),%eax
cmp    -0x18(%rbp),%eax
jle    12fb <main+0x18b>
mov    -0x7a5124(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x28(%rbp),%ecx
mov    -0x14(%rbp),%r8d
mov    -0x18(%rbp),%r9d
lea    0xd72(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
movslq -0x24(%rbp),%rcx
lea    -0x3d2870(%rbp),%rax
imul   $0xfa4,%rcx,%rcx
add    %rcx,%rax
movslq -0x28(%rbp),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    -0x7a5124(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7a5124(%rbp)
jmp    127a <main+0x10a>
movl   $0x1,-0x7a5128(%rbp)
mov    -0x7a5128(%rbp),%eax
cmp    -0x20(%rbp),%eax
jg     13bb <main+0x24b>
mov    -0x10(%rbp),%rdi
lea    0xce8(%rip),%rsi
lea    -0x2c(%rbp),%rdx
mov    $0x0,%al
call   1050 <fscanf@plt>
cmpl   $0x0,-0x2c(%rbp)
jl     1375 <main+0x205>
cmpl   $0xf4240,-0x2c(%rbp)
jle    1396 <main+0x226>
mov    -0x7a5128(%rbp),%esi
mov    -0x2c(%rbp),%edx
lea    0xd21(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x2c(%rbp),%ecx
movslq -0x7a5128(%rbp),%rax
mov    %ecx,-0x3d28d0(%rbp,%rax,4)
mov    -0x7a5128(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7a5128(%rbp)
jmp    1339 <main+0x1c9>
mov    -0x3d28d4(%rbp),%esi
lea    0xd0a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x7a512c(%rbp)
mov    -0x7a512c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jg     15e4 <main+0x474>
movl   $0x1,-0x7a5130(%rbp)
mov    -0x7a5130(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     1499 <main+0x329>
movl   $0x1,-0x7a5134(%rbp)
mov    -0x7a5134(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     1480 <main+0x310>
lea    -0x3d2870(%rbp),%rdi
movslq -0x7a512c(%rbp),%rax
mov    -0x3d28d0(%rbp,%rax,4),%esi
mov    -0x7a5130(%rbp),%edx
mov    -0x7a5134(%rbp),%ecx
mov    -0x14(%rbp),%r8d
mov    -0x18(%rbp),%r9d
call   1060 <score@plt>
mov    %eax,%edx
movslq -0x7a5130(%rbp),%rcx
lea    -0x7a5120(%rbp),%rax
imul   $0xfa4,%rcx,%rcx
add    %rcx,%rax
movslq -0x7a5134(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x7a5134(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7a5134(%rbp)
jmp    140b <main+0x29b>
jmp    1485 <main+0x315>
mov    -0x7a5130(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7a5130(%rbp)
jmp    13f2 <main+0x282>
movl   $0x0,-0x7a5138(%rbp)
movl   $0x0,-0x7a513c(%rbp)
movl   $0x1,-0x7a5140(%rbp)
mov    -0x7a5140(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     1573 <main+0x403>
movl   $0x1,-0x7a5144(%rbp)
mov    -0x7a5144(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     155a <main+0x3ea>
movslq -0x7a5138(%rbp),%rcx
lea    -0x7a5120(%rbp),%rax
imul   $0xfa4,%rcx,%rcx
add    %rcx,%rax
movslq -0x7a513c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
movslq -0x7a5144(%rbp),%rdx
lea    -0x7a5120(%rbp),%rcx
imul   $0xfa4,%rdx,%rdx
add    %rdx,%rcx
movslq -0x7a5140(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jge    1541 <main+0x3d1>
mov    -0x7a5144(%rbp),%eax
mov    %eax,-0x7a5138(%rbp)
mov    -0x7a5140(%rbp),%eax
mov    %eax,-0x7a513c(%rbp)
jmp    1546 <main+0x3d6>
mov    -0x7a5144(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7a5144(%rbp)
jmp    14d0 <main+0x360>
jmp    155f <main+0x3ef>
mov    -0x7a5140(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7a5140(%rbp)
jmp    14b7 <main+0x347>
movslq -0x7a512c(%rbp),%rax
mov    -0x3d28d0(%rbp,%rax,4),%esi
movslq -0x7a5138(%rbp),%rcx
lea    -0x7a5120(%rbp),%rax
imul   $0xfa4,%rcx,%rcx
add    %rcx,%rax
movslq -0x7a513c(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x7a5138(%rbp),%ecx
mov    -0x7a513c(%rbp),%r8d
lea    0xb26(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x7a5120(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1090 <setToZero@plt>
mov    -0x7a512c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7a512c(%rbp)
jmp    13d9 <main+0x269>
lea    0xb01(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x3d28d4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3d28d4(%rbp)
jmp    11c6 <main+0x56>
lea    0xae1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x7a5150,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x7a5138,%rsp
lea    0xe58(%rip),%rdi
lea    0xe61(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     16a0 <main+0x510>
mov    %rax,%rbp
lea    0xe4b(%rip),%rsi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
lea    0x14(%rsp),%r8
lea    0x10(%rsp),%r9
mov    %rax,%rdi
xor    %eax,%eax
call   1070 <fscanf@plt>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
mov    0x14(%rsp),%eax
mov    0x10(%rsp),%ecx
test   %esi,%esi
jne    1209 <main+0x79>
test   %edx,%edx
jne    1209 <main+0x79>
test   %eax,%eax
jne    1209 <main+0x79>
test   %ecx,%ecx
je     1629 <main+0x499>
mov    $0x1,%r14d
lea    0x3d28f0(%rsp),%r12
lea    0xdfd(%rip),%r15
lea    0x18(%rsp),%r13
mov    %rbp,0x30(%rsp)
nopl   0x0(%rax,%rax,1)
cmp    $0x7a120,%eax
ja     1693 <main+0x503>
cmp    $0x14,%ecx
jg     1693 <main+0x503>
test   %ecx,%ecx
jle    1693 <main+0x503>
mov    %r12,%rdi
call   10b0 <setToZero@plt>
cmpl   $0x0,0x14(%rsp)
jle    12d1 <main+0x141>
mov    $0x1,%ebx
mov    %rbp,%rdi
lea    0xdae(%rip),%rsi
lea    0x2c(%rsp),%rdx
lea    0x1c(%rsp),%rcx
xor    %eax,%eax
call   1070 <fscanf@plt>
mov    0x2c(%rsp),%edx
test   %edx,%edx
jle    1651 <main+0x4c1>
mov    0xc(%rsp),%r8d
mov    0x1c(%rsp),%ecx
mov    0x8(%rsp),%r9d
cmp    %r8d,%edx
jg     165f <main+0x4cf>
test   %ecx,%ecx
jle    165f <main+0x4cf>
cmp    %r9d,%ecx
jg     165f <main+0x4cf>
imul   $0xfa4,%rdx,%rax
add    %rsp,%rax
add    $0x3d28f0,%rax
movl   $0x1,(%rax,%rcx,4)
lea    0x1(%rbx),%eax
cmp    0x14(%rsp),%ebx
mov    %eax,%ebx
jl     1260 <main+0xd0>
cmpl   $0x0,0x10(%rsp)
jle    1315 <main+0x185>
mov    $0x1,%ebx
nopl   (%rax)
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1070 <fscanf@plt>
mov    0x18(%rsp),%edx
cmp    $0xf4241,%edx
jae    1679 <main+0x4e9>
mov    %edx,0x40(%rsp,%rbx,4)
lea    0x1(%rbx),%rax
movslq 0x10(%rsp),%rcx
cmp    %rcx,%rbx
mov    %rax,%rbx
jl     12e0 <main+0x150>
lea    0xd96(%rip),%rdi
mov    %r14d,0x28(%rsp)
mov    %r14d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
cmpl   $0x0,0x10(%rsp)
jle    15b0 <main+0x420>
mov    $0x1,%eax
mov    %rax,0x20(%rsp)
jmp    13b2 <main+0x222>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %ebx,%ebx
xor    %r13d,%r13d
mov    0x20(%rsp),%rbp
mov    0x40(%rsp,%rbp,4),%esi
movslq %ebx,%rcx
movslq %r13d,%r8
imul   $0xfa4,%rcx,%rax
add    %rsp,%rax
add    $0xa0,%rax
mov    (%rax,%r8,4),%edx
lea    0xd3e(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
lea    0xa0(%rsp),%rdi
call   10b0 <setToZero@plt>
lea    0x1(%rbp),%rax
movslq 0x10(%rsp),%rcx
cmp    %rcx,%rbp
mov    %rax,0x20(%rsp)
jge    15b0 <main+0x420>
mov    0xc(%rsp),%r8d
test   %r8d,%r8d
jle    1480 <main+0x2f0>
mov    $0x1,%r15d
mov    0x8(%rsp),%r9d
lea    0xa0(%rsp),%r13
jmp    13ff <main+0x26f>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0xc(%rsp),%r8d
lea    0x1(%r15),%rax
movslq %r8d,%rcx
add    $0xfa4,%r13
cmp    %rcx,%r15
mov    %rax,%r15
jge    1485 <main+0x2f5>
test   %r9d,%r9d
jle    13e5 <main+0x255>
mov    0x20(%rsp),%rax
mov    0x40(%rsp,%rax,4),%ebx
mov    %r12,%rdi
mov    %ebx,%esi
mov    %r15d,%edx
mov    $0x1,%ecx
call   1080 <score@plt>
imul   $0xfa4,%r15,%rcx
mov    %eax,0xa4(%rsp,%rcx,1)
mov    0x8(%rsp),%r9d
cmp    $0x2,%r9d
jl     13e0 <main+0x250>
mov    $0x3eb,%ebp
nopl   (%rax)
mov    0xc(%rsp),%r8d
lea    -0x3e9(%rbp),%r14
mov    %r12,%rdi
mov    %ebx,%esi
mov    %r15d,%edx
mov    %r14d,%ecx
call   1080 <score@plt>
mov    %eax,0x0(%r13,%rbp,4)
movslq 0x8(%rsp),%r9
add    $0x1,%rbp
cmp    %r9,%r14
jl     1440 <main+0x2b0>
jmp    13e0 <main+0x250>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x8(%rsp),%r9d
test   %r9d,%r9d
jle    1350 <main+0x1c0>
lea    0x1(%r8),%r11d
add    $0x1,%r9d
lea    -0x1(%r11),%rbp
mov    %rbp,%r15
and    $0xfffffffffffffffe,%r15
xor    %r13d,%r13d
mov    $0x1,%esi
lea    0x1fec(%rsp),%r14
xor    %ebx,%ebx
mov    %rbp,0x38(%rsp)
jmp    14d1 <main+0x341>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rsi
add    $0x4,%r14
cmp    %r9,%rsi
je     1355 <main+0x1c5>
test   %r8d,%r8d
jle    14c0 <main+0x330>
mov    $0x1,%ecx
cmp    $0x2,%r11d
je     1565 <main+0x3d5>
mov    $0x1,%ecx
mov    %r14,%rdi
jmp    1500 <main+0x370>
nop
add    $0x2,%rcx
add    $0x1f48,%rdi
cmp    %r15,%rax
je     1560 <main+0x3d0>
movslq %ebx,%rax
movslq %r13d,%rdx
imul   $0xfa4,%rax,%rax
add    %rsp,%rax
add    $0xa0,%rax
mov    (%rax,%rdx,4),%eax
mov    %ecx,%ebp
mov    %esi,%edx
cmp    -0xfa4(%rdi),%eax
jl     152a <main+0x39a>
mov    %ebx,%ebp
mov    %r13d,%edx
movslq %ebp,%rax
movslq %edx,%rbx
imul   $0xfa4,%rax,%rax
add    %rsp,%rax
add    $0xa0,%rax
mov    (%rax,%rbx,4),%r10d
lea    0x1(%rcx),%rax
mov    %eax,%ebx
mov    %esi,%r13d
cmp    (%rdi),%r10d
jl     14f0 <main+0x360>
mov    %ebp,%ebx
mov    %edx,%r13d
jmp    14f0 <main+0x360>
nopl   0x0(%rax)
mov    0x38(%rsp),%rbp
test   $0x1,%bpl
je     14c0 <main+0x330>
movslq %ebx,%rbx
movslq %r13d,%r13
imul   $0xfa4,%rbx,%rax
add    %rsp,%rax
add    $0xa0,%rax
mov    (%rax,%r13,4),%eax
imul   $0xfa4,%rcx,%rdx
add    %rsp,%rdx
add    $0xa0,%rdx
cmp    (%rdx,%rsi,4),%eax
cmovl  %ecx,%ebx
cmovl  %esi,%r13d
jmp    14c0 <main+0x330>
nopl   0x0(%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x28(%rsp),%r14d
add    $0x1,%r14d
mov    0x30(%rsp),%rbp
mov    %rbp,%rdi
lea    0xa40(%rip),%rsi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
lea    0x14(%rsp),%r8
lea    0x10(%rsp),%r9
xor    %eax,%eax
call   1070 <fscanf@plt>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
mov    0x14(%rsp),%eax
mov    0x10(%rsp),%ecx
test   %esi,%esi
lea    0xa15(%rip),%r15
lea    0x18(%rsp),%r13
jne    1230 <main+0xa0>
test   %edx,%edx
jne    1230 <main+0xa0>
test   %eax,%eax
jne    1230 <main+0xa0>
test   %ecx,%ecx
jne    1230 <main+0xa0>
lea    0xa9e(%rip),%rdi
call   1040 <puts@plt>
mov    %rbp,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0x7a5138,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x1c(%rsp),%ecx
mov    0xc(%rsp),%r8d
mov    0x8(%rsp),%r9d
lea    0x9d6(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
lea    0xa06(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
lea    0x984(%rip),%rdi
mov    %eax,%esi
mov    %ecx,%edx
jmp    1682 <main+0x4f2>
lea    0xa3b(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [16 x i8] c"CoffeeData2.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [32 x i8] c"\0AUnable to open CoffeeData.txt\0A\00"
@.str.3 = [12 x i8] c"%d %d %d %d\00"
@.str.4 = [30 x i8] c"\0A input error n = %d, q = %d\0A\00"
@.str.5 = [6 x i8] c"%d %d\00"
@.str.6 = [74 x i8] c"\0A input error coffee shop location = %d x = %d, y = %d, dx = %d, dy = %d\0A\00"
@.str.7 = [3 x i8] c"%d\00"
@.str.8 = [44 x i8] c"\0A input error query distance i = %d m = %d\0A\00"
@.str.9 = [11 x i8] c"\0ACase %d:\0A\00"
@.str.10 = [17 x i8] c"%d: %d (%d, %d)\0A\00"
@.str.11 = [2 x i8] c"\0A\00"
@.str.12 = [21 x i8] c"\0AAll cases are done\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [1001 x [1001 x i32]]
%11 = alloca [21 x i32]
%12 = alloca i32
%13 = alloca [1001 x [1001 x i32]]
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
store i32 0, i32* %1
%23 = call i32* @fopen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %23, i32** %2
%24 = load i32*, i32** %2
%25 = icmp eq i32* %24, null
br i1 %25, label %26, label %29
26: ; preds = %0
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%28 = call i32 @exit(i32 1)
unreachable
29: ; preds = %0
store i32 1, i32* %12
br label %30
30: ; preds = %29, %234
%31 = load i32*, i32** %2
%32 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %31, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32* %3, i32* %4, i32* %5, i32* %6)
%33 = load i32, i32* %3
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %45
35: ; preds = %30
%36 = load i32, i32* %4
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %45
38: ; preds = %35
%39 = load i32, i32* %5
%40 = icmp eq i32 %39, 0
br i1 %40, label %41, label %45
41: ; preds = %38
%42 = load i32, i32* %6
%43 = icmp eq i32 %42, 0
br i1 %43, label %44, label %45
44: ; preds = %41
br label %238
45: ; preds = %41, %38, %35, %30
%46 = load i32, i32* %5
%47 = icmp sgt i32 %46, 500000
br i1 %47, label %57, label %48
48: ; preds = %45
%49 = load i32, i32* %5
%50 = icmp slt i32 %49, 0
br i1 %50, label %57, label %51
51: ; preds = %48
%52 = load i32, i32* %6
%53 = icmp sgt i32 %52, 20
br i1 %53, label %57, label %54
54: ; preds = %51
%55 = load i32, i32* %6
%56 = icmp slt i32 %55, 1
br i1 %56, label %57, label %62
57: ; preds = %54, %51, %48, %45
%58 = load i32, i32* %5
%59 = load i32, i32* %6
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i32 %58, i32 %59)
%61 = call i32 @exit(i32 1)
unreachable
62: ; preds = %54
%63 = getelementptr inbounds [1001 x [1001 x i32]], [1001 x [1001 x i32]]* %10, i64 0, i64 0
%64 = bitcast [1001 x i32]* %63 to i32**
%65 = load i32, i32* %3
%66 = load i32, i32* %4
%67 = call i32 @setToZero(i32** %64, i32 %65, i32 %66)
store i32 1, i32* %14
br label %68
68: ; preds = %103, %62
%69 = load i32, i32* %14
%70 = load i32, i32* %5
%71 = icmp sle i32 %69, %70
br i1 %71, label %72, label %106
72: ; preds = %68
%73 = load i32*, i32** %2
%74 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %73, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32* %7, i32* %8)
%75 = load i32, i32* %7
%76 = icmp slt i32 %75, 1
br i1 %76, label %88, label %77
77: ; preds = %72
%78 = load i32, i32* %7
%79 = load i32, i32* %3
%80 = icmp sgt i32 %78, %79
br i1 %80, label %88, label %81
81: ; preds = %77
%82 = load i32, i32* %8
%83 = icmp slt i32 %82, 1
br i1 %83, label %88, label %84
84: ; preds = %81
%85 = load i32, i32* %8
%86 = load i32, i32* %4
%87 = icmp sgt i32 %85, %86
br i1 %87, label %88, label %96
88: ; preds = %84, %81, %77, %72
%89 = load i32, i32* %14
%90 = load i32, i32* %7
%91 = load i32, i32* %8
%92 = load i32, i32* %3
%93 = load i32, i32* %4
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.6, i64 0, i64 0), i32 %89, i32 %90, i32 %91, i32 %92, i32 %93)
%95 = call i32 @exit(i32 1)
unreachable
96: ; preds = %84
%97 = load i32, i32* %7
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds [1001 x [1001 x i32]], [1001 x [1001 x i32]]* %10, i64 0, i64 %98
%100 = load i32, i32* %8
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds [1001 x i32], [1001 x i32]* %99, i64 0, i64 %101
store i32 1, i32* %102
br label %103
103: ; preds = %96
%104 = load i32, i32* %14
%105 = add nsw i32 %104, 1
store i32 %105, i32* %14
br label %68
106: ; preds = %68
store i32 1, i32* %15
br label %107
107: ; preds = %129, %106
%108 = load i32, i32* %15
%109 = load i32, i32* %6
%110 = icmp sle i32 %108, %109
br i1 %110, label %111, label %132
111: ; preds = %107
%112 = load i32*, i32** %2
%113 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %112, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %9)
%114 = load i32, i32* %9
%115 = icmp slt i32 %114, 0
br i1 %115, label %119, label %116
116: ; preds = %111
%117 = load i32, i32* %9
%118 = icmp sgt i32 %117, 1000000
br i1 %118, label %119, label %124
119: ; preds = %116, %111
%120 = load i32, i32* %15
%121 = load i32, i32* %9
%122 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.8, i64 0, i64 0), i32 %120, i32 %121)
%123 = call i32 @exit(i32 1)
unreachable
124: ; preds = %116
%125 = load i32, i32* %9
%126 = load i32, i32* %15
%127 = sext i32 %126 to i64
%128 = getelementptr inbounds [21 x i32], [21 x i32]* %11, i64 0, i64 %127
store i32 %125, i32* %128
br label %129
129: ; preds = %124
%130 = load i32, i32* %15
%131 = add nsw i32 %130, 1
store i32 %131, i32* %15
br label %107
132: ; preds = %107
%133 = load i32, i32* %12
%134 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i32 %133)
store i32 1, i32* %16
br label %135
135: ; preds = %231, %132
%136 = load i32, i32* %16
%137 = load i32, i32* %6
%138 = icmp sle i32 %136, %137
br i1 %138, label %139, label %234
139: ; preds = %135
store i32 1, i32* %17
br label %140
140: ; preds = %171, %139
%141 = load i32, i32* %17
%142 = load i32, i32* %3
%143 = icmp sle i32 %141, %142
br i1 %143, label %144, label %174
144: ; preds = %140
store i32 1, i32* %18
br label %145
145: ; preds = %167, %144
%146 = load i32, i32* %18
%147 = load i32, i32* %4
%148 = icmp sle i32 %146, %147
br i1 %148, label %149, label %170
149: ; preds = %145
%150 = getelementptr inbounds [1001 x [1001 x i32]], [1001 x [1001 x i32]]* %10, i64 0, i64 0
%151 = bitcast [1001 x i32]* %150 to i32**
%152 = load i32, i32* %16
%153 = sext i32 %152 to i64
%154 = getelementptr inbounds [21 x i32], [21 x i32]* %11, i64 0, i64 %153
%155 = load i32, i32* %154
%156 = load i32, i32* %17
%157 = load i32, i32* %18
%158 = load i32, i32* %3
%159 = load i32, i32* %4
%160 = call i32 @score(i32** %151, i32 %155, i32 %156, i32 %157, i32 %158, i32 %159)
%161 = load i32, i32* %17
%162 = sext i32 %161 to i64
%163 = getelementptr inbounds [1001 x [1001 x i32]], [1001 x [1001 x i32]]* %13, i64 0, i64 %162
%164 = load i32, i32* %18
%165 = sext i32 %164 to i64
%166 = getelementptr inbounds [1001 x i32], [1001 x i32]* %163, i64 0, i64 %165
store i32 %160, i32* %166
br label %167
167: ; preds = %149
%168 = load i32, i32* %18
%169 = add nsw i32 %168, 1
store i32 %169, i32* %18
br label %145
170: ; preds = %145
br label %171
171: ; preds = %170
%172 = load i32, i32* %17
%173 = add nsw i32 %172, 1
store i32 %173, i32* %17
br label %140
174: ; preds = %140
store i32 0, i32* %19
store i32 0, i32* %20
store i32 1, i32* %21
br label %175
175: ; preds = %208, %174
%176 = load i32, i32* %21
%177 = load i32, i32* %4
%178 = icmp sle i32 %176, %177
br i1 %178, label %179, label %211
179: ; preds = %175
store i32 1, i32* %22
br label %180
180: ; preds = %204, %179
%181 = load i32, i32* %22
%182 = load i32, i32* %3
%183 = icmp sle i32 %181, %182
br i1 %183, label %184, label %207
184: ; preds = %180
%185 = load i32, i32* %19
%186 = sext i32 %185 to i64
%187 = getelementptr inbounds [1001 x [1001 x i32]], [1001 x [1001 x i32]]* %13, i64 0, i64 %186
%188 = load i32, i32* %20
%189 = sext i32 %188 to i64
%190 = getelementptr inbounds [1001 x i32], [1001 x i32]* %187, i64 0, i64 %189
%191 = load i32, i32* %190
%192 = load i32, i32* %22
%193 = sext i32 %192 to i64
%194 = getelementptr inbounds [1001 x [1001 x i32]], [1001 x [1001 x i32]]* %13, i64 0, i64 %193
%195 = load i32, i32* %21
%196 = sext i32 %195 to i64
%197 = getelementptr inbounds [1001 x i32], [1001 x i32]* %194, i64 0, i64 %196
%198 = load i32, i32* %197
%199 = icmp slt i32 %191, %198
br i1 %199, label %200, label %203
200: ; preds = %184
%201 = load i32, i32* %22
store i32 %201, i32* %19
%202 = load i32, i32* %21
store i32 %202, i32* %20
br label %203
203: ; preds = %200, %184
br label %204
204: ; preds = %203
%205 = load i32, i32* %22
%206 = add nsw i32 %205, 1
store i32 %206, i32* %22
br label %180
207: ; preds = %180
br label %208
208: ; preds = %207
%209 = load i32, i32* %21
%210 = add nsw i32 %209, 1
store i32 %210, i32* %21
br label %175
211: ; preds = %175
%212 = load i32, i32* %16
%213 = sext i32 %212 to i64
%214 = getelementptr inbounds [21 x i32], [21 x i32]* %11, i64 0, i64 %213
%215 = load i32, i32* %214
%216 = load i32, i32* %19
%217 = sext i32 %216 to i64
%218 = getelementptr inbounds [1001 x [1001 x i32]], [1001 x [1001 x i32]]* %13, i64 0, i64 %217
%219 = load i32, i32* %20
%220 = sext i32 %219 to i64
%221 = getelementptr inbounds [1001 x i32], [1001 x i32]* %218, i64 0, i64 %220
%222 = load i32, i32* %221
%223 = load i32, i32* %19
%224 = load i32, i32* %20
%225 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.10, i64 0, i64 0), i32 %215, i32 %222, i32 %223, i32 %224)
%226 = getelementptr inbounds [1001 x [1001 x i32]], [1001 x [1001 x i32]]* %13, i64 0, i64 0
%227 = bitcast [1001 x i32]* %226 to i32**
%228 = load i32, i32* %3
%229 = load i32, i32* %4
%230 = call i32 @setToZero(i32** %227, i32 %228, i32 %229)
br label %231
231: ; preds = %211
%232 = load i32, i32* %16
%233 = add nsw i32 %232, 1
store i32 %233, i32* %16
br label %135
234: ; preds = %135
%235 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
%236 = load i32, i32* %12
%237 = add nsw i32 %236, 1
store i32 %237, i32* %12
br label %30
238: ; preds = %44
%239 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.12, i64 0, i64 0))
%240 = load i32*, i32** %2
%241 = call i32 @fclose(i32* %240)
%242 = load i32, i32* %1
ret i32 %242
}

LLVM IR (-O2):
@.str = [16 x i8] c"CoffeeData2.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.3 = [12 x i8] c"%d %d %d %d\00"
@.str.4 = [30 x i8] c"\0A input error n = %d, q = %d\0A\00"
@.str.5 = [6 x i8] c"%d %d\00"
@.str.6 = [74 x i8] c"\0A input error coffee shop location = %d x = %d, y = %d, dx = %d, dy = %d\0A\00"
@.str.7 = [3 x i8] c"%d\00"
@.str.8 = [44 x i8] c"\0A input error query distance i = %d m = %d\0A\00"
@.str.9 = [11 x i8] c"\0ACase %d:\0A\00"
@.str.10 = [17 x i8] c"%d: %d (%d, %d)\0A\00"
@str = [20 x i8] c"\0AAll cases are done\00"
@str.13 = [31 x i8] c"\0AUnable to open CoffeeData.txt\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [1001 x [1001 x i32]]
%9 = alloca [21 x i32]
%10 = alloca [1001 x [1001 x i32]]
%11 = bitcast i32* %1 to i8*
%12 = bitcast i32* %2 to i8*
%13 = bitcast i32* %3 to i8*
%14 = bitcast i32* %4 to i8*
%15 = bitcast i32* %5 to i8*
%16 = bitcast i32* %6 to i8*
%17 = bitcast i32* %7 to i8*
%18 = bitcast [1001 x [1001 x i32]]* %8 to i8*
%19 = bitcast [21 x i32]* %9 to i8*
%20 = bitcast [1001 x [1001 x i32]]* %10 to i8*
%21 = tail call i32* @fopen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%22 = icmp eq i32* %21, null
br i1 %22, label %39, label %23
23: ; preds = %0
%24 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %21, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32* %1, i32* %2, i32* %3, i32* %4)
%25 = load i32, i32* %1
%26 = icmp eq i32 %25, 0
%27 = load i32, i32* %2
%28 = icmp eq i32 %27, 0
%29 = select i1 %26, i1 %28, i1 false
%30 = load i32, i32* %3
%31 = icmp eq i32 %30, 0
%32 = select i1 %29, i1 %31, i1 false
%33 = load i32, i32* %4
%34 = icmp eq i32 %33, 0
%35 = select i1 %32, i1 %34, i1 false
br i1 %35, label %258, label %36
36: ; preds = %23
%37 = bitcast [1001 x [1001 x i32]]* %8 to i32**
%38 = bitcast [1001 x [1001 x i32]]* %10 to i32**
br label %42
39: ; preds = %0
%40 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.13, i64 0, i64 0))
%41 = tail call i32 @exit(i32 1)
unreachable
42: ; preds = %36, %122
%43 = phi i32 [ %33, %36 ], [ %134, %122 ]
%44 = phi i32 [ %30, %36 ], [ %131, %122 ]
%45 = phi i32 [ %27, %36 ], [ %128, %122 ]
%46 = phi i32 [ %25, %36 ], [ %126, %122 ]
%47 = phi i32 [ 1, %36 ], [ %124, %122 ]
%48 = icmp ugt i32 %44, 500000
%49 = icmp sgt i32 %43, 20
%50 = select i1 %48, i1 true, i1 %49
%51 = icmp slt i32 %43, 1
%52 = select i1 %50, i1 true, i1 %51
br i1 %52, label %53, label %56
53: ; preds = %42
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i32 %44, i32 %43)
%55 = call i32 @exit(i32 1)
unreachable
56: ; preds = %42
%57 = call i32 @setToZero(i32** %37, i32 %46, i32 %45)
%58 = load i32, i32* %3
%59 = icmp slt i32 %58, 1
br i1 %59, label %60, label %63
60: ; preds = %87, %56
%61 = load i32, i32* %4
%62 = icmp slt i32 %61, 1
br i1 %62, label %94, label %98
63: ; preds = %56, %87
%64 = phi i32 [ %91, %87 ], [ 1, %56 ]
%65 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %21, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32* %5, i32* %6)
%66 = load i32, i32* %5
%67 = icmp slt i32 %66, 1
br i1 %67, label %68, label %72
68: ; preds = %63
%69 = load i32, i32* %6
%70 = load i32, i32* %1
%71 = load i32, i32* %2
br label %81
72: ; preds = %63
%73 = load i32, i32* %1
%74 = icmp sgt i32 %66, %73
%75 = load i32, i32* %6
%76 = icmp slt i32 %75, 1
%77 = select i1 %74, i1 true, i1 %76
%78 = load i32, i32* %2
%79 = icmp sgt i32 %75, %78
%80 = select i1 %77, i1 true, i1 %79
br i1 %80, label %81, label %87
81: ; preds = %72, %68
%82 = phi i32 [ %71, %68 ], [ %78, %72 ]
%83 = phi i32 [ %70, %68 ], [ %73, %72 ]
%84 = phi i32 [ %69, %68 ], [ %75, %72 ]
%85 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([74 x i8], [74 x i8]* @.str.6, i64 0, i64 0), i32 %64, i32 %66, i32 %84, i32 %83, i32 %82)
%86 = call i32 @exit(i32 1)
unreachable
87: ; preds = %72
%88 = zext i32 %66 to i64
%89 = zext i32 %75 to i64
%90 = getelementptr inbounds [1001 x [1001 x i32]], [1001 x [1001 x i32]]* %8, i64 0, i64 %88, i64 %89
store i32 1, i32* %90
%91 = add nuw nsw i32 %64, 1
%92 = load i32, i32* %3
%93 = icmp slt i32 %64, %92
br i1 %93, label %63, label %60
94: ; preds = %107, %60
%95 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i32 %47)
%96 = load i32, i32* %4
%97 = icmp slt i32 %96, 1
br i1 %97, label %122, label %113
98: ; preds = %60, %107
%99 = phi i64 [ %109, %107 ], [ 1, %60 ]
%100 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %7)
%101 = load i32, i32* %7
%102 = icmp ugt i32 %101, 1000000
br i1 %102, label %103, label %107
103: ; preds = %98
%104 = trunc i64 %99 to i32
%105 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.8, i64 0, i64 0), i32 %104, i32 %101)
%106 = call i32 @exit(i32 1)
unreachable
107: ; preds = %98
%108 = getelementptr inbounds [21 x i32], [21 x i32]* %9, i64 0, i64 %99
store i32 %101, i32* %108
%109 = add nuw nsw i64 %99, 1
%110 = load i32, i32* %4
%111 = sext i32 %110 to i64
%112 = icmp slt i64 %99, %111
br i1 %112, label %98, label %94
113: ; preds = %94, %190
%114 = phi i64 [ %203, %190 ], [ 1, %94 ]
%115 = load i32, i32* %1
%116 = icmp slt i32 %115, 1
br i1 %116, label %117, label %119
117: ; preds = %113
%118 = load i32, i32* %2
br label %137
119: ; preds = %113
%120 = getelementptr inbounds [21 x i32], [21 x i32]* %9, i64 0, i64 %114
%121 = load i32, i32* %2
br label %152
122: ; preds = %190, %94
%123 = call i32 @putchar(i32 10)
%124 = add nuw nsw i32 %47, 1
%125 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %21, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32* %1, i32* %2, i32* %3, i32* %4)
%126 = load i32, i32* %1
%127 = icmp eq i32 %126, 0
%128 = load i32, i32* %2
%129 = icmp eq i32 %128, 0
%130 = select i1 %127, i1 %129, i1 false
%131 = load i32, i32* %3
%132 = icmp eq i32 %131, 0
%133 = select i1 %130, i1 %132, i1 false
%134 = load i32, i32* %4
%135 = icmp eq i32 %134, 0
%136 = select i1 %133, i1 %135, i1 false
br i1 %136, label %258, label %42
137: ; preds = %167, %117
%138 = phi i32 [ %118, %117 ], [ %169, %167 ]
%139 = phi i32 [ %115, %117 ], [ %168, %167 ]
%140 = icmp slt i32 %138, 1
br i1 %140, label %190, label %141
141: ; preds = %137
%142 = icmp slt i32 %139, 1
%143 = add i32 %139, 1
%144 = add nuw i32 %138, 1
%145 = zext i32 %144 to i64
%146 = zext i32 %143 to i64
%147 = add nsw i64 %146, -1
%148 = and i64 %147, 1
%149 = icmp eq i32 %143, 2
%150 = and i64 %147, -2
%151 = icmp eq i64 %148, 0
br label %184
152: ; preds = %119, %167
%153 = phi i32 [ %115, %119 ], [ %168, %167 ]
%154 = phi i32 [ %121, %119 ], [ %169, %167 ]
%155 = phi i64 [ 1, %119 ], [ %170, %167 ]
%156 = icmp slt i32 %154, 1
br i1 %156, label %167, label %157
157: ; preds = %152
%158 = load i32, i32* %120
%159 = trunc i64 %155 to i32
%160 = call i32 @score(i32** %37, i32 %158, i32 %159, i32 1, i32 %153, i32 %154)
%161 = getelementptr inbounds [1001 x [1001 x i32]], [1001 x [1001 x i32]]* %10, i64 0, i64 %155, i64 1
store i32 %160, i32* %161
%162 = load i32, i32* %2
%163 = icmp sgt i32 %162, 1
br i1 %163, label %173, label %164
164: ; preds = %173, %157
%165 = phi i32 [ %162, %157 ], [ %181, %173 ]
%166 = load i32, i32* %1
br label %167
167: ; preds = %164, %152
%168 = phi i32 [ %166, %164 ], [ %153, %152 ]
%169 = phi i32 [ %165, %164 ], [ %154, %152 ]
%170 = add nuw nsw i64 %155, 1
%171 = sext i32 %168 to i64
%172 = icmp slt i64 %155, %171
br i1 %172, label %152, label %137
173: ; preds = %157, %173
%174 = phi i32 [ %181, %173 ], [ %162, %157 ]
%175 = phi i64 [ %176, %173 ], [ 1, %157 ]
%176 = add nuw nsw i64 %175, 1
%177 = load i32, i32* %1
%178 = trunc i64 %176 to i32
%179 = call i32 @score(i32** %37, i32 %158, i32 %159, i32 %178, i32 %177, i32 %174)
%180 = getelementptr inbounds [1001 x [1001 x i32]], [1001 x [1001 x i32]]* %10, i64 0, i64 %155, i64 %176
store i32 %179, i32* %180
%181 = load i32, i32* %2
%182 = sext i32 %181 to i64
%183 = icmp slt i64 %176, %182
br i1 %183, label %173, label %164
184: ; preds = %141, %224
%185 = phi i64 [ 1, %141 ], [ %227, %224 ]
%186 = phi i32 [ 0, %141 ], [ %226, %224 ]
%187 = phi i32 [ 0, %141 ], [ %225, %224 ]
br i1 %142, label %224, label %188
188: ; preds = %184
%189 = trunc i64 %185 to i32
br i1 %149, label %207, label %229
190: ; preds = %224, %137
%191 = phi i32 [ 0, %137 ], [ %225, %224 ]
%192 = phi i32 [ 0, %137 ], [ %226, %224 ]
%193 = getelementptr inbounds [21 x i32], [21 x i32]* %9, i64 0, i64 %114
%194 = load i32, i32* %193
%195 = sext i32 %191 to i64
%196 = sext i32 %192 to i64
%197 = getelementptr inbounds [1001 x [1001 x i32]], [1001 x [1001 x i32]]* %10, i64 0, i64 %195, i64 %196
%198 = load i32, i32* %197
%199 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.10, i64 0, i64 0), i32 %194, i32 %198, i32 %191, i32 %192)
%200 = load i32, i32* %1
%201 = load i32, i32* %2
%202 = call i32 @setToZero(i32** %38, i32 %200, i32 %201)
%203 = add nuw nsw i64 %114, 1
%204 = load i32, i32* %4
%205 = sext i32 %204 to i64
%206 = icmp slt i64 %114, %205
br i1 %206, label %113, label %122
207: ; preds = %229, %188
%208 = phi i32 [ undef, %188 ], [ %253, %229 ]
%209 = phi i32 [ undef, %188 ], [ %254, %229 ]
%210 = phi i64 [ 1, %188 ], [ %255, %229 ]
%211 = phi i32 [ %186, %188 ], [ %254, %229 ]
%212 = phi i32 [ %187, %188 ], [ %253, %229 ]
br i1 %151, label %224, label %213
213: ; preds = %207
%214 = sext i32 %212 to i64
%215 = sext i32 %211 to i64
%216 = getelementptr inbounds [1001 x [1001 x i32]], [1001 x [1001 x i32]]* %10, i64 0, i64 %214, i64 %215
%217 = load i32, i32* %216
%218 = getelementptr inbounds [1001 x [1001 x i32]], [1001 x [1001 x i32]]* %10, i64 0, i64 %210, i64 %185
%219 = load i32, i32* %218
%220 = icmp slt i32 %217, %219
%221 = trunc i64 %210 to i32
%222 = select i1 %220, i32 %221, i32 %212
%223 = select i1 %220, i32 %189, i32 %211
br label %224
224: ; preds = %213, %207, %184
%225 = phi i32 [ %187, %184 ], [ %208, %207 ], [ %222, %213 ]
%226 = phi i32 [ %186, %184 ], [ %209, %207 ], [ %223, %213 ]
%227 = add nuw nsw i64 %185, 1
%228 = icmp eq i64 %227, %145
br i1 %228, label %190, label %184
229: ; preds = %188, %229
%230 = phi i64 [ %255, %229 ], [ 1, %188 ]
%231 = phi i32 [ %254, %229 ], [ %186, %188 ]
%232 = phi i32 [ %253, %229 ], [ %187, %188 ]
%233 = phi i64 [ %256, %229 ], [ 0, %188 ]
%234 = sext i32 %232 to i64
%235 = sext i32 %231 to i64
%236 = getelementptr inbounds [1001 x [1001 x i32]], [1001 x [1001 x i32]]* %10, i64 0, i64 %234, i64 %235
%237 = load i32, i32* %236
%238 = getelementptr inbounds [1001 x [1001 x i32]], [1001 x [1001 x i32]]* %10, i64 0, i64 %230, i64 %185
%239 = load i32, i32* %238
%240 = icmp slt i32 %237, %239
%241 = trunc i64 %230 to i32
%242 = select i1 %240, i32 %241, i32 %232
%243 = select i1 %240, i32 %189, i32 %231
%244 = add nuw nsw i64 %230, 1
%245 = sext i32 %242 to i64
%246 = sext i32 %243 to i64
%247 = getelementptr inbounds [1001 x [1001 x i32]], [1001 x [1001 x i32]]* %10, i64 0, i64 %245, i64 %246
%248 = load i32, i32* %247
%249 = getelementptr inbounds [1001 x [1001 x i32]], [1001 x [1001 x i32]]* %10, i64 0, i64 %244, i64 %185
%250 = load i32, i32* %249
%251 = icmp slt i32 %248, %250
%252 = trunc i64 %244 to i32
%253 = select i1 %251, i32 %252, i32 %242
%254 = select i1 %251, i32 %189, i32 %243
%255 = add nuw nsw i64 %230, 2
%256 = add i64 %233, 2
%257 = icmp eq i64 %256, %150
br i1 %257, label %207, label %229
258: ; preds = %122, %23
%259 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%260 = call i32 @fclose(i32* %21)
ret i32 0
}