#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 */

/* Variables and functions */
char *buildString(char **, int);
int /*<<< orphan*/ eipa_free(void **, int, char *);
char *eipa_malloc(scalar_t__, int, char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
char *callKernel(char *name) {
  char *aux = eipa_malloc(
      (strlen(name) + strlen("<<<blocks,grid>>>(TODO:parameters);") + 1), 234,
      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
      "2022-01-22/02-19-57/repos/WikiDreams/CUDA-SAK/refs/heads/master/"
      "Cuda-SAK/functions.c");
  strcpy(aux, name);
  strcat(aux, "<<<blocks,grid>>>(TODO:parameters);");
  char *string[6] = {"dim3 grid(TODO:set grid dimensions);",
                     "dim3 blocks(TODO:set block dimensions);",
                     aux,
                     "cudaDeviceSynchronize();",
                     "cudaError_t err = cudaGetLastError();",
                     "HANDLE_ERROR( err );"};
  char *result = buildString(string, 6);
  eipa_free((void **)(&(aux)), 252,
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/WikiDreams/CUDA-SAK/refs/heads/master/"
            "Cuda-SAK/functions.c");
  return result;
}


x86 assembly (clang, -O0):
<callKernel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x50(%rbp)
lea    0xe80(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x50(%rbp),%rdi
add    %rax,%rdi
add    $0x1,%rdi
mov    $0xea,%esi
lea    0xe88(%rip),%rdx
call   1070 <eipa_malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rdi
lea    0xe43(%rip),%rsi
call   1080 <strcat@plt>
lea    0xef0(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0xf0a(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
lea    0xf1f(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xf2d(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    0xf48(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    -0x40(%rbp),%rdi
mov    $0x6,%esi
call   1050 <buildString@plt>
mov    %rax,-0x48(%rbp)
lea    -0x10(%rbp),%rdi
mov    $0xfc,%esi
lea    0xe01(%rip),%rdx
call   1060 <eipa_free@plt>
mov    -0x48(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<callKernel>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
mov    %rdi,%r15
call   1040 <strlen@plt>
lea    0x24(%rax),%rdi
lea    0xea8(%rip),%r14
mov    $0xea,%esi
mov    %r14,%rdx
call   1070 <eipa_malloc@plt>
mov    %rax,%rbx
mov    %rax,0x8(%rsp)
mov    %rax,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
lea    0xe5d(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcat@plt>
lea    0xf07(%rip),%rax
mov    %rax,0x10(%rsp)
lea    0xf20(%rip),%rax
mov    %rax,0x18(%rsp)
mov    %rbx,0x20(%rsp)
lea    0xf37(%rip),%rax
mov    %rax,0x28(%rsp)
lea    0xf44(%rip),%rax
mov    %rax,0x30(%rsp)
lea    0xf5e(%rip),%rax
mov    %rax,0x38(%rsp)
lea    0x10(%rsp),%rdi
mov    $0x6,%esi
call   1050 <buildString@plt>
mov    %rax,%rbx
lea    0x8(%rsp),%rdi
mov    $0xfc,%esi
mov    %r14,%rdx
call   1060 <eipa_free@plt>
mov    %rbx,%rax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [36 x i8] c"<<<blocks,grid>>>(TODO:parameters);\00"
@.str.1 = [149 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/WikiDreams/CUDA-SAK/refs/heads/master/Cuda-SAK/functions.c\00"
@.str.2 = [37 x i8] c"dim3 grid(TODO:set grid dimensions);\00"
@.str.3 = [40 x i8] c"dim3 blocks(TODO:set block dimensions);\00"
@.str.4 = [25 x i8] c"cudaDeviceSynchronize();\00"
@.str.5 = [38 x i8] c"cudaError_t err = cudaGetLastError();\00"
@.str.6 = [21 x i8] c"HANDLE_ERROR( err );\00"
define i8* @callKernel(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca [6 x i8*]
%5 = alloca i8*
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i64 @strlen(i8* %6)
%8 = call i64 @strlen(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%9 = add nsw i64 %7, %8
%10 = add nsw i64 %9, 1
%11 = call i8* @eipa_malloc(i64 %10, i32 234, i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.1, i64 0, i64 0))
store i8* %11, i8** %3
%12 = load i8*, i8** %3
%13 = load i8*, i8** %2
%14 = call i32 @strcpy(i8* %12, i8* %13)
%15 = load i8*, i8** %3
%16 = call i32 @strcat(i8* %15, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%17 = getelementptr inbounds [6 x i8*], [6 x i8*]* %4, i64 0, i64 0
store i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8** %17
%18 = getelementptr inbounds i8*, i8** %17, i64 1
store i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i8** %18
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %3
store i8* %20, i8** %19
%21 = getelementptr inbounds i8*, i8** %19, i64 1
store i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i8** %21
%22 = getelementptr inbounds i8*, i8** %21, i64 1
store i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0), i8** %22
%23 = getelementptr inbounds i8*, i8** %22, i64 1
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i8** %23
%24 = getelementptr inbounds [6 x i8*], [6 x i8*]* %4, i64 0, i64 0
%25 = call i8* @buildString(i8** %24, i32 6)
store i8* %25, i8** %5
%26 = call i32 @eipa_free(i8** %3, i32 252, i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.1, i64 0, i64 0))
%27 = load i8*, i8** %5
ret i8* %27
}

LLVM IR (-O2):
@.str = [36 x i8] c"<<<blocks,grid>>>(TODO:parameters);\00"
@.str.1 = [149 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/WikiDreams/CUDA-SAK/refs/heads/master/Cuda-SAK/functions.c\00"
@.str.2 = [37 x i8] c"dim3 grid(TODO:set grid dimensions);\00"
@.str.3 = [40 x i8] c"dim3 blocks(TODO:set block dimensions);\00"
@.str.4 = [25 x i8] c"cudaDeviceSynchronize();\00"
@.str.5 = [38 x i8] c"cudaError_t err = cudaGetLastError();\00"
@.str.6 = [21 x i8] c"HANDLE_ERROR( err );\00"
define i8* @callKernel(i8* %0) {
%2 = alloca i8*
%3 = alloca [6 x i8*]
%4 = bitcast i8** %2 to i8*
%5 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%6 = add nsw i64 %5, 36
%7 = tail call i8* @eipa_malloc(i64 %6, i32 234, i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.1, i64 0, i64 0))
store i8* %7, i8** %2
%8 = tail call i32 @strcpy(i8* %7, i8* %0)
%9 = tail call i32 @strcat(i8* %7, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%10 = bitcast [6 x i8*]* %3 to i8*
%11 = getelementptr inbounds [6 x i8*], [6 x i8*]* %3, i64 0, i64 0
store i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8** %11
%12 = getelementptr inbounds [6 x i8*], [6 x i8*]* %3, i64 0, i64 1
store i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i8** %12
%13 = getelementptr inbounds [6 x i8*], [6 x i8*]* %3, i64 0, i64 2
store i8* %7, i8** %13
%14 = getelementptr inbounds [6 x i8*], [6 x i8*]* %3, i64 0, i64 3
store i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i8** %14
%15 = getelementptr inbounds [6 x i8*], [6 x i8*]* %3, i64 0, i64 4
store i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0), i8** %15
%16 = getelementptr inbounds [6 x i8*], [6 x i8*]* %3, i64 0, i64 5
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i8** %16
%17 = call i8* @buildString(i8** %11, i32 6)
%18 = call i32 @eipa_free(i8** %2, i32 252, i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.1, i64 0, i64 0))
ret i8* %17
}