#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*/ clCreateProgramWithBinary(int /*<<< orphan*/, int,
                                             int /*<<< orphan*/ **,
                                             size_t const *,
                                             unsigned 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 *, int *);
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/test/gemm/"
              "gemm_block8x8_thread8x8_test.c",
              195);
  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/test/gemm/"
              "gemm_block8x8_thread8x8_test.c",
              208);
  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/test/gemm/"
              "gemm_block8x8_thread8x8_test.c",
              250);
  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/test/gemm/"
              "gemm_block8x8_thread8x8_test.c",
              265);
  char *gemm_kernel_file = "gemm.co";
  int length;
  char *gemm_kernel = getKernelSource(gemm_kernel_file, &length);
  program = clCreateProgramWithBinary(
      context, 1, &device_id, (const size_t *)&length,
      (const unsigned 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/test/gemm/"
              "gemm_block8x8_thread8x8_test.c",
              332);
  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/test/gemm/"
              "gemm_block8x8_thread8x8_test.c",
              351);
  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/test/gemm/"
              "gemm_block8x8_thread8x8_test.c",
              365);
  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/test/gemm/"
              "gemm_block8x8_thread8x8_test.c",
              386);
  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/test/gemm/"
              "gemm_block8x8_thread8x8_test.c",
              393);
  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/test/gemm/"
              "gemm_block8x8_thread8x8_test.c",
              400);
  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/test/gemm/"
              "gemm_block8x8_thread8x8_test.c",
              426);
  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/test/gemm/"
              "gemm_block8x8_thread8x8_test.c",
              438);
  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/test/gemm/"
              "gemm_block8x8_thread8x8_test.c",
              477);
  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/test/gemm/"
              "gemm_block8x8_thread8x8_test.c",
              525);
  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/test/gemm/"
              "gemm_block8x8_thread8x8_test.c",
              553);
  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    $0xf0,%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   1120 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x24(%rbp),%eax
