#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/bench/gemm_block8x8_thread8x8.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/bench/gemm_block8x8_thread8x8.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/bench/gemm_block8x8_thread8x8.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/bench/gemm_block8x8_thread8x8.c",
              264);
  char *gemm_kernel = getKernelSource("gemm_block8x8_thread8x8_preG.cl");
  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/bench/gemm_block8x8_thread8x8.c",
              285);
  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/bench/gemm_block8x8_thread8x8.c",
              304);
  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/bench/gemm_block8x8_thread8x8.c",
              318);
  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/bench/gemm_block8x8_thread8x8.c",
              339);
  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/bench/gemm_block8x8_thread8x8.c",
              346);
  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/bench/gemm_block8x8_thread8x8.c",
              353);
  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/bench/gemm_block8x8_thread8x8.c",
              379);
  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/bench/gemm_block8x8_thread8x8.c",
              391);
  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/bench/gemm_block8x8_thread8x8.c",
              430);
  const size_t global[2] = {M / 8, N / 8};
  const size_t local[2] = {8, 8};
  printf("Starting my SGEMM M = %d N = %d K = %d "
         "running...(repeated %d times)\n",
         M, N, K, 5);
  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/bench/gemm_block8x8_thread8x8.c",
              477);
  double gflops =
      ((long)M * (long)N * (long)K * 2 * 1.0) / (double)(1000 * 1000 * 1000);
  printf("\nThe kernel ran in %lf seconds\n", rtime);
  printf("%.1lf GFLOPS\n", 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/bench/gemm_block8x8_thread8x8.c",
              505);
  if (err != CL_SUCCESS) {
    printf("Error: Failed to read output array\n");
  }
  printf("\n");
  correct = 0;
  float temp = 0;
  printf("Verifing the GPU result...\n");
  for (int i = 0; i < M; ++i) {
    for (int j = 0; j < N; ++j) {
      temp = 0;
      for (int k = 0; k < K; ++k) {
        temp += h_a[k * M + i] * h_b[j * K + k];
      }
      temp -= h_c[j * M + i];
      if (temp * temp < (0.001) * (0.001)) {
        ++correct;
      } else {
        printf("temp %f h_c %f\n", temp, h_c[i]);
      }
    }
  }
  printf("C = A * B: %d out of %d results were correct.\n", correct, M * N);
  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    0xc36(%rip),%rsi
