#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 /*<<< orphan*/ *cl_device_id;
typedef int /*<<< orphan*/ cl_context;
typedef int /*<<< orphan*/ cl_command_queue;

/* Variables and functions */
int /*<<< orphan*/ CL_DEVICE_TYPE_DEFAULT;
int /*<<< orphan*/ CL_MEM_READ_ONLY;
int /*<<< orphan*/ CL_MEM_READ_WRITE;
int CL_SUCCESS;
int /*<<< orphan*/ CL_TRUE;
int EXIT_FAILURE;
scalar_t__ RAND_MAX;
int atoi(char *);
int /*<<< orphan*/ check_error(int, char *, char *, int);
int clBuildProgram(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/ *,
                   int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                   int /*<<< orphan*/ *);
int clCreateBuffer(int /*<<< orphan*/, int /*<<< orphan*/, int,
                   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 const *, size_t const *,
                           int /*<<< orphan*/, int /*<<< orphan*/ *,
                           int /*<<< orphan*/ *);
int clEnqueueReadBuffer(int /*<<< orphan*/, int, int /*<<< orphan*/,
                        int /*<<< orphan*/, int, float *, int /*<<< orphan*/,
                        int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int clEnqueueWriteBuffer(int /*<<< orphan*/, int, int /*<<< orphan*/,
                         int /*<<< orphan*/, int, float *, int /*<<< orphan*/,
                         int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int clFinish(int /*<<< orphan*/);
int clGetDeviceIDs(int /*<<< orphan*/, int /*<<< orphan*/, int,
                   int /*<<< orphan*/ **, int /*<<< orphan*/ *);
int clGetPlatformIDs(int, int /*<<< orphan*/ *, int *);
int /*<<< orphan*/ clReleaseCommandQueue(int /*<<< orphan*/);
int /*<<< orphan*/ clReleaseContext(int /*<<< orphan*/);
int /*<<< orphan*/ clReleaseKernel(int /*<<< orphan*/);
int /*<<< orphan*/ clReleaseMemObject(int);
int /*<<< orphan*/ clReleaseProgram(int /*<<< orphan*/);
int clSetKernelArg(int /*<<< orphan*/, int, int, int *);
int /*<<< orphan*/ free(float *);
char *getKernelSource(char *);
float *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
float rand();
double wtime();
int main(int argc, char *argv[]) {
  int err;
  unsigned int correct;
  int M = atoi(argv[1]);
  int N = atoi(argv[2]);
  int K = atoi(argv[3]);
  ;
  float *h_a = malloc(M * K * sizeof(float));
  float *h_b = malloc(K * N * sizeof(float));
  float *h_c = malloc(M * N * sizeof(float));
  cl_device_id device_id;
  cl_context context;
  cl_command_queue command_queue;
  cl_program program;
  cl_kernel ko_MatMul;
  cl_mem d_a;
  cl_mem d_b;
  cl_mem d_c;
  int i = 0;
  for (i = 0; i < M * K; ++i) {
    h_a[i] = rand() / (float)RAND_MAX;
  }
  for (i = 0; i < N * K; ++i) {
    h_b[i] = rand() / (float)RAND_MAX;
  }
  cl_uint num_platforms;
  err = clGetPlatformIDs(0, NULL, &num_platforms);
  check_error(err, "Finding platforms",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/haohaibo/tutorial/refs/heads/master/"
              "LearnOpenCLFromScratch/dgemm/NN/gemm_block8x8_thread8x8_test.c",
              194);
  if (num_platforms == 0) {
    printf("Found 0 platforms\n");
    return EXIT_FAILURE;
  }
  cl_platform_id platform[num_platforms];
  err = clGetPlatformIDs(num_platforms, platform, NULL);
  check_error(err, "Getting platforms's IDs",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/haohaibo/tutorial/refs/heads/master/"
              "LearnOpenCLFromScratch/dgemm/NN/gemm_block8x8_thread8x8_test.c",
              207);
  for (i = 0; i < num_platforms; ++i) {
    err = clGetDeviceIDs(platform[i], CL_DEVICE_TYPE_DEFAULT, 1, &device_id,
                         NULL);
    if (err == CL_SUCCESS) {
      break;
    }
  }
  if (device_id == NULL) {
    printf("No devices found\n");
  }
  context = clCreateContext(0, 1, &device_id, NULL, NULL, &err);
  check_error(err, "Creating context",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/haohaibo/tutorial/refs/heads/master/"
              "LearnOpenCLFromScratch/dgemm/NN/gemm_block8x8_thread8x8_test.c",
              249);
  command_queue = clCreateCommandQueue(context, device_id, 0, &err);
  check_error(err, "Creating command queue",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/haohaibo/tutorial/refs/heads/master/"
              "LearnOpenCLFromScratch/dgemm/NN/gemm_block8x8_thread8x8_test.c",
              264);
  char *gemm_kernel_file = "gemm_block8x8_thread8x8_private_manual_unroll_preG_"
                           "noif_512unroll_nobank_test.cl";
  char *gemm_kernel = getKernelSource(gemm_kernel_file);
  program = clCreateProgramWithSource(context, 1, (const char **)&gemm_kernel,
                                      NULL, &err);
  check_error(err, "Creating program from source",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/haohaibo/tutorial/refs/heads/master/"
              "LearnOpenCLFromScratch/dgemm/NN/gemm_block8x8_thread8x8_test.c",
              301);
  err = clBuildProgram(program, 0, NULL, NULL, NULL, NULL);
  check_error(err, "Build program",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/haohaibo/tutorial/refs/heads/master/"
              "LearnOpenCLFromScratch/dgemm/NN/gemm_block8x8_thread8x8_test.c",
              320);
  ko_MatMul = clCreateKernel(program, "gemm", &err);
  check_error(err, "Creating kernel",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/haohaibo/tutorial/refs/heads/master/"
              "LearnOpenCLFromScratch/dgemm/NN/gemm_block8x8_thread8x8_test.c",
              334);
  d_a = clCreateBuffer(context, CL_MEM_READ_ONLY, sizeof(float) * M * K, NULL,
                       &err);
  check_error(err, "Creating buffer d_a",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/haohaibo/tutorial/refs/heads/master/"
              "LearnOpenCLFromScratch/dgemm/NN/gemm_block8x8_thread8x8_test.c",
              355);
  d_b = clCreateBuffer(context, CL_MEM_READ_ONLY, sizeof(float) * K * N, NULL,
                       &err);
  check_error(err, "Creating buffer d_b",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/haohaibo/tutorial/refs/heads/master/"
              "LearnOpenCLFromScratch/dgemm/NN/gemm_block8x8_thread8x8_test.c",
              362);
  d_c = clCreateBuffer(context, CL_MEM_READ_WRITE, sizeof(float) * M * N, NULL,
                       &err);
  check_error(err, "Creating buffer d_c",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/haohaibo/tutorial/refs/heads/master/"
              "LearnOpenCLFromScratch/dgemm/NN/gemm_block8x8_thread8x8_test.c",
              369);
  err = clEnqueueWriteBuffer(command_queue, d_a, CL_TRUE, 0,
                             sizeof(float) * M * K, h_a, 0, NULL, NULL);
  check_error(err, "Copying h_a to d_a",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/haohaibo/tutorial/refs/heads/master/"
              "LearnOpenCLFromScratch/dgemm/NN/gemm_block8x8_thread8x8_test.c",
              395);
  err = clEnqueueWriteBuffer(command_queue, d_b, CL_TRUE, 0,
                             sizeof(float) * K * N, h_b, 0, NULL, NULL);
  check_error(err, "Copying h_b to d_b",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/haohaibo/tutorial/refs/heads/master/"
              "LearnOpenCLFromScratch/dgemm/NN/gemm_block8x8_thread8x8_test.c",
              407);
  err = clSetKernelArg(ko_MatMul, 0, sizeof(cl_mem), &d_a);
  err |= clSetKernelArg(ko_MatMul, 1, sizeof(cl_mem), &d_b);
  err |= clSetKernelArg(ko_MatMul, 2, sizeof(cl_mem), &d_c);
  err |= clSetKernelArg(ko_MatMul, 3, sizeof(int), &M);
  err |= clSetKernelArg(ko_MatMul, 4, sizeof(int), &N);
  err |= clSetKernelArg(ko_MatMul, 5, sizeof(int), &K);
  check_error(err, "Setting kernel arguments",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/haohaibo/tutorial/refs/heads/master/"
              "LearnOpenCLFromScratch/dgemm/NN/gemm_block8x8_thread8x8_test.c",
              446);
  const size_t global[2] = {M / 8, N / 8};
  const size_t local[2] = {8, 8};
  printf("%d\t\t", M);
  double rtime = wtime();
  for (int i = 0; i < 5; ++i) {
    err = clEnqueueNDRangeKernel(command_queue, ko_MatMul, 2, NULL, global,
                                 local, 0, NULL, NULL);
    err = clFinish(command_queue);
  }
  rtime = (wtime() - rtime) / (double)5;
  check_error(err, "Waiting for kernel to finish",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/haohaibo/tutorial/refs/heads/master/"
              "LearnOpenCLFromScratch/dgemm/NN/gemm_block8x8_thread8x8_test.c",
              494);
  double gflops =
      ((long)M * (long)N * (long)K * 2 * 1.0) / (double)(1000 * 1000 * 1000);
  printf("%.1lf GFLOPS", gflops / rtime);
  err = clEnqueueReadBuffer(command_queue, d_c, CL_TRUE, 0,
                            sizeof(float) * M * N, h_c, 0, NULL, NULL);
  check_error(err, "Copying d_c to h_c",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/haohaibo/tutorial/refs/heads/master/"
              "LearnOpenCLFromScratch/dgemm/NN/gemm_block8x8_thread8x8_test.c",
              522);
  if (err != CL_SUCCESS) {
    printf("Error: Failed to read output array\n");
  }
  printf("\n");
  correct = 0;
  float temp = 0;
  clReleaseMemObject(d_a);
  clReleaseMemObject(d_b);
  clReleaseMemObject(d_c);
  clReleaseContext(context);
  clReleaseCommandQueue(command_queue);
  clReleaseProgram(program);
  clReleaseKernel(ko_MatMul);
  free(h_a);
  free(h_b);
  free(h_c);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1180 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1180 <atoi@plt>
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1180 <atoi@plt>
mov    %eax,-0x24(%rbp)
mov    -0x1c(%rbp),%eax
imul   -0x24(%rbp),%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1130 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x24(%rbp),%eax
imul   -0x20(%rbp),%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1130 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x1c(%rbp),%eax
imul   -0x20(%rbp),%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1130 <malloc@plt>
mov    %rax,-0x40(%rbp)
movl   $0x0,-0x68(%rbp)
movl   $0x0,-0x68(%rbp)
mov    -0x68(%rbp),%eax
mov    -0x1c(%rbp),%ecx
imul   -0x24(%rbp),%ecx
cmp    %ecx,%eax
jge    1383 <main+0xe3>
mov    $0x0,%al
call   11b0 <rand@plt>
mov    0x2c79(%rip),%rax
cvtsi2ssq (%rax),%xmm1
divss  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movslq -0x68(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    133f <main+0x9f>
movl   $0x0,-0x68(%rbp)
mov    -0x68(%rbp),%eax
mov    -0x20(%rbp),%ecx
imul   -0x24(%rbp),%ecx
cmp    %ecx,%eax
jge    13ce <main+0x12e>
mov    $0x0,%al
call   11b0 <rand@plt>
mov    0x2c2e(%rip),%rax
cvtsi2ssq (%rax),%xmm1
divss  %xmm1,%xmm0
mov    -0x38(%rbp),%rax
movslq -0x68(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    138a <main+0xea>
xor    %edi,%edi
xor    %eax,%eax
mov    %eax,%esi
lea    -0x6c(%rbp),%rdx
call   10d0 <clGetPlatformIDs@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
lea    0xc2e(%rip),%rsi
lea    0xc39(%rip),%rdx
mov    $0xc2,%ecx
call   1110 <check_error@plt>
cmpl   $0x0,-0x6c(%rbp)
jne    1424 <main+0x184>
lea    0xcdb(%rip),%rdi
mov    $0x0,%al
call   10e0 <printf@plt>
mov    0x2ba6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1b22 <main+0x882>
mov    -0x6c(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x78(%rbp)
lea    0xf(,%rax,4),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rsi
sub    %rcx,%rsi
mov    %rsi,-0xd8(%rbp)
mov    %rsi,%rsp
mov    %rax,-0x80(%rbp)
mov    -0x6c(%rbp),%edi
xor    %eax,%eax
mov    %eax,%edx
call   10d0 <clGetPlatformIDs@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
lea    0xc93(%rip),%rsi
lea    0xbbc(%rip),%rdx
mov    $0xcf,%ecx
call   1110 <check_error@plt>
movl   $0x0,-0x68(%rbp)
mov    -0x68(%rbp),%eax
cmp    -0x6c(%rbp),%eax
jge    14e2 <main+0x242>
mov    -0xd8(%rbp),%rax
movslq -0x68(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    0x2b28(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edx
lea    -0x48(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   10a0 <clGetDeviceIDs@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2aee(%rip),%rcx
cmp    (%rcx),%eax
jne    14cf <main+0x22f>
jmp    14e2 <main+0x242>
jmp    14d4 <main+0x234>
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    147f <main+0x1df>
cmpq   $0x0,-0x48(%rbp)
jne    14fb <main+0x25b>
lea    0xc1e(%rip),%rdi
mov    $0x0,%al
call   10e0 <printf@plt>
xor    %edi,%edi
mov    $0x1,%esi
lea    -0x48(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%r8d
lea    -0x14(%rbp),%r9
mov    %r8,%rcx
call   1100 <clCreateContext@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x14(%rbp),%edi
lea    0xc00(%rip),%rsi
lea    0xaff(%rip),%rdx
mov    $0xf9,%ecx
call   1110 <check_error@plt>
mov    -0x4c(%rbp),%edi
mov    -0x48(%rbp),%rsi
xor    %edx,%edx
lea    -0x14(%rbp),%rcx
call   10c0 <clCreateCommandQueue@plt>
mov    %eax,-0x50(%rbp)
mov    -0x14(%rbp),%edi
lea    0xbe1(%rip),%rsi
lea    0xacf(%rip),%rdx
mov    $0x108,%ecx
call   1110 <check_error@plt>
lea    0xbe0(%rip),%rax
mov    %rax,-0x88(%rbp)
mov    -0x88(%rbp),%rdi
call   1190 <getKernelSource@plt>
mov    %rax,-0x90(%rbp)
mov    -0x4c(%rbp),%edi
mov    $0x1,%esi
lea    -0x90(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x14(%rbp),%r8
call   1060 <clCreateProgramWithSource@plt>
mov    %eax,-0x54(%rbp)
mov    -0x14(%rbp),%edi
lea    0xbee(%rip),%rsi
lea    0xa74(%rip),%rdx
mov    $0x12d,%ecx
call   1110 <check_error@plt>
mov    -0x54(%rbp),%edi
xor    %esi,%esi
xor    %eax,%eax
mov    %eax,%r9d
mov    %r9,%rdx
mov    %r9,%rcx
mov    %r9,%r8
call   1030 <clBuildProgram@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
lea    0xbd5(%rip),%rsi
lea    0xa3e(%rip),%rdx
mov    $0x140,%ecx
call   1110 <check_error@plt>
mov    -0x54(%rbp),%edi
lea    0xbc8(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1170 <clCreateKernel@plt>
mov    %eax,-0x58(%rbp)
mov    -0x14(%rbp),%edi
lea    0xbb7(%rip),%rsi
lea    0xa0d(%rip),%rdx
mov    $0x14e,%ecx
call   1110 <check_error@plt>
mov    -0x4c(%rbp),%edi
mov    0x2987(%rip),%rax
mov    (%rax),%esi
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
movslq -0x24(%rbp),%rcx
imul   %rcx,%rax
mov    %eax,%edx
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x14(%rbp),%r8
call   1080 <clCreateBuffer@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x14(%rbp),%edi
lea    0xb7e(%rip),%rsi
lea    0x9c4(%rip),%rdx
mov    $0x163,%ecx
call   1110 <check_error@plt>
mov    -0x4c(%rbp),%edi
mov    0x293e(%rip),%rax
mov    (%rax),%esi
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
movslq -0x20(%rbp),%rcx
imul   %rcx,%rax
mov    %eax,%edx
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x14(%rbp),%r8
call   1080 <clCreateBuffer@plt>
mov    %eax,-0x60(%rbp)
mov    -0x14(%rbp),%edi
lea    0xb49(%rip),%rsi
lea    0x97b(%rip),%rdx
mov    $0x16a,%ecx
call   1110 <check_error@plt>
mov    -0x4c(%rbp),%edi
mov    0x291d(%rip),%rax
mov    (%rax),%esi
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
movslq -0x20(%rbp),%rcx
imul   %rcx,%rax
mov    %eax,%edx
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x14(%rbp),%r8
call   1080 <clCreateBuffer@plt>
mov    %eax,-0x64(%rbp)
mov    -0x14(%rbp),%edi
lea    0xb14(%rip),%rsi
lea    0x932(%rip),%rdx
mov    $0x171,%ecx
call   1110 <check_error@plt>
mov    -0x50(%rbp),%edi
mov    -0x5c(%rbp),%esi
mov    0x28d9(%rip),%rax
mov    (%rax),%edx
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
movslq -0x24(%rbp),%rcx
imul   %rcx,%rax
mov    %eax,%r8d
mov    -0x30(%rbp),%r9
xor    %ecx,%ecx
xor    %eax,%eax
sub    $0x20,%rsp
movl   $0x0,(%rsp)
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
call   11c0 <clEnqueueWriteBuffer@plt>
add    $0x20,%rsp
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
lea    0xaba(%rip),%rsi
lea    0x8c4(%rip),%rdx
mov    $0x18b,%ecx
call   1110 <check_error@plt>
mov    -0x50(%rbp),%edi
mov    -0x60(%rbp),%esi
mov    0x286b(%rip),%rax
mov    (%rax),%edx
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
movslq -0x20(%rbp),%rcx
imul   %rcx,%rax
mov    %eax,%r8d
mov    -0x38(%rbp),%r9
xor    %ecx,%ecx
xor    %eax,%eax
sub    $0x20,%rsp
movl   $0x0,(%rsp)
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
call   11c0 <clEnqueueWriteBuffer@plt>
add    $0x20,%rsp
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
lea    0xa5f(%rip),%rsi
lea    0x856(%rip),%rdx
mov    $0x197,%ecx
call   1110 <check_error@plt>
mov    -0x58(%rbp),%edi
xor    %esi,%esi
mov    $0x4,%edx
lea    -0x5c(%rbp),%rcx
call   11a0 <clSetKernelArg@plt>
mov    %eax,-0x14(%rbp)
mov    -0x58(%rbp),%edi
mov    $0x1,%esi
mov    $0x4,%edx
lea    -0x60(%rbp),%rcx
call   11a0 <clSetKernelArg@plt>
or     -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x58(%rbp),%edi
mov    $0x2,%esi
mov    $0x4,%edx
lea    -0x64(%rbp),%rcx
call   11a0 <clSetKernelArg@plt>
or     -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x58(%rbp),%edi
mov    $0x3,%esi
mov    $0x4,%edx
lea    -0x1c(%rbp),%rcx
call   11a0 <clSetKernelArg@plt>
or     -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x58(%rbp),%edi
mov    $0x4,%edx
lea    -0x20(%rbp),%rcx
mov    %edx,%esi
call   11a0 <clSetKernelArg@plt>
or     -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x58(%rbp),%edi
mov    $0x5,%esi
mov    $0x4,%edx
lea    -0x24(%rbp),%rcx
call   11a0 <clSetKernelArg@plt>
or     -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
lea    0x9b8(%rip),%rsi
lea    0x79c(%rip),%rdx
mov    $0x1be,%ecx
call   1110 <check_error@plt>
mov    -0x1c(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cltq
mov    %rax,-0xa0(%rbp)
mov    -0x20(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cltq
mov    %rax,-0x98(%rbp)
mov    0x9f9(%rip),%rax
mov    %rax,-0xb0(%rbp)
mov    0x9f3(%rip),%rax
mov    %rax,-0xa8(%rbp)
mov    -0x1c(%rbp),%esi
lea    0x972(%rip),%rdi
mov    $0x0,%al
call   10e0 <printf@plt>
mov    $0x0,%al
call   10f0 <wtime@plt>
movsd  %xmm0,-0xb8(%rbp)
ff
movl   $0x0,-0xbc(%rbp)
cmpl   $0x5,-0xbc(%rbp)
jge    197a <main+0x6da>
mov    -0x50(%rbp),%edi
mov    -0x58(%rbp),%esi
lea    -0xa0(%rbp),%r8
lea    -0xb0(%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,-0x14(%rbp)
mov    -0x50(%rbp),%edi
call   1050 <clFinish@plt>
mov    %eax,-0x14(%rbp)
mov    -0xbc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xbc(%rbp)
jmp    1906 <main+0x666>
mov    $0x0,%al
call   10f0 <wtime@plt>
subsd  -0xb8(%rbp),%xmm0
ff
movsd  0x67f(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
mov    -0x14(%rbp),%edi
lea    0x8b6(%rip),%rsi
lea    0x67c(%rip),%rdx
mov    $0x1ee,%ecx
call   1110 <check_error@plt>
movslq -0x1c(%rbp),%rax
movslq -0x20(%rbp),%rcx
imul   %rcx,%rax
movslq -0x24(%rbp),%rcx
imul   %rcx,%rax
shl    $0x1,%rax
cvtsi2sd %rax,%xmm0
movsd  0x62b(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0x617(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0xc8(%rbp)
ff
movsd  -0xc8(%rbp),%xmm0
ff
divsd  -0xb8(%rbp),%xmm0
ff
lea    0x86e(%rip),%rdi
mov    $0x1,%al
call   10e0 <printf@plt>
mov    -0x50(%rbp),%edi
mov    -0x64(%rbp),%esi
mov    0x25c8(%rip),%rax
mov    (%rax),%edx
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
movslq -0x20(%rbp),%rcx
imul   %rcx,%rax
mov    %eax,%r8d
mov    -0x40(%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,-0x14(%rbp)
mov    -0x14(%rbp),%edi
lea    0x817(%rip),%rsi
lea    0x5b3(%rip),%rdx
mov    $0x20a,%ecx
call   1110 <check_error@plt>
mov    -0x14(%rbp),%eax
mov    0x2525(%rip),%rcx
cmp    (%rcx),%eax
je     1aa1 <main+0x801>
lea    0x800(%rip),%rdi
mov    $0x0,%al
call   10e0 <printf@plt>
lea    0x67a(%rip),%rdi
mov    $0x0,%al
call   10e0 <printf@plt>
movl   $0x0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xcc(%rbp)
ff
mov    -0x5c(%rbp),%edi
call   1160 <clReleaseMemObject@plt>
mov    -0x60(%rbp),%edi
call   1160 <clReleaseMemObject@plt>
mov    -0x64(%rbp),%edi
call   1160 <clReleaseMemObject@plt>
mov    -0x4c(%rbp),%edi
call   1150 <clReleaseContext@plt>
mov    -0x50(%rbp),%edi
call   1120 <clReleaseCommandQueue@plt>
mov    -0x54(%rbp),%edi
call   1090 <clReleaseProgram@plt>
mov    -0x58(%rbp),%edi
call   1070 <clReleaseKernel@plt>
mov    -0x30(%rbp),%rdi
call   1040 <free@plt>
mov    -0x38(%rbp),%rdi
call   1040 <free@plt>
mov    -0x40(%rbp),%rdi
call   1040 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x78(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa8,%rsp
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   11a0 <atoi@plt>
mov    %eax,%r12d
mov    %eax,-0x38(%rbp)
mov    0x10(%rbx),%rdi
call   11a0 <atoi@plt>
mov    %eax,%r13d
mov    %eax,-0x34(%rbp)
mov    0x18(%rbx),%rdi
call   11a0 <atoi@plt>
mov    %eax,%ebx
mov    %eax,-0x4c(%rbp)
lea    0x0(,%r12,4),%r15d
mov    %r15d,%edi
imul   %eax,%edi
mov    %edi,-0x40(%rbp)
call   1150 <malloc@plt>
mov    %rax,-0x60(%rbp)
mov    %r13d,%r14d
imul   %ebx,%r14d
lea    0x0(,%r14,4),%edi
mov    %edi,-0x90(%rbp)
call   1150 <malloc@plt>
mov    %rax,-0x58(%rbp)
imul   %r13d,%r15d
mov    -0x60(%rbp),%r13
mov    %r15d,-0x78(%rbp)
mov    %r15d,%edi
call   1150 <malloc@plt>
mov    %rax,-0xa0(%rbp)
imul   %r12d,%ebx
test   %ebx,%ebx
jle    1393 <main+0xd3>
mov    %ebx,%r12d
mov    0x2c70(%rip),%r15
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   11d0 <rand@plt>
xorps  %xmm1,%xmm1
cvtsi2ssq (%r15),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,0x0(%r13,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1370 <main+0xb0>
test   %r14d,%r14d
mov    -0x58(%rbp),%r12
jle    13d2 <main+0x112>
mov    %r14d,%r15d
mov    0x2c32(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   11d0 <rand@plt>
xorps  %xmm1,%xmm1
cvtsi2ssq (%r14),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,(%r12,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    13b0 <main+0xf0>
lea    -0x30(%rbp),%rdx
xor    %edi,%edi
xor    %esi,%esi
call   10f0 <clGetPlatformIDs@plt>
mov    %eax,-0x2c(%rbp)
lea    0xc47(%rip),%rsi
lea    0xc52(%rip),%rdx
mov    %eax,%edi
mov    $0xc2,%ecx
call   1130 <check_error@plt>
mov    -0x30(%rbp),%eax
test   %rax,%rax
je     1abf <main+0x7ff>
mov    %rsp,-0x98(%rbp)
mov    %rsp,%r13
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
mov    -0x30(%rbp),%edi
mov    %r13,%rsi
xor    %edx,%edx
call   10f0 <clGetPlatformIDs@plt>
mov    %eax,-0x2c(%rbp)
lea    0xcc4(%rip),%rsi
lea    0xc00(%rip),%rdx
mov    %eax,%edi
mov    $0xcf,%ecx
call   1130 <check_error@plt>
cmpl   $0x0,-0x30(%rbp)
jle    14a7 <main+0x1e7>
mov    $0x1,%ebx
mov    0x2b68(%rip),%r14
lea    -0x68(%rbp),%r12
mov    0x2b45(%rip),%r15
nopl   0x0(%rax,%rax,1)
mov    -0x4(%r13,%rbx,4),%edi
mov    (%r14),%esi
mov    $0x1,%edx
mov    %r12,%rcx
xor    %r8d,%r8d
call   10c0 <clGetDeviceIDs@plt>
mov    %eax,-0x2c(%rbp)
cmp    (%r15),%eax
je     14a0 <main+0x1e0>
lea    0x1(%rbx),%rax
movslq -0x30(%rbp),%rcx
cmp    %rcx,%rbx
mov    %rax,%rbx
jl     1470 <main+0x1b0>
cmpq   $0x0,-0x68(%rbp)
jne    14b3 <main+0x1f3>
lea    0xe02(%rip),%rdi
call   1080 <puts@plt>
lea    -0x68(%rbp),%rdx
lea    -0x2c(%rbp),%r13
xor    %edi,%edi
mov    $0x1,%esi
xor    %ecx,%ecx
xor    %r8d,%r8d
mov    %r13,%r9
call   1120 <clCreateContext@plt>
mov    %eax,%r14d
mov    -0x2c(%rbp),%edi
lea    0xc3b(%rip),%rsi
lea    0xb5f(%rip),%r12
mov    %r12,%rdx
mov    $0xf9,%ecx
call   1130 <check_error@plt>
mov    -0x68(%rbp),%rsi
mov    %r14d,%edi
xor    %edx,%edx
mov    %r13,%rcx
call   10e0 <clCreateCommandQueue@plt>
mov    %eax,-0x6c(%rbp)
mov    -0x2c(%rbp),%edi
lea    0xc1a(%rip),%rsi
mov    %r12,%rdx
mov    $0x108,%ecx
call   1130 <check_error@plt>
lea    0xc1d(%rip),%rdi
call   11b0 <getKernelSource@plt>
mov    %rax,-0xa8(%rbp)
lea    -0xa8(%rbp),%rdx
mov    %r14d,%edi
mov    $0x1,%esi
xor    %ecx,%ecx
mov    %r13,%r8
call   1070 <clCreateProgramWithSource@plt>
mov    %eax,%ebx
mov    -0x2c(%rbp),%edi
lea    0xc3d(%rip),%rsi
mov    %r12,%rdx
mov    $0x12d,%ecx
call   1130 <check_error@plt>
mov    %ebx,%edi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1030 <clBuildProgram@plt>
mov    %eax,-0x2c(%rbp)
lea    0xc30(%rip),%rsi
mov    %eax,%edi
mov    %r12,%rdx
mov    $0x140,%ecx
call   1130 <check_error@plt>
lea    0xc28(%rip),%rsi
mov    %ebx,-0x70(%rbp)
mov    %ebx,%edi
mov    %r13,%rdx
call   1190 <clCreateKernel@plt>
mov    %eax,%r15d
mov    -0x2c(%rbp),%edi
lea    0xc13(%rip),%rsi
mov    %r12,%rbx
mov    %r12,%rdx
mov    $0x14e,%ecx
call   1130 <check_error@plt>
mov    0x29f4(%rip),%rax
mov    (%rax),%esi
mov    %r14d,%edi
mov    -0x40(%rbp),%edx
xor    %ecx,%ecx
mov    %r13,%r8
mov    %r13,%r12
call   10a0 <clCreateBuffer@plt>
mov    %eax,%r13d
mov    %eax,-0x48(%rbp)
mov    -0x2c(%rbp),%edi
lea    0xbe7(%rip),%rsi
mov    %rbx,%rdx
mov    $0x163,%ecx
call   1130 <check_error@plt>
mov    0x29bb(%rip),%rax
mov    (%rax),%esi
mov    %r14d,%edi
mov    -0x90(%rbp),%edx
xor    %ecx,%ecx
mov    %r12,%r8
call   10a0 <clCreateBuffer@plt>
mov    %eax,%r12d
mov    %eax,-0x44(%rbp)
mov    -0x2c(%rbp),%edi
lea    0xbc2(%rip),%rsi
mov    %rbx,%rdx
mov    $0x16a,%ecx
call   1130 <check_error@plt>
mov    0x29aa(%rip),%rax
mov    (%rax),%esi
mov    %r14d,-0x74(%rbp)
mov    %r14d,%edi
mov    -0x6c(%rbp),%ebx
mov    -0x78(%rbp),%edx
xor    %ecx,%ecx
lea    -0x2c(%rbp),%r8
call   10a0 <clCreateBuffer@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x2c(%rbp),%edi
lea    0xb9b(%rip),%rsi
lea    0x9de(%rip),%rdx
mov    $0x171,%ecx
call   1130 <check_error@plt>
mov    0x2973(%rip),%r14
mov    (%r14),%edx
sub    $0x20,%rsp
xorps  %xmm0,%xmm0
movups %xmm0,0x8(%rsp)
movl   $0x0,(%rsp)
mov    %ebx,%edi
mov    %r13d,%esi
xor    %ecx,%ecx
mov    -0x40(%rbp),%r8d
mov    -0x60(%rbp),%r9
call   11e0 <clEnqueueWriteBuffer@plt>
add    $0x20,%rsp
mov    %eax,-0x2c(%rbp)
lea    0xb5f(%rip),%rsi
mov    %eax,%edi
lea    0x98c(%rip),%rdx
mov    %rdx,%r13
mov    $0x18b,%ecx
call   1130 <check_error@plt>
mov    (%r14),%edx
sub    $0x20,%rsp
xorps  %xmm0,%xmm0
movups %xmm0,0x8(%rsp)
movl   $0x0,(%rsp)
mov    %ebx,%edi
mov    %r12d,%esi
xor    %ecx,%ecx
mov    -0x90(%rbp),%r8d
mov    -0x58(%rbp),%r9
call   11e0 <clEnqueueWriteBuffer@plt>
add    $0x20,%rsp
mov    %eax,-0x2c(%rbp)
lea    0xb21(%rip),%rsi
mov    %eax,%edi
mov    %r13,%rdx
mov    $0x197,%ecx
call   1130 <check_error@plt>
lea    -0x48(%rbp),%rcx
mov    %r15d,%edi
xor    %esi,%esi
mov    $0x4,%edx
call   11c0 <clSetKernelArg@plt>
mov    %eax,-0x2c(%rbp)
lea    -0x44(%rbp),%rcx
mov    %r15d,%edi
mov    $0x1,%esi
mov    $0x4,%edx
call   11c0 <clSetKernelArg@plt>
or     %eax,-0x2c(%rbp)
lea    -0x3c(%rbp),%rcx
mov    %r15d,%edi
mov    $0x2,%esi
mov    $0x4,%edx
call   11c0 <clSetKernelArg@plt>
or     %eax,-0x2c(%rbp)
lea    -0x38(%rbp),%rcx
mov    %r15d,%edi
mov    $0x3,%esi
mov    $0x4,%edx
call   11c0 <clSetKernelArg@plt>
or     %eax,-0x2c(%rbp)
lea    -0x34(%rbp),%rcx
mov    %r15d,%edi
mov    $0x4,%esi
mov    $0x4,%edx
call   11c0 <clSetKernelArg@plt>
or     %eax,-0x2c(%rbp)
lea    -0x4c(%rbp),%rcx
mov    %r15d,%edi
mov    $0x5,%esi
mov    $0x4,%edx
call   11c0 <clSetKernelArg@plt>
or     -0x2c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
lea    0xa88(%rip),%rsi
mov    %eax,%edi
mov    %r13,%rdx
mov    $0x1be,%ecx
call   1130 <check_error@plt>
mov    -0x38(%rbp),%esi
movd   %esi,%xmm0
movd   -0x34(%rbp),%xmm1
punpckldq %xmm1,%xmm0
movdqa %xmm0,%xmm1
psrad  $0x1f,%xmm1
psrld  $0x1d,%xmm1
paddd  %xmm0,%xmm1
psrad  $0x3,%xmm1
pxor   %xmm0,%xmm0
pcmpgtd %xmm1,%xmm0
punpckldq %xmm0,%xmm1
movdqa %xmm1,-0xd0(%rbp)
ff
movapd 0x824(%rip),%xmm0
movapd %xmm0,-0xc0(%rbp)
ff
lea    0xa40(%rip),%rdi
xor    %eax,%eax
call   1100 <printf@plt>
xor    %eax,%eax
call   1110 <wtime@plt>
movsd  %xmm0,-0x90(%rbp)
ff
sub    $0x20,%rsp
xorpd  %xmm0,%xmm0
movupd %xmm0,0x8(%rsp)
movl   $0x0,(%rsp)
lea    -0xd0(%rbp),%r12
lea    -0xc0(%rbp),%r14
mov    %ebx,%edi
mov    %r15d,%esi
mov    $0x2,%edx
xor    %ecx,%ecx
mov    %r12,%r8
mov    %r14,%r9
call   10d0 <clEnqueueNDRangeKernel@plt>
add    $0x20,%rsp
mov    %eax,-0x2c(%rbp)
mov    %ebx,%edi
call   1060 <clFinish@plt>
mov    %eax,-0x2c(%rbp)
sub    $0x20,%rsp
xorpd  %xmm0,%xmm0
movupd %xmm0,0x8(%rsp)
movl   $0x0,(%rsp)
mov    %ebx,%edi
mov    %r15d,%esi
mov    $0x2,%edx
xor    %ecx,%ecx
mov    %r12,%r8
mov    %r14,%r9
call   10d0 <clEnqueueNDRangeKernel@plt>
add    $0x20,%rsp
mov    %eax,-0x2c(%rbp)
mov    %ebx,%edi
call   1060 <clFinish@plt>
mov    %eax,-0x2c(%rbp)
sub    $0x20,%rsp
xorpd  %xmm0,%xmm0
movupd %xmm0,0x8(%rsp)
movl   $0x0,(%rsp)
mov    %ebx,%edi
mov    %r15d,%esi
mov    $0x2,%edx
xor    %ecx,%ecx
mov    %r12,%r8
mov    %r14,%r9
call   10d0 <clEnqueueNDRangeKernel@plt>
add    $0x20,%rsp
mov    %eax,-0x2c(%rbp)
mov    %ebx,%edi
call   1060 <clFinish@plt>
mov    %eax,-0x2c(%rbp)
sub    $0x20,%rsp
xorpd  %xmm0,%xmm0
movupd %xmm0,0x8(%rsp)
movl   $0x0,(%rsp)
mov    %ebx,%edi
mov    %r15d,%esi
mov    $0x2,%edx
xor    %ecx,%ecx
mov    %r12,%r8
mov    %r14,%r9
call   10d0 <clEnqueueNDRangeKernel@plt>
add    $0x20,%rsp
mov    %eax,-0x2c(%rbp)
mov    %ebx,%edi
call   1060 <clFinish@plt>
mov    %eax,-0x2c(%rbp)
sub    $0x20,%rsp
xorpd  %xmm0,%xmm0
movupd %xmm0,0x8(%rsp)
movl   $0x0,(%rsp)
mov    %ebx,%edi
mov    %r15d,%r13d
mov    %r15d,%esi
mov    $0x2,%edx
xor    %ecx,%ecx
mov    %r12,%r8
mov    %r14,%r9
call   10d0 <clEnqueueNDRangeKernel@plt>
add    $0x20,%rsp
mov    %eax,-0x2c(%rbp)
mov    %ebx,%edi
call   1060 <clFinish@plt>
mov    %eax,-0x2c(%rbp)
xor    %eax,%eax
call   1110 <wtime@plt>
subsd  -0x90(%rbp),%xmm0
ff
movapd %xmm0,-0x90(%rbp)
ff
mov    -0x2c(%rbp),%edi
lea    0x8cc(%rip),%rsi
lea    0x6b7(%rip),%r15
mov    %r15,%rdx
mov    $0x1ee,%ecx
call   1130 <check_error@plt>
movslq -0x38(%rbp),%rax
movslq -0x34(%rbp),%rcx
imul   %rax,%rcx
movslq -0x4c(%rbp),%rax
imul   %rcx,%rax
add    %rax,%rax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
unpcklpd -0x90(%rbp),%xmm0
ff
divpd  0x639(%rip),%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
divsd  %xmm1,%xmm0
lea    0x893(%rip),%rdi
mov    $0x1,%al
call   1100 <printf@plt>
mov    -0x3c(%rbp),%esi
mov    0x25fd(%rip),%rax
mov    (%rax),%edx
mov    -0x38(%rbp),%r8d
imul   -0x34(%rbp),%r8d
shl    $0x2,%r8d
sub    $0x20,%rsp
xorpd  %xmm0,%xmm0
movupd %xmm0,0x8(%rsp)
movl   $0x0,(%rsp)
mov    %ebx,%edi
xor    %ecx,%ecx
mov    -0xa0(%rbp),%r14
mov    %r14,%r9
call   1160 <clEnqueueReadBuffer@plt>
add    $0x20,%rsp
mov    %eax,-0x2c(%rbp)
lea    0x84a(%rip),%rsi
mov    %eax,%edi
mov    %r15,%rdx
mov    $0x20a,%ecx
call   1130 <check_error@plt>
mov    -0x2c(%rbp),%eax
mov    0x2567(%rip),%rcx
cmp    (%rcx),%eax
je     1a59 <main+0x799>
lea    0x839(%rip),%rdi
call   1080 <puts@plt>
mov    $0xa,%edi
call   1050 <putchar@plt>
mov    -0x48(%rbp),%edi
call   1180 <clReleaseMemObject@plt>
mov    -0x44(%rbp),%edi
call   1180 <clReleaseMemObject@plt>
mov    -0x3c(%rbp),%edi
call   1180 <clReleaseMemObject@plt>
mov    -0x74(%rbp),%edi
call   1170 <clReleaseContext@plt>
mov    %ebx,%edi
call   1140 <clReleaseCommandQueue@plt>
mov    -0x70(%rbp),%edi
call   10b0 <clReleaseProgram@plt>
mov    %r13d,%edi
call   1090 <clReleaseKernel@plt>
mov    -0x60(%rbp),%rdi
call   1040 <free@plt>
mov    -0x58(%rbp),%rdi
call   1040 <free@plt>
mov    %r14,%rdi
call   1040 <free@plt>
mov    -0x98(%rbp),%rsp
xor    %eax,%eax
jmp    1ad4 <main+0x814>
lea    0x7fb(%rip),%rdi
call   1080 <puts@plt>
mov    0x24ee(%rip),%rax
mov    (%rax),%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@RAND_MAX = global i64 0
@.str = [18 x i8] c"Finding platforms\00"
@.str.1 = [189 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/haohaibo/tutorial/refs/heads/master/LearnOpenCLFromScratch/dgemm/NN/gemm_block8x8_thread8x8_test.c\00"
@.str.2 = [19 x i8] c"Found 0 platforms\0A\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [24 x i8] c"Getting platforms's IDs\00"
@CL_DEVICE_TYPE_DEFAULT = global i32 0
@CL_SUCCESS = global i32 0
@.str.4 = [18 x i8] c"No devices found\0A\00"
@.str.5 = [17 x i8] c"Creating context\00"
@.str.6 = [23 x i8] c"Creating command queue\00"
@.str.7 = [81 x i8] c"gemm_block8x8_thread8x8_private_manual_unroll_preG_noif_512unroll_nobank_test.cl\00"
@.str.8 = [29 x i8] c"Creating program from source\00"
@.str.9 = [14 x i8] c"Build program\00"
@.str.10 = [5 x i8] c"gemm\00"
@.str.11 = [16 x i8] c"Creating kernel\00"
@CL_MEM_READ_ONLY = global i32 0
@.str.12 = [20 x i8] c"Creating buffer d_a\00"
@.str.13 = [20 x i8] c"Creating buffer d_b\00"
@CL_MEM_READ_WRITE = global i32 0
@.str.14 = [20 x i8] c"Creating buffer d_c\00"
@CL_TRUE = global i32 0
@.str.15 = [19 x i8] c"Copying h_a to d_a\00"
@.str.16 = [19 x i8] c"Copying h_b to d_b\00"
@.str.17 = [25 x i8] c"Setting kernel arguments\00"
@__const.main.local = [2 x i64] [i64 8, i64 8]
@.str.18 = [5 x i8] c"%d\09\09\00"
@.str.19 = [29 x i8] c"Waiting for kernel to finish\00"
@.str.20 = [13 x i8] c"%.1lf GFLOPS\00"
@.str.21 = [19 x i8] c"Copying d_c to h_c\00"
@.str.22 = [36 x i8] c"Error: Failed to read output array\0A\00"
@.str.23 = [2 x i8] c"\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 i32
%10 = alloca i32
%11 = alloca float*
%12 = alloca float*
%13 = alloca float*
%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
%23 = alloca i32
%24 = alloca i8*
%25 = alloca i64
%26 = alloca i8*
%27 = alloca i8*
%28 = alloca [2 x i64]
%29 = alloca [2 x i64]
%30 = alloca double
%31 = alloca i32
%32 = alloca double
%33 = alloca float
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 1
%36 = load i8*, i8** %35
%37 = call i32 @atoi(i8* %36)
store i32 %37, i32* %8
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 2
%40 = load i8*, i8** %39
%41 = call i32 @atoi(i8* %40)
store i32 %41, i32* %9
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 3
%44 = load i8*, i8** %43
%45 = call i32 @atoi(i8* %44)
store i32 %45, i32* %10
%46 = load i32, i32* %8
%47 = load i32, i32* %10
%48 = mul nsw i32 %46, %47
%49 = sext i32 %48 to i64
%50 = mul i64 %49, 4
%51 = trunc i64 %50 to i32
%52 = call float* @malloc(i32 %51)
store float* %52, float** %11
%53 = load i32, i32* %10
%54 = load i32, i32* %9
%55 = mul nsw i32 %53, %54
%56 = sext i32 %55 to i64
%57 = mul i64 %56, 4
%58 = trunc i64 %57 to i32
%59 = call float* @malloc(i32 %58)
store float* %59, float** %12
%60 = load i32, i32* %8
%61 = load i32, i32* %9
%62 = mul nsw i32 %60, %61
%63 = sext i32 %62 to i64
%64 = mul i64 %63, 4
%65 = trunc i64 %64 to i32
%66 = call float* @malloc(i32 %65)
store float* %66, float** %13
store i32 0, i32* %22
store i32 0, i32* %22
br label %67
67: ; preds = %82, %2
%68 = load i32, i32* %22
%69 = load i32, i32* %8
%70 = load i32, i32* %10
%71 = mul nsw i32 %69, %70
%72 = icmp slt i32 %68, %71
br i1 %72, label %73, label %85
73: ; preds = %67
%74 = call float (...) @rand()
%75 = load i64, i64* @RAND_MAX
%76 = sitofp i64 %75 to float
%77 = fdiv float %74, %76
%78 = load float*, float** %11
%79 = load i32, i32* %22
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds float, float* %78, i64 %80
store float %77, float* %81
br label %82
82: ; preds = %73
%83 = load i32, i32* %22
%84 = add nsw i32 %83, 1
store i32 %84, i32* %22
br label %67
85: ; preds = %67
store i32 0, i32* %22
br label %86
86: ; preds = %101, %85
%87 = load i32, i32* %22
%88 = load i32, i32* %9
%89 = load i32, i32* %10
%90 = mul nsw i32 %88, %89
%91 = icmp slt i32 %87, %90
br i1 %91, label %92, label %104
92: ; preds = %86
%93 = call float (...) @rand()
%94 = load i64, i64* @RAND_MAX
%95 = sitofp i64 %94 to float
%96 = fdiv float %93, %95
%97 = load float*, float** %12
%98 = load i32, i32* %22
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds float, float* %97, i64 %99
store float %96, float* %100
br label %101
101: ; preds = %92
%102 = load i32, i32* %22
%103 = add nsw i32 %102, 1
store i32 %103, i32* %22
br label %86
104: ; preds = %86
%105 = call i32 @clGetPlatformIDs(i32 0, i32* null, i32* %23)
store i32 %105, i32* %6
%106 = load i32, i32* %6
%107 = call i32 @check_error(i32 %106, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([189 x i8], [189 x i8]* @.str.1, i64 0, i64 0), i32 194)
%108 = load i32, i32* %23
%109 = icmp eq i32 %108, 0
br i1 %109, label %110, label %113
110: ; preds = %104
%111 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%112 = load i32, i32* @EXIT_FAILURE
store i32 %112, i32* %3
br label %348
113: ; preds = %104
%114 = load i32, i32* %23
%115 = zext i32 %114 to i64
%116 = call i8* @llvm.stacksave()
store i8* %116, i8** %24
%117 = alloca i32, i64 %115
store i64 %115, i64* %25
%118 = load i32, i32* %23
%119 = call i32 @clGetPlatformIDs(i32 %118, i32* %117, i32* null)
store i32 %119, i32* %6
%120 = load i32, i32* %6
%121 = call i32 @check_error(i32 %120, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([189 x i8], [189 x i8]* @.str.1, i64 0, i64 0), i32 207)
store i32 0, i32* %22
br label %122
122: ; preds = %138, %113
%123 = load i32, i32* %22
%124 = load i32, i32* %23
%125 = icmp slt i32 %123, %124
br i1 %125, label %126, label %141
126: ; preds = %122
%127 = load i32, i32* %22
%128 = sext i32 %127 to i64
%129 = getelementptr inbounds i32, i32* %117, i64 %128
%130 = load i32, i32* %129
%131 = load i32, i32* @CL_DEVICE_TYPE_DEFAULT
%132 = call i32 @clGetDeviceIDs(i32 %130, i32 %131, i32 1, i32** %14, i32* null)
store i32 %132, i32* %6
%133 = load i32, i32* %6
%134 = load i32, i32* @CL_SUCCESS
%135 = icmp eq i32 %133, %134
br i1 %135, label %136, label %137
136: ; preds = %126
br label %141
137: ; preds = %126
br label %138
138: ; preds = %137
%139 = load i32, i32* %22
%140 = add nsw i32 %139, 1
store i32 %140, i32* %22
br label %122
141: ; preds = %136, %122
%142 = load i32*, i32** %14
%143 = icmp eq i32* %142, null
br i1 %143, label %144, label %146
144: ; preds = %141
%145 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
br label %146
146: ; preds = %144, %141
%147 = call i32 @clCreateContext(i32 0, i32 1, i32** %14, i32* null, i32* null, i32* %6)
store i32 %147, i32* %15
%148 = load i32, i32* %6
%149 = call i32 @check_error(i32 %148, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([189 x i8], [189 x i8]* @.str.1, i64 0, i64 0), i32 249)
%150 = load i32, i32* %15
%151 = load i32*, i32** %14
%152 = call i32 @clCreateCommandQueue(i32 %150, i32* %151, i32 0, i32* %6)
store i32 %152, i32* %16
%153 = load i32, i32* %6
%154 = call i32 @check_error(i32 %153, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([189 x i8], [189 x i8]* @.str.1, i64 0, i64 0), i32 264)
store i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.7, i64 0, i64 0), i8** %26
%155 = load i8*, i8** %26
%156 = call i8* @getKernelSource(i8* %155)
store i8* %156, i8** %27
%157 = load i32, i32* %15
%158 = call i32 @clCreateProgramWithSource(i32 %157, i32 1, i8** %27, i32* null, i32* %6)
store i32 %158, i32* %17
%159 = load i32, i32* %6
%160 = call i32 @check_error(i32 %159, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([189 x i8], [189 x i8]* @.str.1, i64 0, i64 0), i32 301)
%161 = load i32, i32* %17
%162 = call i32 @clBuildProgram(i32 %161, i32 0, i32* null, i32* null, i32* null, i32* null)
store i32 %162, i32* %6
%163 = load i32, i32* %6
%164 = call i32 @check_error(i32 %163, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([189 x i8], [189 x i8]* @.str.1, i64 0, i64 0), i32 320)
%165 = load i32, i32* %17
%166 = call i32 @clCreateKernel(i32 %165, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), i32* %6)
store i32 %166, i32* %18
%167 = load i32, i32* %6
%168 = call i32 @check_error(i32 %167, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([189 x i8], [189 x i8]* @.str.1, i64 0, i64 0), i32 334)
%169 = load i32, i32* %15
%170 = load i32, i32* @CL_MEM_READ_ONLY
%171 = load i32, i32* %8
%172 = sext i32 %171 to i64
%173 = mul i64 4, %172
%174 = load i32, i32* %10
%175 = sext i32 %174 to i64
%176 = mul i64 %173, %175
%177 = trunc i64 %176 to i32
%178 = call i32 @clCreateBuffer(i32 %169, i32 %170, i32 %177, i32* null, i32* %6)
store i32 %178, i32* %19
%179 = load i32, i32* %6
%180 = call i32 @check_error(i32 %179, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([189 x i8], [189 x i8]* @.str.1, i64 0, i64 0), i32 355)
%181 = load i32, i32* %15
%182 = load i32, i32* @CL_MEM_READ_ONLY
%183 = load i32, i32* %10
%184 = sext i32 %183 to i64
%185 = mul i64 4, %184
%186 = load i32, i32* %9
%187 = sext i32 %186 to i64
%188 = mul i64 %185, %187
%189 = trunc i64 %188 to i32
%190 = call i32 @clCreateBuffer(i32 %181, i32 %182, i32 %189, i32* null, i32* %6)
store i32 %190, i32* %20
%191 = load i32, i32* %6
%192 = call i32 @check_error(i32 %191, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([189 x i8], [189 x i8]* @.str.1, i64 0, i64 0), i32 362)
%193 = load i32, i32* %15
%194 = load i32, i32* @CL_MEM_READ_WRITE
%195 = load i32, i32* %8
%196 = sext i32 %195 to i64
%197 = mul i64 4, %196
%198 = load i32, i32* %9
%199 = sext i32 %198 to i64
%200 = mul i64 %197, %199
%201 = trunc i64 %200 to i32
%202 = call i32 @clCreateBuffer(i32 %193, i32 %194, i32 %201, i32* null, i32* %6)
store i32 %202, i32* %21
%203 = load i32, i32* %6
%204 = call i32 @check_error(i32 %203, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([189 x i8], [189 x i8]* @.str.1, i64 0, i64 0), i32 369)
%205 = load i32, i32* %16
%206 = load i32, i32* %19
%207 = load i32, i32* @CL_TRUE
%208 = load i32, i32* %8
%209 = sext i32 %208 to i64
%210 = mul i64 4, %209
%211 = load i32, i32* %10
%212 = sext i32 %211 to i64
%213 = mul i64 %210, %212
%214 = trunc i64 %213 to i32
%215 = load float*, float** %11
%216 = call i32 @clEnqueueWriteBuffer(i32 %205, i32 %206, i32 %207, i32 0, i32 %214, float* %215, i32 0, i32* null, i32* null)
store i32 %216, i32* %6
%217 = load i32, i32* %6
%218 = call i32 @check_error(i32 %217, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.15, i64 0, i64 0), i8* getelementptr inbounds ([189 x i8], [189 x i8]* @.str.1, i64 0, i64 0), i32 395)
%219 = load i32, i32* %16
%220 = load i32, i32* %20
%221 = load i32, i32* @CL_TRUE
%222 = load i32, i32* %10
%223 = sext i32 %222 to i64
%224 = mul i64 4, %223
%225 = load i32, i32* %9
%226 = sext i32 %225 to i64
%227 = mul i64 %224, %226
%228 = trunc i64 %227 to i32
%229 = load float*, float** %12
%230 = call i32 @clEnqueueWriteBuffer(i32 %219, i32 %220, i32 %221, i32 0, i32 %228, float* %229, i32 0, i32* null, i32* null)
store i32 %230, i32* %6
%231 = load i32, i32* %6
%232 = call i32 @check_error(i32 %231, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([189 x i8], [189 x i8]* @.str.1, i64 0, i64 0), i32 407)
%233 = load i32, i32* %18
%234 = call i32 @clSetKernelArg(i32 %233, i32 0, i32 4, i32* %19)
store i32 %234, i32* %6
%235 = load i32, i32* %18
%236 = call i32 @clSetKernelArg(i32 %235, i32 1, i32 4, i32* %20)
%237 = load i32, i32* %6
%238 = or i32 %237, %236
store i32 %238, i32* %6
%239 = load i32, i32* %18
%240 = call i32 @clSetKernelArg(i32 %239, i32 2, i32 4, i32* %21)
%241 = load i32, i32* %6
%242 = or i32 %241, %240
store i32 %242, i32* %6
%243 = load i32, i32* %18
%244 = call i32 @clSetKernelArg(i32 %243, i32 3, i32 4, i32* %8)
%245 = load i32, i32* %6
%246 = or i32 %245, %244
store i32 %246, i32* %6
%247 = load i32, i32* %18
%248 = call i32 @clSetKernelArg(i32 %247, i32 4, i32 4, i32* %9)
%249 = load i32, i32* %6
%250 = or i32 %249, %248
store i32 %250, i32* %6
%251 = load i32, i32* %18
%252 = call i32 @clSetKernelArg(i32 %251, i32 5, i32 4, i32* %10)
%253 = load i32, i32* %6
%254 = or i32 %253, %252
store i32 %254, i32* %6
%255 = load i32, i32* %6
%256 = call i32 @check_error(i32 %255, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.17, i64 0, i64 0), i8* getelementptr inbounds ([189 x i8], [189 x i8]* @.str.1, i64 0, i64 0), i32 446)
%257 = getelementptr inbounds [2 x i64], [2 x i64]* %28, i64 0, i64 0
%258 = load i32, i32* %8
%259 = sdiv i32 %258, 8
%260 = sext i32 %259 to i64
store i64 %260, i64* %257
%261 = getelementptr inbounds i64, i64* %257, i64 1
%262 = load i32, i32* %9
%263 = sdiv i32 %262, 8
%264 = sext i32 %263 to i64
store i64 %264, i64* %261
%265 = bitcast [2 x i64]* %29 to i8*
%266 = load i32, i32* %8
%267 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.18, i64 0, i64 0), i32 %266)
%268 = call double (...) @wtime()
store double %268, double* %30
store i32 0, i32* %31
br label %269
269: ; preds = %280, %146
%270 = load i32, i32* %31
%271 = icmp slt i32 %270, 5
br i1 %271, label %272, label %283
272: ; preds = %269
%273 = load i32, i32* %16
%274 = load i32, i32* %18
%275 = getelementptr inbounds [2 x i64], [2 x i64]* %28, i64 0, i64 0
%276 = getelementptr inbounds [2 x i64], [2 x i64]* %29, i64 0, i64 0
%277 = call i32 @clEnqueueNDRangeKernel(i32 %273, i32 %274, i32 2, i32* null, i64* %275, i64* %276, i32 0, i32* null, i32* null)
store i32 %277, i32* %6
%278 = load i32, i32* %16
%279 = call i32 @clFinish(i32 %278)
store i32 %279, i32* %6
br label %280
280: ; preds = %272
%281 = load i32, i32* %31
%282 = add nsw i32 %281, 1
store i32 %282, i32* %31
br label %269
283: ; preds = %269
%284 = call double (...) @wtime()
%285 = load double, double* %30
%286 = fsub double %284, %285
%287 = fdiv double %286, 5.000000e+00
store double %287, double* %30
%288 = load i32, i32* %6
%289 = call i32 @check_error(i32 %288, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.19, i64 0, i64 0), i8* getelementptr inbounds ([189 x i8], [189 x i8]* @.str.1, i64 0, i64 0), i32 494)
%290 = load i32, i32* %8
%291 = sext i32 %290 to i64
%292 = load i32, i32* %9
%293 = sext i32 %292 to i64
%294 = mul nsw i64 %291, %293
%295 = load i32, i32* %10
%296 = sext i32 %295 to i64
%297 = mul nsw i64 %294, %296
%298 = mul nsw i64 %297, 2
%299 = sitofp i64 %298 to double
%300 = fmul double %299, 1.000000e+00
%301 = fdiv double %300, 1.000000e+09
store double %301, double* %32
%302 = load double, double* %32
%303 = load double, double* %30
%304 = fdiv double %302, %303
%305 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.20, i64 0, i64 0), double %304)
%306 = load i32, i32* %16
%307 = load i32, i32* %21
%308 = load i32, i32* @CL_TRUE
%309 = load i32, i32* %8
%310 = sext i32 %309 to i64
%311 = mul i64 4, %310
%312 = load i32, i32* %9
%313 = sext i32 %312 to i64
%314 = mul i64 %311, %313
%315 = trunc i64 %314 to i32
%316 = load float*, float** %13
%317 = call i32 @clEnqueueReadBuffer(i32 %306, i32 %307, i32 %308, i32 0, i32 %315, float* %316, i32 0, i32* null, i32* null)
store i32 %317, i32* %6
%318 = load i32, i32* %6
%319 = call i32 @check_error(i32 %318, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.21, i64 0, i64 0), i8* getelementptr inbounds ([189 x i8], [189 x i8]* @.str.1, i64 0, i64 0), i32 522)
%320 = load i32, i32* %6
%321 = load i32, i32* @CL_SUCCESS
%322 = icmp ne i32 %320, %321
br i1 %322, label %323, label %325
323: ; preds = %283
%324 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.22, i64 0, i64 0))
br label %325
325: ; preds = %323, %283
%326 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.23, i64 0, i64 0))
store i32 0, i32* %7
store float 0.000000e+00, float* %33
%327 = load i32, i32* %19
%328 = call i32 @clReleaseMemObject(i32 %327)
%329 = load i32, i32* %20
%330 = call i32 @clReleaseMemObject(i32 %329)
%331 = load i32, i32* %21
%332 = call i32 @clReleaseMemObject(i32 %331)
%333 = load i32, i32* %15
%334 = call i32 @clReleaseContext(i32 %333)
%335 = load i32, i32* %16
%336 = call i32 @clReleaseCommandQueue(i32 %335)
%337 = load i32, i32* %17
%338 = call i32 @clReleaseProgram(i32 %337)
%339 = load i32, i32* %18
%340 = call i32 @clReleaseKernel(i32 %339)
%341 = load float*, float** %11
%342 = call i32 @free(float* %341)
%343 = load float*, float** %12
%344 = call i32 @free(float* %343)
%345 = load float*, float** %13
%346 = call i32 @free(float* %345)
store i32 0, i32* %3
%347 = load i8*, i8** %24
br label %348
348: ; preds = %325, %110
%349 = load i32, i32* %3
ret i32 %349
}

LLVM IR (-O2):
@RAND_MAX = global i64 0
@.str = [18 x i8] c"Finding platforms\00"
@.str.1 = [189 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/haohaibo/tutorial/refs/heads/master/LearnOpenCLFromScratch/dgemm/NN/gemm_block8x8_thread8x8_test.c\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [24 x i8] c"Getting platforms's IDs\00"
@CL_DEVICE_TYPE_DEFAULT = global i32 0
@CL_SUCCESS = global i32 0
@.str.5 = [17 x i8] c"Creating context\00"
@.str.6 = [23 x i8] c"Creating command queue\00"
@.str.7 = [81 x i8] c"gemm_block8x8_thread8x8_private_manual_unroll_preG_noif_512unroll_nobank_test.cl\00"
@.str.8 = [29 x i8] c"Creating program from source\00"
@.str.9 = [14 x i8] c"Build program\00"
@.str.10 = [5 x i8] c"gemm\00"
@.str.11 = [16 x i8] c"Creating kernel\00"
@CL_MEM_READ_ONLY = global i32 0
@.str.12 = [20 x i8] c"Creating buffer d_a\00"
@.str.13 = [20 x i8] c"Creating buffer d_b\00"
@CL_MEM_READ_WRITE = global i32 0
@.str.14 = [20 x i8] c"Creating buffer d_c\00"
@CL_TRUE = global i32 0
@.str.15 = [19 x i8] c"Copying h_a to d_a\00"
@.str.16 = [19 x i8] c"Copying h_b to d_b\00"
@.str.17 = [25 x i8] c"Setting kernel arguments\00"
@__const.main.local = [2 x i64] [i64 8, i64 8]
@.str.18 = [5 x i8] c"%d\09\09\00"
@.str.19 = [29 x i8] c"Waiting for kernel to finish\00"
@.str.20 = [13 x i8] c"%.1lf GFLOPS\00"
@.str.21 = [19 x i8] c"Copying d_c to h_c\00"
@str = [35 x i8] c"Error: Failed to read output array\00"
@str.24 = [17 x i8] c"No devices found\00"
@str.25 = [18 x i8] c"Found 0 platforms\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca <2 x i64>
%14 = alloca [2 x i64]
%15 = bitcast i32* %3 to i8*
%16 = bitcast i32* %4 to i8*
%17 = getelementptr inbounds i8*, i8** %1, i64 1
%18 = load i8*, i8** %17
%19 = tail call i32 @atoi(i8* %18)
store i32 %19, i32* %4
%20 = bitcast i32* %5 to i8*
%21 = getelementptr inbounds i8*, i8** %1, i64 2
%22 = load i8*, i8** %21
%23 = tail call i32 @atoi(i8* %22)
store i32 %23, i32* %5
%24 = bitcast i32* %6 to i8*
%25 = getelementptr inbounds i8*, i8** %1, i64 3
%26 = load i8*, i8** %25
%27 = tail call i32 @atoi(i8* %26)
store i32 %27, i32* %6
%28 = shl i32 %19, 2
%29 = mul i32 %28, %27
%30 = tail call float* @malloc(i32 %29)
%31 = shl i32 %23, 2
%32 = mul i32 %31, %27
%33 = tail call float* @malloc(i32 %32)
%34 = mul i32 %28, %23
%35 = tail call float* @malloc(i32 %34)
%36 = bitcast i32** %7 to i8*
%37 = bitcast i32* %8 to i8*
%38 = bitcast i32* %9 to i8*
%39 = bitcast i32* %10 to i8*
%40 = mul i32 %27, %19
%41 = icmp sgt i32 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %2
%43 = zext i32 %40 to i64
br label %49
44: ; preds = %49, %2
%45 = mul i32 %27, %23
%46 = icmp sgt i32 %45, 0
br i1 %46, label %47, label %67
47: ; preds = %44
%48 = zext i32 %45 to i64
br label %58
49: ; preds = %42, %49
%50 = phi i64 [ 0, %42 ], [ %56, %49 ]
%51 = tail call float (...) @rand()
%52 = load i64, i64* @RAND_MAX
%53 = sitofp i64 %52 to float
%54 = fdiv float %51, %53
%55 = getelementptr inbounds float, float* %30, i64 %50
store float %54, float* %55
%56 = add nuw nsw i64 %50, 1
%57 = icmp eq i64 %56, %43
br i1 %57, label %44, label %49
58: ; preds = %47, %58
%59 = phi i64 [ 0, %47 ], [ %65, %58 ]
%60 = tail call float (...) @rand()
%61 = load i64, i64* @RAND_MAX
%62 = sitofp i64 %61 to float
%63 = fdiv float %60, %62
%64 = getelementptr inbounds float, float* %33, i64 %59
store float %63, float* %64
%65 = add nuw nsw i64 %59, 1
%66 = icmp eq i64 %65, %48
br i1 %66, label %67, label %58
67: ; preds = %58, %44
%68 = bitcast i32* %11 to i8*
%69 = call i32 @clGetPlatformIDs(i32 0, i32* null, i32* %11)
store i32 %69, i32* %3
%70 = call i32 @check_error(i32 %69, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([189 x i8], [189 x i8]* @.str.1, i64 0, i64 0), i32 194)
%71 = load i32, i32* %11
%72 = icmp eq i32 %71, 0
br i1 %72, label %73, label %76
73: ; preds = %67
%74 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.25, i64 0, i64 0))
%75 = load i32, i32* @EXIT_FAILURE
br label %229
76: ; preds = %67
%77 = zext i32 %71 to i64
%78 = call i8* @llvm.stacksave()
%79 = alloca i32, i64 %77
%80 = load i32, i32* %11
%81 = call i32 @clGetPlatformIDs(i32 %80, i32* %79, i32* null)
store i32 %81, i32* %3
%82 = call i32 @check_error(i32 %81, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([189 x i8], [189 x i8]* @.str.1, i64 0, i64 0), i32 207)
%83 = load i32, i32* %11
%84 = icmp sgt i32 %83, 0
br i1 %84, label %85, label %101
85: ; preds = %76, %85
%86 = phi i64 [ %93, %85 ], [ 0, %76 ]
%87 = getelementptr inbounds i32, i32* %79, i64 %86
%88 = load i32, i32* %87
%89 = load i32, i32* @CL_DEVICE_TYPE_DEFAULT
%90 = call i32 @clGetDeviceIDs(i32 %88, i32 %89, i32 1, i32** %7, i32* null)
store i32 %90, i32* %3
%91 = load i32, i32* @CL_SUCCESS
%92 = icmp ne i32 %90, %91
%93 = add nuw nsw i64 %86, 1
%94 = load i32, i32* %11
%95 = sext i32 %94 to i64
%96 = icmp slt i64 %93, %95
%97 = select i1 %92, i1 %96, i1 false
br i1 %97, label %85, label %98
98: ; preds = %85
%99 = load i32*, i32** %7
%100 = icmp eq i32* %99, null
br i1 %100, label %101, label %103
101: ; preds = %76, %98
%102 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.24, i64 0, i64 0))
br label %103
103: ; preds = %101, %98
%104 = call i32 @clCreateContext(i32 0, i32 1, i32** %7, i32* null, i32* null, i32* %3)
%105 = load i32, i32* %3
%106 = call i32 @check_error(i32 %105, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([189 x i8], [189 x i8]* @.str.1, i64 0, i64 0), i32 249)
%107 = load i32*, i32** %7
%108 = call i32 @clCreateCommandQueue(i32 %104, i32* %107, i32 0, i32* %3)
%109 = load i32, i32* %3
%110 = call i32 @check_error(i32 %109, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([189 x i8], [189 x i8]* @.str.1, i64 0, i64 0), i32 264)
%111 = bitcast i8** %12 to i8*
%112 = call i8* @getKernelSource(i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.7, i64 0, i64 0))
store i8* %112, i8** %12
%113 = call i32 @clCreateProgramWithSource(i32 %104, i32 1, i8** %12, i32* null, i32* %3)
%114 = load i32, i32* %3
%115 = call i32 @check_error(i32 %114, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([189 x i8], [189 x i8]* @.str.1, i64 0, i64 0), i32 301)
%116 = call i32 @clBuildProgram(i32 %113, i32 0, i32* null, i32* null, i32* null, i32* null)
store i32 %116, i32* %3
%117 = call i32 @check_error(i32 %116, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([189 x i8], [189 x i8]* @.str.1, i64 0, i64 0), i32 320)
%118 = call i32 @clCreateKernel(i32 %113, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), i32* %3)
%119 = load i32, i32* %3
%120 = call i32 @check_error(i32 %119, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([189 x i8], [189 x i8]* @.str.1, i64 0, i64 0), i32 334)
%121 = load i32, i32* @CL_MEM_READ_ONLY
%122 = call i32 @clCreateBuffer(i32 %104, i32 %121, i32 %29, i32* null, i32* %3)
store i32 %122, i32* %8
%123 = load i32, i32* %3
%124 = call i32 @check_error(i32 %123, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([189 x i8], [189 x i8]* @.str.1, i64 0, i64 0), i32 355)
%125 = load i32, i32* @CL_MEM_READ_ONLY
%126 = shl i32 %27, 2
%127 = mul i32 %126, %23
%128 = call i32 @clCreateBuffer(i32 %104, i32 %125, i32 %127, i32* null, i32* %3)
store i32 %128, i32* %9
%129 = load i32, i32* %3
%130 = call i32 @check_error(i32 %129, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([189 x i8], [189 x i8]* @.str.1, i64 0, i64 0), i32 362)
%131 = load i32, i32* @CL_MEM_READ_WRITE
%132 = call i32 @clCreateBuffer(i32 %104, i32 %131, i32 %34, i32* null, i32* %3)
store i32 %132, i32* %10
%133 = load i32, i32* %3
%134 = call i32 @check_error(i32 %133, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([189 x i8], [189 x i8]* @.str.1, i64 0, i64 0), i32 369)
%135 = load i32, i32* @CL_TRUE
%136 = call i32 @clEnqueueWriteBuffer(i32 %108, i32 %122, i32 %135, i32 0, i32 %29, float* %30, i32 0, i32* null, i32* null)
store i32 %136, i32* %3
%137 = call i32 @check_error(i32 %136, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.15, i64 0, i64 0), i8* getelementptr inbounds ([189 x i8], [189 x i8]* @.str.1, i64 0, i64 0), i32 395)
%138 = load i32, i32* @CL_TRUE
%139 = call i32 @clEnqueueWriteBuffer(i32 %108, i32 %128, i32 %138, i32 0, i32 %127, float* %33, i32 0, i32* null, i32* null)
store i32 %139, i32* %3
%140 = call i32 @check_error(i32 %139, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([189 x i8], [189 x i8]* @.str.1, i64 0, i64 0), i32 407)
%141 = call i32 @clSetKernelArg(i32 %118, i32 0, i32 4, i32* %8)
store i32 %141, i32* %3
%142 = call i32 @clSetKernelArg(i32 %118, i32 1, i32 4, i32* %9)
%143 = load i32, i32* %3
%144 = or i32 %143, %142
store i32 %144, i32* %3
%145 = call i32 @clSetKernelArg(i32 %118, i32 2, i32 4, i32* %10)
%146 = load i32, i32* %3
%147 = or i32 %146, %145
store i32 %147, i32* %3
%148 = call i32 @clSetKernelArg(i32 %118, i32 3, i32 4, i32* %4)
%149 = load i32, i32* %3
%150 = or i32 %149, %148
store i32 %150, i32* %3
%151 = call i32 @clSetKernelArg(i32 %118, i32 4, i32 4, i32* %5)
%152 = load i32, i32* %3
%153 = or i32 %152, %151
store i32 %153, i32* %3
%154 = call i32 @clSetKernelArg(i32 %118, i32 5, i32 4, i32* %6)
%155 = load i32, i32* %3
%156 = or i32 %155, %154
store i32 %156, i32* %3
%157 = call i32 @check_error(i32 %156, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.17, i64 0, i64 0), i8* getelementptr inbounds ([189 x i8], [189 x i8]* @.str.1, i64 0, i64 0), i32 446)
%158 = bitcast <2 x i64>* %13 to i8*
%159 = getelementptr inbounds <2 x i64>, <2 x i64>* %13, i64 0, i64 0
%160 = load i32, i32* %4
%161 = load i32, i32* %5
%162 = insertelement <2 x i32> poison, i32 %160, i64 0
%163 = insertelement <2 x i32> %162, i32 %161, i64 1
%164 = sdiv <2 x i32> %163, <i32 8, i32 8>
%165 = sext <2 x i32> %164 to <2 x i64>
store <2 x i64> %165, <2 x i64>* %13
%166 = bitcast [2 x i64]* %14 to i8*
%167 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.18, i64 0, i64 0), i32 %160)
%168 = call double (...) @wtime()
%169 = getelementptr inbounds [2 x i64], [2 x i64]* %14, i64 0, i64 0
%170 = call i32 @clEnqueueNDRangeKernel(i32 %108, i32 %118, i32 2, i32* null, i64* %159, i64* %169, i32 0, i32* null, i32* null)
store i32 %170, i32* %3
%171 = call i32 @clFinish(i32 %108)
store i32 %171, i32* %3
%172 = call i32 @clEnqueueNDRangeKernel(i32 %108, i32 %118, i32 2, i32* null, i64* %159, i64* %169, i32 0, i32* null, i32* null)
store i32 %172, i32* %3
%173 = call i32 @clFinish(i32 %108)
store i32 %173, i32* %3
%174 = call i32 @clEnqueueNDRangeKernel(i32 %108, i32 %118, i32 2, i32* null, i64* %159, i64* %169, i32 0, i32* null, i32* null)
store i32 %174, i32* %3
%175 = call i32 @clFinish(i32 %108)
store i32 %175, i32* %3
%176 = call i32 @clEnqueueNDRangeKernel(i32 %108, i32 %118, i32 2, i32* null, i64* %159, i64* %169, i32 0, i32* null, i32* null)
store i32 %176, i32* %3
%177 = call i32 @clFinish(i32 %108)
store i32 %177, i32* %3
%178 = call i32 @clEnqueueNDRangeKernel(i32 %108, i32 %118, i32 2, i32* null, i64* %159, i64* %169, i32 0, i32* null, i32* null)
store i32 %178, i32* %3
%179 = call i32 @clFinish(i32 %108)
store i32 %179, i32* %3
%180 = call double (...) @wtime()
%181 = fsub double %180, %168
%182 = load i32, i32* %3
%183 = call i32 @check_error(i32 %182, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.19, i64 0, i64 0), i8* getelementptr inbounds ([189 x i8], [189 x i8]* @.str.1, i64 0, i64 0), i32 494)
%184 = load i32, i32* %4
%185 = sext i32 %184 to i64
%186 = load i32, i32* %5
%187 = sext i32 %186 to i64
%188 = load i32, i32* %6
%189 = sext i32 %188 to i64
%190 = shl nsw i64 %185, 1
%191 = mul i64 %190, %187
%192 = mul i64 %191, %189
%193 = sitofp i64 %192 to double
%194 = insertelement <2 x double> poison, double %193, i64 0
%195 = insertelement <2 x double> %194, double %181, i64 1
%196 = fdiv <2 x double> %195, <double 1.000000e+09, double 5.000000e+00>
%197 = extractelement <2 x double> %196, i64 0
%198 = extractelement <2 x double> %196, i64 1
%199 = fdiv double %197, %198
%200 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.20, i64 0, i64 0), double %199)
%201 = load i32, i32* %10
%202 = load i32, i32* @CL_TRUE
%203 = load i32, i32* %4
%204 = shl i32 %203, 2
%205 = load i32, i32* %5
%206 = mul i32 %204, %205
%207 = call i32 @clEnqueueReadBuffer(i32 %108, i32 %201, i32 %202, i32 0, i32 %206, float* %35, i32 0, i32* null, i32* null)
store i32 %207, i32* %3
%208 = call i32 @check_error(i32 %207, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.21, i64 0, i64 0), i8* getelementptr inbounds ([189 x i8], [189 x i8]* @.str.1, i64 0, i64 0), i32 522)
%209 = load i32, i32* %3
%210 = load i32, i32* @CL_SUCCESS
%211 = icmp eq i32 %209, %210
br i1 %211, label %214, label %212
212: ; preds = %103
%213 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
br label %214
214: ; preds = %212, %103
%215 = call i32 @putchar(i32 10)
%216 = load i32, i32* %8
%217 = call i32 @clReleaseMemObject(i32 %216)
%218 = load i32, i32* %9
%219 = call i32 @clReleaseMemObject(i32 %218)
%220 = load i32, i32* %10
%221 = call i32 @clReleaseMemObject(i32 %220)
%222 = call i32 @clReleaseContext(i32 %104)
%223 = call i32 @clReleaseCommandQueue(i32 %108)
%224 = call i32 @clReleaseProgram(i32 %113)
%225 = call i32 @clReleaseKernel(i32 %118)
%226 = call i32 @free(float* %30)
%227 = call i32 @free(float* %33)
%228 = call i32 @free(float* %35)
br label %229
229: ; preds = %214, %73
%230 = phi i32 [ %75, %73 ], [ 0, %214 ]
ret i32 %230
}