#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/TN/gemm_block8x8_thread8x8.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/TN/gemm_block8x8_thread8x8.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/TN/gemm_block8x8_thread8x8.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/TN/gemm_block8x8_thread8x8.c",
              274);
  char *gemm_kernel = getKernelSource("gemm_block8x8_thread8x8.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/TN/gemm_block8x8_thread8x8.c",
              296);
  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/TN/gemm_block8x8_thread8x8.c",
              315);
  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/TN/gemm_block8x8_thread8x8.c",
              329);
  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/TN/gemm_block8x8_thread8x8.c",
              350);
  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/TN/gemm_block8x8_thread8x8.c",
              357);
  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/TN/gemm_block8x8_thread8x8.c",
              364);
  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/TN/gemm_block8x8_thread8x8.c",
              390);
  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/TN/gemm_block8x8_thread8x8.c",
              402);
  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/TN/gemm_block8x8_thread8x8.c",
              441);
  const size_t global[2] = {M / 8, N / 8};
  const size_t local[2] = {8, 8};
  printf("Starting my SGEMM M = %d N = %d K = %d "
         "running...(repeated %d times)\n",
         M, N, K, 5);
  double rtime = wtime();
  for (int i = 0; i < 5; ++i) {
    err = clEnqueueNDRangeKernel(command_queue, ko_MatMul, 2, NULL, global,
                                 local, 0, NULL, NULL);
    err = clFinish(command_queue);
  }
  rtime = (wtime() - rtime) / (double)5;
  check_error(err, "Waiting for kernel to finish",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/haohaibo/tutorial/refs/heads/master/"
              "LearnOpenCLFromScratch/dgemm/TN/gemm_block8x8_thread8x8.c",
              490);
  double gflops =
      ((long)M * (long)N * (long)K * 2 * 1.0) / (double)(1000 * 1000 * 1000);
  printf("\nThe kernel ran in %lf seconds\n", rtime);
  printf("%.1lf GFLOPS\n", gflops / rtime);
  err = clEnqueueReadBuffer(command_queue, d_c, CL_TRUE, 0,
                            sizeof(float) * M * N, h_c, 0, NULL, NULL);
  check_error(err, "Copying d_c to h_c",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/haohaibo/tutorial/refs/heads/master/"
              "LearnOpenCLFromScratch/dgemm/TN/gemm_block8x8_thread8x8.c",
              518);
  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    0xcb3(%rip),%rdi