lea    0xc41(%rip),%rdx
mov    $0xc2,%ecx
call   1110 <check_error@plt>
cmpl   $0x0,-0x6c(%rbp)
jne    1424 <main+0x184>
lea    0xce1(%rip),%rdi
mov    $0x0,%al
call   10e0 <printf@plt>
mov    0x2ba6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1cda <main+0xa3a>
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,-0xe0(%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    0xc99(%rip),%rsi
lea    0xbc4(%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    -0xe0(%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    0xc24(%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    0xc06(%rip),%rsi
lea    0xb07(%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    0xbe7(%rip),%rsi
lea    0xad7(%rip),%rdx
mov    $0x108,%ecx
call   1110 <check_error@plt>
lea    0xbe6(%rip),%rdi
call   1190 <getKernelSource@plt>
mov    %rax,-0x88(%rbp)
mov    -0x4c(%rbp),%edi
mov    $0x1,%esi
lea    -0x88(%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    0xbd1(%rip),%rsi
lea    0xa8a(%rip),%rdx
mov    $0x11d,%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    0xbb8(%rip),%rsi
lea    0xa54(%rip),%rdx
mov    $0x130,%ecx
call   1110 <check_error@plt>
mov    -0x54(%rbp),%edi
lea    0xbab(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1170 <clCreateKernel@plt>
mov    %eax,-0x58(%rbp)
mov    -0x14(%rbp),%edi
lea    0xb9a(%rip),%rsi
lea    0xa23(%rip),%rdx
mov    $0x13e,%ecx
call   1110 <check_error@plt>
mov    -0x4c(%rbp),%edi
mov    0x2995(%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    0xb61(%rip),%rsi
lea    0x9da(%rip),%rdx
mov    $0x153,%ecx
call   1110 <check_error@plt>
mov    -0x4c(%rbp),%edi
mov    0x294c(%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    0xb2c(%rip),%rsi
lea    0x991(%rip),%rdx
mov    $0x15a,%ecx
call   1110 <check_error@plt>
mov    -0x4c(%rbp),%edi
mov    0x292b(%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    0xaf7(%rip),%rsi
lea    0x948(%rip),%rdx
mov    $0x161,%ecx
call   1110 <check_error@plt>
mov    -0x50(%rbp),%edi
mov    -0x5c(%rbp),%esi
mov    0x28e7(%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    0xa9d(%rip),%rsi
lea    0x8da(%rip),%rdx
mov    $0x17b,%ecx
call   1110 <check_error@plt>
mov    -0x50(%rbp),%edi
mov    -0x60(%rbp),%esi
mov    0x2879(%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    0xa42(%rip),%rsi
lea    0x86c(%rip),%rdx
mov    $0x187,%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    0x99b(%rip),%rsi
lea    0x7b2(%rip),%rdx
mov    $0x1ae,%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    0xa97(%rip),%rax
mov    %rax,-0xb0(%rbp)
mov    0xa91(%rip),%rax
mov    %rax,-0xa8(%rbp)
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x24(%rbp),%ecx
lea    0x94f(%rip),%rdi
mov    $0x5,%r8d
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    1978 <main+0x6d8>
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    1904 <main+0x664>
mov    $0x0,%al
call   10f0 <wtime@plt>
subsd  -0xb8(%rbp),%xmm0
ff
movsd  0x681(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
mov    -0x14(%rbp),%edi
lea    0x8ce(%rip),%rsi
lea    0x686(%rip),%rdx
mov    $0x1dd,%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  0x62d(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0x619(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0xc8(%rbp)
ff
movsd  -0xb8(%rbp),%xmm0
ff
lea    0x88e(%rip),%rdi
mov    $0x1,%al
call   10e0 <printf@plt>
movsd  -0xc8(%rbp),%xmm0
ff
divsd  -0xb8(%rbp),%xmm0
ff
lea    0x890(%rip),%rdi
mov    $0x1,%al
call   10e0 <printf@plt>
mov    -0x50(%rbp),%edi
mov    -0x64(%rbp),%esi
mov    0x25b4(%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    0x83a(%rip),%rsi
lea    0x5a7(%rip),%rdx
mov    $0x1f9,%ecx
call   1110 <check_error@plt>
mov    -0x14(%rbp),%eax
mov    0x2511(%rip),%rcx
cmp    (%rcx),%eax
je     1ab5 <main+0x815>
lea    0x823(%rip),%rdi
mov    $0x0,%al
call   10e0 <printf@plt>
lea    0x7b5(%rip),%rdi
mov    $0x0,%al
call   10e0 <printf@plt>
movl   $0x0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xcc(%rbp)
ff
lea    0x819(%rip),%rdi
mov    $0x0,%al
call   10e0 <printf@plt>
movl   $0x0,-0xd0(%rbp)
mov    -0xd0(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1c61 <main+0x9c1>
movl   $0x0,-0xd4(%rbp)
mov    -0xd4(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1c48 <main+0x9a8>
xorps  %xmm0,%xmm0
movss  %xmm0,-0xcc(%rbp)
ff
movl   $0x0,-0xd8(%rbp)
mov    -0xd8(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1b9d <main+0x8fd>
mov    -0x30(%rbp),%rax
mov    -0xd8(%rbp),%ecx
imul   -0x1c(%rbp),%ecx
add    -0xd0(%rbp),%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x38(%rbp),%rax
mov    -0xd4(%rbp),%ecx
imul   -0x24(%rbp),%ecx
add    -0xd8(%rbp),%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm2
movss  -0xcc(%rbp),%xmm1
ff
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0xcc(%rbp)
ff
mov    -0xd8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd8(%rbp)
jmp    1b2a <main+0x88a>
mov    -0x40(%rbp),%rax
mov    -0xd4(%rbp),%ecx
imul   -0x1c(%rbp),%ecx
add    -0xd0(%rbp),%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm1
movss  -0xcc(%rbp),%xmm0
ff
subss  %xmm1,%xmm0
movss  %xmm0,-0xcc(%rbp)
ff
movss  -0xcc(%rbp),%xmm0
ff
mulss  -0xcc(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm1
movsd  0x42f(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1c01 <main+0x961>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1c2f <main+0x98f>
movss  -0xcc(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
mov    -0x40(%rbp),%rax
movslq -0xd0(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0x6e9(%rip),%rdi
mov    $0x2,%al
call   10e0 <printf@plt>
jmp    1c34 <main+0x994>
mov    -0xd4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd4(%rbp)
jmp    1b06 <main+0x866>
jmp    1c4d <main+0x9ad>
mov    -0xd0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd0(%rbp)
jmp    1aed <main+0x84d>
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
imul   -0x20(%rbp),%edx
lea    0x6af(%rip),%rdi
mov    $0x0,%al
call   10e0 <printf@plt>
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    $0xb8,%rsp
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   11a0 <atoi@plt>
mov    %eax,-0x30(%rbp)
mov    %rax,%r14
mov    %rax,-0x50(%rbp)
mov    0x10(%rbx),%rdi
call   11a0 <atoi@plt>
mov    %eax,%r12d
mov    %eax,-0x34(%rbp)
mov    0x18(%rbx),%rdi
call   11a0 <atoi@plt>
mov    %eax,%r13d
mov    %eax,-0x40(%rbp)
lea    0x0(,%r14,4),%ebx
mov    %ebx,%edi
imul   %eax,%edi
mov    %edi,-0x38(%rbp)
call   1150 <malloc@plt>
mov    %rax,%r15
mov    %r12d,%eax
imul   %r13d,%eax
mov    %rax,-0x58(%rbp)
lea    0x0(,%rax,4),%edi
mov    %edi,-0x80(%rbp)
call   1150 <malloc@plt>
mov    %rax,-0x60(%rbp)
imul   %r12d,%ebx
mov    %ebx,-0xb0(%rbp)
mov    %ebx,%edi
call   1150 <malloc@plt>
mov    %rax,%r14
imul   -0x50(%rbp),%r13d
test   %r13d,%r13d
jle    1393 <main+0xd3>
mov    %r13d,%r13d
mov    0x2c72(%rip),%r12
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   11d0 <rand@plt>
xorps  %xmm1,%xmm1
cvtsi2ssq (%r12),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,(%r15,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1370 <main+0xb0>
mov    %r15,-0x50(%rbp)
mov    -0x58(%rbp),%rax
test   %eax,%eax
mov    -0x60(%rbp),%r13
jle    13d3 <main+0x113>
mov    %eax,%r12d
mov    0x2c2b(%rip),%r15
xor    %ebx,%ebx
nop
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    13b0 <main+0xf0>
lea    -0x3c(%rbp),%rdx
xor    %edi,%edi
xor    %esi,%esi
call   10f0 <clGetPlatformIDs@plt>
mov    %eax,-0x2c(%rbp)
lea    0xc4e(%rip),%rsi
lea    0xc59(%rip),%rdx
mov    %eax,%edi
mov    $0xc2,%ecx
call   1130 <check_error@plt>
mov    -0x3c(%rbp),%eax
test   %rax,%rax
je     1cb6 <main+0x9f6>
mov    %rsp,-0xb8(%rbp)
mov    %rsp,%r12
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
mov    -0x3c(%rbp),%edi
mov    %r12,%rsi
xor    %edx,%edx
call   10f0 <clGetPlatformIDs@plt>
mov    %eax,-0x2c(%rbp)
lea    0xcc9(%rip),%rsi
lea    0xc07(%rip),%rdx
mov    %eax,%edi
mov    $0xcf,%ecx
call   1130 <check_error@plt>
cmpl   $0x0,-0x3c(%rbp)
jle    14b0 <main+0x1f0>
mov    $0x1,%ebx
lea    -0x88(%rbp),%r13
mov    0x2b48(%rip),%r15
nopl   0x0(%rax,%rax,1)
mov    -0x4(%r12,%rbx,4),%edi
mov    0x2b4c(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edx
mov    %r13,%rcx
xor    %r8d,%r8d
call   10c0 <clGetDeviceIDs@plt>
mov    %eax,-0x2c(%rbp)
cmp    (%r15),%eax
je     14a6 <main+0x1e6>
lea    0x1(%rbx),%rax
movslq -0x3c(%rbp),%rcx
cmp    %rcx,%rbx
mov    %rax,%rbx
jl     1470 <main+0x1b0>
cmpq   $0x0,-0x88(%rbp)
jne    14bc <main+0x1fc>
lea    0xe8a(%rip),%rdi
call   1080 <puts@plt>
xor    %eax,%eax
mov    %rax,-0x58(%rbp)
lea    -0x88(%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,%r12d
mov    -0x2c(%rbp),%edi
lea    0xc2f(%rip),%rsi
lea    0xb55(%rip),%rbx
mov    %rbx,%rdx
mov    $0xf9,%ecx
call   1130 <check_error@plt>
mov    -0x88(%rbp),%rsi
mov    %r12d,%edi
xor    %edx,%edx
mov    %r13,%rcx
call   10e0 <clCreateCommandQueue@plt>
mov    %eax,-0x64(%rbp)
mov    -0x2c(%rbp),%edi
lea    0xc0b(%rip),%rsi
mov    %rbx,%rdx
mov    %rbx,%r15
mov    $0x108,%ecx
call   1130 <check_error@plt>
lea    0xc0b(%rip),%rdi
call   11b0 <getKernelSource@plt>
mov    %rax,-0xc0(%rbp)
lea    -0xc0(%rbp),%rdx
mov    %r12d,%edi
mov    $0x1,%esi
xor    %ecx,%ecx
mov    %r13,%r8
call   1070 <clCreateProgramWithSource@plt>
mov    %eax,%ebx
mov    -0x2c(%rbp),%edi
lea    0xbfa(%rip),%rsi
mov    %r15,%rdx
mov    %r15,%r13
mov    $0x11d,%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    0xbea(%rip),%rsi
mov    %eax,%edi
mov    %r15,%rdx
mov    $0x130,%ecx
call   1130 <check_error@plt>
lea    0xbe2(%rip),%rsi
mov    %ebx,-0x90(%rbp)
mov    %ebx,%edi
lea    -0x2c(%rbp),%rbx
mov    %rbx,%rdx
call   1190 <clCreateKernel@plt>
mov    %eax,%r15d
mov    -0x2c(%rbp),%edi
lea    0xbc6(%rip),%rsi
mov    %r13,%rdx
mov    $0x13e,%ecx
call   1130 <check_error@plt>
mov    0x29d5(%rip),%rax
mov    (%rax),%esi
mov    %r12d,%edi
mov    -0x38(%rbp),%edx
xor    %ecx,%ecx
mov    %rbx,%r8
call   10a0 <clCreateBuffer@plt>
mov    %eax,%r13d
mov    %eax,-0x6c(%rbp)
mov    -0x2c(%rbp),%edi
lea    0xba0(%rip),%rsi
lea    0xa3e(%rip),%rdx
mov    $0x153,%ecx
call   1130 <check_error@plt>
mov    0x299b(%rip),%rax
mov    (%rax),%esi
mov    %r12d,%edi
mov    -0x80(%rbp),%edx
xor    %ecx,%ecx
mov    %rbx,%r8
call   10a0 <clCreateBuffer@plt>
mov    %eax,-0x8c(%rbp)
mov    %eax,-0x68(%rbp)
mov    -0x2c(%rbp),%edi
lea    0xb77(%rip),%rsi
lea    0xa01(%rip),%rdx
mov    $0x15a,%ecx
call   1130 <check_error@plt>
mov    0x2986(%rip),%rax
mov    (%rax),%esi
mov    %r12d,-0x94(%rbp)
mov    %r12d,%edi
mov    -0xb0(%rbp),%edx
xor    %ecx,%ecx
mov    %rbx,%r8
call   10a0 <clCreateBuffer@plt>
mov    %eax,-0x44(%rbp)
mov    -0x2c(%rbp),%edi
lea    0xb4a(%rip),%rsi
lea    0x9c0(%rip),%rdx
mov    %rdx,%rbx
mov    $0x161,%ecx
call   1130 <check_error@plt>
mov    0x294a(%rip),%rax
mov    (%rax),%edx
sub    $0x20,%rsp
xorps  %xmm0,%xmm0
movups %xmm0,0x8(%rsp)
movl   $0x0,(%rsp)
mov    -0x64(%rbp),%r12d
mov    %r12d,%edi
mov    %r13d,%esi
xor    %ecx,%ecx
mov    -0x38(%rbp),%r8d
mov    -0x50(%rbp),%r9
call   11e0 <clEnqueueWriteBuffer@plt>
add    $0x20,%rsp
mov    %eax,-0x2c(%rbp)
lea    0xb07(%rip),%rsi
mov    %eax,%edi
mov    %rbx,%rdx
mov    $0x17b,%ecx
call   1130 <check_error@plt>
mov    0x28f8(%rip),%rax
mov    (%rax),%edx
sub    $0x20,%rsp
xorps  %xmm0,%xmm0
movups %xmm0,0x8(%rsp)
movl   $0x0,(%rsp)
mov    %r12d,%edi
mov    -0x8c(%rbp),%esi
xor    %ecx,%ecx
mov    -0x80(%rbp),%r8d
mov    -0x60(%rbp),%r9
call   11e0 <clEnqueueWriteBuffer@plt>
add    $0x20,%rsp
mov    %eax,-0x2c(%rbp)
lea    0xac9(%rip),%rsi
mov    %eax,%edi
mov    %rbx,%rdx
mov    $0x187,%ecx
call   1130 <check_error@plt>
lea    -0x6c(%rbp),%rcx
mov    %r15d,%edi
xor    %esi,%esi
mov    $0x4,%edx
call   11c0 <clSetKernelArg@plt>
mov    %eax,-0x2c(%rbp)
lea    -0x68(%rbp),%rcx
mov    %r15d,%edi
mov    $0x1,%esi
mov    $0x4,%edx
call   11c0 <clSetKernelArg@plt>
or     %eax,-0x2c(%rbp)
lea    -0x44(%rbp),%rcx
mov    %r15d,%edi
mov    $0x2,%esi
mov    $0x4,%edx
call   11c0 <clSetKernelArg@plt>
or     %eax,-0x2c(%rbp)
lea    -0x30(%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    -0x40(%rbp),%rcx
mov    %r15d,%edi
mov    $0x5,%esi
mov    $0x4,%edx
call   11c0 <clSetKernelArg@plt>
or     -0x2c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
lea    0xa30(%rip),%rsi
mov    %eax,%edi
mov    %rbx,%rdx
mov    $0x1ae,%ecx
call   1130 <check_error@plt>
mov    -0x30(%rbp),%esi
mov    -0x34(%rbp),%edx
movd   %edx,%xmm0
movd   %esi,%xmm1
punpckldq %xmm0,%xmm1
movdqa %xmm1,%xmm0
psrad  $0x1f,%xmm0
psrld  $0x1d,%xmm0
paddd  %xmm1,%xmm0
psrad  $0x3,%xmm0
pxor   %xmm1,%xmm1
pcmpgtd %xmm0,%xmm1
punpckldq %xmm1,%xmm0
movdqa %xmm0,-0xe0(%rbp)
ff
movapd 0x7f5(%rip),%xmm0
movapd %xmm0,-0xd0(%rbp)
ff
mov    -0x40(%rbp),%ecx
lea    0x9e3(%rip),%rdi
mov    $0x5,%r8d
xor    %eax,%eax
call   1100 <printf@plt>
xor    %eax,%eax
call   1110 <wtime@plt>
movsd  %xmm0,-0x80(%rbp)
sub    $0x20,%rsp
xorpd  %xmm0,%xmm0
movupd %xmm0,0x8(%rsp)
movl   $0x0,(%rsp)
lea    -0xe0(%rbp),%r13
lea    -0xd0(%rbp),%r9
mov    %r12d,%ebx
mov    %r12d,%edi
mov    %r15d,%esi
mov    $0x2,%edx
xor    %ecx,%ecx
mov    %r13,%r8
mov    %r9,%r12
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    %r13,%r8
mov    %r12,%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    %r13,%r8
mov    %r12,%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    %r13,%r8
mov    %r12,%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,-0x38(%rbp)
mov    %r15d,%esi
mov    $0x2,%edx
xor    %ecx,%ecx
mov    %r13,%r8
mov    %r12,%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  -0x80(%rbp),%xmm0
movapd %xmm0,-0x80(%rbp)
mov    -0x2c(%rbp),%edi
lea    0x8ae(%rip),%rsi
lea    0x68b(%rip),%r15
mov    %r15,%rdx
mov    $0x1dd,%ecx
call   1130 <check_error@plt>
movslq -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
imul   %rax,%rcx
movslq -0x40(%rbp),%rax
imul   %rcx,%rax
add    %rax,%rax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
unpcklpd -0x80(%rbp),%xmm0
divpd  0x608(%rip),%xmm0
movapd %xmm0,-0x80(%rbp)
unpckhpd %xmm0,%xmm0
movapd %xmm0,-0xb0(%rbp)
ff
lea    0x873(%rip),%rdi
mov    $0x1,%al
call   1100 <printf@plt>
movapd -0x80(%rbp),%xmm0
divsd  -0xb0(%rbp),%xmm0
ff
lea    0x878(%rip),%rdi
mov    $0x1,%al
call   1100 <printf@plt>
mov    -0x44(%rbp),%esi
mov    0x25ac(%rip),%rax
mov    (%rax),%edx
mov    -0x30(%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    %r14,%r9
call   1160 <clEnqueueReadBuffer@plt>
add    $0x20,%rsp
mov    %eax,-0x2c(%rbp)
lea    0x837(%rip),%rsi
mov    %eax,%edi
mov    %r15,%rdx
mov    $0x1f9,%ecx
call   1130 <check_error@plt>
mov    -0x2c(%rbp),%eax
mov    0x251d(%rip),%rcx
cmp    (%rcx),%eax
je     1aa3 <main+0x7e3>
lea    0x880(%rip),%rdi
call   1080 <puts@plt>
mov    $0xa,%edi
call   1050 <putchar@plt>
lea    0x84f(%rip),%rdi
call   1080 <puts@plt>
mov    -0x30(%rbp),%eax
mov    -0x34(%rbp),%edx
test   %eax,%eax
jle    1c3d <main+0x97d>
mov    -0x60(%rbp),%rcx
add    $0x4,%rcx
mov    %rcx,-0x80(%rbp)
xor    %r15d,%r15d
movsd  0x552(%rip),%xmm2
xor    %r13d,%r13d
xor    %ecx,%ecx
mov    %rcx,-0x58(%rbp)
jmp    1b07 <main+0x847>
nopl   0x0(%rax)
mov    -0x30(%rbp),%eax
add    $0x1,%r13
movslq %eax,%rcx
add    $0x4,%r15
cmp    %rcx,%r13
jge    1c3d <main+0x97d>
test   %edx,%edx
jle    1af3 <main+0x833>
xor    %r12d,%r12d
mov    -0x50(%rbp),%r11
jmp    1b54 <main+0x894>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cvtss2sd %xmm0,%xmm0
movss  (%r14,%r13,4),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0x78f(%rip),%rdi
mov    $0x2,%al
call   1100 <printf@plt>
movsd  0x4ec(%rip),%xmm2
mov    -0x50(%rbp),%r11
mov    -0x34(%rbp),%edx
add    $0x1,%r12d
cmp    %edx,%r12d
jge    1af0 <main+0x830>
mov    -0x40(%rbp),%r9d
movslq -0x30(%rbp),%r8
test   %r9d,%r9d
jle    1b70 <main+0x8b0>
cmp    $0x1,%r9d
jne    1b80 <main+0x8c0>
xorpd  %xmm0,%xmm0
xor    %esi,%esi
jmp    1bdb <main+0x91b>
nop
xorpd  %xmm0,%xmm0
jmp    1c08 <main+0x948>
nopl   0x0(%rax)
mov    %r9d,%edi
and    $0xfffffffe,%edi
lea    (%r8,%r13,1),%r10
lea    0x0(,%r8,8),%rax
mov    %r9d,%ecx
imul   %r12d,%ecx
movslq %ecx,%rcx
mov    -0x80(%rbp),%rsi
lea    (%rsi,%rcx,4),%rcx
xorpd  %xmm0,%xmm0
mov    %r11,%rbx
xor    %esi,%esi
nopl   (%rax)
movss  (%rbx,%r15,1),%xmm1
mulss  -0x4(%rcx,%rsi,4),%xmm1
addss  %xmm0,%xmm1
movss  (%rbx,%r10,4),%xmm0
mulss  (%rcx,%rsi,4),%xmm0
addss  %xmm1,%xmm0
add    $0x2,%rsi
add    %rax,%rbx
cmp    %rsi,%rdi
jne    1bb0 <main+0x8f0>
test   $0x1,%r9b
je     1c08 <main+0x948>
imul   %r12d,%r9d
movslq %r9d,%rax
mov    %rsi,%rcx
imul   %r8,%rcx
add    %r13,%rcx
movss  (%r11,%rcx,4),%xmm1
add    %rsi,%rax
mov    -0x60(%rbp),%rcx
mulss  (%rcx,%rax,4),%xmm1
addss  %xmm1,%xmm0
imul   %r12d,%r8d
movslq %r8d,%rax
add    %r13,%rax
subss  (%r14,%rax,4),%xmm0
movaps %xmm0,%xmm1
mulss  %xmm0,%xmm1
cvtss2sd %xmm1,%xmm1
ucomisd %xmm1,%xmm2
jbe    1b20 <main+0x860>
mov    -0x58(%rbp),%rax
add    $0x1,%eax
mov    %rax,-0x58(%rbp)
jmp    1b4b <main+0x88b>
imul   %eax,%edx
lea    0x68d(%rip),%rdi
xor    %r13d,%r13d
mov    -0x58(%rbp),%rsi
xor    %eax,%eax
call   1100 <printf@plt>
mov    -0x6c(%rbp),%edi
call   1180 <clReleaseMemObject@plt>
mov    -0x68(%rbp),%edi
call   1180 <clReleaseMemObject@plt>
mov    -0x44(%rbp),%edi
call   1180 <clReleaseMemObject@plt>
mov    -0x94(%rbp),%edi
call   1170 <clReleaseContext@plt>
mov    -0x64(%rbp),%edi
call   1140 <clReleaseCommandQueue@plt>
mov    -0x90(%rbp),%edi
call   10b0 <clReleaseProgram@plt>
mov    -0x38(%rbp),%edi
call   1090 <clReleaseKernel@plt>
mov    -0x50(%rbp),%rdi
call   1040 <free@plt>
mov    -0x60(%rbp),%rdi
call   1040 <free@plt>
mov    %r14,%rdi
call   1040 <free@plt>
mov    -0xb8(%rbp),%rsp
jmp    1ccc <main+0xa0c>
lea    0x695(%rip),%rdi
call   1080 <puts@plt>
mov    0x22f7(%rip),%rax
mov    (%rax),%r13d
mov    %r13d,%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 = [187 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/bench/gemm_block8x8_thread8x8.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 = [32 x i8] c"gemm_block8x8_thread8x8_preG.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 = [70 x i8] c"Starting my SGEMM M = %d N = %d K = %d running...(repeated %d times)\0A\00"
@.str.19 = [29 x i8] c"Waiting for kernel to finish\00"
@.str.20 = [32 x i8] c"\0AThe kernel ran in %lf seconds\0A\00"
@.str.21 = [14 x i8] c"%.1lf GFLOPS\0A\00"
@.str.22 = [19 x i8] c"Copying d_c to h_c\00"
@.str.23 = [36 x i8] c"Error: Failed to read output array\0A\00"
@.str.24 = [2 x i8] c"\0A\00"
@.str.25 = [28 x i8] c"Verifing the GPU result...\0A\00"
@.str.26 = [16 x i8] c"temp %f h_c %f\0A\00"
@.str.27 = [47 x i8] c"C = A * B: %d out of %d results were correct.\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 [2 x i64]
%28 = alloca [2 x i64]
%29 = alloca double
%30 = alloca i32
%31 = alloca double
%32 = alloca float
%33 = alloca i32
%34 = alloca i32
%35 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 1
%38 = load i8*, i8** %37
%39 = call i32 @atoi(i8* %38)
store i32 %39, i32* %8
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 2
%42 = load i8*, i8** %41
%43 = call i32 @atoi(i8* %42)
store i32 %43, i32* %9
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 3
%46 = load i8*, i8** %45
%47 = call i32 @atoi(i8* %46)
store i32 %47, i32* %10
%48 = load i32, i32* %8
%49 = load i32, i32* %10
%50 = mul nsw i32 %48, %49
%51 = sext i32 %50 to i64
%52 = mul i64 %51, 4
%53 = trunc i64 %52 to i32
%54 = call float* @malloc(i32 %53)
store float* %54, float** %11
%55 = load i32, i32* %10
%56 = load i32, i32* %9
%57 = mul nsw i32 %55, %56
%58 = sext i32 %57 to i64
%59 = mul i64 %58, 4
%60 = trunc i64 %59 to i32
%61 = call float* @malloc(i32 %60)
store float* %61, float** %12
%62 = load i32, i32* %8
%63 = load i32, i32* %9
%64 = mul nsw i32 %62, %63
%65 = sext i32 %64 to i64
%66 = mul i64 %65, 4
%67 = trunc i64 %66 to i32
%68 = call float* @malloc(i32 %67)
store float* %68, float** %13
store i32 0, i32* %22
store i32 0, i32* %22
br label %69
69: ; preds = %84, %2
%70 = load i32, i32* %22
%71 = load i32, i32* %8
%72 = load i32, i32* %10
%73 = mul nsw i32 %71, %72
%74 = icmp slt i32 %70, %73
br i1 %74, label %75, label %87
75: ; preds = %69
%76 = call float (...) @rand()
%77 = load i64, i64* @RAND_MAX
%78 = sitofp i64 %77 to float
%79 = fdiv float %76, %78
%80 = load float*, float** %11
%81 = load i32, i32* %22
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds float, float* %80, i64 %82
store float %79, float* %83
br label %84
84: ; preds = %75
%85 = load i32, i32* %22
%86 = add nsw i32 %85, 1
store i32 %86, i32* %22
br label %69
87: ; preds = %69
store i32 0, i32* %22
br label %88
88: ; preds = %103, %87
%89 = load i32, i32* %22
%90 = load i32, i32* %9
%91 = load i32, i32* %10
%92 = mul nsw i32 %90, %91
%93 = icmp slt i32 %89, %92
br i1 %93, label %94, label %106
94: ; preds = %88
%95 = call float (...) @rand()
%96 = load i64, i64* @RAND_MAX
%97 = sitofp i64 %96 to float
%98 = fdiv float %95, %97
%99 = load float*, float** %12
%100 = load i32, i32* %22
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds float, float* %99, i64 %101
store float %98, float* %102
br label %103
103: ; preds = %94
%104 = load i32, i32* %22
%105 = add nsw i32 %104, 1
store i32 %105, i32* %22
br label %88
106: ; preds = %88
%107 = call i32 @clGetPlatformIDs(i32 0, i32* null, i32* %23)
store i32 %107, i32* %6
%108 = load i32, i32* %6
%109 = call i32 @check_error(i32 %108, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([187 x i8], [187 x i8]* @.str.1, i64 0, i64 0), i32 194)
%110 = load i32, i32* %23
%111 = icmp eq i32 %110, 0
br i1 %111, label %112, label %115
112: ; preds = %106
%113 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%114 = load i32, i32* @EXIT_FAILURE
store i32 %114, i32* %3
br label %436
115: ; preds = %106
%116 = load i32, i32* %23
%117 = zext i32 %116 to i64
%118 = call i8* @llvm.stacksave()
store i8* %118, i8** %24
%119 = alloca i32, i64 %117
store i64 %117, i64* %25
%120 = load i32, i32* %23
%121 = call i32 @clGetPlatformIDs(i32 %120, i32* %119, i32* null)
store i32 %121, i32* %6
%122 = load i32, i32* %6
%123 = call i32 @check_error(i32 %122, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([187 x i8], [187 x i8]* @.str.1, i64 0, i64 0), i32 207)
store i32 0, i32* %22
br label %124
124: ; preds = %140, %115
%125 = load i32, i32* %22
%126 = load i32, i32* %23
%127 = icmp slt i32 %125, %126
br i1 %127, label %128, label %143
128: ; preds = %124
%129 = load i32, i32* %22
%130 = sext i32 %129 to i64
%131 = getelementptr inbounds i32, i32* %119, i64 %130
%132 = load i32, i32* %131
%133 = load i32, i32* @CL_DEVICE_TYPE_DEFAULT
%134 = call i32 @clGetDeviceIDs(i32 %132, i32 %133, i32 1, i32** %14, i32* null)
store i32 %134, i32* %6
%135 = load i32, i32* %6
%136 = load i32, i32* @CL_SUCCESS
%137 = icmp eq i32 %135, %136
br i1 %137, label %138, label %139
138: ; preds = %128
br label %143
139: ; preds = %128
br label %140
140: ; preds = %139
%141 = load i32, i32* %22
%142 = add nsw i32 %141, 1
store i32 %142, i32* %22
br label %124
143: ; preds = %138, %124
%144 = load i32*, i32** %14
%145 = icmp eq i32* %144, null
br i1 %145, label %146, label %148
146: ; preds = %143
%147 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
br label %148
148: ; preds = %146, %143
%149 = call i32 @clCreateContext(i32 0, i32 1, i32** %14, i32* null, i32* null, i32* %6)
store i32 %149, i32* %15
%150 = load i32, i32* %6
%151 = call i32 @check_error(i32 %150, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([187 x i8], [187 x i8]* @.str.1, i64 0, i64 0), i32 249)
%152 = load i32, i32* %15
%153 = load i32*, i32** %14
%154 = call i32 @clCreateCommandQueue(i32 %152, i32* %153, i32 0, i32* %6)
store i32 %154, i32* %16
%155 = load i32, i32* %6
%156 = call i32 @check_error(i32 %155, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([187 x i8], [187 x i8]* @.str.1, i64 0, i64 0), i32 264)
%157 = call i8* @getKernelSource(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0))
store i8* %157, i8** %26
%158 = load i32, i32* %15
%159 = call i32 @clCreateProgramWithSource(i32 %158, i32 1, i8** %26, i32* null, i32* %6)
store i32 %159, i32* %17
%160 = load i32, i32* %6
%161 = call i32 @check_error(i32 %160, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([187 x i8], [187 x i8]* @.str.1, i64 0, i64 0), i32 285)
%162 = load i32, i32* %17
%163 = call i32 @clBuildProgram(i32 %162, i32 0, i32* null, i32* null, i32* null, i32* null)
store i32 %163, i32* %6
%164 = load i32, i32* %6
%165 = call i32 @check_error(i32 %164, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([187 x i8], [187 x i8]* @.str.1, i64 0, i64 0), i32 304)
%166 = load i32, i32* %17
%167 = call i32 @clCreateKernel(i32 %166, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), i32* %6)
store i32 %167, i32* %18
%168 = load i32, i32* %6
%169 = call i32 @check_error(i32 %168, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([187 x i8], [187 x i8]* @.str.1, i64 0, i64 0), i32 318)
%170 = load i32, i32* %15
%171 = load i32, i32* @CL_MEM_READ_ONLY
%172 = load i32, i32* %8
%173 = sext i32 %172 to i64
%174 = mul i64 4, %173
%175 = load i32, i32* %10
%176 = sext i32 %175 to i64
%177 = mul i64 %174, %176
%178 = trunc i64 %177 to i32
%179 = call i32 @clCreateBuffer(i32 %170, i32 %171, i32 %178, i32* null, i32* %6)
store i32 %179, i32* %19
%180 = load i32, i32* %6
%181 = call i32 @check_error(i32 %180, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([187 x i8], [187 x i8]* @.str.1, i64 0, i64 0), i32 339)
%182 = load i32, i32* %15
%183 = load i32, i32* @CL_MEM_READ_ONLY
%184 = load i32, i32* %10
%185 = sext i32 %184 to i64
%186 = mul i64 4, %185
%187 = load i32, i32* %9
%188 = sext i32 %187 to i64
%189 = mul i64 %186, %188
%190 = trunc i64 %189 to i32
%191 = call i32 @clCreateBuffer(i32 %182, i32 %183, i32 %190, i32* null, i32* %6)
store i32 %191, i32* %20
%192 = load i32, i32* %6
%193 = call i32 @check_error(i32 %192, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([187 x i8], [187 x i8]* @.str.1, i64 0, i64 0), i32 346)
%194 = load i32, i32* %15
%195 = load i32, i32* @CL_MEM_READ_WRITE
%196 = load i32, i32* %8
%197 = sext i32 %196 to i64
%198 = mul i64 4, %197
%199 = load i32, i32* %9
%200 = sext i32 %199 to i64
%201 = mul i64 %198, %200
%202 = trunc i64 %201 to i32
%203 = call i32 @clCreateBuffer(i32 %194, i32 %195, i32 %202, i32* null, i32* %6)
store i32 %203, i32* %21
%204 = load i32, i32* %6
%205 = call i32 @check_error(i32 %204, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([187 x i8], [187 x i8]* @.str.1, i64 0, i64 0), i32 353)
%206 = load i32, i32* %16
%207 = load i32, i32* %19
%208 = load i32, i32* @CL_TRUE
%209 = load i32, i32* %8
%210 = sext i32 %209 to i64
%211 = mul i64 4, %210
%212 = load i32, i32* %10
%213 = sext i32 %212 to i64
%214 = mul i64 %211, %213
%215 = trunc i64 %214 to i32
%216 = load float*, float** %11
%217 = call i32 @clEnqueueWriteBuffer(i32 %206, i32 %207, i32 %208, i32 0, i32 %215, float* %216, i32 0, i32* null, i32* null)
store i32 %217, i32* %6
%218 = load i32, i32* %6
%219 = call i32 @check_error(i32 %218, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.15, i64 0, i64 0), i8* getelementptr inbounds ([187 x i8], [187 x i8]* @.str.1, i64 0, i64 0), i32 379)
%220 = load i32, i32* %16
%221 = load i32, i32* %20
%222 = load i32, i32* @CL_TRUE
%223 = load i32, i32* %10
%224 = sext i32 %223 to i64
%225 = mul i64 4, %224
%226 = load i32, i32* %9
%227 = sext i32 %226 to i64
%228 = mul i64 %225, %227
%229 = trunc i64 %228 to i32
%230 = load float*, float** %12
%231 = call i32 @clEnqueueWriteBuffer(i32 %220, i32 %221, i32 %222, i32 0, i32 %229, float* %230, i32 0, i32* null, i32* null)
store i32 %231, i32* %6
%232 = load i32, i32* %6
%233 = call i32 @check_error(i32 %232, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([187 x i8], [187 x i8]* @.str.1, i64 0, i64 0), i32 391)
%234 = load i32, i32* %18
%235 = call i32 @clSetKernelArg(i32 %234, i32 0, i32 4, i32* %19)
store i32 %235, i32* %6
%236 = load i32, i32* %18
%237 = call i32 @clSetKernelArg(i32 %236, i32 1, i32 4, i32* %20)
%238 = load i32, i32* %6
%239 = or i32 %238, %237
store i32 %239, i32* %6
%240 = load i32, i32* %18
%241 = call i32 @clSetKernelArg(i32 %240, i32 2, i32 4, i32* %21)
%242 = load i32, i32* %6
%243 = or i32 %242, %241
store i32 %243, i32* %6
%244 = load i32, i32* %18
%245 = call i32 @clSetKernelArg(i32 %244, i32 3, i32 4, i32* %8)
%246 = load i32, i32* %6
%247 = or i32 %246, %245
store i32 %247, i32* %6
%248 = load i32, i32* %18
%249 = call i32 @clSetKernelArg(i32 %248, i32 4, i32 4, i32* %9)
%250 = load i32, i32* %6
%251 = or i32 %250, %249
store i32 %251, i32* %6
%252 = load i32, i32* %18
%253 = call i32 @clSetKernelArg(i32 %252, i32 5, i32 4, i32* %10)
%254 = load i32, i32* %6
%255 = or i32 %254, %253
store i32 %255, i32* %6
%256 = load i32, i32* %6
%257 = call i32 @check_error(i32 %256, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.17, i64 0, i64 0), i8* getelementptr inbounds ([187 x i8], [187 x i8]* @.str.1, i64 0, i64 0), i32 430)
%258 = getelementptr inbounds [2 x i64], [2 x i64]* %27, i64 0, i64 0
%259 = load i32, i32* %8
%260 = sdiv i32 %259, 8
%261 = sext i32 %260 to i64
store i64 %261, i64* %258
%262 = getelementptr inbounds i64, i64* %258, i64 1
%263 = load i32, i32* %9
%264 = sdiv i32 %263, 8
%265 = sext i32 %264 to i64
store i64 %265, i64* %262
%266 = bitcast [2 x i64]* %28 to i8*
%267 = load i32, i32* %8
%268 = load i32, i32* %9
%269 = load i32, i32* %10
%270 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.18, i64 0, i64 0), i32 %267, i32 %268, i32 %269, i32 5)
%271 = call double (...) @wtime()
store double %271, double* %29
store i32 0, i32* %30
br label %272
272: ; preds = %283, %148
%273 = load i32, i32* %30
%274 = icmp slt i32 %273, 5
br i1 %274, label %275, label %286
275: ; preds = %272
%276 = load i32, i32* %16
%277 = load i32, i32* %18
%278 = getelementptr inbounds [2 x i64], [2 x i64]* %27, i64 0, i64 0
%279 = getelementptr inbounds [2 x i64], [2 x i64]* %28, i64 0, i64 0
%280 = call i32 @clEnqueueNDRangeKernel(i32 %276, i32 %277, i32 2, i32* null, i64* %278, i64* %279, i32 0, i32* null, i32* null)
store i32 %280, i32* %6
%281 = load i32, i32* %16
%282 = call i32 @clFinish(i32 %281)
store i32 %282, i32* %6
br label %283
283: ; preds = %275
%284 = load i32, i32* %30
%285 = add nsw i32 %284, 1
store i32 %285, i32* %30
br label %272
286: ; preds = %272
%287 = call double (...) @wtime()
%288 = load double, double* %29
%289 = fsub double %287, %288
%290 = fdiv double %289, 5.000000e+00
store double %290, double* %29
%291 = load i32, i32* %6
%292 = call i32 @check_error(i32 %291, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.19, i64 0, i64 0), i8* getelementptr inbounds ([187 x i8], [187 x i8]* @.str.1, i64 0, i64 0), i32 477)
%293 = load i32, i32* %8
%294 = sext i32 %293 to i64
%295 = load i32, i32* %9
%296 = sext i32 %295 to i64
%297 = mul nsw i64 %294, %296
%298 = load i32, i32* %10
%299 = sext i32 %298 to i64
%300 = mul nsw i64 %297, %299
%301 = mul nsw i64 %300, 2
%302 = sitofp i64 %301 to double
%303 = fmul double %302, 1.000000e+00
%304 = fdiv double %303, 1.000000e+09
store double %304, double* %31
%305 = load double, double* %29
%306 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.20, i64 0, i64 0), double %305)
%307 = load double, double* %31
%308 = load double, double* %29
%309 = fdiv double %307, %308
%310 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.21, i64 0, i64 0), double %309)
%311 = load i32, i32* %16
%312 = load i32, i32* %21
%313 = load i32, i32* @CL_TRUE
%314 = load i32, i32* %8
%315 = sext i32 %314 to i64
%316 = mul i64 4, %315
%317 = load i32, i32* %9
%318 = sext i32 %317 to i64
%319 = mul i64 %316, %318
%320 = trunc i64 %319 to i32
%321 = load float*, float** %13
%322 = call i32 @clEnqueueReadBuffer(i32 %311, i32 %312, i32 %313, i32 0, i32 %320, float* %321, i32 0, i32* null, i32* null)
store i32 %322, i32* %6
%323 = load i32, i32* %6
%324 = call i32 @check_error(i32 %323, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.22, i64 0, i64 0), i8* getelementptr inbounds ([187 x i8], [187 x i8]* @.str.1, i64 0, i64 0), i32 505)
%325 = load i32, i32* %6
%326 = load i32, i32* @CL_SUCCESS
%327 = icmp ne i32 %325, %326
br i1 %327, label %328, label %330
328: ; preds = %286
%329 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.23, i64 0, i64 0))
br label %330
330: ; preds = %328, %286
%331 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.24, i64 0, i64 0))
store i32 0, i32* %7
store float 0.000000e+00, float* %32
%332 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.25, i64 0, i64 0))
store i32 0, i32* %33
br label %333
333: ; preds = %406, %330
%334 = load i32, i32* %33
%335 = load i32, i32* %8
%336 = icmp slt i32 %334, %335
br i1 %336, label %337, label %409
337: ; preds = %333
store i32 0, i32* %34
br label %338
338: ; preds = %402, %337
%339 = load i32, i32* %34
%340 = load i32, i32* %9
%341 = icmp slt i32 %339, %340
br i1 %341, label %342, label %405
342: ; preds = %338
store float 0.000000e+00, float* %32
store i32 0, i32* %35
br label %343
343: ; preds = %368, %342
%344 = load i32, i32* %35
%345 = load i32, i32* %10
%346 = icmp slt i32 %344, %345
br i1 %346, label %347, label %371
347: ; preds = %343
%348 = load float*, float** %11
%349 = load i32, i32* %35
%350 = load i32, i32* %8
%351 = mul nsw i32 %349, %350
%352 = load i32, i32* %33
%353 = add nsw i32 %351, %352
%354 = sext i32 %353 to i64
%355 = getelementptr inbounds float, float* %348, i64 %354
%356 = load float, float* %355
%357 = load float*, float** %12
%358 = load i32, i32* %34
%359 = load i32, i32* %10
%360 = mul nsw i32 %358, %359
%361 = load i32, i32* %35
%362 = add nsw i32 %360, %361
%363 = sext i32 %362 to i64
%364 = getelementptr inbounds float, float* %357, i64 %363
%365 = load float, float* %364
%366 = load float, float* %32
%367 = call float @llvm.fmuladd.f32(float %356, float %365, float %366)
store float %367, float* %32
br label %368
368: ; preds = %347
%369 = load i32, i32* %35
%370 = add nsw i32 %369, 1
store i32 %370, i32* %35
br label %343
371: ; preds = %343
%372 = load float*, float** %13
%373 = load i32, i32* %34
%374 = load i32, i32* %8
%375 = mul nsw i32 %373, %374
%376 = load i32, i32* %33
%377 = add nsw i32 %375, %376
%378 = sext i32 %377 to i64
%379 = getelementptr inbounds float, float* %372, i64 %378
%380 = load float, float* %379
%381 = load float, float* %32
%382 = fsub float %381, %380
store float %382, float* %32
%383 = load float, float* %32
%384 = load float, float* %32
%385 = fmul float %383, %384
%386 = fpext float %385 to double
%387 = fcmp olt double %386, 0x3EB0C6F7A0B5ED8D
br i1 %387, label %388, label %391
388: ; preds = %371
%389 = load i32, i32* %7
%390 = add i32 %389, 1
store i32 %390, i32* %7
br label %401
391: ; preds = %371
%392 = load float, float* %32
%393 = fpext float %392 to double
%394 = load float*, float** %13
%395 = load i32, i32* %33
%396 = sext i32 %395 to i64
%397 = getelementptr inbounds float, float* %394, i64 %396
%398 = load float, float* %397
%399 = fpext float %398 to double
%400 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.26, i64 0, i64 0), double %393, double %399)
br label %401
401: ; preds = %391, %388
br label %402
402: ; preds = %401
%403 = load i32, i32* %34
%404 = add nsw i32 %403, 1
store i32 %404, i32* %34
br label %338
405: ; preds = %338
br label %406
406: ; preds = %405
%407 = load i32, i32* %33
%408 = add nsw i32 %407, 1
store i32 %408, i32* %33
br label %333
409: ; preds = %333
%410 = load i32, i32* %7
%411 = load i32, i32* %8
%412 = load i32, i32* %9
%413 = mul nsw i32 %411, %412
%414 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.27, i64 0, i64 0), i32 %410, i32 %413)
%415 = load i32, i32* %19
%416 = call i32 @clReleaseMemObject(i32 %415)
%417 = load i32, i32* %20
%418 = call i32 @clReleaseMemObject(i32 %417)
%419 = load i32, i32* %21
%420 = call i32 @clReleaseMemObject(i32 %419)
%421 = load i32, i32* %15
%422 = call i32 @clReleaseContext(i32 %421)
%423 = load i32, i32* %16
%424 = call i32 @clReleaseCommandQueue(i32 %423)
%425 = load i32, i32* %17
%426 = call i32 @clReleaseProgram(i32 %425)
%427 = load i32, i32* %18
%428 = call i32 @clReleaseKernel(i32 %427)
%429 = load float*, float** %11
%430 = call i32 @free(float* %429)
%431 = load float*, float** %12
%432 = call i32 @free(float* %431)
%433 = load float*, float** %13
%434 = call i32 @free(float* %433)
store i32 0, i32* %3
%435 = load i8*, i8** %24
br label %436
436: ; preds = %409, %112
%437 = load i32, i32* %3
ret i32 %437
}

LLVM IR (-O2):
@RAND_MAX = global i64 0
@.str = [18 x i8] c"Finding platforms\00"
@.str.1 = [187 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/bench/gemm_block8x8_thread8x8.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 = [32 x i8] c"gemm_block8x8_thread8x8_preG.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 = [70 x i8] c"Starting my SGEMM M = %d N = %d K = %d running...(repeated %d times)\0A\00"
@.str.19 = [29 x i8] c"Waiting for kernel to finish\00"
@.str.20 = [32 x i8] c"\0AThe kernel ran in %lf seconds\0A\00"
@.str.21 = [14 x i8] c"%.1lf GFLOPS\0A\00"
@.str.22 = [19 x i8] c"Copying d_c to h_c\00"
@.str.26 = [16 x i8] c"temp %f h_c %f\0A\00"
@.str.27 = [47 x i8] c"C = A * B: %d out of %d results were correct.\0A\00"
@str = [27 x i8] c"Verifing the GPU result...\00"
@str.28 = [35 x i8] c"Error: Failed to read output array\00"
@str.29 = [17 x i8] c"No devices found\00"
@str.30 = [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 ([187 x i8], [187 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.30, i64 0, i64 0))
%75 = load i32, i32* @EXIT_FAILURE
br label %338
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 ([187 x i8], [187 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.29, 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 ([187 x i8], [187 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 ([187 x i8], [187 x i8]* @.str.1, i64 0, i64 0), i32 264)
%111 = bitcast i8** %12 to i8*
%112 = call i8* @getKernelSource(i8* getelementptr inbounds ([32 x i8], [32 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 ([187 x i8], [187 x i8]* @.str.1, i64 0, i64 0), i32 285)
%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 ([187 x i8], [187 x i8]* @.str.1, i64 0, i64 0), i32 304)
%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 ([187 x i8], [187 x i8]* @.str.1, i64 0, i64 0), i32 318)
%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 ([187 x i8], [187 x i8]* @.str.1, i64 0, i64 0), i32 339)
%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 ([187 x i8], [187 x i8]* @.str.1, i64 0, i64 0), i32 346)
%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 ([187 x i8], [187 x i8]* @.str.1, i64 0, i64 0), i32 353)
%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 ([187 x i8], [187 x i8]* @.str.1, i64 0, i64 0), i32 379)
%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 ([187 x i8], [187 x i8]* @.str.1, i64 0, i64 0), i32 391)
%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 ([187 x i8], [187 x i8]* @.str.1, i64 0, i64 0), i32 430)
%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 = load i32, i32* %6
%168 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([70 x i8], [70 x i8]* @.str.18, i64 0, i64 0), i32 %160, i32 %161, i32 %167, i32 5)
%169 = call double (...) @wtime()
%170 = getelementptr inbounds [2 x i64], [2 x i64]* %14, i64 0, i64 0
%171 = call i32 @clEnqueueNDRangeKernel(i32 %108, i32 %118, i32 2, i32* null, i64* %159, i64* %170, i32 0, i32* null, i32* null)
store i32 %171, i32* %3
%172 = call i32 @clFinish(i32 %108)
store i32 %172, i32* %3
%173 = call i32 @clEnqueueNDRangeKernel(i32 %108, i32 %118, i32 2, i32* null, i64* %159, i64* %170, i32 0, i32* null, i32* null)
store i32 %173, i32* %3
%174 = call i32 @clFinish(i32 %108)
store i32 %174, i32* %3
%175 = call i32 @clEnqueueNDRangeKernel(i32 %108, i32 %118, i32 2, i32* null, i64* %159, i64* %170, i32 0, i32* null, i32* null)
store i32 %175, i32* %3
%176 = call i32 @clFinish(i32 %108)
store i32 %176, i32* %3
%177 = call i32 @clEnqueueNDRangeKernel(i32 %108, i32 %118, i32 2, i32* null, i64* %159, i64* %170, i32 0, i32* null, i32* null)
store i32 %177, i32* %3
%178 = call i32 @clFinish(i32 %108)
store i32 %178, i32* %3
%179 = call i32 @clEnqueueNDRangeKernel(i32 %108, i32 %118, i32 2, i32* null, i64* %159, i64* %170, i32 0, i32* null, i32* null)
store i32 %179, i32* %3
%180 = call i32 @clFinish(i32 %108)
store i32 %180, i32* %3
%181 = call double (...) @wtime()
%182 = fsub double %181, %169
%183 = load i32, i32* %3
%184 = call i32 @check_error(i32 %183, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.19, i64 0, i64 0), i8* getelementptr inbounds ([187 x i8], [187 x i8]* @.str.1, i64 0, i64 0), i32 477)
%185 = load i32, i32* %4
%186 = sext i32 %185 to i64
%187 = load i32, i32* %5
%188 = sext i32 %187 to i64
%189 = load i32, i32* %6
%190 = sext i32 %189 to i64
%191 = shl nsw i64 %186, 1
%192 = mul i64 %191, %188
%193 = mul i64 %192, %190
%194 = sitofp i64 %193 to double
%195 = insertelement <2 x double> poison, double %194, i64 0
%196 = insertelement <2 x double> %195, double %182, i64 1
%197 = fdiv <2 x double> %196, <double 1.000000e+09, double 5.000000e+00>
%198 = extractelement <2 x double> %197, i64 1
%199 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.20, i64 0, i64 0), double %198)
%200 = extractelement <2 x double> %197, i64 0
%201 = fdiv double %200, %198
%202 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.21, i64 0, i64 0), double %201)
%203 = load i32, i32* %10
%204 = load i32, i32* @CL_TRUE
%205 = load i32, i32* %4
%206 = shl i32 %205, 2
%207 = load i32, i32* %5
%208 = mul i32 %206, %207
%209 = call i32 @clEnqueueReadBuffer(i32 %108, i32 %203, i32 %204, i32 0, i32 %208, float* %35, i32 0, i32* null, i32* null)
store i32 %209, i32* %3
%210 = call i32 @check_error(i32 %209, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.22, i64 0, i64 0), i8* getelementptr inbounds ([187 x i8], [187 x i8]* @.str.1, i64 0, i64 0), i32 505)
%211 = load i32, i32* %3
%212 = load i32, i32* @CL_SUCCESS
%213 = icmp eq i32 %211, %212
br i1 %213, label %216, label %214
214: ; preds = %103
%215 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.28, i64 0, i64 0))
br label %216
216: ; preds = %214, %103
%217 = call i32 @putchar(i32 10)
%218 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%219 = load i32, i32* %4
%220 = icmp sgt i32 %219, 0
%221 = load i32, i32* %5
br i1 %220, label %222, label %231
222: ; preds = %216, %268
%223 = phi i32 [ %269, %268 ], [ %219, %216 ]
%224 = phi i32 [ %270, %268 ], [ %221, %216 ]
%225 = phi i32 [ %271, %268 ], [ %221, %216 ]
%226 = phi i64 [ %273, %268 ], [ 0, %216 ]
%227 = phi i32 [ %272, %268 ], [ 0, %216 ]
%228 = icmp sgt i32 %225, 0
br i1 %228, label %229, label %268
229: ; preds = %222
%230 = getelementptr inbounds float, float* %35, i64 %226
br label %250
231: ; preds = %268, %216
%232 = phi i32 [ %221, %216 ], [ %270, %268 ]
%233 = phi i32 [ 0, %216 ], [ %272, %268 ]
%234 = phi i32 [ %219, %216 ], [ %269, %268 ]
%235 = mul nsw i32 %232, %234
%236 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.27, i64 0, i64 0), i32 %233, i32 %235)
%237 = load i32, i32* %8
%238 = call i32 @clReleaseMemObject(i32 %237)
%239 = load i32, i32* %9
%240 = call i32 @clReleaseMemObject(i32 %239)
%241 = load i32, i32* %10
%242 = call i32 @clReleaseMemObject(i32 %241)
%243 = call i32 @clReleaseContext(i32 %104)
%244 = call i32 @clReleaseCommandQueue(i32 %108)
%245 = call i32 @clReleaseProgram(i32 %113)
%246 = call i32 @clReleaseKernel(i32 %118)
%247 = call i32 @free(float* %30)
%248 = call i32 @free(float* %33)
%249 = call i32 @free(float* %35)
br label %338
250: ; preds = %229, %333
%251 = phi i32 [ %224, %229 ], [ %334, %333 ]
%252 = phi i32 [ 0, %229 ], [ %336, %333 ]
%253 = phi i32 [ %227, %229 ], [ %335, %333 ]
%254 = load i32, i32* %6
%255 = icmp sgt i32 %254, 0
%256 = load i32, i32* %4
br i1 %255, label %257, label %290
257: ; preds = %250
%258 = mul nsw i32 %254, %252
%259 = sext i32 %256 to i64
%260 = sext i32 %258 to i64
%261 = zext i32 %254 to i64
%262 = and i64 %261, 1
%263 = icmp eq i32 %254, 1
br i1 %263, label %276, label %264
264: ; preds = %257
%265 = and i64 %261, 4294967294
br label %301
266: ; preds = %333
%267 = load i32, i32* %4
br label %268
268: ; preds = %266, %222
%269 = phi i32 [ %223, %222 ], [ %267, %266 ]
%270 = phi i32 [ %224, %222 ], [ %334, %266 ]
%271 = phi i32 [ %225, %222 ], [ %334, %266 ]
%272 = phi i32 [ %227, %222 ], [ %335, %266 ]
%273 = add nuw nsw i64 %226, 1
%274 = sext i32 %269 to i64
%275 = icmp slt i64 %273, %274
br i1 %275, label %222, label %231
276: ; preds = %301, %257
%277 = phi float [ undef, %257 ], [ %321, %301 ]
%278 = phi i64 [ 0, %257 ], [ %322, %301 ]
%279 = phi float [ 0.000000e+00, %257 ], [ %321, %301 ]
%280 = icmp eq i64 %262, 0
br i1 %280, label %290, label %281
281: ; preds = %276
%282 = mul nsw i64 %278, %259
%283 = add nsw i64 %282, %226
%284 = getelementptr inbounds float, float* %30, i64 %283
%285 = load float, float* %284
%286 = add nsw i64 %278, %260
%287 = getelementptr inbounds float, float* %33, i64 %286
%288 = load float, float* %287
%289 = call float @llvm.fmuladd.f32(float %285, float %288, float %279)
br label %290
290: ; preds = %281, %276, %250
%291 = phi float [ 0.000000e+00, %250 ], [ %277, %276 ], [ %289, %281 ]
%292 = mul nsw i32 %256, %252
%293 = sext i32 %292 to i64
%294 = add nsw i64 %226, %293
%295 = getelementptr inbounds float, float* %35, i64 %294
%296 = load float, float* %295
%297 = fsub float %291, %296
%298 = fmul float %297, %297
%299 = fpext float %298 to double
%300 = fcmp olt double %299, 0x3EB0C6F7A0B5ED8D
br i1 %300, label %325, label %327
301: ; preds = %301, %264
%302 = phi i64 [ 0, %264 ], [ %322, %301 ]
%303 = phi float [ 0.000000e+00, %264 ], [ %321, %301 ]
%304 = phi i64 [ 0, %264 ], [ %323, %301 ]
%305 = mul nsw i64 %302, %259
%306 = add nsw i64 %305, %226
%307 = getelementptr inbounds float, float* %30, i64 %306
%308 = load float, float* %307
%309 = add nsw i64 %302, %260
%310 = getelementptr inbounds float, float* %33, i64 %309
%311 = load float, float* %310
%312 = call float @llvm.fmuladd.f32(float %308, float %311, float %303)
%313 = or i64 %302, 1
%314 = mul nsw i64 %313, %259
%315 = add nsw i64 %314, %226
%316 = getelementptr inbounds float, float* %30, i64 %315
%317 = load float, float* %316
%318 = add nsw i64 %313, %260
%319 = getelementptr inbounds float, float* %33, i64 %318
%320 = load float, float* %319
%321 = call float @llvm.fmuladd.f32(float %317, float %320, float %312)
%322 = add nuw nsw i64 %302, 2
%323 = add i64 %304, 2
%324 = icmp eq i64 %323, %265
br i1 %324, label %276, label %301
325: ; preds = %290
%326 = add i32 %253, 1
br label %333
327: ; preds = %290
%328 = fpext float %297 to double
%329 = load float, float* %230
%330 = fpext float %329 to double
%331 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.26, i64 0, i64 0), double %328, double %330)
%332 = load i32, i32* %5
br label %333
333: ; preds = %325, %327
%334 = phi i32 [ %251, %325 ], [ %332, %327 ]
%335 = phi i32 [ %326, %325 ], [ %253, %327 ]
%336 = add nuw nsw i32 %252, 1
%337 = icmp slt i32 %336, %334
br i1 %337, label %250, label %266
338: ; preds = %231, %73
%339 = phi i32 [ %75, %73 ], [ 0, %231 ]
ret i32 %339
}