#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);
char *unified() {
  char *string[44] = {
      "#include <stdio.h>",
      "#include <stdlib.h>",
      "#include <math.h> ",
      "#define SIZE 64",
      "",
      "#if __CUDA_ARCH__ >= 650",
      "__global__ void kernel(int *a_k, int *b_k, int *c_k, int size) {",
      "  	/* idx = index that the thread is processing */",
      "	int idx = blockIdx.x*blockDim.x+threadIdx.x;",
      "	int stride = gridDim.x * blockDim.x;",
      "",
      "	while(idx < size) {",
      "		c_k[idx] = a_k[idx] * b_k[idx];",
      "		idx = idx+stride;",
      "	}",
      "}",
      "",
      "int main(int argc char *argv[]) {",
      "	int * a_d; ",
      "	int * b_d;",
      "	int * c_d;",
      "",
      "	cudaMallocManaged(&a_d, SIZE * sizeof(int));",
      "	cudaMallocManaged(&b_d, SIZE * sizeof(int));",
      "	cudaMallocManaged(&c_d, SIZE * sizeof(int));",
      "",
      "	for (int i=0; i < SIZE; i++) {",
      "		a_d[i] = i * i;",
      "		b_d[i] = i;",
      "	}",
      "",
      "	kernel<<<24>>>(a_d, b_d, c_d, SIZE);",
      "",
      "	for (int i=0; i < SIZE; i++) {",
      "		printf(\"indice %d= %d\\n\", i, c_d[i]);",
      "	}",
      "",
      "	cudaFree(a_d);",
      "	cudaFree(b_d);",
      "	cudaFree(c_d);",
      "",
      "	return 0;",
      "}",
      "#endif"};
  return buildString(string, 44);
}


x86 assembly (clang, -O0):
<unified>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
lea    -0x160(%rbp),%rdi
lea    0x2b87(%rip),%rsi
mov    $0x160,%edx
call   1040 <memcpy@plt>
lea    -0x160(%rbp),%rdi
mov    $0x2c,%esi
call   1030 <buildString@plt>
add    $0x160,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unified>:
push   %rbx
sub    $0x160,%rsp
lea    0x2b91(%rip),%rsi
mov    %rsp,%rbx
mov    $0x160,%edx
mov    %rbx,%rdi
call   1040 <memcpy@plt>
mov    %rbx,%rdi
mov    $0x2c,%esi
call   1030 <buildString@plt>
add    $0x160,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [19 x i8] c"#include <stdio.h>\00"
@.str.1 = [20 x i8] c"#include <stdlib.h>\00"
@.str.2 = [19 x i8] c"#include <math.h> \00"
@.str.3 = [16 x i8] c"#define SIZE 64\00"
@.str.4 = [1 x i8] zeroinitializer
@.str.5 = [25 x i8] c"#if __CUDA_ARCH__ >= 650\00"
@.str.6 = [65 x i8] c"__global__ void kernel(int *a_k, int *b_k, int *c_k, int size) {\00"
@.str.7 = [51 x i8] c" \09/* idx = index that the thread is processing */\00"
@.str.8 = [46 x i8] c"\09int idx = blockIdx.x*blockDim.x+threadIdx.x;\00"
@.str.9 = [38 x i8] c"\09int stride = gridDim.x * blockDim.x;\00"
@.str.10 = [21 x i8] c"\09while(idx < size) {\00"
@.str.11 = [34 x i8] c"\09\09c_k[idx] = a_k[idx] * b_k[idx];\00"
@.str.12 = [20 x i8] c"\09\09idx = idx+stride;\00"
@.str.13 = [3 x i8] c"\09}\00"
@.str.14 = [2 x i8] c"}\00"
@.str.15 = [34 x i8] c"int main(int argc char *argv[]) {\00"
@.str.16 = [13 x i8] c"\09int * a_d; \00"
@.str.17 = [12 x i8] c"\09int * b_d;\00"
@.str.18 = [12 x i8] c"\09int * c_d;\00"
@.str.19 = [46 x i8] c"\09cudaMallocManaged(&a_d, SIZE * sizeof(int));\00"
@.str.20 = [46 x i8] c"\09cudaMallocManaged(&b_d, SIZE * sizeof(int));\00"
@.str.21 = [46 x i8] c"\09cudaMallocManaged(&c_d, SIZE * sizeof(int));\00"
@.str.22 = [32 x i8] c"\09for (int i=0; i < SIZE; i++) {\00"
@.str.23 = [18 x i8] c"\09\09a_d[i] = i * i;\00"
@.str.24 = [14 x i8] c"\09\09b_d[i] = i;\00"
@.str.25 = [38 x i8] c"\09kernel<<<24>>>(a_d, b_d, c_d, SIZE);\00"
@.str.26 = [40 x i8] c"\09\09printf(\22indice %d= %d\\n\22, i, c_d[i]);\00"
@.str.27 = [16 x i8] c"\09cudaFree(a_d);\00"
@.str.28 = [16 x i8] c"\09cudaFree(b_d);\00"
@.str.29 = [16 x i8] c"\09cudaFree(c_d);\00"
@.str.30 = [11 x i8] c"\09return 0;\00"
@.str.31 = [7 x i8] c"#endif\00"
@__const.unified.string = [44 x i8*] [i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.15, i32 0, i32 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.16, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.17, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.18, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.19, i32 0, i32 0), i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.20, i32 0, i32 0), i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.21, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.22, i32 0, i32 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.23, i32 0, i32 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.24, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.25, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.22, i32 0, i32 0), i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.26, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.27, i32 0, i32 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.28, i32 0, i32 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.29, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.30, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.31, i32 0, i32 0)]
define i8* @unified() {
%1 = alloca [44 x i8*]
%2 = bitcast [44 x i8*]* %1 to i8*
%3 = getelementptr inbounds [44 x i8*], [44 x i8*]* %1, i64 0, i64 0
%4 = call i8* @buildString(i8** %3, i32 44)
ret i8* %4
}

