#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 cl_uint;
typedef int /*<<< orphan*/ cl_program;
typedef int /*<<< orphan*/ cl_platform_id;
typedef int cl_mem;
typedef int /*<<< orphan*/ cl_kernel;
typedef int cl_int;
typedef scalar_t__ cl_device_type;
typedef int /*<<< orphan*/ cl_device_id;
typedef int /*<<< orphan*/ cl_context_properties;
typedef int /*<<< orphan*/ cl_context;
typedef int /*<<< orphan*/ cl_command_queue;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ CL_CONTEXT_PLATFORM;
int /*<<< orphan*/ CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS;
int /*<<< orphan*/ CL_DEVICE_MAX_WORK_ITEM_SIZES;
scalar_t__ CL_DEVICE_TYPE_CPU;
scalar_t__ CL_DEVICE_TYPE_GPU;
int /*<<< orphan*/ CL_TRUE;
int atoi(char *);
int /*<<< orphan*/ chk(int, char *, int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int clBuildProgram(int /*<<< orphan*/, int, int /*<<< orphan*/ *,
                   int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                   int /*<<< orphan*/ *);
int clCreateBuffer(int /*<<< orphan*/, int /*<<< orphan*/, size_t const,
                   int /*<<< orphan*/ *, int *);
int /*<<< orphan*/ clCreateCommandQueue(int /*<<< orphan*/, int /*<<< orphan*/,
                                        int /*<<< orphan*/, int *);
int /*<<< orphan*/ clCreateContext(int /*<<< orphan*/ *, int,
                                   int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                                   int /*<<< orphan*/ *, int *);
int /*<<< orphan*/ clCreateKernel(int /*<<< orphan*/, char *, int *);
int /*<<< orphan*/ clCreateProgramWithSource(int /*<<< orphan*/, int,
                                             char const **,
                                             int /*<<< orphan*/ *, int *);
int clEnqueueNDRangeKernel(int /*<<< orphan*/, int /*<<< orphan*/, int,
                           int /*<<< orphan*/ *, size_t *, size_t *,
                           int /*<<< orphan*/, int /*<<< orphan*/ *,
                           int /*<<< orphan*/ *);
int clEnqueueReadBuffer(int /*<<< orphan*/, int, int /*<<< orphan*/,
                        int /*<<< orphan*/, size_t const, int *,
                        int /*<<< orphan*/, int /*<<< orphan*/ *,
                        int /*<<< orphan*/ *);
int clEnqueueWriteBuffer(int /*<<< orphan*/, int, int /*<<< orphan*/,
                         int /*<<< orphan*/, size_t const, int *,
                         int /*<<< orphan*/, int /*<<< orphan*/ *,
                         int /*<<< orphan*/ *);
int clGetDeviceIDs(int /*<<< orphan*/, scalar_t__, int, int /*<<< orphan*/ *,
                   int /*<<< orphan*/ *);
int clGetDeviceInfo(int /*<<< orphan*/, int /*<<< orphan*/, int, ...);
int clGetPlatformIDs(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int clSetKernelArg(int /*<<< orphan*/, int, int, int *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, char *);
scalar_t__ malloc(int const);
int /*<<< orphan*/ printGrid(int *, int, int);
int /*<<< orphan*/ printf(char *, ...);
char *readSource(char *);
scalar_t__ scanf(char *, char *);
scalar_t__ strcmp(char *, char *);
int strlen(char *);
int strtob(char **, int, char *);
int main(int argc, char **argv) {
  cl_int east_wood, M, N;
  char line[1024];
  int item = 0;
  const int max = 2 * (2 * 1024 * 1024);
  int *grid = (int *)malloc(max * sizeof(int));
  if (argc < 2) {
    printf("%s file|- [iterations [skip [c|gpu]]]\n", *argv);
    exit(1);
  }
  FILE *in = strcmp(argv[1], "-") ? fopen(argv[1], "r") : NULL;
  cl_device_type pu = CL_DEVICE_TYPE_GPU;
  int iterations, printskip;
  iterations = (argc > 2) ? atoi(argv[2]) : 0;
  printskip = (argc > 3) ? atoi(argv[3]) : 1;
  printskip =
      ((printskip > iterations) || (printskip < 1)) ? iterations : printskip;
  if ((argc > 4) && ((argv[4][0]) == 'C'))
    pu = CL_DEVICE_TYPE_CPU;
  for (M = N = 0; (in ? fscanf(in, "%s", line) : scanf("%s", line)) > 0; M++) {
    int len, bin;
    char *word;
    if ((len = strlen(line)) > N)
      N = len;
    for (word = line; len > 30; len -= 30) {
      bin = strtob(&word, 30, "- _") << 1;
      grid[item] = bin;
      if ((item += 2) > (max - 2))
        exit(-1);
    }
    grid[item] = strtob(&word, len, "- _") << (31 - len);
    item += 2;
  }
  if (in)
    fclose(in);
  printGrid(grid, M, N);
  cl_int status;
  int Mwg, Nwg, Mwi, Nwi = (N > 30) ? 30 : (N ? N : 1);
  cl_platform_id platform;
  status = clGetPlatformIDs(1, &platform, NULL);
  chk(status, "clGetPlatformIDs", NULL, NULL);
  cl_device_id device;
  printf("ideal workgroup size %d*%d, requesting %cPU\n", M,
         Nwi = (N - 1 + Nwi) / Nwi, (pu == CL_DEVICE_TYPE_GPU) ? 'G' : 'C');
  status = clGetDeviceIDs(platform, pu, 1, &device, NULL);
  chk(status, "clGetDeviceIDs", NULL, NULL);
  cl_uint numdims;
  status = clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS,
                           sizeof(cl_uint), &numdims, NULL);
  chk(status, "clGetDeviceInfo", NULL, NULL);
  size_t dims[numdims];
  status = clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_ITEM_SIZES,
                           numdims * sizeof(size_t), &dims, NULL);
  chk(status, "clGetDeviceInfo", NULL, NULL);
  printf("the max workgroup size of which is reported as %d*%d\n", (int)dims[0],
         (int)dims[1]);
  Mwi = (dims[0] < M) ? dims[0] : M;
  Mwg = (M - 1 + Mwi) / Mwi;
  Nwi = (dims[1] < Nwi) ? dims[1] : Nwi;
  Nwg = ((N - 1) / 30 + Nwi) / Nwi;
  const size_t dataSize = sizeof(int) * (Mwg * Nwg) * (Mwi * Nwi);
  printf("requesting %d*%d workgroups %d*%d=%d\n", Mwg, Nwg, Mwi, Nwi,
         item / 2);
  cl_context_properties props[3] = {CL_CONTEXT_PLATFORM,
                                    (cl_context_properties)(platform), 0};
  cl_context context;
  context = clCreateContext(props, 1, &device, NULL, NULL, &status);
  chk(status, "clCreateContext", NULL, NULL);
  cl_command_queue queue;
  queue = clCreateCommandQueue(context, device, 0, &status);
  chk(status, "clCreateCommandQueue", NULL, NULL);
  const char *source = readSource("gamelife.cl");
  cl_program program;
  program = clCreateProgramWithSource(context, 1, &source, NULL, &status);
  chk(status, "clCreateProgramWithSource", NULL, NULL);
  status = clBuildProgram(program, 1, &device, NULL, NULL, NULL);
  chk(status, "clBuildProgram", &device, &program);
  cl_kernel evolve = clCreateKernel(program, "evolve", &status);
  chk(status, "clCreateKernel", NULL, NULL);
  cl_mem d_grid, d_invalid;
  d_grid = clCreateBuffer(context, 0, dataSize, NULL, &status);
  chk(status, "clCreateBuffer", NULL, NULL);
  for (cl_int i = 0; (iterations == 0) || (i < iterations); i++) {
    if (i == 0) {
      cl_int sl = 2, sh = 3, rl = 3, rh = 3;
      status = clSetKernelArg(evolve, 0, sizeof(cl_mem), &d_grid);
      status |= clSetKernelArg(evolve, 1, sizeof(cl_int), &sl);
      status |= clSetKernelArg(evolve, 2, sizeof(cl_int), &sh);
      status |= clSetKernelArg(evolve, 3, sizeof(cl_int), &rl);
      status |= clSetKernelArg(evolve, 4, sizeof(cl_int), &rh);
      status |= clSetKernelArg(evolve, 5, sizeof(cl_int), &i);
      chk(status, "clSetKernelArg", NULL, NULL);
      status = clEnqueueWriteBuffer(queue, d_grid, CL_TRUE, 0, dataSize, grid,
                                    0, NULL, NULL);
      chk(status, "clEnqueueWriteBuffer", NULL, NULL);
    }
    size_t globalSize[2] = {M, Nwg};
    size_t localSize[2] = {Mwi, 1};
    status = clEnqueueNDRangeKernel(queue, evolve, 2, NULL, globalSize,
                                    localSize, 0, NULL, NULL);
    chk(status, "clEnqueueNDRangeKernel", NULL, NULL);
    if ((printskip == 0) || ((i + 1) % printskip == 0)) {
      status = clEnqueueReadBuffer(queue, d_grid, CL_TRUE, 0, dataSize, grid, 0,
                                   NULL, NULL);
      chk(status, "clEnqueueReadBuffer", NULL, NULL);
      printf("%d/%d:\n", (i + 1), iterations);
      printGrid(&grid[i & 1], M, N);
    }
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x560,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x424(%rbp)
movl   $0x400000,-0x428(%rbp)
mov    $0x1000000,%edi
call   1130 <malloc@plt>
mov    %rax,-0x430(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1317 <main+0x67>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xcfa(%rip),%rdi
mov    $0x0,%al
call   10e0 <printf@plt>
mov    $0x1,%edi
call   11a0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd01(%rip),%rsi
call   1110 <strcmp@plt>
cmp    $0x0,%rax
je     1355 <main+0xa5>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe71(%rip),%rsi
call   1160 <fopen@plt>
mov    %rax,-0x508(%rbp)
jmp    1363 <main+0xb3>
xor    %eax,%eax
mov    %rax,-0x508(%rbp)
jmp    1363 <main+0xb3>
mov    -0x508(%rbp),%rax
mov    %rax,-0x438(%rbp)
mov    0x2c60(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x440(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    13a4 <main+0xf4>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1190 <atoi@plt>
mov    %eax,-0x50c(%rbp)
jmp    13b1 <main+0x101>
xor    %eax,%eax
mov    %eax,-0x50c(%rbp)
jmp    13b1 <main+0x101>
mov    -0x50c(%rbp),%eax
mov    %eax,-0x444(%rbp)
cmpl   $0x3,-0x8(%rbp)
jle    13df <main+0x12f>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1190 <atoi@plt>
mov    %eax,-0x510(%rbp)
jmp    13ef <main+0x13f>
mov    $0x1,%eax
mov    %eax,-0x510(%rbp)
jmp    13ef <main+0x13f>
mov    -0x510(%rbp),%eax
mov    %eax,-0x448(%rbp)
mov    -0x448(%rbp),%eax
cmp    -0x444(%rbp),%eax
jg     141a <main+0x16a>
cmpl   $0x1,-0x448(%rbp)
jge    142b <main+0x17b>
mov    -0x444(%rbp),%eax
mov    %eax,-0x514(%rbp)
jmp    1437 <main+0x187>
mov    -0x448(%rbp),%eax
mov    %eax,-0x514(%rbp)
mov    -0x514(%rbp),%eax
mov    %eax,-0x448(%rbp)
cmpl   $0x4,-0x8(%rbp)
jle    1472 <main+0x1c2>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
movsbl (%rax),%eax
cmp    $0x43,%eax
jne    1472 <main+0x1c2>
mov    0x2b60(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x440(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
cmpq   $0x0,-0x438(%rbp)
je     14b4 <main+0x204>
mov    -0x438(%rbp),%rdi
lea    -0x420(%rbp),%rdx
lea    0xb86(%rip),%rsi
call   10f0 <fscanf@plt>
mov    %rax,-0x520(%rbp)
jmp    14ce <main+0x21e>
lea    -0x420(%rbp),%rsi
lea    0xb67(%rip),%rdi
call   1150 <scanf@plt>
mov    %rax,-0x520(%rbp)
mov    -0x520(%rbp),%rax
cmp    $0x0,%rax
jle    15e9 <main+0x339>
lea    -0x420(%rbp),%rdi
call   10a0 <strlen@plt>
mov    %eax,-0x44c(%rbp)
cmp    -0x1c(%rbp),%eax
jle    1503 <main+0x253>
mov    -0x44c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
lea    -0x420(%rbp),%rax
mov    %rax,-0x458(%rbp)
cmpl   $0x1e,-0x44c(%rbp)
jle    1593 <main+0x2e3>
lea    -0x458(%rbp),%rdi
mov    $0x1e,%esi
lea    0xafb(%rip),%rdx
call   11b0 <strtob@plt>
shl    $0x1,%eax
mov    %eax,-0x450(%rbp)
mov    -0x450(%rbp),%edx
mov    -0x430(%rbp),%rax
movslq -0x424(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x424(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x424(%rbp)
cmp    $0x3ffffe,%eax
jle    157a <main+0x2ca>
mov    $0xffffffff,%edi
call   11a0 <exit@plt>
jmp    157f <main+0x2cf>
mov    -0x44c(%rbp),%eax
sub    $0x1e,%eax
mov    %eax,-0x44c(%rbp)
jmp    1511 <main+0x261>
mov    -0x44c(%rbp),%esi
lea    -0x458(%rbp),%rdi
lea    0xa85(%rip),%rdx
call   11b0 <strtob@plt>
mov    %eax,%edx
mov    $0x1f,%ecx
sub    -0x44c(%rbp),%ecx
shl    %cl,%edx
mov    -0x430(%rbp),%rax
movslq -0x424(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x424(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x424(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1480 <main+0x1d0>
cmpq   $0x0,-0x438(%rbp)
je     1603 <main+0x353>
mov    -0x438(%rbp),%rdi
call   1090 <fclose@plt>
mov    -0x430(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1170 <printGrid@plt>
cmpl   $0x1e,-0x1c(%rbp)
jle    162f <main+0x37f>
mov    $0x1e,%eax
mov    %eax,-0x524(%rbp)
jmp    1663 <main+0x3b3>
cmpl   $0x0,-0x1c(%rbp)
je     1647 <main+0x397>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x528(%rbp)
jmp    1657 <main+0x3a7>
mov    $0x1,%eax
mov    %eax,-0x528(%rbp)
jmp    1657 <main+0x3a7>
mov    -0x528(%rbp),%eax
mov    %eax,-0x524(%rbp)
mov    -0x524(%rbp),%eax
mov    %eax,-0x46c(%rbp)
xor    %eax,%eax
mov    %eax,-0x544(%rbp)
mov    %eax,%edx
mov    %rdx,-0x538(%rbp)
mov    $0x1,%edi
mov    %edi,-0x540(%rbp)
lea    -0x470(%rbp),%rsi
call   10d0 <clGetPlatformIDs@plt>
mov    -0x538(%rbp),%rcx
mov    %eax,-0x45c(%rbp)
mov    -0x45c(%rbp),%edi
lea    0x97f(%rip),%rsi
mov    %rcx,%rdx
call   1050 <chk@plt>
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edi
mov    -0x46c(%rbp),%ecx
mov    %ecx,%edx
mov    %edi,%eax
lea    -0x1(%rax,%rdx,1),%eax
cltd
idiv   %ecx
mov    %eax,%edx
mov    -0x544(%rbp),%eax
mov    %edx,-0x46c(%rbp)
mov    -0x440(%rbp),%rcx
mov    0x28ec(%rip),%rdi
mov    (%rdi),%rdi
sub    %rdi,%rcx
sete   %cl
movzbl %cl,%edi
mov    %edi,%ecx
lea    0x43(,%rcx,4),%ecx
lea    0x939(%rip),%rdi
mov    %al,-0x539(%rbp)
call   10e0 <printf@plt>
mov    -0x540(%rbp),%edx
mov    -0x538(%rbp),%r8
mov    -0x470(%rbp),%edi
mov    -0x440(%rbp),%rsi
lea    -0x474(%rbp),%rcx
call   1070 <clGetDeviceIDs@plt>
mov    -0x538(%rbp),%rcx
mov    %eax,-0x45c(%rbp)
mov    -0x45c(%rbp),%edi
lea    0x91b(%rip),%rsi
mov    %rcx,%rdx
call   1050 <chk@plt>
mov    -0x538(%rbp),%r8
mov    -0x539(%rbp),%al
mov    -0x474(%rbp),%edi
mov    0x284b(%rip),%rcx
mov    (%rcx),%esi
mov    $0x4,%edx
lea    -0x478(%rbp),%rcx
call   1080 <clGetDeviceInfo@plt>
mov    -0x538(%rbp),%rcx
mov    %eax,-0x45c(%rbp)
mov    -0x45c(%rbp),%edi
lea    0x8db(%rip),%rsi
mov    %rcx,%rdx
call   1050 <chk@plt>
mov    -0x478(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x480(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x530(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x488(%rbp)
mov    -0x474(%rbp),%edi
mov    0x27f6(%rip),%rax
mov    (%rax),%esi
movslq -0x478(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edx
xor    %eax,%eax
mov    %eax,%r8d
mov    $0x0,%al
call   1080 <clGetDeviceInfo@plt>
mov    %eax,-0x45c(%rbp)
mov    -0x45c(%rbp),%edi
lea    0x865(%rip),%rsi
xor    %eax,%eax
mov    %eax,%ecx
mov    %rcx,%rdx
call   1050 <chk@plt>
mov    -0x530(%rbp),%rax
mov    (%rax),%rcx
mov    %ecx,%esi
mov    0x8(%rax),%rax
mov    %eax,%edx
lea    0x850(%rip),%rdi
mov    $0x0,%al
call   10e0 <printf@plt>
mov    -0x530(%rbp),%rax
mov    (%rax),%rax
movslq -0x18(%rbp),%rcx
cmp    %rcx,%rax
jae    1871 <main+0x5c1>
mov    -0x530(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x550(%rbp)
jmp    187c <main+0x5cc>
movslq -0x18(%rbp),%rax
mov    %rax,-0x550(%rbp)
mov    -0x550(%rbp),%rax
mov    %eax,-0x468(%rbp)
mov    -0x18(%rbp),%eax
sub    $0x1,%eax
add    -0x468(%rbp),%eax
cltd
idivl  -0x468(%rbp)
mov    %eax,%ecx
mov    -0x530(%rbp),%rax
mov    %ecx,-0x460(%rbp)
mov    0x8(%rax),%rax
movslq -0x46c(%rbp),%rcx
cmp    %rcx,%rax
jae    18d6 <main+0x626>
mov    -0x530(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x558(%rbp)
jmp    18e4 <main+0x634>
movslq -0x46c(%rbp),%rax
mov    %rax,-0x558(%rbp)
mov    -0x558(%rbp),%rax
mov    %eax,-0x46c(%rbp)
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
mov    $0x1e,%ecx
cltd
idiv   %ecx
add    -0x46c(%rbp),%eax
cltd
idivl  -0x46c(%rbp)
mov    %eax,-0x464(%rbp)
mov    -0x460(%rbp),%eax
imul   -0x464(%rbp),%eax
cltq
shl    $0x2,%rax
mov    -0x468(%rbp),%ecx
imul   -0x46c(%rbp),%ecx
movslq %ecx,%rcx
imul   %rcx,%rax
mov    %rax,-0x490(%rbp)
mov    -0x460(%rbp),%esi
mov    -0x464(%rbp),%eax
mov    %eax,-0x55c(%rbp)
mov    -0x468(%rbp),%ecx
mov    -0x46c(%rbp),%r8d
mov    -0x424(%rbp),%eax
mov    $0x2,%edi
cltd
idiv   %edi
mov    -0x55c(%rbp),%edx
mov    %eax,%r9d
lea    0x746(%rip),%rdi
mov    $0x0,%al
call   10e0 <printf@plt>
mov    0x262d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x49c(%rbp)
mov    -0x470(%rbp),%eax
mov    %eax,-0x498(%rbp)
movl   $0x0,-0x494(%rbp)
lea    -0x49c(%rbp),%rdi
mov    $0x1,%esi
lea    -0x474(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%r8d
lea    -0x45c(%rbp),%r9
mov    %r8,%rcx
call   1100 <clCreateContext@plt>
mov    %eax,-0x4a0(%rbp)
mov    -0x45c(%rbp),%edi
lea    0x706(%rip),%rsi
xor    %eax,%eax
mov    %eax,%ecx
mov    %rcx,%rdx
call   1050 <chk@plt>
mov    -0x4a0(%rbp),%edi
mov    -0x474(%rbp),%esi
xor    %edx,%edx
lea    -0x45c(%rbp),%rcx
call   10c0 <clCreateCommandQueue@plt>
mov    %eax,-0x4a4(%rbp)
mov    -0x45c(%rbp),%edi
lea    0x6dd(%rip),%rsi
xor    %eax,%eax
mov    %eax,%ecx
mov    %rcx,%rdx
call   1050 <chk@plt>
lea    0x6df(%rip),%rdi
call   1120 <readSource@plt>
mov    %rax,-0x4b0(%rbp)
mov    -0x4a0(%rbp),%edi
mov    $0x1,%esi
lea    -0x4b0(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x45c(%rbp),%r8
call   1040 <clCreateProgramWithSource@plt>
mov    %eax,-0x4b4(%rbp)
mov    -0x45c(%rbp),%edi
lea    0x6aa(%rip),%rsi
xor    %eax,%eax
mov    %eax,%ecx
mov    %rcx,%rdx
call   1050 <chk@plt>
mov    -0x4b4(%rbp),%edi
mov    $0x1,%esi
lea    -0x474(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%r9d
mov    %r9,%rcx
mov    %r9,%r8
call   1030 <clBuildProgram@plt>
mov    %eax,-0x45c(%rbp)
mov    -0x45c(%rbp),%edi
lea    0x683(%rip),%rsi
lea    -0x474(%rbp),%rdx
lea    -0x4b4(%rbp),%rcx
call   1050 <chk@plt>
mov    -0x4b4(%rbp),%edi
lea    0x672(%rip),%rsi
lea    -0x45c(%rbp),%rdx
call   1180 <clCreateKernel@plt>
mov    %eax,-0x4b8(%rbp)
mov    -0x45c(%rbp),%edi
lea    0x65a(%rip),%rsi
xor    %eax,%eax
mov    %eax,%ecx
mov    %rcx,%rdx
call   1050 <chk@plt>
mov    -0x4a0(%rbp),%edi
mov    -0x490(%rbp),%rdx
xor    %esi,%esi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x45c(%rbp),%r8
call   1060 <clCreateBuffer@plt>
mov    %eax,-0x4bc(%rbp)
mov    -0x45c(%rbp),%edi
lea    0x62b(%rip),%rsi
xor    %eax,%eax
mov    %eax,%ecx
mov    %rcx,%rdx
call   1050 <chk@plt>
movl   $0x0,-0x4c4(%rbp)
mov    $0x1,%al
cmpl   $0x0,-0x444(%rbp)
mov    %al,-0x55d(%rbp)
je     1b6e <main+0x8be>
mov    -0x4c4(%rbp),%eax
cmp    -0x444(%rbp),%eax
setl   %al
mov    %al,-0x55d(%rbp)
mov    -0x55d(%rbp),%al
test   $0x1,%al
jne    1b81 <main+0x8d1>
jmp    1ea7 <main+0xbf7>
cmpl   $0x0,-0x4c4(%rbp)
jne    1d1f <main+0xa6f>
movl   $0x2,-0x4c8(%rbp)
movl   $0x3,-0x4cc(%rbp)
movl   $0x3,-0x4d0(%rbp)
movl   $0x3,-0x4d4(%rbp)
mov    -0x4b8(%rbp),%edi
xor    %esi,%esi
mov    $0x4,%edx
lea    -0x4bc(%rbp),%rcx
call   11c0 <clSetKernelArg@plt>
mov    %eax,-0x45c(%rbp)
mov    -0x4b8(%rbp),%edi
mov    $0x1,%esi
mov    $0x4,%edx
lea    -0x4c8(%rbp),%rcx
call   11c0 <clSetKernelArg@plt>
or     -0x45c(%rbp),%eax
mov    %eax,-0x45c(%rbp)
mov    -0x4b8(%rbp),%edi
mov    $0x2,%esi
mov    $0x4,%edx
lea    -0x4cc(%rbp),%rcx
call   11c0 <clSetKernelArg@plt>
or     -0x45c(%rbp),%eax
mov    %eax,-0x45c(%rbp)
mov    -0x4b8(%rbp),%edi
mov    $0x3,%esi
mov    $0x4,%edx
lea    -0x4d0(%rbp),%rcx
call   11c0 <clSetKernelArg@plt>
or     -0x45c(%rbp),%eax
mov    %eax,-0x45c(%rbp)
mov    -0x4b8(%rbp),%edi
mov    $0x4,%edx
lea    -0x4d4(%rbp),%rcx
mov    %edx,%esi
call   11c0 <clSetKernelArg@plt>
or     -0x45c(%rbp),%eax
mov    %eax,-0x45c(%rbp)
mov    -0x4b8(%rbp),%edi
mov    $0x5,%esi
mov    $0x4,%edx
lea    -0x4c4(%rbp),%rcx
call   11c0 <clSetKernelArg@plt>
or     -0x45c(%rbp),%eax
mov    %eax,-0x45c(%rbp)
mov    -0x45c(%rbp),%edi
lea    0x4c1(%rip),%rsi
xor    %eax,%eax
mov    %eax,%ecx
mov    %rcx,%rdx
call   1050 <chk@plt>
mov    -0x4a4(%rbp),%edi
mov    -0x4bc(%rbp),%esi
mov    0x2322(%rip),%rax
mov    (%rax),%edx
mov    -0x490(%rbp),%r8
mov    -0x430(%rbp),%r9
xor    %ecx,%ecx
xor    %eax,%eax
sub    $0x20,%rsp
movl   $0x0,(%rsp)
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
call   11d0 <clEnqueueWriteBuffer@plt>
add    $0x20,%rsp
mov    %eax,-0x45c(%rbp)
mov    -0x45c(%rbp),%edi
lea    0x464(%rip),%rsi
xor    %eax,%eax
mov    %eax,%ecx
mov    %rcx,%rdx
call   1050 <chk@plt>
movslq -0x18(%rbp),%rax
mov    %rax,-0x4f0(%rbp)
movslq -0x464(%rbp),%rax
mov    %rax,-0x4e8(%rbp)
movslq -0x468(%rbp),%rax
mov    %rax,-0x500(%rbp)
movq   $0x1,-0x4f8(%rbp)
mov    -0x4a4(%rbp),%edi
mov    -0x4b8(%rbp),%esi
lea    -0x4f0(%rbp),%r8
lea    -0x500(%rbp),%r9
mov    $0x2,%edx
xor    %eax,%eax
mov    %eax,%ecx
xor    %eax,%eax
sub    $0x20,%rsp
movl   $0x0,(%rsp)
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
call   10b0 <clEnqueueNDRangeKernel@plt>
add    $0x20,%rsp
mov    %eax,-0x45c(%rbp)
mov    -0x45c(%rbp),%edi
lea    0x3dd(%rip),%rsi
xor    %eax,%eax
mov    %eax,%ecx
mov    %rcx,%rdx
call   1050 <chk@plt>
cmpl   $0x0,-0x448(%rbp)
je     1de1 <main+0xb31>
mov    -0x4c4(%rbp),%eax
add    $0x1,%eax
cltd
idivl  -0x448(%rbp)
cmp    $0x0,%edx
jne    1e8e <main+0xbde>
mov    -0x4a4(%rbp),%edi
mov    -0x4bc(%rbp),%esi
mov    0x21f4(%rip),%rax
mov    (%rax),%edx
mov    -0x490(%rbp),%r8
mov    -0x430(%rbp),%r9
xor    %ecx,%ecx
xor    %eax,%eax
sub    $0x20,%rsp
movl   $0x0,(%rsp)
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
call   1140 <clEnqueueReadBuffer@plt>
add    $0x20,%rsp
mov    %eax,-0x45c(%rbp)
mov    -0x45c(%rbp),%edi
lea    0x362(%rip),%rsi
xor    %eax,%eax
mov    %eax,%ecx
mov    %rcx,%rdx
call   1050 <chk@plt>
mov    -0x4c4(%rbp),%esi
add    $0x1,%esi
mov    -0x444(%rbp),%edx
lea    0x354(%rip),%rdi
mov    $0x0,%al
call   10e0 <printf@plt>
mov    -0x430(%rbp),%rdi
mov    -0x4c4(%rbp),%eax
and    $0x1,%eax
cltq
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1170 <printGrid@plt>
jmp    1e93 <main+0xbe3>
mov    -0x4c4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c4(%rbp)
jmp    1b44 <main+0x894>
xor    %edi,%edi
call   11a0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x4a8,%rsp
mov    %rsi,%r14
mov    %edi,%r15d
mov    $0x1000000,%edi
call   1130 <malloc@plt>
cmp    $0x1,%r15d
jg     12f5 <main+0x45>
mov    (%r14),%rsi
lea    0xd2c(%rip),%rdi
xor    %eax,%eax
call   10e0 <printf@plt>
mov    $0x1,%edi
call   11a0 <exit@plt>
mov    %rax,%r12
mov    0x8(%r14),%rdi
lea    0xd34(%rip),%rsi
call   1110 <strcmp@plt>
xor    %ecx,%ecx
mov    %rcx,-0x48(%rbp)
test   %rax,%rax
jne    1318 <main+0x68>
xor    %r13d,%r13d
jmp    132b <main+0x7b>
mov    0x8(%r14),%rdi
lea    0xea2(%rip),%rsi
call   1160 <fopen@plt>
mov    %rax,%r13
mov    0x2ca6(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x70(%rbp)
cmp    $0x3,%r15d
mov    %r12,-0x58(%rbp)
jb     1364 <main+0xb4>
mov    0x10(%r14),%rdi
call   1190 <atoi@plt>
mov    %eax,%ebx
cmp    $0x3,%r15d
mov    %rbx,-0x48(%rbp)
jne    1492 <main+0x1e2>
test   %ebx,%ebx
jg     14d4 <main+0x224>
mov    -0x48(%rbp),%rax
mov    %eax,-0x38(%rbp)
xor    %ebx,%ebx
lea    -0x4d0(%rbp),%r12
lea    0xcc1(%rip),%r14
lea    -0xa0(%rbp),%r15
movl   $0x0,-0x3c(%rbp)
xor    %eax,%eax
mov    %rax,-0x78(%rbp)
mov    %r13,-0x50(%rbp)
jmp    13db <main+0x12b>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r13d,%r12d
mov    %r15,%rdi
mov    %r12d,%esi
mov    %r14,%rdx
call   11b0 <strtob@plt>
mov    $0x1f,%cl
sub    %r12b,%cl
shl    %cl,%eax
movslq %ebx,%rbx
mov    -0x58(%rbp),%rcx
mov    %eax,(%rcx,%rbx,4)
add    $0x2,%ebx
mov    -0x78(%rbp),%rax
add    $0x1,%eax
mov    %rax,-0x78(%rbp)
mov    -0x50(%rbp),%r13
lea    -0x4d0(%rbp),%r12
test   %r13,%r13
je     1400 <main+0x150>
mov    %r13,%rdi
lea    0xc4f(%rip),%rsi
mov    %r12,%rdx
call   10f0 <fscanf@plt>
test   %rax,%rax
jg     1418 <main+0x168>
jmp    14e0 <main+0x230>
nopl   0x0(%rax)
lea    0xc32(%rip),%rdi
mov    %r12,%rsi
call   1150 <scanf@plt>
test   %rax,%rax
jle    14e8 <main+0x238>
mov    %r12,%rdi
call   10a0 <strlen@plt>
mov    %eax,%r13d
mov    -0x3c(%rbp),%eax
cmp    %eax,%r13d
cmovg  %r13d,%eax
mov    %eax,-0x3c(%rbp)
mov    %r12,-0xa0(%rbp)
cmp    $0x1f,%r13d
jl     13a0 <main+0xf0>
movslq %ebx,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%rdi
mov    $0x1e,%esi
mov    %r14,%rdx
call   11b0 <strtob@plt>
add    %eax,%eax
mov    -0x58(%rbp),%rcx
mov    %eax,(%rcx,%rbx,4)
cmp    $0x3ffffd,%rbx
jge    1488 <main+0x1d8>
add    $0x2,%rbx
lea    -0x1e(%r13),%r12d
cmp    $0x3c,%r13d
mov    %r12d,%r13d
jg     1450 <main+0x1a0>
jmp    13a3 <main+0xf3>
mov    $0xffffffff,%edi
call   11a0 <exit@plt>
mov    0x18(%r14),%rdi
call   1190 <atoi@plt>
test   %eax,%eax
mov    %eax,%ecx
cmovle %ebx,%ecx
cmp    %ebx,%eax
cmovg  %ebx,%ecx
mov    %ecx,-0x38(%rbp)
cmp    $0x5,%r15d
jb     136b <main+0xbb>
mov    0x20(%r14),%rax
cmpb   $0x43,(%rax)
jne    136b <main+0xbb>
mov    0x2b00(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x70(%rbp)
jmp    136b <main+0xbb>
movl   $0x1,-0x38(%rbp)
jmp    136b <main+0xbb>
mov    %r13,%rdi
call   1090 <fclose@plt>
mov    -0x58(%rbp),%rdi
mov    -0x78(%rbp),%r15
mov    %r15d,%esi
mov    -0x3c(%rbp),%r14d
mov    %r14d,%edx
call   1170 <printGrid@plt>
mov    %r14d,%eax
sub    $0x1,%eax
mov    %rax,%r12
mov    %rax,-0x50(%rbp)
mov    $0x1,%eax
mov    %r14d,%ecx
cmovb  %eax,%ecx
cmp    $0x1f,%r14d
mov    $0x1e,%r14d
cmovl  %ecx,%r14d
lea    -0x60(%rbp),%rsi
mov    $0x1,%edi
xor    %edx,%edx
call   10d0 <clGetPlatformIDs@plt>
mov    %eax,-0x2c(%rbp)
lea    0xb01(%rip),%rsi
mov    %eax,%edi
xor    %edx,%edx
xor    %ecx,%ecx
call   1050 <chk@plt>
lea    (%r14,%r12,1),%eax
cltd
idiv   %r14d
mov    %eax,%edx
mov    %eax,-0x68(%rbp)
xor    %eax,%eax
mov    -0x70(%rbp),%r14
mov    0x2a74(%rip),%rcx
cmp    (%rcx),%r14
sete   %al
lea    0x43(,%rax,4),%ecx
lea    0xad9(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   10e0 <printf@plt>
mov    -0x60(%rbp),%edi
lea    -0x34(%rbp),%rcx
mov    %r14,%rsi
mov    $0x1,%edx
xor    %r8d,%r8d
call   1070 <clGetDeviceIDs@plt>
mov    %eax,-0x2c(%rbp)
lea    0xadb(%rip),%rsi
mov    %eax,%edi
xor    %edx,%edx
xor    %ecx,%ecx
call   1050 <chk@plt>
mov    -0x34(%rbp),%edi
mov    0x2a08(%rip),%rax
mov    (%rax),%esi
lea    -0x88(%rbp),%rcx
mov    $0x4,%edx
xor    %r8d,%r8d
xor    %eax,%eax
call   1080 <clGetDeviceInfo@plt>
mov    %eax,-0x2c(%rbp)
lea    0xab3(%rip),%rsi
mov    %eax,%edi
xor    %edx,%edx
xor    %ecx,%ecx
call   1050 <chk@plt>
mov    -0x88(%rbp),%eax
mov    %rsp,%r13
lea    0xf(,%rax,8),%r12
and    $0xfffffffffffffff0,%r12
mov    %r13,%r14
sub    %r12,%r14
mov    %r14,%rsp
mov    -0x34(%rbp),%edi
mov    0x29d3(%rip),%rcx
mov    (%rcx),%esi
lea    0x0(,%rax,8),%edx
mov    %r14,%rcx
xor    %r8d,%r8d
xor    %eax,%eax
call   1080 <clGetDeviceInfo@plt>
mov    %eax,-0x2c(%rbp)
mov    %eax,%edi
lea    0xa5e(%rip),%rsi
xor    %edx,%edx
xor    %ecx,%ecx
call   1050 <chk@plt>
neg    %r12
mov    (%r14),%esi
mov    0x8(%r14),%edx
lea    0xa54(%rip),%rdi
xor    %eax,%eax
call   10e0 <printf@plt>
mov    (%r14),%rcx
mov    %r15d,%eax
cmp    %rax,%rcx
mov    %rax,-0x70(%rbp)
cmovae %rax,%rcx
lea    (%r15,%rcx,1),%eax
add    $0xffffffff,%eax
cltd
idiv   %ecx
mov    %eax,%esi
mov    0x8(%r13,%r12,1),%rax
movslq -0x68(%rbp),%r8
cmp    %r8,%rax
cmovb  %eax,%r8d
movslq -0x50(%rbp),%rax
imul   $0xffffffff88888889,%rax,%rdx
shr    $0x20,%rdx
add    %edx,%eax
mov    %eax,%edx
shr    $0x1f,%edx
sar    $0x4,%eax
add    %edx,%eax
add    %r8d,%eax
cltd
idiv   %r8d
mov    %eax,%edx
imul   %esi,%edx
movslq %edx,%rdi
mov    %ecx,%edx
imul   %r8d,%edx
movslq %edx,%r15
imul   %rdi,%r15
shl    $0x2,%r15
mov    %ebx,%r9d
shr    $0x1f,%r9d
add    %ebx,%r9d
sar    %r9d
lea    0xa07(%rip),%rdi
mov    %eax,-0x7c(%rbp)
mov    %eax,%edx
mov    %rcx,-0x50(%rbp)
xor    %eax,%eax
call   10e0 <printf@plt>
mov    0x28d5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xac(%rbp)
mov    -0x60(%rbp),%eax
mov    %eax,-0xa8(%rbp)
movl   $0x0,-0xa4(%rbp)
lea    -0xac(%rbp),%rdi
lea    -0x2c(%rbp),%rbx
mov    $0x1,%esi
lea    -0x34(%rbp),%rdx
xor    %ecx,%ecx
xor    %r8d,%r8d
mov    %rbx,%r9
call   1100 <clCreateContext@plt>
mov    %eax,%r12d
mov    -0x2c(%rbp),%edi
lea    0x9cd(%rip),%rsi
xor    %edx,%edx
xor    %ecx,%ecx
call   1050 <chk@plt>
mov    -0x34(%rbp),%esi
mov    %r12d,%edi
xor    %edx,%edx
mov    %rbx,%rcx
call   10c0 <clCreateCommandQueue@plt>
mov    %eax,%r13d
mov    -0x2c(%rbp),%edi
lea    0x9b7(%rip),%rsi
xor    %edx,%edx
xor    %ecx,%ecx
call   1050 <chk@plt>
lea    0x9bc(%rip),%rdi
call   1120 <readSource@plt>
mov    %rax,-0xc8(%rbp)
lea    -0xc8(%rbp),%rdx
mov    %r12d,%edi
mov    $0x1,%esi
xor    %ecx,%ecx
mov    %rbx,%r8
call   1040 <clCreateProgramWithSource@plt>
mov    %eax,%r14d
mov    %eax,-0x5c(%rbp)
mov    -0x2c(%rbp),%edi
lea    0x993(%rip),%rsi
xor    %edx,%edx
xor    %ecx,%ecx
call   1050 <chk@plt>
mov    %r14d,%edi
mov    $0x1,%esi
lea    -0x34(%rbp),%rbx
mov    %rbx,%rdx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1030 <clBuildProgram@plt>
mov    %eax,-0x2c(%rbp)
lea    0x97e(%rip),%rsi
lea    -0x5c(%rbp),%rcx
mov    %eax,%edi
mov    %rbx,%rdx
call   1050 <chk@plt>
mov    -0x5c(%rbp),%edi
lea    0x975(%rip),%rsi
lea    -0x2c(%rbp),%rbx
mov    %rbx,%rdx
call   1180 <clCreateKernel@plt>
mov    %eax,%r14d
mov    -0x2c(%rbp),%edi
lea    0x963(%rip),%rsi
xor    %edx,%edx
xor    %ecx,%ecx
call   1050 <chk@plt>
mov    %r12d,%edi
xor    %esi,%esi
mov    %r15,-0x68(%rbp)
mov    %r15,%rdx
xor    %ecx,%ecx
mov    %rbx,%r8
call   1060 <clCreateBuffer@plt>
mov    %eax,-0x40(%rbp)
mov    -0x2c(%rbp),%edi
lea    0x946(%rip),%rsi
xor    %edx,%edx
xor    %ecx,%ecx
call   1050 <chk@plt>
movl   $0x0,-0x30(%rbp)
mov    -0x48(%rbp),%r12
test   %r12d,%r12d
mov    -0x38(%rbp),%ebx
js     1aa0 <main+0x7f0>
movslq -0x7c(%rbp),%r15
xor    %ecx,%ecx
nopl   0x0(%rax)
test   %ecx,%ecx
jne    1978 <main+0x6c8>
movl   $0x2,-0xa0(%rbp)
movl   $0x3,-0xc0(%rbp)
movl   $0x3,-0x84(%rbp)
movl   $0x3,-0x80(%rbp)
mov    %r14d,%edi
xor    %esi,%esi
mov    $0x4,%edx
lea    -0x40(%rbp),%rcx
call   11c0 <clSetKernelArg@plt>
mov    %eax,-0x2c(%rbp)
mov    %r14d,%edi
mov    $0x1,%esi
mov    $0x4,%edx
lea    -0xa0(%rbp),%rcx
call   11c0 <clSetKernelArg@plt>
or     %eax,-0x2c(%rbp)
mov    %r14d,%edi
mov    $0x2,%esi
mov    $0x4,%edx
lea    -0xc0(%rbp),%rcx
call   11c0 <clSetKernelArg@plt>
or     %eax,-0x2c(%rbp)
mov    %r14d,%edi
mov    $0x3,%esi
mov    $0x4,%edx
lea    -0x84(%rbp),%rcx
call   11c0 <clSetKernelArg@plt>
or     %eax,-0x2c(%rbp)
mov    %r14d,%edi
mov    $0x4,%esi
mov    $0x4,%edx
lea    -0x80(%rbp),%rcx
call   11c0 <clSetKernelArg@plt>
or     %eax,-0x2c(%rbp)
mov    %r14d,%edi
mov    $0x5,%esi
mov    $0x4,%edx
lea    -0x30(%rbp),%rcx
call   11c0 <clSetKernelArg@plt>
or     -0x2c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    %eax,%edi
lea    0x853(%rip),%rsi
xor    %edx,%edx
xor    %ecx,%ecx
call   1050 <chk@plt>
mov    -0x40(%rbp),%esi
mov    0x26b0(%rip),%rax
mov    (%rax),%edx
sub    $0x20,%rsp
xorps  %xmm0,%xmm0
movups %xmm0,0x8(%rsp)
movl   $0x0,(%rsp)
mov    %r13d,%edi
xor    %ecx,%ecx
mov    -0x68(%rbp),%r8
mov    -0x58(%rbp),%r9
call   11d0 <clEnqueueWriteBuffer@plt>
add    $0x20,%rsp
mov    %eax,-0x2c(%rbp)
mov    %eax,%edi
lea    0x818(%rip),%rsi
xor    %edx,%edx
xor    %ecx,%ecx
call   1050 <chk@plt>
mov    -0x70(%rbp),%rax
mov    %rax,-0xa0(%rbp)
mov    %r15,-0x98(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,-0xc0(%rbp)
movq   $0x1,-0xb8(%rbp)
sub    $0x20,%rsp
xorps  %xmm0,%xmm0
movups %xmm0,0x8(%rsp)
movl   $0x0,(%rsp)
mov    %r13d,%edi
mov    %r14d,%esi
mov    $0x2,%edx
xor    %ecx,%ecx
lea    -0xa0(%rbp),%r8
lea    -0xc0(%rbp),%r9
call   10b0 <clEnqueueNDRangeKernel@plt>
add    $0x20,%rsp
mov    %eax,-0x2c(%rbp)
mov    %eax,%edi
lea    0x7b9(%rip),%rsi
xor    %edx,%edx
xor    %ecx,%ecx
call   1050 <chk@plt>
test   %ebx,%ebx
je     1a03 <main+0x753>
mov    -0x30(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,%eax
cltd
idiv   %ebx
test   %edx,%edx
jne    1a8b <main+0x7db>
mov    -0x40(%rbp),%esi
mov    0x25db(%rip),%rax
mov    (%rax),%edx
sub    $0x20,%rsp
xorps  %xmm0,%xmm0
movups %xmm0,0x8(%rsp)
movl   $0x0,(%rsp)
mov    %r13d,%edi
xor    %ecx,%ecx
mov    -0x68(%rbp),%r8
mov    -0x58(%rbp),%r12
mov    %r12,%r9
call   1140 <clEnqueueReadBuffer@plt>
add    $0x20,%rsp
mov    %eax,-0x2c(%rbp)
mov    %eax,%edi
lea    0x76c(%rip),%rsi
xor    %edx,%edx
xor    %ecx,%ecx
call   1050 <chk@plt>
mov    -0x30(%rbp),%esi
add    $0x1,%esi
lea    0x76a(%rip),%rdi
mov    -0x48(%rbp),%rdx
xor    %eax,%eax
call   10e0 <printf@plt>
mov    -0x30(%rbp),%eax
and    $0x1,%eax
lea    (%r12,%rax,4),%rdi
mov    -0x38(%rbp),%ebx
mov    -0x48(%rbp),%r12
mov    -0x78(%rbp),%rsi
mov    -0x3c(%rbp),%edx
call   1170 <printGrid@plt>
mov    -0x30(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,-0x30(%rbp)
test   %r12d,%r12d
je     1850 <main+0x5a0>
cmp    %r12d,%ecx
jl     1850 <main+0x5a0>
xor    %edi,%edi
call   11a0 <exit@plt>

LLVM IR (-O0):
@.str = [39 x i8] c"%s file|- [iterations [skip [c|gpu]]]\0A\00"
@.str.1 = [2 x i8] c"-\00"
@.str.2 = [2 x i8] c"r\00"
@CL_DEVICE_TYPE_GPU = global i64 0
@CL_DEVICE_TYPE_CPU = global i64 0
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [4 x i8] c"- _\00"
@.str.5 = [17 x i8] c"clGetPlatformIDs\00"
@.str.6 = [45 x i8] c"ideal workgroup size %d*%d, requesting %cPU\0A\00"
@.str.7 = [15 x i8] c"clGetDeviceIDs\00"
@CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS = global i32 0
@.str.8 = [16 x i8] c"clGetDeviceInfo\00"
@CL_DEVICE_MAX_WORK_ITEM_SIZES = global i32 0
@.str.9 = [54 x i8] c"the max workgroup size of which is reported as %d*%d\0A\00"
@.str.10 = [38 x i8] c"requesting %d*%d workgroups %d*%d=%d\0A\00"
@CL_CONTEXT_PLATFORM = global i32 0
@.str.11 = [16 x i8] c"clCreateContext\00"
@.str.12 = [21 x i8] c"clCreateCommandQueue\00"
@.str.13 = [12 x i8] c"gamelife.cl\00"
@.str.14 = [26 x i8] c"clCreateProgramWithSource\00"
@.str.15 = [15 x i8] c"clBuildProgram\00"
@.str.16 = [7 x i8] c"evolve\00"
@.str.17 = [15 x i8] c"clCreateKernel\00"
@.str.18 = [15 x i8] c"clCreateBuffer\00"
@.str.19 = [15 x i8] c"clSetKernelArg\00"
@CL_TRUE = global i32 0
@.str.20 = [21 x i8] c"clEnqueueWriteBuffer\00"
@.str.21 = [23 x i8] c"clEnqueueNDRangeKernel\00"
@.str.22 = [20 x i8] c"clEnqueueReadBuffer\00"
@.str.23 = [8 x i8] c"%d/%d:\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [1024 x i8]
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i64
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i8*
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
%26 = alloca i32
%27 = alloca i32
%28 = alloca i8*
%29 = alloca i64
%30 = alloca i64
%31 = alloca [3 x i32]
%32 = alloca i32
%33 = alloca i32
%34 = alloca i8*
%35 = alloca i32
%36 = alloca i32
%37 = alloca i32
%38 = alloca i32
%39 = alloca i32
%40 = alloca i32
%41 = alloca i32
%42 = alloca i32
%43 = alloca i32
%44 = alloca [2 x i64]
%45 = alloca [2 x i64]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %10
store i32 4194304, i32* %11
%46 = call i64 @malloc(i32 16777216)
%47 = inttoptr i64 %46 to i32*
store i32* %47, i32** %12
%48 = load i32, i32* %4
%49 = icmp slt i32 %48, 2
br i1 %49, label %50, label %55
50: ; preds = %2
%51 = load i8**, i8*** %5
%52 = load i8*, i8** %51
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %52)
%54 = call i32 @exit(i32 1)
unreachable
55: ; preds = %2
%56 = load i8**, i8*** %5
%57 = getelementptr inbounds i8*, i8** %56, i64 1
%58 = load i8*, i8** %57
%59 = call i64 @strcmp(i8* %58, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%60 = icmp ne i64 %59, 0
br i1 %60, label %61, label %66
61: ; preds = %55
%62 = load i8**, i8*** %5
%63 = getelementptr inbounds i8*, i8** %62, i64 1
%64 = load i8*, i8** %63
%65 = call i32* @fopen(i8* %64, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %67
66: ; preds = %55
br label %67
67: ; preds = %66, %61
%68 = phi i32* [ %65, %61 ], [ null, %66 ]
store i32* %68, i32** %13
%69 = load i64, i64* @CL_DEVICE_TYPE_GPU
store i64 %69, i64* %14
%70 = load i32, i32* %4
%71 = icmp sgt i32 %70, 2
br i1 %71, label %72, label %77
72: ; preds = %67
%73 = load i8**, i8*** %5
%74 = getelementptr inbounds i8*, i8** %73, i64 2
%75 = load i8*, i8** %74
%76 = call i32 @atoi(i8* %75)
br label %78
77: ; preds = %67
br label %78
78: ; preds = %77, %72
%79 = phi i32 [ %76, %72 ], [ 0, %77 ]
store i32 %79, i32* %15
%80 = load i32, i32* %4
%81 = icmp sgt i32 %80, 3
br i1 %81, label %82, label %87
82: ; preds = %78
%83 = load i8**, i8*** %5
%84 = getelementptr inbounds i8*, i8** %83, i64 3
%85 = load i8*, i8** %84
%86 = call i32 @atoi(i8* %85)
br label %88
87: ; preds = %78
br label %88
88: ; preds = %87, %82
%89 = phi i32 [ %86, %82 ], [ 1, %87 ]
store i32 %89, i32* %16
%90 = load i32, i32* %16
%91 = load i32, i32* %15
%92 = icmp sgt i32 %90, %91
br i1 %92, label %96, label %93
93: ; preds = %88
%94 = load i32, i32* %16
%95 = icmp slt i32 %94, 1
br i1 %95, label %96, label %98
96: ; preds = %93, %88
%97 = load i32, i32* %15
br label %100
98: ; preds = %93
%99 = load i32, i32* %16
br label %100
100: ; preds = %98, %96
%101 = phi i32 [ %97, %96 ], [ %99, %98 ]
store i32 %101, i32* %16
%102 = load i32, i32* %4
%103 = icmp sgt i32 %102, 4
br i1 %103, label %104, label %114
104: ; preds = %100
%105 = load i8**, i8*** %5
%106 = getelementptr inbounds i8*, i8** %105, i64 4
%107 = load i8*, i8** %106
%108 = getelementptr inbounds i8, i8* %107, i64 0
%109 = load i8, i8* %108
%110 = sext i8 %109 to i32
%111 = icmp eq i32 %110, 67
br i1 %111, label %112, label %114
112: ; preds = %104
%113 = load i64, i64* @CL_DEVICE_TYPE_CPU
store i64 %113, i64* %14
br label %114
114: ; preds = %112, %104, %100
store i32 0, i32* %8
store i32 0, i32* %7
br label %115
115: ; preds = %169, %114
%116 = load i32*, i32** %13
%117 = icmp ne i32* %116, null
br i1 %117, label %118, label %122
118: ; preds = %115
%119 = load i32*, i32** %13
%120 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%121 = call i64 @fscanf(i32* %119, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %120)
br label %125
122: ; preds = %115
%123 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%124 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %123)
br label %125
125: ; preds = %122, %118
%126 = phi i64 [ %121, %118 ], [ %124, %122 ]
%127 = icmp sgt i64 %126, 0
br i1 %127, label %128, label %172
128: ; preds = %125
%129 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%130 = call i32 @strlen(i8* %129)
store i32 %130, i32* %17
%131 = load i32, i32* %8
%132 = icmp sgt i32 %130, %131
br i1 %132, label %133, label %135
133: ; preds = %128
%134 = load i32, i32* %17
store i32 %134, i32* %8
br label %135
135: ; preds = %133, %128
%136 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
store i8* %136, i8** %19
br label %137
137: ; preds = %154, %135
%138 = load i32, i32* %17
%139 = icmp sgt i32 %138, 30
br i1 %139, label %140, label %157
140: ; preds = %137
%141 = call i32 @strtob(i8** %19, i32 30, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%142 = shl i32 %141, 1
store i32 %142, i32* %18
%143 = load i32, i32* %18
%144 = load i32*, i32** %12
%145 = load i32, i32* %10
%146 = sext i32 %145 to i64
%147 = getelementptr inbounds i32, i32* %144, i64 %146
store i32 %143, i32* %147
%148 = load i32, i32* %10
%149 = add nsw i32 %148, 2
store i32 %149, i32* %10
%150 = icmp sgt i32 %149, 4194302
br i1 %150, label %151, label %153
151: ; preds = %140
%152 = call i32 @exit(i32 -1)
unreachable
153: ; preds = %140
br label %154
154: ; preds = %153
%155 = load i32, i32* %17
%156 = sub nsw i32 %155, 30
store i32 %156, i32* %17
br label %137
157: ; preds = %137
%158 = load i32, i32* %17
%159 = call i32 @strtob(i8** %19, i32 %158, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%160 = load i32, i32* %17
%161 = sub nsw i32 31, %160
%162 = shl i32 %159, %161
%163 = load i32*, i32** %12
%164 = load i32, i32* %10
%165 = sext i32 %164 to i64
%166 = getelementptr inbounds i32, i32* %163, i64 %165
store i32 %162, i32* %166
%167 = load i32, i32* %10
%168 = add nsw i32 %167, 2
store i32 %168, i32* %10
br label %169
169: ; preds = %157
%170 = load i32, i32* %7
%171 = add nsw i32 %170, 1
store i32 %171, i32* %7
br label %115
172: ; preds = %125
%173 = load i32*, i32** %13
%174 = icmp ne i32* %173, null
br i1 %174, label %175, label %178
175: ; preds = %172
%176 = load i32*, i32** %13
%177 = call i32 @fclose(i32* %176)
br label %178
178: ; preds = %175, %172
%179 = load i32*, i32** %12
%180 = load i32, i32* %7
%181 = load i32, i32* %8
%182 = call i32 @printGrid(i32* %179, i32 %180, i32 %181)
%183 = load i32, i32* %8
%184 = icmp sgt i32 %183, 30
br i1 %184, label %185, label %186
185: ; preds = %178
br label %194
186: ; preds = %178
%187 = load i32, i32* %8
%188 = icmp ne i32 %187, 0
br i1 %188, label %189, label %191
189: ; preds = %186
%190 = load i32, i32* %8
br label %192
191: ; preds = %186
br label %192
192: ; preds = %191, %189
%193 = phi i32 [ %190, %189 ], [ 1, %191 ]
br label %194
194: ; preds = %192, %185
%195 = phi i32 [ 30, %185 ], [ %193, %192 ]
store i32 %195, i32* %24
%196 = call i32 @clGetPlatformIDs(i32 1, i32* %25, i32* null)
store i32 %196, i32* %20
%197 = load i32, i32* %20
%198 = call i32 @chk(i32 %197, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i32* null, i32* null)
%199 = load i32, i32* %7
%200 = load i32, i32* %8
%201 = sub nsw i32 %200, 1
%202 = load i32, i32* %24
%203 = add nsw i32 %201, %202
%204 = load i32, i32* %24
%205 = sdiv i32 %203, %204
store i32 %205, i32* %24
%206 = load i64, i64* %14
%207 = load i64, i64* @CL_DEVICE_TYPE_GPU
%208 = icmp eq i64 %206, %207
%209 = zext i1 %208 to i64
%210 = select i1 %208, i32 71, i32 67
%211 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.6, i64 0, i64 0), i32 %199, i32 %205, i32 %210)
%212 = load i32, i32* %25
%213 = load i64, i64* %14
%214 = call i32 @clGetDeviceIDs(i32 %212, i64 %213, i32 1, i32* %26, i32* null)
store i32 %214, i32* %20
%215 = load i32, i32* %20
%216 = call i32 @chk(i32 %215, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i32* null, i32* null)
%217 = load i32, i32* %26
%218 = load i32, i32* @CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS
%219 = call i32 (i32, i32, i32, ...) @clGetDeviceInfo(i32 %217, i32 %218, i32 4, i32* %27, i8* null)
store i32 %219, i32* %20
%220 = load i32, i32* %20
%221 = call i32 @chk(i32 %220, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i32* null, i32* null)
%222 = load i32, i32* %27
%223 = zext i32 %222 to i64
%224 = call i8* @llvm.stacksave()
store i8* %224, i8** %28
%225 = alloca i64, i64 %223
store i64 %223, i64* %29
%226 = load i32, i32* %26
%227 = load i32, i32* @CL_DEVICE_MAX_WORK_ITEM_SIZES
%228 = load i32, i32* %27
%229 = sext i32 %228 to i64
%230 = mul i64 %229, 8
%231 = trunc i64 %230 to i32
%232 = call i32 (i32, i32, i32, ...) @clGetDeviceInfo(i32 %226, i32 %227, i32 %231, i64* %225, i8* null)
store i32 %232, i32* %20
%233 = load i32, i32* %20
%234 = call i32 @chk(i32 %233, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i32* null, i32* null)
%235 = getelementptr inbounds i64, i64* %225, i64 0
%236 = load i64, i64* %235
%237 = trunc i64 %236 to i32
%238 = getelementptr inbounds i64, i64* %225, i64 1
%239 = load i64, i64* %238
%240 = trunc i64 %239 to i32
%241 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.9, i64 0, i64 0), i32 %237, i32 %240)
%242 = getelementptr inbounds i64, i64* %225, i64 0
%243 = load i64, i64* %242
%244 = load i32, i32* %7
%245 = sext i32 %244 to i64
%246 = icmp ult i64 %243, %245
br i1 %246, label %247, label %250
247: ; preds = %194
%248 = getelementptr inbounds i64, i64* %225, i64 0
%249 = load i64, i64* %248
br label %253
250: ; preds = %194
%251 = load i32, i32* %7
%252 = sext i32 %251 to i64
br label %253
253: ; preds = %250, %247
%254 = phi i64 [ %249, %247 ], [ %252, %250 ]
%255 = trunc i64 %254 to i32
store i32 %255, i32* %23
%256 = load i32, i32* %7
%257 = sub nsw i32 %256, 1
%258 = load i32, i32* %23
%259 = add nsw i32 %257, %258
%260 = load i32, i32* %23
%261 = sdiv i32 %259, %260
store i32 %261, i32* %21
%262 = getelementptr inbounds i64, i64* %225, i64 1
%263 = load i64, i64* %262
%264 = load i32, i32* %24
%265 = sext i32 %264 to i64
%266 = icmp ult i64 %263, %265
br i1 %266, label %267, label %270
267: ; preds = %253
%268 = getelementptr inbounds i64, i64* %225, i64 1
%269 = load i64, i64* %268
br label %273
270: ; preds = %253
%271 = load i32, i32* %24
%272 = sext i32 %271 to i64
br label %273
273: ; preds = %270, %267
%274 = phi i64 [ %269, %267 ], [ %272, %270 ]
%275 = trunc i64 %274 to i32
store i32 %275, i32* %24
%276 = load i32, i32* %8
%277 = sub nsw i32 %276, 1
%278 = sdiv i32 %277, 30
%279 = load i32, i32* %24
%280 = add nsw i32 %278, %279
%281 = load i32, i32* %24
%282 = sdiv i32 %280, %281
store i32 %282, i32* %22
%283 = load i32, i32* %21
%284 = load i32, i32* %22
%285 = mul nsw i32 %283, %284
%286 = sext i32 %285 to i64
%287 = mul i64 4, %286
%288 = load i32, i32* %23
%289 = load i32, i32* %24
%290 = mul nsw i32 %288, %289
%291 = sext i32 %290 to i64
%292 = mul i64 %287, %291
store i64 %292, i64* %30
%293 = load i32, i32* %21
%294 = load i32, i32* %22
%295 = load i32, i32* %23
%296 = load i32, i32* %24
%297 = load i32, i32* %10
%298 = sdiv i32 %297, 2
%299 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.10, i64 0, i64 0), i32 %293, i32 %294, i32 %295, i32 %296, i32 %298)
%300 = getelementptr inbounds [3 x i32], [3 x i32]* %31, i64 0, i64 0
%301 = load i32, i32* @CL_CONTEXT_PLATFORM
store i32 %301, i32* %300
%302 = getelementptr inbounds i32, i32* %300, i64 1
%303 = load i32, i32* %25
store i32 %303, i32* %302
%304 = getelementptr inbounds i32, i32* %302, i64 1
store i32 0, i32* %304
%305 = getelementptr inbounds [3 x i32], [3 x i32]* %31, i64 0, i64 0
%306 = call i32 @clCreateContext(i32* %305, i32 1, i32* %26, i32* null, i32* null, i32* %20)
store i32 %306, i32* %32
%307 = load i32, i32* %20
%308 = call i32 @chk(i32 %307, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0), i32* null, i32* null)
%309 = load i32, i32* %32
%310 = load i32, i32* %26
%311 = call i32 @clCreateCommandQueue(i32 %309, i32 %310, i32 0, i32* %20)
store i32 %311, i32* %33
%312 = load i32, i32* %20
%313 = call i32 @chk(i32 %312, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.12, i64 0, i64 0), i32* null, i32* null)
%314 = call i8* @readSource(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.13, i64 0, i64 0))
store i8* %314, i8** %34
%315 = load i32, i32* %32
%316 = call i32 @clCreateProgramWithSource(i32 %315, i32 1, i8** %34, i32* null, i32* %20)
store i32 %316, i32* %35
%317 = load i32, i32* %20
%318 = call i32 @chk(i32 %317, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.14, i64 0, i64 0), i32* null, i32* null)
%319 = load i32, i32* %35
%320 = call i32 @clBuildProgram(i32 %319, i32 1, i32* %26, i32* null, i32* null, i32* null)
store i32 %320, i32* %20
%321 = load i32, i32* %20
%322 = call i32 @chk(i32 %321, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.15, i64 0, i64 0), i32* %26, i32* %35)
%323 = load i32, i32* %35
%324 = call i32 @clCreateKernel(i32 %323, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.16, i64 0, i64 0), i32* %20)
store i32 %324, i32* %36
%325 = load i32, i32* %20
%326 = call i32 @chk(i32 %325, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.17, i64 0, i64 0), i32* null, i32* null)
%327 = load i32, i32* %32
%328 = load i64, i64* %30
%329 = call i32 @clCreateBuffer(i32 %327, i32 0, i64 %328, i32* null, i32* %20)
store i32 %329, i32* %37
%330 = load i32, i32* %20
%331 = call i32 @chk(i32 %330, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.18, i64 0, i64 0), i32* null, i32* null)
store i32 0, i32* %39
br label %332
332: ; preds = %425, %273
%333 = load i32, i32* %15
%334 = icmp eq i32 %333, 0
br i1 %334, label %339, label %335
335: ; preds = %332
%336 = load i32, i32* %39
%337 = load i32, i32* %15
%338 = icmp slt i32 %336, %337
br label %339
339: ; preds = %335, %332
%340 = phi i1 [ true, %332 ], [ %338, %335 ]
br i1 %340, label %341, label %428
341: ; preds = %339
%342 = load i32, i32* %39
%343 = icmp eq i32 %342, 0
br i1 %343, label %344, label %377
344: ; preds = %341
store i32 2, i32* %40
store i32 3, i32* %41
store i32 3, i32* %42
store i32 3, i32* %43
%345 = load i32, i32* %36
%346 = call i32 @clSetKernelArg(i32 %345, i32 0, i32 4, i32* %37)
store i32 %346, i32* %20
%347 = load i32, i32* %36
%348 = call i32 @clSetKernelArg(i32 %347, i32 1, i32 4, i32* %40)
%349 = load i32, i32* %20
%350 = or i32 %349, %348
store i32 %350, i32* %20
%351 = load i32, i32* %36
%352 = call i32 @clSetKernelArg(i32 %351, i32 2, i32 4, i32* %41)
%353 = load i32, i32* %20
%354 = or i32 %353, %352
store i32 %354, i32* %20
%355 = load i32, i32* %36
%356 = call i32 @clSetKernelArg(i32 %355, i32 3, i32 4, i32* %42)
%357 = load i32, i32* %20
%358 = or i32 %357, %356
store i32 %358, i32* %20
%359 = load i32, i32* %36
%360 = call i32 @clSetKernelArg(i32 %359, i32 4, i32 4, i32* %43)
%361 = load i32, i32* %20
%362 = or i32 %361, %360
store i32 %362, i32* %20
%363 = load i32, i32* %36
%364 = call i32 @clSetKernelArg(i32 %363, i32 5, i32 4, i32* %39)
%365 = load i32, i32* %20
%366 = or i32 %365, %364
store i32 %366, i32* %20
%367 = load i32, i32* %20
%368 = call i32 @chk(i32 %367, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.19, i64 0, i64 0), i32* null, i32* null)
%369 = load i32, i32* %33
%370 = load i32, i32* %37
%371 = load i32, i32* @CL_TRUE
%372 = load i64, i64* %30
%373 = load i32*, i32** %12
%374 = call i32 @clEnqueueWriteBuffer(i32 %369, i32 %370, i32 %371, i32 0, i64 %372, i32* %373, i32 0, i32* null, i32* null)
store i32 %374, i32* %20
%375 = load i32, i32* %20
%376 = call i32 @chk(i32 %375, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.20, i64 0, i64 0), i32* null, i32* null)
br label %377
377: ; preds = %344, %341
%378 = getelementptr inbounds [2 x i64], [2 x i64]* %44, i64 0, i64 0
%379 = load i32, i32* %7
%380 = sext i32 %379 to i64
store i64 %380, i64* %378
%381 = getelementptr inbounds i64, i64* %378, i64 1
%382 = load i32, i32* %22
%383 = sext i32 %382 to i64
store i64 %383, i64* %381
%384 = getelementptr inbounds [2 x i64], [2 x i64]* %45, i64 0, i64 0
%385 = load i32, i32* %23
%386 = sext i32 %385 to i64
store i64 %386, i64* %384
%387 = getelementptr inbounds i64, i64* %384, i64 1
store i64 1, i64* %387
%388 = load i32, i32* %33
%389 = load i32, i32* %36
%390 = getelementptr inbounds [2 x i64], [2 x i64]* %44, i64 0, i64 0
%391 = getelementptr inbounds [2 x i64], [2 x i64]* %45, i64 0, i64 0
%392 = call i32 @clEnqueueNDRangeKernel(i32 %388, i32 %389, i32 2, i32* null, i64* %390, i64* %391, i32 0, i32* null, i32* null)
store i32 %392, i32* %20
%393 = load i32, i32* %20
%394 = call i32 @chk(i32 %393, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.21, i64 0, i64 0), i32* null, i32* null)
%395 = load i32, i32* %16
%396 = icmp eq i32 %395, 0
br i1 %396, label %403, label %397
397: ; preds = %377
%398 = load i32, i32* %39
%399 = add nsw i32 %398, 1
%400 = load i32, i32* %16
%401 = srem i32 %399, %400
%402 = icmp eq i32 %401, 0
br i1 %402, label %403, label %424
403: ; preds = %397, %377
%404 = load i32, i32* %33
%405 = load i32, i32* %37
%406 = load i32, i32* @CL_TRUE
%407 = load i64, i64* %30
%408 = load i32*, i32** %12
%409 = call i32 @clEnqueueReadBuffer(i32 %404, i32 %405, i32 %406, i32 0, i64 %407, i32* %408, i32 0, i32* null, i32* null)
store i32 %409, i32* %20
%410 = load i32, i32* %20
%411 = call i32 @chk(i32 %410, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.22, i64 0, i64 0), i32* null, i32* null)
%412 = load i32, i32* %39
%413 = add nsw i32 %412, 1
%414 = load i32, i32* %15
%415 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.23, i64 0, i64 0), i32 %413, i32 %414)
%416 = load i32*, i32** %12
%417 = load i32, i32* %39
%418 = and i32 %417, 1
%419 = sext i32 %418 to i64
%420 = getelementptr inbounds i32, i32* %416, i64 %419
%421 = load i32, i32* %7
%422 = load i32, i32* %8
%423 = call i32 @printGrid(i32* %420, i32 %421, i32 %422)
br label %424
424: ; preds = %403, %397
br label %425
425: ; preds = %424
%426 = load i32, i32* %39
%427 = add nsw i32 %426, 1
store i32 %427, i32* %39
br label %332
428: ; preds = %339
%429 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [39 x i8] c"%s file|- [iterations [skip [c|gpu]]]\0A\00"
@.str.1 = [2 x i8] c"-\00"
@.str.2 = [2 x i8] c"r\00"
@CL_DEVICE_TYPE_GPU = global i64 0
@CL_DEVICE_TYPE_CPU = global i64 0
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [4 x i8] c"- _\00"
@.str.5 = [17 x i8] c"clGetPlatformIDs\00"
@.str.6 = [45 x i8] c"ideal workgroup size %d*%d, requesting %cPU\0A\00"
@.str.7 = [15 x i8] c"clGetDeviceIDs\00"
@CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS = global i32 0
@.str.8 = [16 x i8] c"clGetDeviceInfo\00"
@CL_DEVICE_MAX_WORK_ITEM_SIZES = global i32 0
@.str.9 = [54 x i8] c"the max workgroup size of which is reported as %d*%d\0A\00"
@.str.10 = [38 x i8] c"requesting %d*%d workgroups %d*%d=%d\0A\00"
@CL_CONTEXT_PLATFORM = global i32 0
@.str.11 = [16 x i8] c"clCreateContext\00"
@.str.12 = [21 x i8] c"clCreateCommandQueue\00"
@.str.13 = [12 x i8] c"gamelife.cl\00"
@.str.14 = [26 x i8] c"clCreateProgramWithSource\00"
@.str.15 = [15 x i8] c"clBuildProgram\00"
@.str.16 = [7 x i8] c"evolve\00"
@.str.17 = [15 x i8] c"clCreateKernel\00"
@.str.18 = [15 x i8] c"clCreateBuffer\00"
@.str.19 = [15 x i8] c"clSetKernelArg\00"
@CL_TRUE = global i32 0
@.str.20 = [21 x i8] c"clEnqueueWriteBuffer\00"
@.str.21 = [23 x i8] c"clEnqueueNDRangeKernel\00"
@.str.22 = [20 x i8] c"clEnqueueReadBuffer\00"
@.str.23 = [8 x i8] c"%d/%d:\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [3 x i32]
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca [2 x i64]
%19 = alloca [2 x i64]
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%21 = tail call i64 @malloc(i32 16777216)
%22 = inttoptr i64 %21 to i32*
%23 = icmp slt i32 %0, 2
br i1 %23, label %24, label %28
24: ; preds = %2
%25 = load i8*, i8** %1
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %25)
%27 = tail call i32 @exit(i32 1)
unreachable
28: ; preds = %2
%29 = getelementptr inbounds i8*, i8** %1, i64 1
%30 = load i8*, i8** %29
%31 = tail call i64 @strcmp(i8* %30, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %36, label %33
33: ; preds = %28
%34 = load i8*, i8** %29
%35 = tail call i32* @fopen(i8* %34, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %36
36: ; preds = %28, %33
%37 = phi i32* [ %35, %33 ], [ null, %28 ]
%38 = load i64, i64* @CL_DEVICE_TYPE_GPU
%39 = icmp ugt i32 %0, 2
br i1 %39, label %40, label %47
40: ; preds = %36
%41 = getelementptr inbounds i8*, i8** %1, i64 2
%42 = load i8*, i8** %41
%43 = tail call i32 @atoi(i8* %42)
%44 = icmp eq i32 %0, 3
br i1 %44, label %45, label %49
45: ; preds = %40
%46 = icmp slt i32 %43, 1
br i1 %46, label %47, label %65
47: ; preds = %36, %45
%48 = phi i32 [ %43, %45 ], [ 0, %36 ]
br label %65
49: ; preds = %40
%50 = getelementptr inbounds i8*, i8** %1, i64 3
%51 = load i8*, i8** %50
%52 = tail call i32 @atoi(i8* %51)
%53 = icmp sgt i32 %52, %43
%54 = icmp slt i32 %52, 1
%55 = or i1 %53, %54
%56 = select i1 %55, i32 %43, i32 %52
%57 = icmp ugt i32 %0, 4
br i1 %57, label %58, label %65
58: ; preds = %49
%59 = getelementptr inbounds i8*, i8** %1, i64 4
%60 = load i8*, i8** %59
%61 = load i8, i8* %60
%62 = icmp eq i8 %61, 67
%63 = load i64, i64* @CL_DEVICE_TYPE_CPU
%64 = select i1 %62, i64 %63, i64 %38
br label %65
65: ; preds = %47, %45, %58, %49
%66 = phi i32 [ %56, %49 ], [ %56, %58 ], [ %48, %47 ], [ 1, %45 ]
%67 = phi i32 [ %43, %49 ], [ %43, %58 ], [ %48, %47 ], [ %43, %45 ]
%68 = phi i64 [ %38, %49 ], [ %64, %58 ], [ %38, %47 ], [ %38, %45 ]
%69 = icmp eq i32* %37, null
%70 = bitcast i8** %4 to i8*
br label %71
71: ; preds = %103, %65
%72 = phi i32 [ 0, %65 ], [ %111, %103 ]
%73 = phi i32 [ 0, %65 ], [ %84, %103 ]
%74 = phi i32 [ 0, %65 ], [ %112, %103 ]
br i1 %69, label %75, label %78
75: ; preds = %71
%76 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %20)
%77 = icmp sgt i64 %76, 0
br i1 %77, label %81, label %115
78: ; preds = %71
%79 = call i64 @fscanf(i32* %37, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %20)
%80 = icmp sgt i64 %79, 0
br i1 %80, label %81, label %113
81: ; preds = %78, %75
%82 = call i32 @strlen(i8* %20)
%83 = icmp sgt i32 %82, %73
%84 = select i1 %83, i32 %82, i32 %73
store i8* %20, i8** %4
%85 = icmp sgt i32 %82, 30
br i1 %85, label %86, label %103
86: ; preds = %81
%87 = sext i32 %72 to i64
br label %88
88: ; preds = %86, %97
%89 = phi i64 [ %87, %86 ], [ %98, %97 ]
%90 = phi i32 [ %82, %86 ], [ %99, %97 ]
%91 = call i32 @strtob(i8** %4, i32 30, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%92 = shl i32 %91, 1
%93 = getelementptr inbounds i32, i32* %22, i64 %89
store i32 %92, i32* %93
%94 = icmp sgt i64 %89, 4194300
br i1 %94, label %95, label %97
95: ; preds = %88
%96 = call i32 @exit(i32 -1)
unreachable
97: ; preds = %88
%98 = add nsw i64 %89, 2
%99 = add nsw i32 %90, -30
%100 = icmp sgt i32 %90, 60
br i1 %100, label %88, label %101
101: ; preds = %97
%102 = trunc i64 %98 to i32
br label %103
103: ; preds = %101, %81
%104 = phi i32 [ %82, %81 ], [ %99, %101 ]
%105 = phi i32 [ %72, %81 ], [ %102, %101 ]
%106 = call i32 @strtob(i8** %4, i32 %104, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%107 = sub nsw i32 31, %104
%108 = shl i32 %106, %107
%109 = sext i32 %105 to i64
%110 = getelementptr inbounds i32, i32* %22, i64 %109
store i32 %108, i32* %110
%111 = add nsw i32 %105, 2
%112 = add nuw nsw i32 %74, 1
br label %71
113: ; preds = %78
%114 = call i32 @fclose(i32* %37)
br label %115
115: ; preds = %75, %113
%116 = call i32 @printGrid(i32* %22, i32 %74, i32 %73)
%117 = bitcast i32* %5 to i8*
%118 = icmp sgt i32 %73, 30
%119 = icmp eq i32 %73, 0
%120 = select i1 %119, i32 1, i32 %73
%121 = select i1 %118, i32 30, i32 %120
%122 = bitcast i32* %6 to i8*
%123 = call i32 @clGetPlatformIDs(i32 1, i32* %6, i32* null)
store i32 %123, i32* %5
%124 = call i32 @chk(i32 %123, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i32* null, i32* null)
%125 = bitcast i32* %7 to i8*
%126 = add nsw i32 %73, -1
%127 = add nsw i32 %121, %126
%128 = sdiv i32 %127, %121
%129 = load i64, i64* @CL_DEVICE_TYPE_GPU
%130 = icmp eq i64 %68, %129
%131 = select i1 %130, i32 71, i32 67
%132 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.6, i64 0, i64 0), i32 %74, i32 %128, i32 %131)
%133 = load i32, i32* %6
%134 = call i32 @clGetDeviceIDs(i32 %133, i64 %68, i32 1, i32* %7, i32* null)
store i32 %134, i32* %5
%135 = call i32 @chk(i32 %134, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i32* null, i32* null)
%136 = bitcast i32* %8 to i8*
%137 = load i32, i32* %7
%138 = load i32, i32* @CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS
%139 = call i32 (i32, i32, i32, ...) @clGetDeviceInfo(i32 %137, i32 %138, i32 4, i32* %8, i8* null)
store i32 %139, i32* %5
%140 = call i32 @chk(i32 %139, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i32* null, i32* null)
%141 = load i32, i32* %8
%142 = zext i32 %141 to i64
%143 = alloca i64, i64 %142
%144 = load i32, i32* %7
%145 = load i32, i32* @CL_DEVICE_MAX_WORK_ITEM_SIZES
%146 = shl i32 %141, 3
%147 = call i32 (i32, i32, i32, ...) @clGetDeviceInfo(i32 %144, i32 %145, i32 %146, i64* %143, i8* null)
store i32 %147, i32* %5
%148 = call i32 @chk(i32 %147, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i32* null, i32* null)
%149 = load i64, i64* %143
%150 = trunc i64 %149 to i32
%151 = getelementptr inbounds i64, i64* %143, i64 1
%152 = load i64, i64* %151
%153 = trunc i64 %152 to i32
%154 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.9, i64 0, i64 0), i32 %150, i32 %153)
%155 = load i64, i64* %143
%156 = zext i32 %74 to i64
%157 = icmp ult i64 %155, %156
%158 = select i1 %157, i64 %155, i64 %156
%159 = trunc i64 %158 to i32
%160 = add nsw i32 %74, -1
%161 = add nsw i32 %160, %159
%162 = sdiv i32 %161, %159
%163 = load i64, i64* %151
%164 = sext i32 %128 to i64
%165 = icmp ult i64 %163, %164
%166 = select i1 %165, i64 %163, i64 %164
%167 = trunc i64 %166 to i32
%168 = sdiv i32 %126, 30
%169 = add nsw i32 %168, %167
%170 = sdiv i32 %169, %167
%171 = mul nsw i32 %170, %162
%172 = sext i32 %171 to i64
%173 = shl nsw i64 %172, 2
%174 = shl nuw nsw i64 %158, 32
%175 = mul i64 %174, %166
%176 = ashr exact i64 %175, 32
%177 = mul i64 %173, %176
%178 = sdiv i32 %72, 2
%179 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.10, i64 0, i64 0), i32 %162, i32 %170, i32 %159, i32 %167, i32 %178)
%180 = bitcast [3 x i32]* %9 to i8*
%181 = getelementptr inbounds [3 x i32], [3 x i32]* %9, i64 0, i64 0
%182 = load i32, i32* @CL_CONTEXT_PLATFORM
store i32 %182, i32* %181
%183 = getelementptr inbounds [3 x i32], [3 x i32]* %9, i64 0, i64 1
%184 = load i32, i32* %6
store i32 %184, i32* %183
%185 = getelementptr inbounds [3 x i32], [3 x i32]* %9, i64 0, i64 2
store i32 0, i32* %185
%186 = call i32 @clCreateContext(i32* %181, i32 1, i32* %7, i32* null, i32* null, i32* %5)
%187 = load i32, i32* %5
%188 = call i32 @chk(i32 %187, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0), i32* null, i32* null)
%189 = load i32, i32* %7
%190 = call i32 @clCreateCommandQueue(i32 %186, i32 %189, i32 0, i32* %5)
%191 = load i32, i32* %5
%192 = call i32 @chk(i32 %191, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.12, i64 0, i64 0), i32* null, i32* null)
%193 = bitcast i8** %10 to i8*
%194 = call i8* @readSource(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.13, i64 0, i64 0))
store i8* %194, i8** %10
%195 = bitcast i32* %11 to i8*
%196 = call i32 @clCreateProgramWithSource(i32 %186, i32 1, i8** %10, i32* null, i32* %5)
store i32 %196, i32* %11
%197 = load i32, i32* %5
%198 = call i32 @chk(i32 %197, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.14, i64 0, i64 0), i32* null, i32* null)
%199 = call i32 @clBuildProgram(i32 %196, i32 1, i32* %7, i32* null, i32* null, i32* null)
store i32 %199, i32* %5
%200 = call i32 @chk(i32 %199, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.15, i64 0, i64 0), i32* %7, i32* %11)
%201 = load i32, i32* %11
%202 = call i32 @clCreateKernel(i32 %201, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.16, i64 0, i64 0), i32* %5)
%203 = load i32, i32* %5
%204 = call i32 @chk(i32 %203, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.17, i64 0, i64 0), i32* null, i32* null)
%205 = bitcast i32* %12 to i8*
%206 = call i32 @clCreateBuffer(i32 %186, i32 0, i64 %177, i32* null, i32* %5)
store i32 %206, i32* %12
%207 = load i32, i32* %5
%208 = call i32 @chk(i32 %207, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.18, i64 0, i64 0), i32* null, i32* null)
%209 = bitcast i32* %13 to i8*
%210 = icmp eq i32 %67, 0
store i32 0, i32* %13
%211 = icmp sgt i32 %67, -1
br i1 %211, label %212, label %225
212: ; preds = %115
%213 = bitcast i32* %14 to i8*
%214 = bitcast i32* %15 to i8*
%215 = bitcast i32* %16 to i8*
%216 = bitcast i32* %17 to i8*
%217 = bitcast [2 x i64]* %18 to i8*
%218 = getelementptr inbounds [2 x i64], [2 x i64]* %18, i64 0, i64 0
%219 = getelementptr inbounds [2 x i64], [2 x i64]* %18, i64 0, i64 1
%220 = sext i32 %170 to i64
%221 = bitcast [2 x i64]* %19 to i8*
%222 = getelementptr inbounds [2 x i64], [2 x i64]* %19, i64 0, i64 0
%223 = getelementptr inbounds [2 x i64], [2 x i64]* %19, i64 0, i64 1
%224 = icmp eq i32 %66, 0
br label %227
225: ; preds = %275, %115
%226 = call i32 @exit(i32 0)
unreachable
227: ; preds = %212, %275
%228 = phi i32 [ 0, %212 ], [ %276, %275 ]
%229 = icmp eq i32 %228, 0
br i1 %229, label %230, label %252
230: ; preds = %227
store i32 2, i32* %14
store i32 3, i32* %15
store i32 3, i32* %16
store i32 3, i32* %17
%231 = call i32 @clSetKernelArg(i32 %202, i32 0, i32 4, i32* %12)
store i32 %231, i32* %5
%232 = call i32 @clSetKernelArg(i32 %202, i32 1, i32 4, i32* %14)
%233 = load i32, i32* %5
%234 = or i32 %233, %232
store i32 %234, i32* %5
%235 = call i32 @clSetKernelArg(i32 %202, i32 2, i32 4, i32* %15)
%236 = load i32, i32* %5
%237 = or i32 %236, %235
store i32 %237, i32* %5
%238 = call i32 @clSetKernelArg(i32 %202, i32 3, i32 4, i32* %16)
%239 = load i32, i32* %5
%240 = or i32 %239, %238
store i32 %240, i32* %5
%241 = call i32 @clSetKernelArg(i32 %202, i32 4, i32 4, i32* %17)
%242 = load i32, i32* %5
%243 = or i32 %242, %241
store i32 %243, i32* %5
%244 = call i32 @clSetKernelArg(i32 %202, i32 5, i32 4, i32* %13)
%245 = load i32, i32* %5
%246 = or i32 %245, %244
store i32 %246, i32* %5
%247 = call i32 @chk(i32 %246, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.19, i64 0, i64 0), i32* null, i32* null)
%248 = load i32, i32* %12
%249 = load i32, i32* @CL_TRUE
%250 = call i32 @clEnqueueWriteBuffer(i32 %190, i32 %248, i32 %249, i32 0, i64 %177, i32* %22, i32 0, i32* null, i32* null)
store i32 %250, i32* %5
%251 = call i32 @chk(i32 %250, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.20, i64 0, i64 0), i32* null, i32* null)
br label %252
252: ; preds = %230, %227
store i64 %156, i64* %218
store i64 %220, i64* %219
store i64 %158, i64* %222
store i64 1, i64* %223
%253 = call i32 @clEnqueueNDRangeKernel(i32 %190, i32 %202, i32 2, i32* null, i64* %218, i64* %222, i32 0, i32* null, i32* null)
store i32 %253, i32* %5
%254 = call i32 @chk(i32 %253, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.21, i64 0, i64 0), i32* null, i32* null)
br i1 %224, label %260, label %255
255: ; preds = %252
%256 = load i32, i32* %13
%257 = add nsw i32 %256, 1
%258 = srem i32 %257, %66
%259 = icmp eq i32 %258, 0
br i1 %259, label %260, label %275
260: ; preds = %255, %252
%261 = load i32, i32* %12
%262 = load i32, i32* @CL_TRUE
%263 = call i32 @clEnqueueReadBuffer(i32 %190, i32 %261, i32 %262, i32 0, i64 %177, i32* %22, i32 0, i32* null, i32* null)
store i32 %263, i32* %5
%264 = call i32 @chk(i32 %263, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.22, i64 0, i64 0), i32* null, i32* null)
%265 = load i32, i32* %13
%266 = add nsw i32 %265, 1
%267 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.23, i64 0, i64 0), i32 %266, i32 %67)
%268 = load i32, i32* %13
%269 = and i32 %268, 1
%270 = zext i32 %269 to i64
%271 = getelementptr inbounds i32, i32* %22, i64 %270
%272 = call i32 @printGrid(i32* %271, i32 %74, i32 %73)
%273 = load i32, i32* %13
%274 = add nsw i32 %273, 1
br label %275
275: ; preds = %260, %255
%276 = phi i32 [ %274, %260 ], [ %257, %255 ]
store i32 %276, i32* %13
%277 = icmp slt i32 %276, %67
%278 = select i1 %210, i1 true, i1 %277
br i1 %278, label %227, label %225
}