mov    $0x0,%al
call   10e0 <printf@plt>
mov    0x2b83(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1b59 <main+0x8a9>
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    0xc6b(%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    0xbf6(%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    0xbd8(%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    0xbb9(%rip),%rsi
lea    0xaac(%rip),%rdx
mov    $0x112,%ecx
call   1120 <check_error@plt>
lea    0xbb8(%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    0xb9e(%rip),%rsi
lea    0xa5f(%rip),%rdx
mov    $0x128,%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    0xb85(%rip),%rsi
lea    0xa29(%rip),%rdx
mov    $0x13b,%ecx
call   1120 <check_error@plt>
mov    -0x54(%rbp),%edi
lea    0xb78(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1180 <clCreateKernel@plt>
mov    %eax,-0x58(%rbp)
mov    -0x14(%rbp),%edi
lea    0xb67(%rip),%rsi
lea    0x9f8(%rip),%rdx
mov    $0x149,%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    0xb2e(%rip),%rsi
lea    0x9af(%rip),%rdx
mov    $0x15e,%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    0xaf9(%rip),%rsi
lea    0x966(%rip),%rdx
mov    $0x165,%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    0xac4(%rip),%rsi
lea    0x91d(%rip),%rdx
mov    $0x16c,%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    0xa6a(%rip),%rsi
lea    0x8af(%rip),%rdx
mov    $0x186,%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    0xa0f(%rip),%rsi
lea    0x841(%rip),%rdx
mov    $0x192,%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    0x968(%rip),%rsi
lea    0x787(%rip),%rdx
mov    $0x1b9,%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    0xa14(%rip),%rax
mov    %rax,-0xb0(%rbp)
mov    0xa0e(%rip),%rax
mov    %rax,-0xa8(%rbp)
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x24(%rbp),%ecx
lea    0x91c(%rip),%rdi
mov    $0x5,%r8d
mov    $0x0,%al
call   10e0 <printf@plt>
mov    $0x0,%al
call   10f0 <wtime@plt>
movsd  %xmm0,-0xb8(%rbp)
ff
movl   $0x0,-0xbc(%rbp)
cmpl   $0x5,-0xbc(%rbp)
jge    199b <main+0x6eb>
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    1927 <main+0x677>
mov    $0x0,%al
call   10f0 <wtime@plt>
subsd  -0xb8(%rbp),%xmm0
ff
movsd  0x65e(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
mov    -0x14(%rbp),%edi
lea    0x89b(%rip),%rsi
lea    0x65b(%rip),%rdx
mov    $0x1ea,%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  0x60a(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0x5f6(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0xc8(%rbp)
ff
movsd  -0xb8(%rbp),%xmm0
ff
lea    0x85b(%rip),%rdi
mov    $0x1,%al
call   10e0 <printf@plt>
movsd  -0xc8(%rbp),%xmm0
ff
divsd  -0xb8(%rbp),%xmm0
ff
lea    0x85d(%rip),%rdi
mov    $0x1,%al
call   10e0 <printf@plt>
mov    -0x50(%rbp),%edi
mov    -0x64(%rbp),%esi
mov    0x2591(%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    0x807(%rip),%rsi
lea    0x57c(%rip),%rdx
mov    $0x206,%ecx
call   1120 <check_error@plt>
mov    -0x14(%rbp),%eax
mov    0x24ee(%rip),%rcx
cmp    (%rcx),%eax
je     1ad8 <main+0x828>
lea    0x7f0(%rip),%rdi
mov    $0x0,%al
call   10e0 <printf@plt>
lea    0x782(%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    $0xb8,%rsp
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   11b0 <atoi@plt>
mov    %eax,-0x38(%rbp)
mov    %rax,%r14
mov    %rax,-0x58(%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,-0x40(%rbp)
lea    0x0(,%r14,4),%ebx
mov    %ebx,%edi
imul   %eax,%edi
mov    %edi,-0xb0(%rbp)
call   1160 <malloc@plt>
mov    %rax,%r12
mov    %r15d,%eax
imul   %r13d,%eax
mov    %rax,-0x78(%rbp)
lea    0x0(,%rax,4),%edi
mov    %edi,-0x70(%rbp)
call   1160 <malloc@plt>
mov    %rax,%r14
mov    %r15d,-0x50(%rbp)
imul   %r15d,%ebx
mov    %ebx,-0x98(%rbp)
mov    %ebx,%edi
call   1160 <malloc@plt>
mov    %rax,-0xb8(%rbp)
mov    -0x58(%rbp),%rax
mov    %r13d,-0x80(%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,-0x58(%rbp)
mov    -0x78(%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    -0x80(%rbp),%edi
mov    -0x50(%rbp),%esi
mov    %r14,%rdx
call   1130 <matrixTranspose@plt>
mov    %rax,-0x50(%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     1b31 <main+0x861>
mov    %rsp,-0x80(%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    0xc8f(%rip),%rsi
lea    0xbd0(%rip),%rdx
mov    %eax,%edi
mov    $0xd9,%ecx
call   1140 <check_error@plt>
cmpl   $0x0,-0x30(%rbp)
jle    14db <main+0x20b>
mov    $0x1,%ebx
mov    0x2b38(%rip),%r15
lea    -0x88(%rbp),%r14
mov    0x2b12(%rip),%r13
xchg   %ax,%ax
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,-0x88(%rbp)
jne    14e7 <main+0x217>
lea    0xdf5(%rip),%rdi
call   1080 <puts@plt>
lea    -0x88(%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    0xbff(%rip),%rsi
lea    0xb28(%rip),%r12
mov    %r12,%rdx
mov    $0x103,%ecx
call   1140 <check_error@plt>
mov    -0x88(%rbp),%rsi
mov    %r15d,%edi
xor    %edx,%edx
mov    %r14,%rcx
call   10e0 <clCreateCommandQueue@plt>
mov    %eax,-0x90(%rbp)
mov    -0x2c(%rbp),%edi
lea    0xbd8(%rip),%rsi
mov    %r12,%rdx
mov    $0x112,%ecx
call   1140 <check_error@plt>
lea    0xbdb(%rip),%rdi
call   11c0 <getKernelSource@plt>
mov    %rax,-0xc0(%rbp)
lea    -0xc0(%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    0xbc5(%rip),%rsi
mov    %r12,%rdx
mov    $0x128,%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    0xbb8(%rip),%rsi
mov    %eax,%edi
mov    %r12,%rdx
mov    $0x13b,%ecx
call   1140 <check_error@plt>
lea    0xbb0(%rip),%rsi
mov    %ebx,-0x94(%rbp)
mov    %ebx,%edi
mov    %r14,%rdx
call   11a0 <clCreateKernel@plt>
mov    %eax,-0x8c(%rbp)
mov    -0x2c(%rbp),%edi
lea    0xb95(%rip),%rsi
mov    %r12,%rbx
mov    %r12,%rdx
mov    $0x149,%ecx
call   1140 <check_error@plt>
mov    0x29b1(%rip),%r12
mov    (%r12),%esi
mov    %r15d,%edi
mov    -0xb0(%rbp),%edx
xor    %ecx,%ecx
mov    %r14,%r8
call   10a0 <clCreateBuffer@plt>
mov    %eax,%r13d
mov    %eax,-0x48(%rbp)
mov    -0x2c(%rbp),%edi
lea    0xb67(%rip),%rsi
mov    %rbx,%rdx
mov    $0x15e,%ecx
call   1140 <check_error@plt>
mov    (%r12),%esi
mov    %r15d,%edi
mov    -0x70(%rbp),%edx
xor    %ecx,%ecx
mov    %r14,%r8
call   10a0 <clCreateBuffer@plt>
mov    %eax,%r12d
mov    %eax,-0x44(%rbp)
mov    -0x2c(%rbp),%edi
lea    0xb4a(%rip),%rsi
mov    %rbx,%rdx
mov    $0x165,%ecx
call   1140 <check_error@plt>
mov    0x296d(%rip),%rax
mov    (%rax),%esi
mov    %r15d,-0x78(%rbp)
mov    %r15d,%edi
mov    -0x8c(%rbp),%r14d
mov    -0x98(%rbp),%edx
xor    %ecx,%ecx
lea    -0x2c(%rbp),%r8
call   10a0 <clCreateBuffer@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x2c(%rbp),%edi
lea    0xb1c(%rip),%rsi
mov    %rbx,%rdx
mov    $0x16c,%ecx
call   1140 <check_error@plt>
mov    0x2933(%rip),%rbx
mov    (%rbx),%edx
sub    $0x20,%rsp
xorps  %xmm0,%xmm0
movups %xmm0,0x8(%rsp)
movl   $0x0,(%rsp)
mov    -0x90(%rbp),%r15d
mov    %r15d,%edi
mov    %r13d,%esi
xor    %ecx,%ecx
mov    -0xb0(%rbp),%r8d
mov    -0x58(%rbp),%r9
call   11f0 <clEnqueueWriteBuffer@plt>
add    $0x20,%rsp
mov    %eax,-0x2c(%rbp)
lea    0xada(%rip),%rsi
mov    %eax,%edi
lea    0x942(%rip),%rdx
mov    %rdx,%r13
mov    $0x186,%ecx
call   1140 <check_error@plt>
mov    (%rbx),%edx
sub    $0x20,%rsp
xorps  %xmm0,%xmm0
movups %xmm0,0x8(%rsp)
movl   $0x0,(%rsp)
mov    %r15d,%edi
mov    %r12d,%esi
xor    %ecx,%ecx
mov    -0x70(%rbp),%r8d
mov    %r15d,%ebx
mov    -0x50(%rbp),%r9
call   11f0 <clEnqueueWriteBuffer@plt>
add    $0x20,%rsp
mov    %eax,-0x2c(%rbp)
lea    0xa9c(%rip),%rsi
mov    %eax,%edi
mov    %r13,%rdx
mov    $0x192,%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    -0x40(%rbp),%rcx
mov    %r14d,%edi
mov    $0x5,%esi
mov    $0x4,%edx
call   11d0 <clSetKernelArg@plt>
or     -0x2c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
lea    0xa03(%rip),%rsi
mov    %eax,%edi
mov    %r13,%rdx
mov    $0x1b9,%ecx
call   1140 <check_error@plt>
mov    -0x38(%rbp),%esi
mov    -0x34(%rbp),%edx
movd   %edx,%xmm0
movd   %esi,%xmm1
punpckldq %xmm0,%xmm1
movdqa %xmm1,%xmm0
psrad  $0x1f,%xmm0
psrld  $0x1d,%xmm0
paddd  %xmm1,%xmm0
psrad  $0x3,%xmm0
pxor   %xmm1,%xmm1
pcmpgtd %xmm0,%xmm1
punpckldq %xmm1,%xmm0
movdqa %xmm0,-0xe0(%rbp)
ff
movapd 0x7d8(%rip),%xmm0
movapd %xmm0,-0xd0(%rbp)
ff
mov    -0x40(%rbp),%ecx
lea    0x9b6(%rip),%rdi
mov    $0x5,%r8d
xor    %eax,%eax
call   1100 <printf@plt>
xor    %eax,%eax
call   1110 <wtime@plt>
movsd  %xmm0,-0x70(%rbp)
sub    $0x20,%rsp
xorpd  %xmm0,%xmm0
movupd %xmm0,0x8(%rsp)
movl   $0x0,(%rsp)
lea    -0xe0(%rbp),%r12
lea    -0xd0(%rbp),%r13
mov    %r15d,%edi
mov    %r14d,%esi
mov    $0x2,%edx
xor    %ecx,%ecx
mov    %r12,%r8
mov    %r13,%r9
call   10d0 <clEnqueueNDRangeKernel@plt>
add    $0x20,%rsp
mov    %eax,-0x2c(%rbp)
mov    %r15d,%edi
call   1060 <clFinish@plt>
mov    %eax,-0x2c(%rbp)
sub    $0x20,%rsp
xorpd  %xmm0,%xmm0
movupd %xmm0,0x8(%rsp)
movl   $0x0,(%rsp)
mov    %r15d,%edi
mov    %r14d,%esi
mov    $0x2,%edx
xor    %ecx,%ecx
mov    %r12,%r8
mov    %r13,%r9
call   10d0 <clEnqueueNDRangeKernel@plt>
add    $0x20,%rsp
mov    %eax,-0x2c(%rbp)
mov    %r15d,%edi
call   1060 <clFinish@plt>
mov    %eax,-0x2c(%rbp)
sub    $0x20,%rsp
xorpd  %xmm0,%xmm0
movupd %xmm0,0x8(%rsp)
movl   $0x0,(%rsp)
mov    %r15d,%edi
mov    %r14d,%esi
mov    $0x2,%edx
xor    %ecx,%ecx
mov    %r12,%r8
mov    %r13,%r9
call   10d0 <clEnqueueNDRangeKernel@plt>
add    $0x20,%rsp
mov    %eax,-0x2c(%rbp)
mov    %r15d,%edi
call   1060 <clFinish@plt>
mov    %eax,-0x2c(%rbp)
sub    $0x20,%rsp
xorpd  %xmm0,%xmm0
movupd %xmm0,0x8(%rsp)
movl   $0x0,(%rsp)
mov    %r15d,%edi
mov    %r14d,%esi
mov    $0x2,%edx
xor    %ecx,%ecx
mov    %r12,%r8
mov    %r13,%r9
call   10d0 <clEnqueueNDRangeKernel@plt>
add    $0x20,%rsp
mov    %eax,-0x2c(%rbp)
mov    %r15d,%edi
call   1060 <clFinish@plt>
mov    %eax,-0x2c(%rbp)
sub    $0x20,%rsp
xorpd  %xmm0,%xmm0
movupd %xmm0,0x8(%rsp)
movl   $0x0,(%rsp)
mov    %r15d,%edi
mov    %r14d,%r15d
mov    %r14d,%esi
mov    $0x2,%edx
xor    %ecx,%ecx
mov    %r12,%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  -0x70(%rbp),%xmm0
movapd %xmm0,-0x70(%rbp)
mov    -0x2c(%rbp),%edi
lea    0x87d(%rip),%rsi
lea    0x662(%rip),%r12
mov    %r12,%rdx
mov    $0x1ea,%ecx
call   1140 <check_error@plt>
movslq -0x38(%rbp),%rax
movslq -0x34(%rbp),%rcx
imul   %rax,%rcx
movslq -0x40(%rbp),%rax
imul   %rcx,%rax
add    %rax,%rax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
unpcklpd -0x70(%rbp),%xmm0
divpd  0x5e7(%rip),%xmm0
movapd %xmm0,-0x70(%rbp)
unpckhpd %xmm0,%xmm0
movapd %xmm0,-0xb0(%rbp)
ff
lea    0x842(%rip),%rdi
mov    $0x1,%al
call   1100 <printf@plt>
movapd -0x70(%rbp),%xmm0
divsd  -0xb0(%rbp),%xmm0
ff
lea    0x847(%rip),%rdi
mov    $0x1,%al
call   1100 <printf@plt>
mov    -0x3c(%rbp),%esi
mov    0x258b(%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    -0xb8(%rbp),%r14
mov    %r14,%r9
call   1170 <clEnqueueReadBuffer@plt>
add    $0x20,%rsp
mov    %eax,-0x2c(%rbp)
lea    0x7ff(%rip),%rsi
mov    %eax,%edi
mov    %r12,%rdx
mov    $0x206,%ecx
call   1140 <check_error@plt>
mov    -0x2c(%rbp),%eax
mov    0x24f5(%rip),%rcx
cmp    (%rcx),%eax
je     1acb <main+0x7fb>
lea    0x7ee(%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    -0x78(%rbp),%edi
call   1180 <clReleaseContext@plt>
mov    %ebx,%edi
call   1150 <clReleaseCommandQueue@plt>
mov    -0x94(%rbp),%edi
call   10b0 <clReleaseProgram@plt>
mov    %r15d,%edi
call   1090 <clReleaseKernel@plt>
mov    -0x58(%rbp),%rdi
call   1040 <free@plt>
mov    -0x50(%rbp),%rdi
call   1040 <free@plt>
mov    %r14,%rdi
call   1040 <free@plt>
mov    -0x80(%rbp),%rsp
xor    %eax,%eax
jmp    1b46 <main+0x876>
lea    0x7b0(%rip),%rdi
call   1080 <puts@plt>
mov    0x247c(%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 = [184 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/TN/gemm_block8x8_thread8x8.c\00"
@.str.2 = [19 x i8] c"Found 0 platforms\0A\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [24 x i8] c"Getting platforms's IDs\00"
@CL_DEVICE_TYPE_DEFAULT = global i32 0
@CL_SUCCESS = global i32 0
@.str.4 = [18 x i8] c"No devices found\0A\00"
@.str.5 = [17 x i8] c"Creating context\00"
@.str.6 = [23 x i8] c"Creating command queue\00"
@.str.7 = [27 x i8] c"gemm_block8x8_thread8x8.cl\00"
@.str.8 = [29 x i8] c"Creating program from source\00"
@.str.9 = [14 x i8] c"Build program\00"
@.str.10 = [5 x i8] c"gemm\00"
@.str.11 = [16 x i8] c"Creating kernel\00"
@CL_MEM_READ_ONLY = global i32 0
@.str.12 = [20 x i8] c"Creating buffer d_a\00"
@.str.13 = [20 x i8] c"Creating buffer d_b\00"
@CL_MEM_READ_WRITE = global i32 0
@.str.14 = [20 x i8] c"Creating buffer d_c\00"
@CL_TRUE = global i32 0
@.str.15 = [19 x i8] c"Copying h_a to d_a\00"
@.str.16 = [19 x i8] c"Copying h_b to d_b\00"
@.str.17 = [25 x i8] c"Setting kernel arguments\00"
@__const.main.local = [2 x i64] [i64 8, i64 8]
@.str.18 = [70 x i8] c"Starting my SGEMM M = %d N = %d K = %d running...(repeated %d times)\0A\00"
@.str.19 = [29 x i8] c"Waiting for kernel to finish\00"
@.str.20 = [32 x i8] c"\0AThe kernel ran in %lf seconds\0A\00"
@.str.21 = [14 x i8] c"%.1lf GFLOPS\0A\00"
@.str.22 = [19 x i8] c"Copying d_c to h_c\00"
@.str.23 = [36 x i8] c"Error: Failed to read output array\0A\00"
@.str.24 = [2 x i8] c"\0A\00"
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 ([184 x i8], [184 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 %354
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 ([184 x i8], [184 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 ([184 x i8], [184 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 ([184 x i8], [184 x i8]* @.str.1, i64 0, i64 0), i32 274)
%158 = call i8* @getKernelSource(i8* getelementptr inbounds ([27 x i8], [27 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 ([184 x i8], [184 x i8]* @.str.1, i64 0, i64 0), i32 296)
%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 ([184 x i8], [184 x i8]* @.str.1, i64 0, i64 0), i32 315)
%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 ([184 x i8], [184 x i8]* @.str.1, i64 0, i64 0), i32 329)
%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 ([184 x i8], [184 x i8]* @.str.1, i64 0, i64 0), i32 350)
%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 ([184 x i8], [184 x i8]* @.str.1, i64 0, i64 0), i32 357)
%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 ([184 x i8], [184 x i8]* @.str.1, i64 0, i64 0), i32 364)
%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 ([184 x i8], [184 x i8]* @.str.1, i64 0, i64 0), i32 390)
%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 ([184 x i8], [184 x i8]* @.str.1, i64 0, i64 0), i32 402)
%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 ([184 x i8], [184 x i8]* @.str.1, i64 0, i64 0), i32 441)
%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 = load i32, i32* %8
%269 = load i32, i32* %9
%270 = load i32, i32* %10
%271 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.18, i64 0, i64 0), i32 %268, i32 %269, i32 %270, i32 5)
%272 = call double (...) @wtime()
store double %272, double* %29
store i32 0, i32* %30
br label %273
273: ; preds = %284, %149
%274 = load i32, i32* %30
%275 = icmp slt i32 %274, 5
br i1 %275, label %276, label %287
276: ; preds = %273
%277 = load i32, i32* %16
%278 = load i32, i32* %18
%279 = getelementptr inbounds [2 x i64], [2 x i64]* %27, i64 0, i64 0
%280 = getelementptr inbounds [2 x i64], [2 x i64]* %28, i64 0, i64 0
%281 = call i32 @clEnqueueNDRangeKernel(i32 %277, i32 %278, i32 2, i32* null, i64* %279, i64* %280, i32 0, i32* null, i32* null)
store i32 %281, i32* %6
%282 = load i32, i32* %16
%283 = call i32 @clFinish(i32 %282)
store i32 %283, i32* %6
br label %284
284: ; preds = %276
%285 = load i32, i32* %30
%286 = add nsw i32 %285, 1
store i32 %286, i32* %30
br label %273
287: ; preds = %273
%288 = call double (...) @wtime()
%289 = load double, double* %29
%290 = fsub double %288, %289
%291 = fdiv double %290, 5.000000e+00
store double %291, double* %29
%292 = load i32, i32* %6
%293 = call i32 @check_error(i32 %292, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.19, i64 0, i64 0), i8* getelementptr inbounds ([184 x i8], [184 x i8]* @.str.1, i64 0, i64 0), i32 490)
%294 = load i32, i32* %8
%295 = sext i32 %294 to i64
%296 = load i32, i32* %9
%297 = sext i32 %296 to i64
%298 = mul nsw i64 %295, %297
%299 = load i32, i32* %10
%300 = sext i32 %299 to i64
%301 = mul nsw i64 %298, %300
%302 = mul nsw i64 %301, 2
%303 = sitofp i64 %302 to double
%304 = fmul double %303, 1.000000e+00
%305 = fdiv double %304, 1.000000e+09
store double %305, double* %31
%306 = load double, double* %29
%307 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.20, i64 0, i64 0), double %306)
%308 = load double, double* %31
%309 = load double, double* %29
%310 = fdiv double %308, %309
%311 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.21, i64 0, i64 0), double %310)
%312 = load i32, i32* %16
%313 = load i32, i32* %21
%314 = load i32, i32* @CL_TRUE
%315 = load i32, i32* %8
%316 = sext i32 %315 to i64
%317 = mul i64 4, %316
%318 = load i32, i32* %9
%319 = sext i32 %318 to i64
%320 = mul i64 %317, %319
%321 = trunc i64 %320 to i32
%322 = load float*, float** %13
%323 = call i32 @clEnqueueReadBuffer(i32 %312, i32 %313, i32 %314, i32 0, i32 %321, float* %322, i32 0, i32* null, i32* null)
store i32 %323, i32* %6
%324 = load i32, i32* %6
%325 = call i32 @check_error(i32 %324, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.22, i64 0, i64 0), i8* getelementptr inbounds ([184 x i8], [184 x i8]* @.str.1, i64 0, i64 0), i32 518)
%326 = load i32, i32* %6
%327 = load i32, i32* @CL_SUCCESS
%328 = icmp ne i32 %326, %327
br i1 %328, label %329, label %331
329: ; preds = %287
%330 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.23, i64 0, i64 0))
br label %331
331: ; preds = %329, %287
%332 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.24, i64 0, i64 0))
store i32 0, i32* %7
store float 0.000000e+00, float* %32
%333 = load i32, i32* %19
%334 = call i32 @clReleaseMemObject(i32 %333)
%335 = load i32, i32* %20
%336 = call i32 @clReleaseMemObject(i32 %335)
%337 = load i32, i32* %21
%338 = call i32 @clReleaseMemObject(i32 %337)
%339 = load i32, i32* %15
%340 = call i32 @clReleaseContext(i32 %339)
%341 = load i32, i32* %16
%342 = call i32 @clReleaseCommandQueue(i32 %341)
%343 = load i32, i32* %17
%344 = call i32 @clReleaseProgram(i32 %343)
%345 = load i32, i32* %18
%346 = call i32 @clReleaseKernel(i32 %345)
%347 = load float*, float** %11
%348 = call i32 @free(float* %347)
%349 = load float*, float** %12
%350 = call i32 @free(float* %349)
%351 = load float*, float** %13
%352 = call i32 @free(float* %351)
store i32 0, i32* %3
%353 = load i8*, i8** %24
br label %354
354: ; preds = %331, %113
%355 = load i32, i32* %3
ret i32 %355
}

LLVM IR (-O2):
@RAND_MAX = global i64 0
@.str = [18 x i8] c"Finding platforms\00"
@.str.1 = [184 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/TN/gemm_block8x8_thread8x8.c\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [24 x i8] c"Getting platforms's IDs\00"
@CL_DEVICE_TYPE_DEFAULT = global i32 0
@CL_SUCCESS = global i32 0
@.str.5 = [17 x i8] c"Creating context\00"
@.str.6 = [23 x i8] c"Creating command queue\00"
@.str.7 = [27 x i8] c"gemm_block8x8_thread8x8.cl\00"
@.str.8 = [29 x i8] c"Creating program from source\00"
@.str.9 = [14 x i8] c"Build program\00"
@.str.10 = [5 x i8] c"gemm\00"
@.str.11 = [16 x i8] c"Creating kernel\00"
@CL_MEM_READ_ONLY = global i32 0
@.str.12 = [20 x i8] c"Creating buffer d_a\00"
@.str.13 = [20 x i8] c"Creating buffer d_b\00"
@CL_MEM_READ_WRITE = global i32 0
@.str.14 = [20 x i8] c"Creating buffer d_c\00"
@CL_TRUE = global i32 0
@.str.15 = [19 x i8] c"Copying h_a to d_a\00"
@.str.16 = [19 x i8] c"Copying h_b to d_b\00"
@.str.17 = [25 x i8] c"Setting kernel arguments\00"
@__const.main.local = [2 x i64] [i64 8, i64 8]
@.str.18 = [70 x i8] c"Starting my SGEMM M = %d N = %d K = %d running...(repeated %d times)\0A\00"
@.str.19 = [29 x i8] c"Waiting for kernel to finish\00"
@.str.20 = [32 x i8] c"\0AThe kernel ran in %lf seconds\0A\00"
@.str.21 = [14 x i8] c"%.1lf GFLOPS\0A\00"
@.str.22 = [19 x i8] c"Copying d_c to h_c\00"
@str = [35 x i8] c"Error: Failed to read output array\00"
@str.25 = [17 x i8] c"No devices found\00"
@str.26 = [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 ([184 x i8], [184 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.26, i64 0, i64 0))
%76 = load i32, i32* @EXIT_FAILURE
br label %232
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 ([184 x i8], [184 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.25, 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 ([184 x i8], [184 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 ([184 x i8], [184 x i8]* @.str.1, i64 0, i64 0), i32 274)
%112 = bitcast i8** %12 to i8*
%113 = call i8* @getKernelSource(i8* getelementptr inbounds ([27 x i8], [27 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 ([184 x i8], [184 x i8]* @.str.1, i64 0, i64 0), i32 296)
%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 ([184 x i8], [184 x i8]* @.str.1, i64 0, i64 0), i32 315)
%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 ([184 x i8], [184 x i8]* @.str.1, i64 0, i64 0), i32 329)
%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 ([184 x i8], [184 x i8]* @.str.1, i64 0, i64 0), i32 350)
%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 ([184 x i8], [184 x i8]* @.str.1, i64 0, i64 0), i32 357)
%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 ([184 x i8], [184 x i8]* @.str.1, i64 0, i64 0), i32 364)
%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 ([184 x i8], [184 x i8]* @.str.1, i64 0, i64 0), i32 390)
%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 ([184 x i8], [184 x i8]* @.str.1, i64 0, i64 0), i32 402)
%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 ([184 x i8], [184 x i8]* @.str.1, i64 0, i64 0), i32 441)
%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 = load i32, i32* %6
%169 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([70 x i8], [70 x i8]* @.str.18, i64 0, i64 0), i32 %161, i32 %162, i32 %168, i32 5)
%170 = call double (...) @wtime()
%171 = getelementptr inbounds [2 x i64], [2 x i64]* %14, i64 0, i64 0
%172 = call i32 @clEnqueueNDRangeKernel(i32 %109, i32 %119, i32 2, i32* null, i64* %160, i64* %171, 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* %171, 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* %171, 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* %171, i32 0, i32* null, i32* null)
store i32 %178, i32* %3
%179 = call i32 @clFinish(i32 %109)
store i32 %179, i32* %3
%180 = call i32 @clEnqueueNDRangeKernel(i32 %109, i32 %119, i32 2, i32* null, i64* %160, i64* %171, i32 0, i32* null, i32* null)
store i32 %180, i32* %3
%181 = call i32 @clFinish(i32 %109)
store i32 %181, i32* %3
%182 = call double (...) @wtime()
%183 = fsub double %182, %170
%184 = load i32, i32* %3
%185 = call i32 @check_error(i32 %184, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.19, i64 0, i64 0), i8* getelementptr inbounds ([184 x i8], [184 x i8]* @.str.1, i64 0, i64 0), i32 490)
%186 = load i32, i32* %4
%187 = sext i32 %186 to i64
%188 = load i32, i32* %5
%189 = sext i32 %188 to i64
%190 = load i32, i32* %6
%191 = sext i32 %190 to i64
%192 = shl nsw i64 %187, 1
%193 = mul i64 %192, %189
%194 = mul i64 %193, %191
%195 = sitofp i64 %194 to double
%196 = insertelement <2 x double> poison, double %195, i64 0
%197 = insertelement <2 x double> %196, double %183, i64 1
%198 = fdiv <2 x double> %197, <double 1.000000e+09, double 5.000000e+00>
%199 = extractelement <2 x double> %198, i64 1
%200 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.20, i64 0, i64 0), double %199)
%201 = extractelement <2 x double> %198, i64 0
%202 = fdiv double %201, %199
%203 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.21, 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* %35, 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.22, i64 0, i64 0), i8* getelementptr inbounds ([184 x i8], [184 x i8]* @.str.1, i64 0, i64 0), i32 518)
%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, i64 0, i64 0))
br label %217
217: ; preds = %215, %104
%218 = call i32 @putchar(i32 10)
%219 = load i32, i32* %8
%220 = call i32 @clReleaseMemObject(i32 %219)
%221 = load i32, i32* %9
%222 = call i32 @clReleaseMemObject(i32 %221)
%223 = load i32, i32* %10
%224 = call i32 @clReleaseMemObject(i32 %223)
%225 = call i32 @clReleaseContext(i32 %105)
%226 = call i32 @clReleaseCommandQueue(i32 %109)
%227 = call i32 @clReleaseProgram(i32 %114)
%228 = call i32 @clReleaseKernel(i32 %119)
%229 = call i32 @free(float* %30)
%230 = call i32 @free(float* %68)
%231 = call i32 @free(float* %35)
br label %232
232: ; preds = %217, %74
%233 = phi i32 [ %76, %74 ], [ 0, %217 ]
ret i32 %233
}