imul   -0x20(%rbp),%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1120 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x1c(%rbp),%eax
imul   -0x20(%rbp),%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1120 <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   10c0 <clGetPlatformIDs@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
lea    0xc36(%rip),%rsi
lea    0xc41(%rip),%rdx
mov    $0xc3,%ecx
call   1100 <check_error@plt>
cmpl   $0x0,-0x6c(%rbp)
jne    1424 <main+0x184>
lea    0xced(%rip),%rdi
mov    $0x0,%al
call   10d0 <printf@plt>
mov    0x2ba6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1ce5 <main+0xa45>
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,-0xf0(%rbp)
mov    %rsi,%rsp
mov    %rax,-0x80(%rbp)
mov    -0x6c(%rbp),%edi
xor    %eax,%eax
mov    %eax,%edx
call   10c0 <clGetPlatformIDs@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
lea    0xca5(%rip),%rsi
lea    0xbc4(%rip),%rdx
mov    $0xd0,%ecx
call   1100 <check_error@plt>
movl   $0x0,-0x68(%rbp)
mov    -0x68(%rbp),%eax
cmp    -0x6c(%rbp),%eax
jge    14e2 <main+0x242>
mov    -0xf0(%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   1090 <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    0xc30(%rip),%rdi
mov    $0x0,%al
call   10d0 <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   10f0 <clCreateContext@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x14(%rbp),%edi
lea    0xc12(%rip),%rsi
lea    0xb07(%rip),%rdx
mov    $0xfa,%ecx
call   1100 <check_error@plt>
mov    -0x4c(%rbp),%edi
mov    -0x48(%rbp),%rsi
xor    %edx,%edx
lea    -0x14(%rbp),%rcx
call   10b0 <clCreateCommandQueue@plt>
mov    %eax,-0x50(%rbp)
mov    -0x14(%rbp),%edi
lea    0xbf3(%rip),%rsi
lea    0xad7(%rip),%rdx
mov    $0x109,%ecx
call   1100 <check_error@plt>
lea    0xbf2(%rip),%rax
mov    %rax,-0x88(%rbp)
mov    -0x88(%rbp),%rdi
lea    -0x8c(%rbp),%rsi
call   1190 <getKernelSource@plt>
mov    %rax,-0x98(%rbp)
mov    -0x4c(%rbp),%edi
lea    -0x8c(%rbp),%rcx
mov    $0x1,%esi
lea    -0x48(%rbp),%rdx
lea    -0x98(%rbp),%r8
xor    %eax,%eax
mov    %eax,%r9d
lea    -0x14(%rbp),%rax
sub    $0x10,%rsp
mov    %rax,(%rsp)
call   1170 <clCreateProgramWithBinary@plt>
add    $0x10,%rsp
mov    %eax,-0x54(%rbp)
mov    -0x14(%rbp),%edi
lea    0xb98(%rip),%rsi
lea    0xa5d(%rip),%rdx
mov    $0x14c,%ecx
call   1100 <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    0xb7f(%rip),%rsi
lea    0xa27(%rip),%rdx
mov    $0x15f,%ecx
call   1100 <check_error@plt>
mov    -0x54(%rbp),%edi
lea    0xb72(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1160 <clCreateKernel@plt>
mov    %eax,-0x58(%rbp)
mov    -0x14(%rbp),%edi
lea    0xb61(%rip),%rsi
lea    0x9f6(%rip),%rdx
mov    $0x16d,%ecx
call   1100 <check_error@plt>
mov    -0x4c(%rbp),%edi
mov    0x2968(%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   1070 <clCreateBuffer@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x14(%rbp),%edi
lea    0xb28(%rip),%rsi
lea    0x9ad(%rip),%rdx
mov    $0x182,%ecx
call   1100 <check_error@plt>
mov    -0x4c(%rbp),%edi
mov    0x291f(%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   1070 <clCreateBuffer@plt>
mov    %eax,-0x60(%rbp)
mov    -0x14(%rbp),%edi
lea    0xaf3(%rip),%rsi
lea    0x964(%rip),%rdx
mov    $0x189,%ecx
call   1100 <check_error@plt>
mov    -0x4c(%rbp),%edi
mov    0x28fe(%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   1070 <clCreateBuffer@plt>
mov    %eax,-0x64(%rbp)
mov    -0x14(%rbp),%edi
lea    0xabe(%rip),%rsi
lea    0x91b(%rip),%rdx
mov    $0x190,%ecx
call   1100 <check_error@plt>
mov    -0x50(%rbp),%edi
mov    -0x5c(%rbp),%esi
mov    0x28ba(%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    0xa64(%rip),%rsi
lea    0x8ad(%rip),%rdx
mov    $0x1aa,%ecx
call   1100 <check_error@plt>
mov    -0x50(%rbp),%edi
mov    -0x60(%rbp),%esi
mov    0x284c(%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    0xa09(%rip),%rsi
lea    0x83f(%rip),%rdx
mov    $0x1b6,%ecx
call   1100 <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    0x962(%rip),%rsi
lea    0x785(%rip),%rdx
mov    $0x1dd,%ecx
call   1100 <check_error@plt>
mov    -0x1c(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cltq
mov    %rax,-0xb0(%rbp)
mov    -0x20(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cltq
mov    %rax,-0xa8(%rbp)
mov    0xa0a(%rip),%rax
mov    %rax,-0xc0(%rbp)
mov    0xa04(%rip),%rax
mov    %rax,-0xb8(%rbp)
mov    -0x1c(%rbp),%esi
lea    0x91c(%rip),%rdi
mov    $0x0,%al
call   10d0 <printf@plt>
mov    $0x0,%al
call   10e0 <wtime@plt>
movsd  %xmm0,-0xc8(%rbp)
ff
movl   $0x0,-0xcc(%rbp)
cmpl   $0x5,-0xcc(%rbp)
jge    1999 <main+0x6f9>
mov    -0x50(%rbp),%edi
mov    -0x58(%rbp),%esi
lea    -0xb0(%rbp),%r8
lea    -0xc0(%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   10a0 <clEnqueueNDRangeKernel@plt>
add    $0x20,%rsp
mov    %eax,-0x14(%rbp)
mov    -0x50(%rbp),%edi
call   1050 <clFinish@plt>
mov    %eax,-0x14(%rbp)
mov    -0xcc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xcc(%rbp)
jmp    1925 <main+0x685>
mov    $0x0,%al
call   10e0 <wtime@plt>
subsd  -0xc8(%rbp),%xmm0
ff
movsd  0x660(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0xc8(%rbp)
ff
mov    -0x14(%rbp),%edi
lea    0x860(%rip),%rsi
lea    0x665(%rip),%rdx
mov    $0x20d,%ecx
call   1100 <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  0x60c(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0x5f8(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0xd8(%rbp)
ff
movsd  -0xd8(%rbp),%xmm0
ff
divsd  -0xc8(%rbp),%xmm0
ff
lea    0x818(%rip),%rdi
mov    $0x1,%al
call   10d0 <printf@plt>
mov    -0x50(%rbp),%edi
mov    -0x64(%rbp),%esi
mov    0x25a9(%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   1130 <clEnqueueReadBuffer@plt>
add    $0x20,%rsp
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
lea    0x7c1(%rip),%rsi
lea    0x59c(%rip),%rdx
mov    $0x229,%ecx
call   1100 <check_error@plt>
mov    -0x14(%rbp),%eax
mov    0x2506(%rip),%rcx
cmp    (%rcx),%eax
je     1ac0 <main+0x820>
lea    0x7aa(%rip),%rdi
mov    $0x0,%al
call   10d0 <printf@plt>
lea    0x7da(%rip),%rdi
mov    $0x0,%al
call   10d0 <printf@plt>
movl   $0x0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xdc(%rbp)
ff
lea    0x7a0(%rip),%rdi
mov    $0x0,%al
call   10d0 <printf@plt>
movl   $0x0,-0xe0(%rbp)
mov    -0xe0(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1c6c <main+0x9cc>
movl   $0x0,-0xe4(%rbp)
mov    -0xe4(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1c53 <main+0x9b3>
xorps  %xmm0,%xmm0
movss  %xmm0,-0xdc(%rbp)
ff
movl   $0x0,-0xe8(%rbp)
mov    -0xe8(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1ba8 <main+0x908>
mov    -0x30(%rbp),%rax
mov    -0xe8(%rbp),%ecx
imul   -0x1c(%rbp),%ecx
add    -0xe0(%rbp),%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x38(%rbp),%rax
mov    -0xe4(%rbp),%ecx
imul   -0x24(%rbp),%ecx
add    -0xe8(%rbp),%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm2
movss  -0xdc(%rbp),%xmm1
ff
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0xdc(%rbp)
ff
mov    -0xe8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe8(%rbp)
jmp    1b35 <main+0x895>
mov    -0x40(%rbp),%rax
mov    -0xe4(%rbp),%ecx
imul   -0x1c(%rbp),%ecx
add    -0xe0(%rbp),%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm1
movss  -0xdc(%rbp),%xmm0
ff
subss  %xmm1,%xmm0
movss  %xmm0,-0xdc(%rbp)
ff
movss  -0xdc(%rbp),%xmm0
ff
mulss  -0xdc(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm1
movsd  0x424(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1c0c <main+0x96c>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1c3a <main+0x99a>
movss  -0xdc(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
mov    -0x40(%rbp),%rax
movslq -0xe0(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0x670(%rip),%rdi
mov    $0x2,%al
call   10d0 <printf@plt>
jmp    1c3f <main+0x99f>
mov    -0xe4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe4(%rbp)
jmp    1b11 <main+0x871>
jmp    1c58 <main+0x9b8>
mov    -0xe0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe0(%rbp)
jmp    1af8 <main+0x858>
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
imul   -0x20(%rbp),%edx
lea    0x636(%rip),%rdi
mov    $0x0,%al
call   10d0 <printf@plt>
mov    -0x5c(%rbp),%edi
call   1150 <clReleaseMemObject@plt>
mov    -0x60(%rbp),%edi
call   1150 <clReleaseMemObject@plt>
mov    -0x64(%rbp),%edi
call   1150 <clReleaseMemObject@plt>
mov    -0x4c(%rbp),%edi
call   1140 <clReleaseContext@plt>
mov    -0x50(%rbp),%edi
call   1110 <clReleaseCommandQueue@plt>
mov    -0x54(%rbp),%edi
call   1080 <clReleaseProgram@plt>
mov    -0x58(%rbp),%edi
call   1060 <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,-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,-0x48(%rbp)
lea    0x0(,%r14,4),%ebx
mov    %ebx,%edi
imul   %eax,%edi
mov    %edi,-0x38(%rbp)
call   1140 <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   1140 <malloc@plt>
mov    %rax,-0x60(%rbp)
imul   %r12d,%ebx
mov    %ebx,-0x90(%rbp)
mov    %ebx,%edi
call   1140 <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   10e0 <clGetPlatformIDs@plt>
mov    %eax,-0x2c(%rbp)
lea    0xc4e(%rip),%rsi
lea    0xc59(%rip),%rdx
mov    %eax,%edi
mov    $0xc3,%ecx
call   1120 <check_error@plt>
mov    -0x3c(%rbp),%eax
test   %rax,%rax
je     1c96 <main+0x9d6>
mov    %rsp,-0x98(%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   10e0 <clGetPlatformIDs@plt>
mov    %eax,-0x2c(%rbp)
lea    0xcd5(%rip),%rsi
lea    0xc07(%rip),%rdx
mov    %eax,%edi
mov    $0xd0,%ecx
call   1120 <check_error@plt>
cmpl   $0x0,-0x3c(%rbp)
jle    14ad <main+0x1ed>
mov    $0x1,%ebx
lea    -0x70(%rbp),%r13
mov    0x2b4b(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nop
mov    -0x4(%r12,%rbx,4),%edi
mov    0x2b4c(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edx
mov    %r13,%rcx
xor    %r8d,%r8d
call   10b0 <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,-0x70(%rbp)
jne    14b9 <main+0x1f9>
lea    0xe1f(%rip),%rdi
call   1070 <puts@plt>
xor    %eax,%eax
mov    %rax,-0x58(%rbp)
lea    -0x70(%rbp),%rdx
lea    -0x2c(%rbp),%r15
xor    %edi,%edi
mov    $0x1,%esi
xor    %ecx,%ecx
xor    %r8d,%r8d
mov    %r15,%r9
call   1110 <clCreateContext@plt>
mov    %eax,%r12d
mov    -0x2c(%rbp),%edi
lea    0xc41(%rip),%rsi
lea    0xb5b(%rip),%rbx
mov    %rbx,%rdx
mov    $0xfa,%ecx
call   1120 <check_error@plt>
mov    -0x70(%rbp),%rsi
mov    %r12d,%edi
xor    %edx,%edx
mov    %r15,%rcx
call   10d0 <clCreateCommandQueue@plt>
mov    %eax,-0x40(%rbp)
mov    -0x2c(%rbp),%edi
lea    0xc20(%rip),%rsi
mov    %rbx,%rdx
mov    $0x109,%ecx
call   1120 <check_error@plt>
lea    0xc23(%rip),%rdi
lea    -0xa4(%rbp),%r13
mov    %r13,%rsi
call   11b0 <getKernelSource@plt>
mov    %rax,-0xa0(%rbp)
sub    $0x8,%rsp
lea    -0xa0(%rbp),%r8
mov    %r12d,%edi
mov    $0x1,%esi
lea    -0x70(%rbp),%rdx
mov    %r13,%rcx
xor    %r9d,%r9d
push   %r15
call   1190 <clCreateProgramWithBinary@plt>
add    $0x10,%rsp
mov    %eax,%ebx
mov    -0x2c(%rbp),%edi
lea    0xbe1(%rip),%rsi
lea    0xacb(%rip),%rdx
mov    %rdx,%r13
mov    $0x14c,%ecx
call   1120 <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    0xbcd(%rip),%rsi
mov    %eax,%edi
mov    %r13,%rdx
mov    $0x15f,%ecx
call   1120 <check_error@plt>
lea    0xbc5(%rip),%rsi
mov    %ebx,-0x88(%rbp)
mov    %ebx,%edi
mov    %r15,%rbx
mov    %r15,%rdx
call   1180 <clCreateKernel@plt>
mov    %eax,%r15d
mov    -0x2c(%rbp),%edi
lea    0xbaa(%rip),%rsi
mov    %r13,%rdx
mov    $0x16d,%ecx
call   1120 <check_error@plt>
mov    0x29c5(%rip),%rax
mov    (%rax),%esi
mov    %r12d,%edi
mov    -0x38(%rbp),%edx
xor    %ecx,%ecx
mov    %rbx,%r8
call   1090 <clCreateBuffer@plt>
mov    %eax,%r13d
mov    %eax,-0x68(%rbp)
mov    -0x2c(%rbp),%edi
lea    0xb84(%rip),%rsi
lea    0xa2e(%rip),%rdx
mov    $0x182,%ecx
call   1120 <check_error@plt>
mov    0x298b(%rip),%rax
mov    (%rax),%esi
mov    %r12d,%edi
mov    -0x80(%rbp),%edx
xor    %ecx,%ecx
mov    %rbx,%r8
call   1090 <clCreateBuffer@plt>
mov    %eax,-0x84(%rbp)
mov    %eax,-0x64(%rbp)
mov    -0x2c(%rbp),%edi
lea    0xb5b(%rip),%rsi
lea    0x9f1(%rip),%rdx
mov    $0x189,%ecx
call   1120 <check_error@plt>
mov    0x2976(%rip),%rax
mov    (%rax),%esi
mov    %r12d,-0x8c(%rbp)
mov    %r12d,%edi
mov    -0x90(%rbp),%edx
xor    %ecx,%ecx
mov    %rbx,%r8
call   1090 <clCreateBuffer@plt>
mov    %eax,-0x44(%rbp)
mov    -0x2c(%rbp),%edi
lea    0xb2e(%rip),%rsi
lea    0x9b0(%rip),%r12
mov    %r12,%rdx
mov    $0x190,%ecx
call   1120 <check_error@plt>
mov    0x293a(%rip),%rax
mov    (%rax),%edx
sub    $0x20,%rsp
xorps  %xmm0,%xmm0
movups %xmm0,0x8(%rsp)
movl   $0x0,(%rsp)
mov    -0x40(%rbp),%ebx
mov    %ebx,%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    0xaed(%rip),%rsi
mov    %eax,%edi
mov    %r12,%rdx
mov    $0x1aa,%ecx
call   1120 <check_error@plt>
mov    0x28ea(%rip),%rax
mov    (%rax),%edx
sub    $0x20,%rsp
xorps  %xmm0,%xmm0
movups %xmm0,0x8(%rsp)
movl   $0x0,(%rsp)
mov    %ebx,%edi
mov    -0x84(%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    0xab0(%rip),%rsi
mov    %eax,%edi
mov    %r12,%rdx
mov    $0x1b6,%ecx
call   1120 <check_error@plt>
lea    -0x68(%rbp),%rcx
mov    %r15d,%edi
xor    %esi,%esi
mov    $0x4,%edx
call   11c0 <clSetKernelArg@plt>
mov    %eax,-0x2c(%rbp)
lea    -0x64(%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    -0x48(%rbp),%rcx
mov    %r15d,%edi
mov    $0x5,%esi
mov    $0x4,%edx
call   11c0 <clSetKernelArg@plt>
or     -0x2c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
lea    0xa17(%rip),%rsi
mov    %eax,%edi
mov    %r12,%rdx
mov    $0x1dd,%ecx
call   1120 <check_error@plt>
mov    -0x30(%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 0x7ea(%rip),%xmm0
movapd %xmm0,-0xc0(%rbp)
ff
lea    0x9cf(%rip),%rdi
xor    %eax,%eax
call   10f0 <printf@plt>
xor    %eax,%eax
call   1100 <wtime@plt>
movsd  %xmm0,-0x80(%rbp)
sub    $0x20,%rsp
xorpd  %xmm0,%xmm0
movupd %xmm0,0x8(%rsp)
movl   $0x0,(%rsp)
lea    -0xd0(%rbp),%r13
lea    -0xc0(%rbp),%r12
mov    -0x40(%rbp),%ebx
mov    %ebx,%edi
mov    %r15d,%esi
mov    $0x2,%edx
xor    %ecx,%ecx
mov    %r13,%r8
mov    %r12,%r9
call   10c0 <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   10c0 <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   10c0 <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   10c0 <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   10c0 <clEnqueueNDRangeKernel@plt>
add    $0x20,%rsp
mov    %eax,-0x2c(%rbp)
mov    %ebx,%edi
call   1060 <clFinish@plt>
mov    %eax,-0x2c(%rbp)
xor    %eax,%eax
call   1100 <wtime@plt>
subsd  -0x80(%rbp),%xmm0
movapd %xmm0,-0x80(%rbp)
mov    -0x2c(%rbp),%edi
lea    0x860(%rip),%rsi
lea    0x68a(%rip),%r15
mov    %r15,%rdx
mov    $0x20d,%ecx
call   1120 <check_error@plt>
movslq -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
imul   %rax,%rcx
movslq -0x48(%rbp),%rax
imul   %rcx,%rax
add    %rax,%rax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
unpcklpd -0x80(%rbp),%xmm0
divpd  0x607(%rip),%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
divsd  %xmm1,%xmm0
lea    0x82a(%rip),%rdi
mov    $0x1,%al
call   10f0 <printf@plt>
mov    -0x44(%rbp),%esi
mov    0x25cb(%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   1150 <clEnqueueReadBuffer@plt>
add    $0x20,%rsp
mov    %eax,-0x2c(%rbp)
lea    0x7e8(%rip),%rsi
mov    %eax,%edi
mov    %r15,%rdx
mov    $0x229,%ecx
call   1120 <check_error@plt>
mov    -0x2c(%rbp),%eax
mov    0x253c(%rip),%rcx
cmp    (%rcx),%eax
je     1a84 <main+0x7c4>
lea    0x831(%rip),%rdi
call   1070 <puts@plt>
mov    $0xa,%edi
call   1050 <putchar@plt>
lea    0x800(%rip),%rdi
call   1070 <puts@plt>
mov    -0x30(%rbp),%eax
mov    -0x34(%rbp),%edx
test   %eax,%eax
jle    1c1d <main+0x95d>
mov    -0x60(%rbp),%rcx
add    $0x4,%rcx
mov    %rcx,-0x80(%rbp)
xor    %r15d,%r15d
movsd  0x571(%rip),%xmm2
xor    %r13d,%r13d
xor    %ecx,%ecx
mov    %rcx,-0x58(%rbp)
jmp    1ae7 <main+0x827>
nopw   0x0(%rax,%rax,1)
mov    -0x30(%rbp),%eax
add    $0x1,%r13
movslq %eax,%rcx
add    $0x4,%r15
cmp    %rcx,%r13
jge    1c1d <main+0x95d>
test   %edx,%edx
jle    1ad3 <main+0x813>
xor    %r12d,%r12d
mov    -0x50(%rbp),%r11
jmp    1b34 <main+0x874>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cvtss2sd %xmm0,%xmm0
movss  (%r14,%r13,4),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0x741(%rip),%rdi
mov    $0x2,%al
call   10f0 <printf@plt>
movsd  0x50c(%rip),%xmm2
mov    -0x50(%rbp),%r11
mov    -0x34(%rbp),%edx
add    $0x1,%r12d
cmp    %edx,%r12d
jge    1ad0 <main+0x810>
mov    -0x48(%rbp),%r9d
movslq -0x30(%rbp),%r8
test   %r9d,%r9d
jle    1b50 <main+0x890>
cmp    $0x1,%r9d
jne    1b60 <main+0x8a0>
xorpd  %xmm0,%xmm0
xor    %esi,%esi
jmp    1bbb <main+0x8fb>
nop
xorpd  %xmm0,%xmm0
jmp    1be8 <main+0x928>
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    1b90 <main+0x8d0>
test   $0x1,%r9b
je     1be8 <main+0x928>
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    1b00 <main+0x840>
mov    -0x58(%rbp),%rax
add    $0x1,%eax
mov    %rax,-0x58(%rbp)
jmp    1b2b <main+0x86b>
imul   %eax,%edx
lea    0x63f(%rip),%rdi
xor    %r13d,%r13d
mov    -0x58(%rbp),%rsi
xor    %eax,%eax
call   10f0 <printf@plt>
mov    -0x68(%rbp),%edi
call   1170 <clReleaseMemObject@plt>
mov    -0x64(%rbp),%edi
call   1170 <clReleaseMemObject@plt>
mov    -0x44(%rbp),%edi
call   1170 <clReleaseMemObject@plt>
mov    -0x8c(%rbp),%edi
call   1160 <clReleaseContext@plt>
mov    -0x40(%rbp),%edi
call   1130 <clReleaseCommandQueue@plt>
mov    -0x88(%rbp),%edi
call   10a0 <clReleaseProgram@plt>
mov    -0x38(%rbp),%edi
call   1080 <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    -0x98(%rbp),%rsp
jmp    1cac <main+0x9ec>
lea    0x647(%rip),%rdi
call   1070 <puts@plt>
mov    0x2317(%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 = [199 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/test/gemm/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 = [8 x i8] c"gemm.co\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"
@.str.24 = [28 x i8] c"Verifing the GPU result...\0A\00"
@.str.25 = [16 x i8] c"temp %f h_c %f\0A\00"
@.str.26 = [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 i32
%28 = alloca i8*
%29 = alloca [2 x i64]
%30 = alloca [2 x i64]
%31 = alloca double
%32 = alloca i32
%33 = alloca double
%34 = alloca float
%35 = alloca i32
%36 = alloca i32
%37 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 1
%40 = load i8*, i8** %39
%41 = call i32 @atoi(i8* %40)
store i32 %41, i32* %8
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 2
%44 = load i8*, i8** %43
%45 = call i32 @atoi(i8* %44)
store i32 %45, i32* %9
%46 = load i8**, i8*** %5
%47 = getelementptr inbounds i8*, i8** %46, i64 3
%48 = load i8*, i8** %47
%49 = call i32 @atoi(i8* %48)
store i32 %49, i32* %10
%50 = load i32, i32* %8
%51 = load i32, i32* %10
%52 = mul nsw i32 %50, %51
%53 = sext i32 %52 to i64
%54 = mul i64 %53, 4
%55 = trunc i64 %54 to i32
%56 = call float* @malloc(i32 %55)
store float* %56, float** %11
%57 = load i32, i32* %10
%58 = load i32, i32* %9
%59 = mul nsw i32 %57, %58
%60 = sext i32 %59 to i64
%61 = mul i64 %60, 4
%62 = trunc i64 %61 to i32
%63 = call float* @malloc(i32 %62)
store float* %63, float** %12
%64 = load i32, i32* %8
%65 = load i32, i32* %9
%66 = mul nsw i32 %64, %65
%67 = sext i32 %66 to i64
%68 = mul i64 %67, 4
%69 = trunc i64 %68 to i32
%70 = call float* @malloc(i32 %69)
store float* %70, float** %13
store i32 0, i32* %22
store i32 0, i32* %22
br label %71
71: ; preds = %86, %2
%72 = load i32, i32* %22
%73 = load i32, i32* %8
%74 = load i32, i32* %10
%75 = mul nsw i32 %73, %74
%76 = icmp slt i32 %72, %75
br i1 %76, label %77, label %89
77: ; preds = %71
%78 = call float (...) @rand()
%79 = load i64, i64* @RAND_MAX
%80 = sitofp i64 %79 to float
%81 = fdiv float %78, %80
%82 = load float*, float** %11
%83 = load i32, i32* %22
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds float, float* %82, i64 %84
store float %81, float* %85
br label %86
86: ; preds = %77
%87 = load i32, i32* %22
%88 = add nsw i32 %87, 1
store i32 %88, i32* %22
br label %71
89: ; preds = %71
store i32 0, i32* %22
br label %90
90: ; preds = %105, %89
%91 = load i32, i32* %22
%92 = load i32, i32* %9
%93 = load i32, i32* %10
%94 = mul nsw i32 %92, %93
%95 = icmp slt i32 %91, %94
br i1 %95, label %96, label %108
96: ; preds = %90
%97 = call float (...) @rand()
%98 = load i64, i64* @RAND_MAX
%99 = sitofp i64 %98 to float
%100 = fdiv float %97, %99
%101 = load float*, float** %12
%102 = load i32, i32* %22
%103 = sext i32 %102 to i64
%104 = getelementptr inbounds float, float* %101, i64 %103
store float %100, float* %104
br label %105
105: ; preds = %96
%106 = load i32, i32* %22
%107 = add nsw i32 %106, 1
store i32 %107, i32* %22
br label %90
108: ; preds = %90
%109 = call i32 @clGetPlatformIDs(i32 0, i32* null, i32* %23)
store i32 %109, i32* %6
%110 = load i32, i32* %6
%111 = call i32 @check_error(i32 %110, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([199 x i8], [199 x i8]* @.str.1, i64 0, i64 0), i32 195)
%112 = load i32, i32* %23
%113 = icmp eq i32 %112, 0
br i1 %113, label %114, label %117
114: ; preds = %108
%115 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%116 = load i32, i32* @EXIT_FAILURE
store i32 %116, i32* %3
br label %436
117: ; preds = %108
%118 = load i32, i32* %23
%119 = zext i32 %118 to i64
%120 = call i8* @llvm.stacksave()
store i8* %120, i8** %24
%121 = alloca i32, i64 %119
store i64 %119, i64* %25
%122 = load i32, i32* %23
%123 = call i32 @clGetPlatformIDs(i32 %122, i32* %121, i32* null)
store i32 %123, i32* %6
%124 = load i32, i32* %6
%125 = call i32 @check_error(i32 %124, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([199 x i8], [199 x i8]* @.str.1, i64 0, i64 0), i32 208)
store i32 0, i32* %22
br label %126
126: ; preds = %142, %117
%127 = load i32, i32* %22
%128 = load i32, i32* %23
%129 = icmp slt i32 %127, %128
br i1 %129, label %130, label %145
130: ; preds = %126
%131 = load i32, i32* %22
%132 = sext i32 %131 to i64
%133 = getelementptr inbounds i32, i32* %121, i64 %132
%134 = load i32, i32* %133
%135 = load i32, i32* @CL_DEVICE_TYPE_DEFAULT
%136 = call i32 @clGetDeviceIDs(i32 %134, i32 %135, i32 1, i32** %14, i32* null)
store i32 %136, i32* %6
%137 = load i32, i32* %6
%138 = load i32, i32* @CL_SUCCESS
%139 = icmp eq i32 %137, %138
br i1 %139, label %140, label %141
140: ; preds = %130
br label %145
141: ; preds = %130
br label %142
142: ; preds = %141
%143 = load i32, i32* %22
%144 = add nsw i32 %143, 1
store i32 %144, i32* %22
br label %126
145: ; preds = %140, %126
%146 = load i32*, i32** %14
%147 = icmp eq i32* %146, null
br i1 %147, label %148, label %150
148: ; preds = %145
%149 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
br label %150
150: ; preds = %148, %145
%151 = call i32 @clCreateContext(i32 0, i32 1, i32** %14, i32* null, i32* null, i32* %6)
store i32 %151, i32* %15
%152 = load i32, i32* %6
%153 = call i32 @check_error(i32 %152, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([199 x i8], [199 x i8]* @.str.1, i64 0, i64 0), i32 250)
%154 = load i32, i32* %15
%155 = load i32*, i32** %14
%156 = call i32 @clCreateCommandQueue(i32 %154, i32* %155, i32 0, i32* %6)
store i32 %156, i32* %16
%157 = load i32, i32* %6
%158 = call i32 @check_error(i32 %157, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([199 x i8], [199 x i8]* @.str.1, i64 0, i64 0), i32 265)
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i8** %26
%159 = load i8*, i8** %26
%160 = call i8* @getKernelSource(i8* %159, i32* %27)
store i8* %160, i8** %28
%161 = load i32, i32* %15
%162 = bitcast i32* %27 to i64*
%163 = call i32 @clCreateProgramWithBinary(i32 %161, i32 1, i32** %14, i64* %162, i8** %28, i32* null, i32* %6)
store i32 %163, i32* %17
%164 = load i32, i32* %6
%165 = call i32 @check_error(i32 %164, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([199 x i8], [199 x i8]* @.str.1, i64 0, i64 0), i32 332)
%166 = load i32, i32* %17
%167 = call i32 @clBuildProgram(i32 %166, i32 0, i32* null, i32* null, i32* null, i32* null)
store i32 %167, i32* %6
%168 = load i32, i32* %6
%169 = call i32 @check_error(i32 %168, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([199 x i8], [199 x i8]* @.str.1, i64 0, i64 0), i32 351)
%170 = load i32, i32* %17
%171 = call i32 @clCreateKernel(i32 %170, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), i32* %6)
store i32 %171, i32* %18
%172 = load i32, i32* %6
%173 = call i32 @check_error(i32 %172, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([199 x i8], [199 x i8]* @.str.1, i64 0, i64 0), i32 365)
%174 = load i32, i32* %15
%175 = load i32, i32* @CL_MEM_READ_ONLY
%176 = load i32, i32* %8
%177 = sext i32 %176 to i64
%178 = mul i64 4, %177
%179 = load i32, i32* %10
%180 = sext i32 %179 to i64
%181 = mul i64 %178, %180
%182 = trunc i64 %181 to i32
%183 = call i32 @clCreateBuffer(i32 %174, i32 %175, i32 %182, i32* null, i32* %6)
store i32 %183, i32* %19
%184 = load i32, i32* %6
%185 = call i32 @check_error(i32 %184, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([199 x i8], [199 x i8]* @.str.1, i64 0, i64 0), i32 386)
%186 = load i32, i32* %15
%187 = load i32, i32* @CL_MEM_READ_ONLY
%188 = load i32, i32* %10
%189 = sext i32 %188 to i64
%190 = mul i64 4, %189
%191 = load i32, i32* %9
%192 = sext i32 %191 to i64
%193 = mul i64 %190, %192
%194 = trunc i64 %193 to i32
%195 = call i32 @clCreateBuffer(i32 %186, i32 %187, i32 %194, i32* null, i32* %6)
store i32 %195, i32* %20
%196 = load i32, i32* %6
%197 = call i32 @check_error(i32 %196, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([199 x i8], [199 x i8]* @.str.1, i64 0, i64 0), i32 393)
%198 = load i32, i32* %15
%199 = load i32, i32* @CL_MEM_READ_WRITE
%200 = load i32, i32* %8
%201 = sext i32 %200 to i64
%202 = mul i64 4, %201
%203 = load i32, i32* %9
%204 = sext i32 %203 to i64
%205 = mul i64 %202, %204
%206 = trunc i64 %205 to i32
%207 = call i32 @clCreateBuffer(i32 %198, i32 %199, i32 %206, i32* null, i32* %6)
store i32 %207, i32* %21
%208 = load i32, i32* %6
%209 = call i32 @check_error(i32 %208, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([199 x i8], [199 x i8]* @.str.1, i64 0, i64 0), i32 400)
%210 = load i32, i32* %16
%211 = load i32, i32* %19
%212 = load i32, i32* @CL_TRUE
%213 = load i32, i32* %8
%214 = sext i32 %213 to i64
%215 = mul i64 4, %214
%216 = load i32, i32* %10
%217 = sext i32 %216 to i64
%218 = mul i64 %215, %217
%219 = trunc i64 %218 to i32
%220 = load float*, float** %11
%221 = call i32 @clEnqueueWriteBuffer(i32 %210, i32 %211, i32 %212, i32 0, i32 %219, float* %220, i32 0, i32* null, i32* null)
store i32 %221, i32* %6
%222 = load i32, i32* %6
%223 = call i32 @check_error(i32 %222, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.15, i64 0, i64 0), i8* getelementptr inbounds ([199 x i8], [199 x i8]* @.str.1, i64 0, i64 0), i32 426)
%224 = load i32, i32* %16
%225 = load i32, i32* %20
%226 = load i32, i32* @CL_TRUE
%227 = load i32, i32* %10
%228 = sext i32 %227 to i64
%229 = mul i64 4, %228
%230 = load i32, i32* %9
%231 = sext i32 %230 to i64
%232 = mul i64 %229, %231
%233 = trunc i64 %232 to i32
%234 = load float*, float** %12
%235 = call i32 @clEnqueueWriteBuffer(i32 %224, i32 %225, i32 %226, i32 0, i32 %233, float* %234, i32 0, i32* null, i32* null)
store i32 %235, i32* %6
%236 = load i32, i32* %6
%237 = call i32 @check_error(i32 %236, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([199 x i8], [199 x i8]* @.str.1, i64 0, i64 0), i32 438)
%238 = load i32, i32* %18
%239 = call i32 @clSetKernelArg(i32 %238, i32 0, i32 4, i32* %19)
store i32 %239, i32* %6
%240 = load i32, i32* %18
%241 = call i32 @clSetKernelArg(i32 %240, i32 1, i32 4, i32* %20)
%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 2, i32 4, i32* %21)
%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 3, i32 4, i32* %8)
%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 4, i32 4, i32* %9)
%254 = load i32, i32* %6
%255 = or i32 %254, %253
store i32 %255, i32* %6
%256 = load i32, i32* %18
%257 = call i32 @clSetKernelArg(i32 %256, i32 5, i32 4, i32* %10)
%258 = load i32, i32* %6
%259 = or i32 %258, %257
store i32 %259, i32* %6
%260 = load i32, i32* %6
%261 = call i32 @check_error(i32 %260, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.17, i64 0, i64 0), i8* getelementptr inbounds ([199 x i8], [199 x i8]* @.str.1, i64 0, i64 0), i32 477)
%262 = getelementptr inbounds [2 x i64], [2 x i64]* %29, i64 0, i64 0
%263 = load i32, i32* %8
%264 = sdiv i32 %263, 8
%265 = sext i32 %264 to i64
store i64 %265, i64* %262
%266 = getelementptr inbounds i64, i64* %262, i64 1
%267 = load i32, i32* %9
%268 = sdiv i32 %267, 8
%269 = sext i32 %268 to i64
store i64 %269, i64* %266
%270 = bitcast [2 x i64]* %30 to i8*
%271 = load i32, i32* %8
%272 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.18, i64 0, i64 0), i32 %271)
%273 = call double (...) @wtime()
store double %273, double* %31
store i32 0, i32* %32
br label %274
274: ; preds = %285, %150
%275 = load i32, i32* %32
%276 = icmp slt i32 %275, 5
br i1 %276, label %277, label %288
277: ; preds = %274
%278 = load i32, i32* %16
%279 = load i32, i32* %18
%280 = getelementptr inbounds [2 x i64], [2 x i64]* %29, i64 0, i64 0
%281 = getelementptr inbounds [2 x i64], [2 x i64]* %30, i64 0, i64 0
%282 = call i32 @clEnqueueNDRangeKernel(i32 %278, i32 %279, i32 2, i32* null, i64* %280, i64* %281, i32 0, i32* null, i32* null)
store i32 %282, i32* %6
%283 = load i32, i32* %16
%284 = call i32 @clFinish(i32 %283)
store i32 %284, i32* %6
br label %285
285: ; preds = %277
%286 = load i32, i32* %32
%287 = add nsw i32 %286, 1
store i32 %287, i32* %32
br label %274
288: ; preds = %274
%289 = call double (...) @wtime()
%290 = load double, double* %31
%291 = fsub double %289, %290
%292 = fdiv double %291, 5.000000e+00
store double %292, double* %31
%293 = load i32, i32* %6
%294 = call i32 @check_error(i32 %293, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.19, i64 0, i64 0), i8* getelementptr inbounds ([199 x i8], [199 x i8]* @.str.1, i64 0, i64 0), i32 525)
%295 = load i32, i32* %8
%296 = sext i32 %295 to i64
%297 = load i32, i32* %9
%298 = sext i32 %297 to i64
%299 = mul nsw i64 %296, %298
%300 = load i32, i32* %10
%301 = sext i32 %300 to i64
%302 = mul nsw i64 %299, %301
%303 = mul nsw i64 %302, 2
%304 = sitofp i64 %303 to double
%305 = fmul double %304, 1.000000e+00
%306 = fdiv double %305, 1.000000e+09
store double %306, double* %33
%307 = load double, double* %33
%308 = load double, double* %31
%309 = fdiv double %307, %308
%310 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.20, 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.21, i64 0, i64 0), i8* getelementptr inbounds ([199 x i8], [199 x i8]* @.str.1, i64 0, i64 0), i32 553)
%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 = %288
%329 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.22, i64 0, i64 0))
br label %330
330: ; preds = %328, %288
%331 = 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* %34
%332 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.24, i64 0, i64 0))
store i32 0, i32* %35
br label %333
333: ; preds = %406, %330
%334 = load i32, i32* %35
%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* %36
br label %338
338: ; preds = %402, %337
%339 = load i32, i32* %36
%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* %34
store i32 0, i32* %37
br label %343
343: ; preds = %368, %342
%344 = load i32, i32* %37
%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* %37
%350 = load i32, i32* %8
%351 = mul nsw i32 %349, %350
%352 = load i32, i32* %35
%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* %36
%359 = load i32, i32* %10
%360 = mul nsw i32 %358, %359
%361 = load i32, i32* %37
%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* %34
%367 = call float @llvm.fmuladd.f32(float %356, float %365, float %366)
store float %367, float* %34
br label %368
368: ; preds = %347
%369 = load i32, i32* %37
%370 = add nsw i32 %369, 1
store i32 %370, i32* %37
br label %343
371: ; preds = %343
%372 = load float*, float** %13
%373 = load i32, i32* %36
%374 = load i32, i32* %8
%375 = mul nsw i32 %373, %374
%376 = load i32, i32* %35
%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* %34
%382 = fsub float %381, %380
store float %382, float* %34
%383 = load float, float* %34
%384 = load float, float* %34
%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* %34
%393 = fpext float %392 to double
%394 = load float*, float** %13
%395 = load i32, i32* %35
%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.25, 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* %36
%404 = add nsw i32 %403, 1
store i32 %404, i32* %36
br label %338
405: ; preds = %338
br label %406
406: ; preds = %405
%407 = load i32, i32* %35
%408 = add nsw i32 %407, 1
store i32 %408, i32* %35
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.26, 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, %114
%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 = [199 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/test/gemm/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 = [8 x i8] c"gemm.co\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.25 = [16 x i8] c"temp %f h_c %f\0A\00"
@.str.26 = [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.27 = [35 x i8] c"Error: Failed to read output array\00"
@str.28 = [17 x i8] c"No devices found\00"
@str.29 = [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 i32
%13 = alloca i8*
%14 = alloca <2 x i64>
%15 = alloca [2 x i64]
%16 = bitcast i32* %3 to i8*
%17 = bitcast i32* %4 to i8*
%18 = getelementptr inbounds i8*, i8** %1, i64 1
%19 = load i8*, i8** %18
%20 = tail call i32 @atoi(i8* %19)
store i32 %20, i32* %4
%21 = bitcast i32* %5 to i8*
%22 = getelementptr inbounds i8*, i8** %1, i64 2
%23 = load i8*, i8** %22
%24 = tail call i32 @atoi(i8* %23)
store i32 %24, i32* %5
%25 = bitcast i32* %6 to i8*
%26 = getelementptr inbounds i8*, i8** %1, i64 3
%27 = load i8*, i8** %26
%28 = tail call i32 @atoi(i8* %27)
store i32 %28, i32* %6
%29 = shl i32 %20, 2
%30 = mul i32 %29, %28
%31 = tail call float* @malloc(i32 %30)
%32 = shl i32 %24, 2
%33 = mul i32 %32, %28
%34 = tail call float* @malloc(i32 %33)
%35 = mul i32 %29, %24
%36 = tail call float* @malloc(i32 %35)
%37 = bitcast i32** %7 to i8*
%38 = bitcast i32* %8 to i8*
%39 = bitcast i32* %9 to i8*
%40 = bitcast i32* %10 to i8*
%41 = mul i32 %28, %20
%42 = icmp sgt i32 %41, 0
br i1 %42, label %43, label %45
43: ; preds = %2
%44 = zext i32 %41 to i64
br label %50
45: ; preds = %50, %2
%46 = mul i32 %28, %24
%47 = icmp sgt i32 %46, 0
br i1 %47, label %48, label %68
48: ; preds = %45
%49 = zext i32 %46 to i64
br label %59
50: ; preds = %43, %50
%51 = phi i64 [ 0, %43 ], [ %57, %50 ]
%52 = tail call float (...) @rand()
%53 = load i64, i64* @RAND_MAX
%54 = sitofp i64 %53 to float
%55 = fdiv float %52, %54
%56 = getelementptr inbounds float, float* %31, i64 %51
store float %55, float* %56
%57 = add nuw nsw i64 %51, 1
%58 = icmp eq i64 %57, %44
br i1 %58, label %45, label %50
59: ; preds = %48, %59
%60 = phi i64 [ 0, %48 ], [ %66, %59 ]
%61 = tail call float (...) @rand()
%62 = load i64, i64* @RAND_MAX
%63 = sitofp i64 %62 to float
%64 = fdiv float %61, %63
%65 = getelementptr inbounds float, float* %34, i64 %60
store float %64, float* %65
%66 = add nuw nsw i64 %60, 1
%67 = icmp eq i64 %66, %49
br i1 %67, label %68, label %59
68: ; preds = %59, %45
%69 = bitcast i32* %11 to i8*
%70 = call i32 @clGetPlatformIDs(i32 0, i32* null, i32* %11)
store i32 %70, i32* %3
%71 = call i32 @check_error(i32 %70, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([199 x i8], [199 x i8]* @.str.1, i64 0, i64 0), i32 195)
%72 = load i32, i32* %11
%73 = icmp eq i32 %72, 0
br i1 %73, label %74, label %77
74: ; preds = %68
%75 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.29, i64 0, i64 0))
%76 = load i32, i32* @EXIT_FAILURE
br label %339
77: ; preds = %68
%78 = zext i32 %72 to i64
%79 = call i8* @llvm.stacksave()
%80 = alloca i32, i64 %78
%81 = load i32, i32* %11
%82 = call i32 @clGetPlatformIDs(i32 %81, i32* %80, i32* null)
store i32 %82, i32* %3
%83 = call i32 @check_error(i32 %82, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([199 x i8], [199 x i8]* @.str.1, i64 0, i64 0), i32 208)
%84 = load i32, i32* %11
%85 = icmp sgt i32 %84, 0
br i1 %85, label %86, label %102
86: ; preds = %77, %86
%87 = phi i64 [ %94, %86 ], [ 0, %77 ]
%88 = getelementptr inbounds i32, i32* %80, i64 %87
%89 = load i32, i32* %88
%90 = load i32, i32* @CL_DEVICE_TYPE_DEFAULT
%91 = call i32 @clGetDeviceIDs(i32 %89, i32 %90, i32 1, i32** %7, i32* null)
store i32 %91, i32* %3
%92 = load i32, i32* @CL_SUCCESS
%93 = icmp ne i32 %91, %92
%94 = add nuw nsw i64 %87, 1
%95 = load i32, i32* %11
%96 = sext i32 %95 to i64
%97 = icmp slt i64 %94, %96
%98 = select i1 %93, i1 %97, i1 false
br i1 %98, label %86, label %99
99: ; preds = %86
%100 = load i32*, i32** %7
%101 = icmp eq i32* %100, null
br i1 %101, label %102, label %104
102: ; preds = %77, %99
%103 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.28, i64 0, i64 0))
br label %104
104: ; preds = %102, %99
%105 = call i32 @clCreateContext(i32 0, i32 1, i32** %7, i32* null, i32* null, i32* %3)
%106 = load i32, i32* %3
%107 = call i32 @check_error(i32 %106, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([199 x i8], [199 x i8]* @.str.1, i64 0, i64 0), i32 250)
%108 = load i32*, i32** %7
%109 = call i32 @clCreateCommandQueue(i32 %105, i32* %108, i32 0, i32* %3)
%110 = load i32, i32* %3
%111 = call i32 @check_error(i32 %110, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([199 x i8], [199 x i8]* @.str.1, i64 0, i64 0), i32 265)
%112 = bitcast i32* %12 to i8*
%113 = bitcast i8** %13 to i8*
%114 = call i8* @getKernelSource(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i32* %12)
store i8* %114, i8** %13
%115 = bitcast i32* %12 to i64*
%116 = call i32 @clCreateProgramWithBinary(i32 %105, i32 1, i32** %7, i64* %115, i8** %13, i32* null, i32* %3)
%117 = load i32, i32* %3
%118 = call i32 @check_error(i32 %117, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([199 x i8], [199 x i8]* @.str.1, i64 0, i64 0), i32 332)
%119 = call i32 @clBuildProgram(i32 %116, i32 0, i32* null, i32* null, i32* null, i32* null)
store i32 %119, i32* %3
%120 = call i32 @check_error(i32 %119, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([199 x i8], [199 x i8]* @.str.1, i64 0, i64 0), i32 351)
%121 = call i32 @clCreateKernel(i32 %116, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), i32* %3)
%122 = load i32, i32* %3
%123 = call i32 @check_error(i32 %122, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([199 x i8], [199 x i8]* @.str.1, i64 0, i64 0), i32 365)
%124 = load i32, i32* @CL_MEM_READ_ONLY
%125 = call i32 @clCreateBuffer(i32 %105, i32 %124, i32 %30, i32* null, i32* %3)
store i32 %125, i32* %8
%126 = load i32, i32* %3
%127 = call i32 @check_error(i32 %126, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([199 x i8], [199 x i8]* @.str.1, i64 0, i64 0), i32 386)
%128 = load i32, i32* @CL_MEM_READ_ONLY
%129 = shl i32 %28, 2
%130 = mul i32 %129, %24
%131 = call i32 @clCreateBuffer(i32 %105, i32 %128, i32 %130, i32* null, i32* %3)
store i32 %131, i32* %9
%132 = load i32, i32* %3
%133 = call i32 @check_error(i32 %132, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([199 x i8], [199 x i8]* @.str.1, i64 0, i64 0), i32 393)
%134 = load i32, i32* @CL_MEM_READ_WRITE
%135 = call i32 @clCreateBuffer(i32 %105, i32 %134, i32 %35, i32* null, i32* %3)
store i32 %135, i32* %10
%136 = load i32, i32* %3
%137 = call i32 @check_error(i32 %136, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([199 x i8], [199 x i8]* @.str.1, i64 0, i64 0), i32 400)
%138 = load i32, i32* @CL_TRUE
%139 = call i32 @clEnqueueWriteBuffer(i32 %109, i32 %125, i32 %138, i32 0, i32 %30, float* %31, 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.15, i64 0, i64 0), i8* getelementptr inbounds ([199 x i8], [199 x i8]* @.str.1, i64 0, i64 0), i32 426)
%141 = load i32, i32* @CL_TRUE
%142 = call i32 @clEnqueueWriteBuffer(i32 %109, i32 %131, i32 %141, i32 0, i32 %130, float* %34, i32 0, i32* null, i32* null)
store i32 %142, i32* %3
%143 = call i32 @check_error(i32 %142, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([199 x i8], [199 x i8]* @.str.1, i64 0, i64 0), i32 438)
%144 = call i32 @clSetKernelArg(i32 %121, i32 0, i32 4, i32* %8)
store i32 %144, i32* %3
%145 = call i32 @clSetKernelArg(i32 %121, i32 1, i32 4, i32* %9)
%146 = load i32, i32* %3
%147 = or i32 %146, %145
store i32 %147, i32* %3
%148 = call i32 @clSetKernelArg(i32 %121, i32 2, i32 4, i32* %10)
%149 = load i32, i32* %3
%150 = or i32 %149, %148
store i32 %150, i32* %3
%151 = call i32 @clSetKernelArg(i32 %121, i32 3, i32 4, i32* %4)
%152 = load i32, i32* %3
%153 = or i32 %152, %151
store i32 %153, i32* %3
%154 = call i32 @clSetKernelArg(i32 %121, i32 4, i32 4, i32* %5)
%155 = load i32, i32* %3
%156 = or i32 %155, %154
store i32 %156, i32* %3
%157 = call i32 @clSetKernelArg(i32 %121, i32 5, i32 4, i32* %6)
%158 = load i32, i32* %3
%159 = or i32 %158, %157
store i32 %159, i32* %3
%160 = call i32 @check_error(i32 %159, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.17, i64 0, i64 0), i8* getelementptr inbounds ([199 x i8], [199 x i8]* @.str.1, i64 0, i64 0), i32 477)
%161 = bitcast <2 x i64>* %14 to i8*
%162 = getelementptr inbounds <2 x i64>, <2 x i64>* %14, i64 0, i64 0
%163 = load i32, i32* %4
%164 = load i32, i32* %5
%165 = insertelement <2 x i32> poison, i32 %163, i64 0
%166 = insertelement <2 x i32> %165, i32 %164, i64 1
%167 = sdiv <2 x i32> %166, <i32 8, i32 8>
%168 = sext <2 x i32> %167 to <2 x i64>
store <2 x i64> %168, <2 x i64>* %14
%169 = bitcast [2 x i64]* %15 to i8*
%170 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.18, i64 0, i64 0), i32 %163)
%171 = call double (...) @wtime()
%172 = getelementptr inbounds [2 x i64], [2 x i64]* %15, i64 0, i64 0
%173 = call i32 @clEnqueueNDRangeKernel(i32 %109, i32 %121, i32 2, i32* null, i64* %162, i64* %172, i32 0, i32* null, i32* null)
store i32 %173, i32* %3
%174 = call i32 @clFinish(i32 %109)
store i32 %174, i32* %3
%175 = call i32 @clEnqueueNDRangeKernel(i32 %109, i32 %121, i32 2, i32* null, i64* %162, i64* %172, i32 0, i32* null, i32* null)
store i32 %175, i32* %3
%176 = call i32 @clFinish(i32 %109)
store i32 %176, i32* %3
%177 = call i32 @clEnqueueNDRangeKernel(i32 %109, i32 %121, i32 2, i32* null, i64* %162, i64* %172, i32 0, i32* null, i32* null)
store i32 %177, i32* %3
%178 = call i32 @clFinish(i32 %109)
store i32 %178, i32* %3
%179 = call i32 @clEnqueueNDRangeKernel(i32 %109, i32 %121, i32 2, i32* null, i64* %162, i64* %172, i32 0, i32* null, i32* null)
store i32 %179, i32* %3
%180 = call i32 @clFinish(i32 %109)
store i32 %180, i32* %3
%181 = call i32 @clEnqueueNDRangeKernel(i32 %109, i32 %121, i32 2, i32* null, i64* %162, i64* %172, i32 0, i32* null, i32* null)
store i32 %181, i32* %3
%182 = call i32 @clFinish(i32 %109)
store i32 %182, i32* %3
%183 = call double (...) @wtime()
%184 = fsub double %183, %171
%185 = load i32, i32* %3
%186 = call i32 @check_error(i32 %185, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.19, i64 0, i64 0), i8* getelementptr inbounds ([199 x i8], [199 x i8]* @.str.1, i64 0, i64 0), i32 525)
%187 = load i32, i32* %4
%188 = sext i32 %187 to i64
%189 = load i32, i32* %5
%190 = sext i32 %189 to i64
%191 = load i32, i32* %6
%192 = sext i32 %191 to i64
%193 = shl nsw i64 %188, 1
%194 = mul i64 %193, %190
%195 = mul i64 %194, %192
%196 = sitofp i64 %195 to double
%197 = insertelement <2 x double> poison, double %196, i64 0
%198 = insertelement <2 x double> %197, double %184, i64 1
%199 = fdiv <2 x double> %198, <double 1.000000e+09, double 5.000000e+00>
%200 = extractelement <2 x double> %199, i64 0
%201 = extractelement <2 x double> %199, i64 1
%202 = fdiv double %200, %201
%203 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.20, i64 0, i64 0), double %202)
%204 = load i32, i32* %10
%205 = load i32, i32* @CL_TRUE
%206 = load i32, i32* %4
%207 = shl i32 %206, 2
%208 = load i32, i32* %5
%209 = mul i32 %207, %208
%210 = call i32 @clEnqueueReadBuffer(i32 %109, i32 %204, i32 %205, i32 0, i32 %209, float* %36, i32 0, i32* null, i32* null)
store i32 %210, i32* %3
%211 = call i32 @check_error(i32 %210, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.21, i64 0, i64 0), i8* getelementptr inbounds ([199 x i8], [199 x i8]* @.str.1, i64 0, i64 0), i32 553)
%212 = load i32, i32* %3
%213 = load i32, i32* @CL_SUCCESS
%214 = icmp eq i32 %212, %213
br i1 %214, label %217, label %215
215: ; preds = %104
%216 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.27, i64 0, i64 0))
br label %217
217: ; preds = %215, %104
%218 = call i32 @putchar(i32 10)
%219 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%220 = load i32, i32* %4
%221 = icmp sgt i32 %220, 0
%222 = load i32, i32* %5
br i1 %221, label %223, label %232
223: ; preds = %217, %269
%224 = phi i32 [ %270, %269 ], [ %220, %217 ]
%225 = phi i32 [ %271, %269 ], [ %222, %217 ]
%226 = phi i32 [ %272, %269 ], [ %222, %217 ]
%227 = phi i64 [ %274, %269 ], [ 0, %217 ]
%228 = phi i32 [ %273, %269 ], [ 0, %217 ]
%229 = icmp sgt i32 %226, 0
br i1 %229, label %230, label %269
230: ; preds = %223
%231 = getelementptr inbounds float, float* %36, i64 %227
br label %251
232: ; preds = %269, %217
%233 = phi i32 [ %222, %217 ], [ %271, %269 ]
%234 = phi i32 [ 0, %217 ], [ %273, %269 ]
%235 = phi i32 [ %220, %217 ], [ %270, %269 ]
%236 = mul nsw i32 %233, %235
%237 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.26, i64 0, i64 0), i32 %234, i32 %236)
%238 = load i32, i32* %8
%239 = call i32 @clReleaseMemObject(i32 %238)
%240 = load i32, i32* %9
%241 = call i32 @clReleaseMemObject(i32 %240)
%242 = load i32, i32* %10
%243 = call i32 @clReleaseMemObject(i32 %242)
%244 = call i32 @clReleaseContext(i32 %105)
%245 = call i32 @clReleaseCommandQueue(i32 %109)
%246 = call i32 @clReleaseProgram(i32 %116)
%247 = call i32 @clReleaseKernel(i32 %121)
%248 = call i32 @free(float* %31)
%249 = call i32 @free(float* %34)
%250 = call i32 @free(float* %36)
br label %339
251: ; preds = %230, %334
%252 = phi i32 [ %225, %230 ], [ %335, %334 ]
%253 = phi i32 [ 0, %230 ], [ %337, %334 ]
%254 = phi i32 [ %228, %230 ], [ %336, %334 ]
%255 = load i32, i32* %6
%256 = icmp sgt i32 %255, 0
%257 = load i32, i32* %4
br i1 %256, label %258, label %291
258: ; preds = %251
%259 = mul nsw i32 %255, %253
%260 = sext i32 %257 to i64
%261 = sext i32 %259 to i64
%262 = zext i32 %255 to i64
%263 = and i64 %262, 1
%264 = icmp eq i32 %255, 1
br i1 %264, label %277, label %265
265: ; preds = %258
%266 = and i64 %262, 4294967294
br label %302
267: ; preds = %334
%268 = load i32, i32* %4
br label %269
269: ; preds = %267, %223
%270 = phi i32 [ %224, %223 ], [ %268, %267 ]
%271 = phi i32 [ %225, %223 ], [ %335, %267 ]
%272 = phi i32 [ %226, %223 ], [ %335, %267 ]
%273 = phi i32 [ %228, %223 ], [ %336, %267 ]
%274 = add nuw nsw i64 %227, 1
%275 = sext i32 %270 to i64
%276 = icmp slt i64 %274, %275
br i1 %276, label %223, label %232
277: ; preds = %302, %258
%278 = phi float [ undef, %258 ], [ %322, %302 ]
%279 = phi i64 [ 0, %258 ], [ %323, %302 ]
%280 = phi float [ 0.000000e+00, %258 ], [ %322, %302 ]
%281 = icmp eq i64 %263, 0
br i1 %281, label %291, label %282
282: ; preds = %277
%283 = mul nsw i64 %279, %260
%284 = add nsw i64 %283, %227
%285 = getelementptr inbounds float, float* %31, i64 %284
%286 = load float, float* %285
%287 = add nsw i64 %279, %261
%288 = getelementptr inbounds float, float* %34, i64 %287
%289 = load float, float* %288
%290 = call float @llvm.fmuladd.f32(float %286, float %289, float %280)
br label %291
291: ; preds = %282, %277, %251
%292 = phi float [ 0.000000e+00, %251 ], [ %278, %277 ], [ %290, %282 ]
%293 = mul nsw i32 %257, %253
%294 = sext i32 %293 to i64
%295 = add nsw i64 %227, %294
%296 = getelementptr inbounds float, float* %36, i64 %295
%297 = load float, float* %296
%298 = fsub float %292, %297
%299 = fmul float %298, %298
%300 = fpext float %299 to double
%301 = fcmp olt double %300, 0x3EB0C6F7A0B5ED8D
br i1 %301, label %326, label %328
302: ; preds = %302, %265
%303 = phi i64 [ 0, %265 ], [ %323, %302 ]
%304 = phi float [ 0.000000e+00, %265 ], [ %322, %302 ]
%305 = phi i64 [ 0, %265 ], [ %324, %302 ]
%306 = mul nsw i64 %303, %260
%307 = add nsw i64 %306, %227
%308 = getelementptr inbounds float, float* %31, i64 %307
%309 = load float, float* %308
%310 = add nsw i64 %303, %261
%311 = getelementptr inbounds float, float* %34, i64 %310
%312 = load float, float* %311
%313 = call float @llvm.fmuladd.f32(float %309, float %312, float %304)
%314 = or i64 %303, 1
%315 = mul nsw i64 %314, %260
%316 = add nsw i64 %315, %227
%317 = getelementptr inbounds float, float* %31, i64 %316
%318 = load float, float* %317
%319 = add nsw i64 %314, %261
%320 = getelementptr inbounds float, float* %34, i64 %319
%321 = load float, float* %320
%322 = call float @llvm.fmuladd.f32(float %318, float %321, float %313)
%323 = add nuw nsw i64 %303, 2
%324 = add i64 %305, 2
%325 = icmp eq i64 %324, %266
br i1 %325, label %277, label %302
326: ; preds = %291
%327 = add i32 %254, 1
br label %334
328: ; preds = %291
%329 = fpext float %298 to double
%330 = load float, float* %231
%331 = fpext float %330 to double
%332 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.25, i64 0, i64 0), double %329, double %331)
%333 = load i32, i32* %5
br label %334
334: ; preds = %326, %328
%335 = phi i32 [ %252, %326 ], [ %333, %328 ]
%336 = phi i32 [ %327, %326 ], [ %254, %328 ]
%337 = add nuw nsw i32 %253, 1
%338 = icmp slt i32 %337, %335
br i1 %338, label %251, label %267
339: ; preds = %232, %74
%340 = phi i32 [ %76, %74 ], [ 0, %232 ]
ret i32 %340
}