#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);
float *matrixTranspose(int, int, float *);
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;
  }
  h_b = matrixTranspose(K, N, h_b);
  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/NT/gemm_block8x8_thread8x8_test.c",
              204);
  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/NT/gemm_block8x8_thread8x8_test.c",
              217);
  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/NT/gemm_block8x8_thread8x8_test.c",
              259);
  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/NT/gemm_block8x8_thread8x8_test.c",
              274);
  char *gemm_kernel = getKernelSource("gemm_block8x8_thread8x8_private.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/NT/gemm_block8x8_thread8x8_test.c",
              297);
  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/NT/gemm_block8x8_thread8x8_test.c",
              316);
  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/NT/gemm_block8x8_thread8x8_test.c",
              330);
  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/NT/gemm_block8x8_thread8x8_test.c",
              351);
  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/NT/gemm_block8x8_thread8x8_test.c",
              358);
  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/NT/gemm_block8x8_thread8x8_test.c",
              365);
  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/NT/gemm_block8x8_thread8x8_test.c",
              391);
  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/NT/gemm_block8x8_thread8x8_test.c",
              403);
  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/NT/gemm_block8x8_thread8x8_test.c",
              442);
  const size_t global[2] = {M / 8, N / 8};
  const size_t local[2] = {8, 8};
  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/NT/gemm_block8x8_thread8x8_test.c",
              491);
  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/NT/gemm_block8x8_thread8x8_test.c",
              519);
  if (err != CL_SUCCESS) {
    printf("Error: Failed to read output array\n");
  }
  printf("\n");
  correct = 0;
  float temp = 0;
  clReleaseMemObject(d_a);
  clReleaseMemObject(d_b);
  clReleaseMemObject(d_c);
  clReleaseContext(context);
  clReleaseCommandQueue(command_queue);
  clReleaseProgram(program);
  clReleaseKernel(ko_MatMul);
  free(h_a);
  free(h_b);
  free(h_c);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1190 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1190 <atoi@plt>
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1190 <atoi@plt>
mov    %eax,-0x24(%rbp)
mov    -0x1c(%rbp),%eax
imul   -0x24(%rbp),%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1140 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x24(%rbp),%eax
imul   -0x20(%rbp),%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1140 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x1c(%rbp),%eax
imul   -0x20(%rbp),%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1140 <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    1393 <main+0xe3>
mov    $0x0,%al
call   11c0 <rand@plt>
mov    0x2c69(%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    134f <main+0x9f>
movl   $0x0,-0x68(%rbp)
mov    -0x68(%rbp),%eax
mov    -0x20(%rbp),%ecx
imul   -0x24(%rbp),%ecx
cmp    %ecx,%eax
jge    13de <main+0x12e>
mov    $0x0,%al
call   11c0 <rand@plt>
mov    0x2c1e(%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    139a <main+0xea>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    -0x38(%rbp),%rdx
call   1110 <matrixTranspose@plt>
mov    %rax,-0x38(%rbp)
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    0xc0b(%rip),%rsi
lea    0xc16(%rip),%rdx
mov    $0xcc,%ecx
call   1120 <check_error@plt>
cmpl   $0x0,-0x6c(%rbp)
jne    1447 <main+0x197>
lea    0xcb8(%rip),%rdi
mov    $0x0,%al
call   10e0 <printf@plt>
mov    0x2b83(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1b26 <main+0x876>
mov    -0x6c(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x78(%rbp)
lea    0xf(,%rax,4),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rsi
sub    %rcx,%rsi
mov    %rsi,-0xd8(%rbp)
mov    %rsi,%rsp
mov    %rax,-0x80(%rbp)
mov    -0x6c(%rbp),%edi
xor    %eax,%eax
mov    %eax,%edx
call   10d0 <clGetPlatformIDs@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
lea    0xc70(%rip),%rsi
lea    0xb99(%rip),%rdx
mov    $0xd9,%ecx
call   1120 <check_error@plt>
movl   $0x0,-0x68(%rbp)
mov    -0x68(%rbp),%eax
cmp    -0x6c(%rbp),%eax
jge    1505 <main+0x255>
mov    -0xd8(%rbp),%rax
movslq -0x68(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    0x2b05(%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    0x2acb(%rip),%rcx
cmp    (%rcx),%eax
jne    14f2 <main+0x242>
jmp    1505 <main+0x255>
jmp    14f7 <main+0x247>
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    14a2 <main+0x1f2>
cmpq   $0x0,-0x48(%rbp)
jne    151e <main+0x26e>
lea    0xbfb(%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    0xbdd(%rip),%rsi
lea    0xadc(%rip),%rdx
mov    $0x103,%ecx
call   1120 <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    0xbbe(%rip),%rsi
lea    0xaac(%rip),%rdx
mov    $0x112,%ecx
call   1120 <check_error@plt>
lea    0xbbd(%rip),%rdi
call   11a0 <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    0xbab(%rip),%rsi
lea    0xa5f(%rip),%rdx
mov    $0x129,%ecx
call   1120 <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    0xb92(%rip),%rsi
lea    0xa29(%rip),%rdx
mov    $0x13c,%ecx
call   1120 <check_error@plt>
mov    -0x54(%rbp),%edi
lea    0xb85(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1180 <clCreateKernel@plt>
mov    %eax,-0x58(%rbp)
mov    -0x14(%rbp),%edi
lea    0xb74(%rip),%rsi
lea    0x9f8(%rip),%rdx
mov    $0x14a,%ecx
call   1120 <check_error@plt>
mov    -0x4c(%rbp),%edi
mov    0x2972(%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    0xb3b(%rip),%rsi
lea    0x9af(%rip),%rdx
mov    $0x15f,%ecx
call   1120 <check_error@plt>
mov    -0x4c(%rbp),%edi
mov    0x2929(%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    0xb06(%rip),%rsi
lea    0x966(%rip),%rdx
mov    $0x166,%ecx
call   1120 <check_error@plt>
mov    -0x4c(%rbp),%edi
mov    0x2908(%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    0xad1(%rip),%rsi
lea    0x91d(%rip),%rdx
mov    $0x16d,%ecx
call   1120 <check_error@plt>
mov    -0x50(%rbp),%edi
mov    -0x5c(%rbp),%esi
mov    0x28c4(%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   11d0 <clEnqueueWriteBuffer@plt>
add    $0x20,%rsp
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
lea    0xa77(%rip),%rsi
lea    0x8af(%rip),%rdx
mov    $0x187,%ecx
call   1120 <check_error@plt>
mov    -0x50(%rbp),%edi
mov    -0x60(%rbp),%esi
mov    0x2856(%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   11d0 <clEnqueueWriteBuffer@plt>
add    $0x20,%rsp
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
lea    0xa1c(%rip),%rsi
lea    0x841(%rip),%rdx
mov    $0x193,%ecx
call   1120 <check_error@plt>
mov    -0x58(%rbp),%edi
xor    %esi,%esi
mov    $0x4,%edx
lea    -0x5c(%rbp),%rcx
call   11b0 <clSetKernelArg@plt>
mov    %eax,-0x14(%rbp)
mov    -0x58(%rbp),%edi
mov    $0x1,%esi
mov    $0x4,%edx
lea    -0x60(%rbp),%rcx
call   11b0 <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   11b0 <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   11b0 <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   11b0 <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   11b0 <clSetKernelArg@plt>
or     -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
lea    0x975(%rip),%rsi
lea    0x787(%rip),%rdx
mov    $0x1ba,%ecx
call   1120 <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    0x9b4(%rip),%rax
mov    %rax,-0xb0(%rbp)
mov    0x9ae(%rip),%rax
mov    %rax,-0xa8(%rbp)
mov    $0x0,%al
call   10f0 <wtime@plt>
movsd  %xmm0,-0xb8(%rbp)
ff
movl   $0x0,-0xbc(%rbp)
cmpl   $0x5,-0xbc(%rbp)
jge    197e <main+0x6ce>
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    190a <main+0x65a>
mov    $0x0,%al
call   10f0 <wtime@plt>
subsd  -0xb8(%rbp),%xmm0
ff
movsd  0x67b(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
mov    -0x14(%rbp),%edi
lea    0x87f(%rip),%rsi
lea    0x678(%rip),%rdx
mov    $0x1eb,%ecx
call   1120 <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  0x627(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0x613(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0xc8(%rbp)
ff
movsd  -0xc8(%rbp),%xmm0
divsd  -0xb8(%rbp),%xmm0
ff
lea    0x837(%rip),%rdi
mov    $0x1,%al
call   10e0 <printf@plt>
mov    -0x50(%rbp),%edi
mov    -0x64(%rbp),%esi
mov    0x25c4(%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   1150 <clEnqueueReadBuffer@plt>
add    $0x20,%rsp
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
lea    0x7e0(%rip),%rsi
lea    0x5af(%rip),%rdx
mov    $0x207,%ecx
call   1120 <check_error@plt>
mov    -0x14(%rbp),%eax
mov    0x2521(%rip),%rcx
cmp    (%rcx),%eax
je     1aa5 <main+0x7f5>
lea    0x7c9(%rip),%rdi
mov    $0x0,%al
call   10e0 <printf@plt>
lea    0x676(%rip),%rdi
mov    $0x0,%al
call   10e0 <printf@plt>
movl   $0x0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xcc(%rbp)
ff
mov    -0x5c(%rbp),%edi
call   1170 <clReleaseMemObject@plt>
mov    -0x60(%rbp),%edi
call   1170 <clReleaseMemObject@plt>
mov    -0x64(%rbp),%edi
call   1170 <clReleaseMemObject@plt>
mov    -0x4c(%rbp),%edi
call   1160 <clReleaseContext@plt>
mov    -0x50(%rbp),%edi
call   1130 <clReleaseCommandQueue@plt>
mov    -0x54(%rbp),%edi
call   1090 <clReleaseProgram@plt>
mov    -0x58(%rbp),%edi
call   1070 <clReleaseKernel@plt>
mov    -0x30(%rbp),%rdi
call   1040 <free@plt>
mov    -0x38(%rbp),%rdi
call   1040 <free@plt>
mov    -0x40(%rbp),%rdi
call   1040 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x78(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa8,%rsp
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   11b0 <atoi@plt>
mov    %eax,-0x38(%rbp)
mov    %rax,%r14
mov    %rax,-0x60(%rbp)
mov    0x10(%rbx),%rdi
call   11b0 <atoi@plt>
mov    %eax,%r15d
mov    %eax,-0x34(%rbp)
mov    0x18(%rbx),%rdi
call   11b0 <atoi@plt>
mov    %eax,%r13d
mov    %eax,-0x4c(%rbp)
lea    0x0(,%r14,4),%ebx
mov    %ebx,%edi
imul   %eax,%edi
mov    %edi,-0x40(%rbp)
call   1160 <malloc@plt>
mov    %rax,%r12
mov    %r15d,%eax
imul   %r13d,%eax
mov    %rax,-0x68(%rbp)
lea    0x0(,%rax,4),%edi
mov    %edi,-0xa0(%rbp)
call   1160 <malloc@plt>
mov    %rax,%r14
mov    %r15d,-0x58(%rbp)
imul   %r15d,%ebx
mov    %ebx,-0x88(%rbp)
mov    %ebx,%edi
call   1160 <malloc@plt>
mov    %rax,-0xa8(%rbp)
mov    -0x60(%rbp),%rax
mov    %r13d,-0x70(%rbp)
imul   %r13d,%eax
test   %eax,%eax
jle    13b3 <main+0xe3>
mov    %eax,%ebx
mov    0x2c53(%rip),%r13
xor    %r15d,%r15d
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   11e0 <rand@plt>
xorps  %xmm1,%xmm1
cvtsi2ssq 0x0(%r13),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,(%r12,%r15,4)
add    $0x1,%r15
cmp    %r15,%rbx
jne    1390 <main+0xc0>
mov    %r12,-0x60(%rbp)
mov    -0x68(%rbp),%rax
test   %eax,%eax
jle    13f3 <main+0x123>
mov    %eax,%r15d
mov    0x2c0f(%rip),%r12
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   11e0 <rand@plt>
xorps  %xmm1,%xmm1
cvtsi2ssq (%r12),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,(%r14,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    13d0 <main+0x100>
mov    -0x70(%rbp),%edi
mov    -0x58(%rbp),%esi
mov    %r14,%rdx
call   1130 <matrixTranspose@plt>
mov    %rax,-0x58(%rbp)
lea    -0x30(%rbp),%rdx
xor    %edi,%edi
xor    %esi,%esi
call   10f0 <clGetPlatformIDs@plt>
mov    %eax,-0x2c(%rbp)
lea    0xc14(%rip),%rsi
lea    0xc1f(%rip),%rdx
mov    %eax,%edi
mov    $0xcc,%ecx
call   1140 <check_error@plt>
mov    -0x30(%rbp),%eax
test   %rax,%rax
je     1ada <main+0x80a>
mov    %rsp,-0x70(%rbp)
mov    %rsp,%r12
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
mov    -0x30(%rbp),%edi
mov    %r12,%rsi
xor    %edx,%edx
call   10f0 <clGetPlatformIDs@plt>
mov    %eax,-0x2c(%rbp)
lea    0xc94(%rip),%rsi
lea    0xbd0(%rip),%rdx
mov    %eax,%edi
mov    $0xd9,%ecx
call   1140 <check_error@plt>
cmpl   $0x0,-0x30(%rbp)
jle    14d8 <main+0x208>
mov    $0x1,%ebx
mov    0x2b38(%rip),%r15
lea    -0x78(%rbp),%r14
mov    0x2b15(%rip),%r13
nopl   0x0(%rax,%rax,1)
mov    -0x4(%r12,%rbx,4),%edi
mov    (%r15),%esi
mov    $0x1,%edx
mov    %r14,%rcx
xor    %r8d,%r8d
call   10c0 <clGetDeviceIDs@plt>
mov    %eax,-0x2c(%rbp)
cmp    0x0(%r13),%eax
je     14d1 <main+0x201>
lea    0x1(%rbx),%rax
movslq -0x30(%rbp),%rcx
cmp    %rcx,%rbx
mov    %rax,%rbx
jl     14a0 <main+0x1d0>
cmpq   $0x0,-0x78(%rbp)
jne    14e4 <main+0x214>
lea    0xd9e(%rip),%rdi
call   1080 <puts@plt>
lea    -0x78(%rbp),%rdx
lea    -0x2c(%rbp),%r14
xor    %edi,%edi
mov    $0x1,%esi
xor    %ecx,%ecx
xor    %r8d,%r8d
mov    %r14,%r9
call   1120 <clCreateContext@plt>
mov    %eax,%r15d
mov    -0x2c(%rbp),%edi
lea    0xc0a(%rip),%rsi
lea    0xb2e(%rip),%r12
mov    %r12,%rdx
mov    $0x103,%ecx
call   1140 <check_error@plt>
mov    -0x78(%rbp),%rsi
mov    %r15d,%edi
xor    %edx,%edx
mov    %r14,%rcx
call   10e0 <clCreateCommandQueue@plt>
mov    %eax,-0x80(%rbp)
mov    -0x2c(%rbp),%edi
lea    0xbe9(%rip),%rsi
mov    %r12,%rdx
mov    $0x112,%ecx
call   1140 <check_error@plt>
lea    0xbec(%rip),%rdi
call   11c0 <getKernelSource@plt>
mov    %rax,-0xb0(%rbp)
lea    -0xb0(%rbp),%rdx
mov    %r15d,%edi
mov    $0x1,%esi
xor    %ecx,%ecx
mov    %r14,%r8
call   1070 <clCreateProgramWithSource@plt>
mov    %eax,%ebx
mov    -0x2c(%rbp),%edi
lea    0xbde(%rip),%rsi
mov    %r12,%rdx
mov    $0x129,%ecx
call   1140 <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    0xbd1(%rip),%rsi
mov    %eax,%edi
mov    %r12,%rdx
mov    $0x13c,%ecx
call   1140 <check_error@plt>
lea    0xbc9(%rip),%rsi
mov    %ebx,-0x84(%rbp)
mov    %ebx,%edi
mov    %r14,%rdx
call   11a0 <clCreateKernel@plt>
mov    %eax,-0x7c(%rbp)
mov    -0x2c(%rbp),%edi
lea    0xbb1(%rip),%rsi
mov    %r12,%rbx
mov    %r12,%rdx
mov    $0x14a,%ecx
call   1140 <check_error@plt>
mov    0x29c0(%rip),%r12
mov    (%r12),%esi
mov    %r15d,%edi
mov    -0x40(%rbp),%edx
xor    %ecx,%ecx
mov    %r14,%r8
call   10a0 <clCreateBuffer@plt>
mov    %eax,%r13d
mov    %eax,-0x48(%rbp)
mov    -0x2c(%rbp),%edi
lea    0xb86(%rip),%rsi
mov    %rbx,%rdx
mov    $0x15f,%ecx
call   1140 <check_error@plt>
mov    (%r12),%esi
mov    %r15d,%edi
mov    -0xa0(%rbp),%edx
xor    %ecx,%ecx
mov    %r14,%r8
call   10a0 <clCreateBuffer@plt>
mov    %eax,%r12d
mov    %eax,-0x44(%rbp)
mov    -0x2c(%rbp),%edi
lea    0xb66(%rip),%rsi
mov    %rbx,%rdx
mov    $0x166,%ecx
call   1140 <check_error@plt>
mov    0x297c(%rip),%rax
mov    (%rax),%esi
mov    %r15d,-0x68(%rbp)
mov    %r15d,%edi
mov    -0x7c(%rbp),%r14d
mov    -0x88(%rbp),%edx
xor    %ecx,%ecx
lea    -0x2c(%rbp),%r8
call   10a0 <clCreateBuffer@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x2c(%rbp),%edi
lea    0xb3b(%rip),%rsi
mov    %rbx,%rdx
mov    %rbx,%r15
mov    $0x16d,%ecx
call   1140 <check_error@plt>
mov    0x2942(%rip),%rax
mov    (%rax),%edx
sub    $0x20,%rsp
xorps  %xmm0,%xmm0
movups %xmm0,0x8(%rsp)
movl   $0x0,(%rsp)
mov    -0x80(%rbp),%ebx
mov    %ebx,%edi
mov    %r13d,%esi
xor    %ecx,%ecx
mov    -0x40(%rbp),%r8d
mov    -0x60(%rbp),%r9
call   11f0 <clEnqueueWriteBuffer@plt>
add    $0x20,%rsp
mov    %eax,-0x2c(%rbp)
lea    0xafe(%rip),%rsi
mov    %eax,%edi
mov    %r15,%rdx
mov    $0x187,%ecx
call   1140 <check_error@plt>
mov    0x28f2(%rip),%rax
mov    (%rax),%edx
sub    $0x20,%rsp
xorps  %xmm0,%xmm0
movups %xmm0,0x8(%rsp)
movl   $0x0,(%rsp)
mov    %ebx,%edi
mov    %r12d,%esi
xor    %ecx,%ecx
mov    -0xa0(%rbp),%r8d
mov    -0x58(%rbp),%r9
call   11f0 <clEnqueueWriteBuffer@plt>
add    $0x20,%rsp
mov    %eax,-0x2c(%rbp)
lea    0xac1(%rip),%rsi
mov    %eax,%edi
mov    %r15,%rdx
mov    %r15,%r12
mov    $0x193,%ecx
call   1140 <check_error@plt>
lea    -0x48(%rbp),%rcx
mov    %r14d,%edi
xor    %esi,%esi
mov    $0x4,%edx
call   11d0 <clSetKernelArg@plt>
mov    %eax,-0x2c(%rbp)
lea    -0x44(%rbp),%rcx
mov    %r14d,%edi
mov    $0x1,%esi
mov    $0x4,%edx
call   11d0 <clSetKernelArg@plt>
or     %eax,-0x2c(%rbp)
lea    -0x3c(%rbp),%rcx
mov    %r14d,%edi
mov    $0x2,%esi
mov    $0x4,%edx
call   11d0 <clSetKernelArg@plt>
or     %eax,-0x2c(%rbp)
lea    -0x38(%rbp),%rcx
mov    %r14d,%edi
mov    $0x3,%esi
mov    $0x4,%edx
call   11d0 <clSetKernelArg@plt>
or     %eax,-0x2c(%rbp)
lea    -0x34(%rbp),%rcx
mov    %r14d,%edi
mov    $0x4,%esi
mov    $0x4,%edx
call   11d0 <clSetKernelArg@plt>
or     %eax,-0x2c(%rbp)
lea    -0x4c(%rbp),%rcx
mov    %r14d,%edi
mov    $0x5,%esi
mov    $0x4,%edx
call   11d0 <clSetKernelArg@plt>
or     -0x2c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
lea    0xa25(%rip),%rsi
mov    %eax,%edi
mov    %r15,%rdx
mov    $0x1ba,%ecx
call   1140 <check_error@plt>
movd   -0x34(%rbp),%xmm0
movd   -0x38(%rbp),%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,-0xd0(%rbp)
ff
movapd 0x7f1(%rip),%xmm0
movapd %xmm0,-0xc0(%rbp)
ff
xor    %eax,%eax
call   1110 <wtime@plt>
movsd  %xmm0,-0xa0(%rbp)
ff
sub    $0x20,%rsp
xorpd  %xmm0,%xmm0
movupd %xmm0,0x8(%rsp)
movl   $0x0,(%rsp)
lea    -0xd0(%rbp),%r15
lea    -0xc0(%rbp),%r13
mov    %ebx,%edi
mov    %r14d,%esi
mov    $0x2,%edx
xor    %ecx,%ecx
mov    %r15,%r8
mov    %r13,%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    %r14d,%esi
mov    $0x2,%edx
xor    %ecx,%ecx
mov    %r15,%r8
mov    %r13,%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    %r14d,%esi
mov    $0x2,%edx
xor    %ecx,%ecx
mov    %r15,%r8
mov    %r13,%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    %r14d,%esi
mov    $0x2,%edx
xor    %ecx,%ecx
mov    %r15,%r8
mov    %r13,%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    %r14d,%esi
mov    $0x2,%edx
xor    %ecx,%ecx
mov    %r15,%r8
mov    %r13,%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  -0xa0(%rbp),%xmm0
ff
movapd %xmm0,-0xa0(%rbp)
ff
mov    -0x2c(%rbp),%edi
lea    0x877(%rip),%rsi
mov    %r12,%rdx
mov    $0x1eb,%ecx
call   1140 <check_error@plt>
movslq -0x38(%rbp),%rax
movslq -0x34(%rbp),%rcx
imul   %rax,%rcx
movslq -0x4c(%rbp),%rax
imul   %rcx,%rax
add    %rax,%rax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
unpcklpd -0xa0(%rbp),%xmm0
ff
divpd  0x61e(%rip),%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
divsd  %xmm1,%xmm0
lea    0x845(%rip),%rdi
mov    $0x1,%al
call   1100 <printf@plt>
mov    -0x3c(%rbp),%esi
mov    0x25e2(%rip),%rax
mov    (%rax),%edx
mov    -0x38(%rbp),%r8d
imul   -0x34(%rbp),%r8d
shl    $0x2,%r8d
sub    $0x20,%rsp
xorpd  %xmm0,%xmm0
movupd %xmm0,0x8(%rsp)
movl   $0x0,(%rsp)
mov    %ebx,%edi
xor    %ecx,%ecx
mov    -0xa8(%rbp),%r15
mov    %r15,%r9
call   1170 <clEnqueueReadBuffer@plt>
add    $0x20,%rsp
mov    %eax,-0x2c(%rbp)
lea    0x7fc(%rip),%rsi
mov    %eax,%edi
mov    %r12,%rdx
mov    $0x207,%ecx
call   1140 <check_error@plt>
mov    -0x2c(%rbp),%eax
mov    0x254c(%rip),%rcx
cmp    (%rcx),%eax
je     1a74 <main+0x7a4>
lea    0x7eb(%rip),%rdi
call   1080 <puts@plt>
mov    $0xa,%edi
call   1050 <putchar@plt>
mov    -0x48(%rbp),%edi
call   1190 <clReleaseMemObject@plt>
mov    -0x44(%rbp),%edi
call   1190 <clReleaseMemObject@plt>
mov    -0x3c(%rbp),%edi
call   1190 <clReleaseMemObject@plt>
mov    -0x68(%rbp),%edi
call   1180 <clReleaseContext@plt>
mov    %ebx,%edi
call   1150 <clReleaseCommandQueue@plt>
mov    -0x84(%rbp),%edi
call   10b0 <clReleaseProgram@plt>
mov    %r14d,%edi
call   1090 <clReleaseKernel@plt>
mov    -0x60(%rbp),%rdi
call   1040 <free@plt>
mov    -0x58(%rbp),%rdi
call   1040 <free@plt>
mov    %r15,%rdi
call   1040 <free@plt>
mov    -0x70(%rbp),%rsp
xor    %eax,%eax
jmp    1aef <main+0x81f>
lea    0x7ad(%rip),%rdi
call   1080 <puts@plt>
mov    0x24d3(%rip),%rax
mov    (%rax),%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@RAND_MAX = global i64 0
@.str = [18 x i8] c"Finding platforms\00"
@.str.1 = [189 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/haohaibo/tutorial/refs/heads/master/LearnOpenCLFromScratch/dgemm/NT/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 = [35 x i8] c"gemm_block8x8_thread8x8_private.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 = [29 x i8] c"Waiting for kernel to finish\00"
@.str.19 = [13 x i8] c"%.1lf GFLOPS\00"
@.str.20 = [19 x i8] c"Copying d_c to h_c\00"
@str = [35 x i8] c"Error: Failed to read output array\00"
@str.23 = [17 x i8] c"No devices found\00"
@str.24 = [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 = tail call float* @matrixTranspose(i32 %27, i32 %23, float* %33)
%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 ([189 x i8], [189 x i8]* @.str.1, i64 0, i64 0), i32 204)
%72 = load i32, i32* %11
%73 = icmp eq i32 %72, 0
br i1 %73, label %74, label %77
74: ; preds = %67
%75 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.24, i64 0, i64 0))
%76 = load i32, i32* @EXIT_FAILURE
br label %229
77: ; preds = %67
%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 ([189 x i8], [189 x i8]* @.str.1, i64 0, i64 0), i32 217)
%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.23, 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 ([189 x i8], [189 x i8]* @.str.1, i64 0, i64 0), i32 259)
%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 ([189 x i8], [189 x i8]* @.str.1, i64 0, i64 0), i32 274)
%112 = bitcast i8** %12 to i8*
%113 = call i8* @getKernelSource(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.7, i64 0, i64 0))
store i8* %113, i8** %12
%114 = call i32 @clCreateProgramWithSource(i32 %105, i32 1, i8** %12, i32* null, i32* %3)
%115 = load i32, i32* %3
%116 = call i32 @check_error(i32 %115, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([189 x i8], [189 x i8]* @.str.1, i64 0, i64 0), i32 297)
%117 = call i32 @clBuildProgram(i32 %114, i32 0, i32* null, i32* null, i32* null, i32* null)
store i32 %117, i32* %3
%118 = call i32 @check_error(i32 %117, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([189 x i8], [189 x i8]* @.str.1, i64 0, i64 0), i32 316)
%119 = call i32 @clCreateKernel(i32 %114, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), i32* %3)
%120 = load i32, i32* %3
%121 = call i32 @check_error(i32 %120, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([189 x i8], [189 x i8]* @.str.1, i64 0, i64 0), i32 330)
%122 = load i32, i32* @CL_MEM_READ_ONLY
%123 = call i32 @clCreateBuffer(i32 %105, i32 %122, i32 %29, i32* null, i32* %3)
store i32 %123, i32* %8
%124 = load i32, i32* %3
%125 = call i32 @check_error(i32 %124, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([189 x i8], [189 x i8]* @.str.1, i64 0, i64 0), i32 351)
%126 = load i32, i32* @CL_MEM_READ_ONLY
%127 = shl i32 %27, 2
%128 = mul i32 %127, %23
%129 = call i32 @clCreateBuffer(i32 %105, i32 %126, i32 %128, i32* null, i32* %3)
store i32 %129, i32* %9
%130 = load i32, i32* %3
%131 = call i32 @check_error(i32 %130, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([189 x i8], [189 x i8]* @.str.1, i64 0, i64 0), i32 358)
%132 = load i32, i32* @CL_MEM_READ_WRITE
%133 = call i32 @clCreateBuffer(i32 %105, i32 %132, i32 %34, i32* null, i32* %3)
store i32 %133, i32* %10
%134 = load i32, i32* %3
%135 = call i32 @check_error(i32 %134, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([189 x i8], [189 x i8]* @.str.1, i64 0, i64 0), i32 365)
%136 = load i32, i32* @CL_TRUE
%137 = call i32 @clEnqueueWriteBuffer(i32 %109, i32 %123, i32 %136, i32 0, i32 %29, float* %30, i32 0, i32* null, i32* null)
store i32 %137, i32* %3
%138 = call i32 @check_error(i32 %137, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.15, i64 0, i64 0), i8* getelementptr inbounds ([189 x i8], [189 x i8]* @.str.1, i64 0, i64 0), i32 391)
%139 = load i32, i32* @CL_TRUE
%140 = call i32 @clEnqueueWriteBuffer(i32 %109, i32 %129, i32 %139, i32 0, i32 %128, float* %68, i32 0, i32* null, i32* null)
store i32 %140, i32* %3
%141 = call i32 @check_error(i32 %140, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.16, i64 0, i64 0), i8* getelementptr inbounds ([189 x i8], [189 x i8]* @.str.1, i64 0, i64 0), i32 403)
%142 = call i32 @clSetKernelArg(i32 %119, i32 0, i32 4, i32* %8)
store i32 %142, i32* %3
%143 = call i32 @clSetKernelArg(i32 %119, i32 1, i32 4, i32* %9)
%144 = load i32, i32* %3
%145 = or i32 %144, %143
store i32 %145, i32* %3
%146 = call i32 @clSetKernelArg(i32 %119, i32 2, i32 4, i32* %10)
%147 = load i32, i32* %3
%148 = or i32 %147, %146
store i32 %148, i32* %3
%149 = call i32 @clSetKernelArg(i32 %119, i32 3, i32 4, i32* %4)
%150 = load i32, i32* %3
%151 = or i32 %150, %149
store i32 %151, i32* %3
%152 = call i32 @clSetKernelArg(i32 %119, i32 4, i32 4, i32* %5)
%153 = load i32, i32* %3
%154 = or i32 %153, %152
store i32 %154, i32* %3
%155 = call i32 @clSetKernelArg(i32 %119, i32 5, i32 4, i32* %6)
%156 = load i32, i32* %3
%157 = or i32 %156, %155
store i32 %157, i32* %3
%158 = call i32 @check_error(i32 %157, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.17, i64 0, i64 0), i8* getelementptr inbounds ([189 x i8], [189 x i8]* @.str.1, i64 0, i64 0), i32 442)
%159 = bitcast <2 x i64>* %13 to i8*
%160 = getelementptr inbounds <2 x i64>, <2 x i64>* %13, i64 0, i64 0
%161 = load i32, i32* %4
%162 = load i32, i32* %5
%163 = insertelement <2 x i32> poison, i32 %161, i64 0
%164 = insertelement <2 x i32> %163, i32 %162, i64 1
%165 = sdiv <2 x i32> %164, <i32 8, i32 8>
%166 = sext <2 x i32> %165 to <2 x i64>
store <2 x i64> %166, <2 x i64>* %13
%167 = bitcast [2 x i64]* %14 to i8*
%168 = call double (...) @wtime()
%169 = getelementptr inbounds [2 x i64], [2 x i64]* %14, i64 0, i64 0
%170 = call i32 @clEnqueueNDRangeKernel(i32 %109, i32 %119, i32 2, i32* null, i64* %160, i64* %169, i32 0, i32* null, i32* null)
store i32 %170, i32* %3
%171 = call i32 @clFinish(i32 %109)
store i32 %171, i32* %3
%172 = call i32 @clEnqueueNDRangeKernel(i32 %109, i32 %119, i32 2, i32* null, i64* %160, i64* %169, i32 0, i32* null, i32* null)
store i32 %172, i32* %3
%173 = call i32 @clFinish(i32 %109)
store i32 %173, i32* %3
%174 = call i32 @clEnqueueNDRangeKernel(i32 %109, i32 %119, i32 2, i32* null, i64* %160, i64* %169, i32 0, i32* null, i32* null)
store i32 %174, i32* %3
%175 = call i32 @clFinish(i32 %109)
store i32 %175, i32* %3
%176 = call i32 @clEnqueueNDRangeKernel(i32 %109, i32 %119, i32 2, i32* null, i64* %160, i64* %169, i32 0, i32* null, i32* null)
store i32 %176, i32* %3
%177 = call i32 @clFinish(i32 %109)
store i32 %177, i32* %3
%178 = call i32 @clEnqueueNDRangeKernel(i32 %109, i32 %119, i32 2, i32* null, i64* %160, i64* %169, i32 0, i32* null, i32* null)
store i32 %178, i32* %3
%179 = call i32 @clFinish(i32 %109)
store i32 %179, i32* %3
%180 = call double (...) @wtime()
%181 = fsub double %180, %168
%182 = load i32, i32* %3
%183 = call i32 @check_error(i32 %182, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.18, i64 0, i64 0), i8* getelementptr inbounds ([189 x i8], [189 x i8]* @.str.1, i64 0, i64 0), i32 491)
%184 = load i32, i32* %4
%185 = sext i32 %184 to i64
%186 = load i32, i32* %5
%187 = sext i32 %186 to i64
%188 = load i32, i32* %6
%189 = sext i32 %188 to i64
%190 = shl nsw i64 %185, 1
%191 = mul i64 %190, %187
%192 = mul i64 %191, %189
%193 = sitofp i64 %192 to double
%194 = insertelement <2 x double> poison, double %193, i64 0
%195 = insertelement <2 x double> %194, double %181, i64 1
%196 = fdiv <2 x double> %195, <double 1.000000e+09, double 5.000000e+00>
%197 = extractelement <2 x double> %196, i64 0
%198 = extractelement <2 x double> %196, i64 1
%199 = fdiv double %197, %198
%200 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.19, i64 0, i64 0), double %199)
%201 = load i32, i32* %10
%202 = load i32, i32* @CL_TRUE
%203 = load i32, i32* %4
%204 = shl i32 %203, 2
%205 = load i32, i32* %5
%206 = mul i32 %204, %205
%207 = call i32 @clEnqueueReadBuffer(i32 %109, i32 %201, i32 %202, i32 0, i32 %206, float* %35, i32 0, i32* null, i32* null)
store i32 %207, i32* %3
%208 = call i32 @check_error(i32 %207, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.20, i64 0, i64 0), i8* getelementptr inbounds ([189 x i8], [189 x i8]* @.str.1, i64 0, i64 0), i32 519)
%209 = load i32, i32* %3
%210 = load i32, i32* @CL_SUCCESS
%211 = icmp eq i32 %209, %210
br i1 %211, label %214, label %212
212: ; preds = %104
%213 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
br label %214
214: ; preds = %212, %104
%215 = call i32 @putchar(i32 10)
%216 = load i32, i32* %8
%217 = call i32 @clReleaseMemObject(i32 %216)
%218 = load i32, i32* %9
%219 = call i32 @clReleaseMemObject(i32 %218)
%220 = load i32, i32* %10
%221 = call i32 @clReleaseMemObject(i32 %220)
%222 = call i32 @clReleaseContext(i32 %105)
%223 = call i32 @clReleaseCommandQueue(i32 %109)
%224 = call i32 @clReleaseProgram(i32 %114)
%225 = call i32 @clReleaseKernel(i32 %119)
%226 = call i32 @free(float* %30)
%227 = call i32 @free(float* %68)
%228 = call i32 @free(float* %35)
br label %229
229: ; preds = %214, %74
%230 = phi i32 [ %76, %74 ], [ 0, %214 ]
ret i32 %230
}