LLVM IR (-O2):
@.str = [19 x i8] c"#include <stdio.h>\00"
@.str.1 = [20 x i8] c"#include <stdlib.h>\00"
@.str.2 = [19 x i8] c"#include <math.h> \00"
@.str.3 = [16 x i8] c"#define SIZE 64\00"
@.str.4 = [1 x i8] zeroinitializer
@.str.5 = [25 x i8] c"#if __CUDA_ARCH__ >= 650\00"
@.str.6 = [65 x i8] c"__global__ void kernel(int *a_k, int *b_k, int *c_k, int size) {\00"
@.str.7 = [51 x i8] c" \09/* idx = index that the thread is processing */\00"
@.str.8 = [46 x i8] c"\09int idx = blockIdx.x*blockDim.x+threadIdx.x;\00"
@.str.9 = [38 x i8] c"\09int stride = gridDim.x * blockDim.x;\00"
@.str.10 = [21 x i8] c"\09while(idx < size) {\00"
@.str.11 = [34 x i8] c"\09\09c_k[idx] = a_k[idx] * b_k[idx];\00"
@.str.12 = [20 x i8] c"\09\09idx = idx+stride;\00"
@.str.13 = [3 x i8] c"\09}\00"
@.str.14 = [2 x i8] c"}\00"
@.str.15 = [34 x i8] c"int main(int argc char *argv[]) {\00"
@.str.16 = [13 x i8] c"\09int * a_d; \00"
@.str.17 = [12 x i8] c"\09int * b_d;\00"
@.str.18 = [12 x i8] c"\09int * c_d;\00"
@.str.19 = [46 x i8] c"\09cudaMallocManaged(&a_d, SIZE * sizeof(int));\00"
@.str.20 = [46 x i8] c"\09cudaMallocManaged(&b_d, SIZE * sizeof(int));\00"
@.str.21 = [46 x i8] c"\09cudaMallocManaged(&c_d, SIZE * sizeof(int));\00"
@.str.22 = [32 x i8] c"\09for (int i=0; i < SIZE; i++) {\00"
@.str.23 = [18 x i8] c"\09\09a_d[i] = i * i;\00"
@.str.24 = [14 x i8] c"\09\09b_d[i] = i;\00"
@.str.25 = [38 x i8] c"\09kernel<<<24>>>(a_d, b_d, c_d, SIZE);\00"
@.str.26 = [40 x i8] c"\09\09printf(\22indice %d= %d\\n\22, i, c_d[i]);\00"
@.str.27 = [16 x i8] c"\09cudaFree(a_d);\00"
@.str.28 = [16 x i8] c"\09cudaFree(b_d);\00"
@.str.29 = [16 x i8] c"\09cudaFree(c_d);\00"
@.str.30 = [11 x i8] c"\09return 0;\00"
@.str.31 = [7 x i8] c"#endif\00"
@__const.unified.string = [44 x i8*] [i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.15, i32 0, i32 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.16, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.17, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.18, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.19, i32 0, i32 0), i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.20, i32 0, i32 0), i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.21, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.22, i32 0, i32 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.23, i32 0, i32 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.24, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.25, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.22, i32 0, i32 0), i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.26, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.27, i32 0, i32 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.28, i32 0, i32 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.29, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.30, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.31, i32 0, i32 0)]
define i8* @unified() {
%1 = alloca [44 x i8*]
%2 = bitcast [44 x i8*]* %1 to i8*
%3 = getelementptr inbounds [44 x i8*], [44 x i8*]* %1, i64 0, i64 0
%4 = call i8* @buildString(i8** %3, i32 44)
ret i8* %4
}