#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 *handleError() {
  char *string[47] = {
      "#ifndef __HANDLE_ERROR_H__",
      "#define __HANDLE_ERROR_H__",
      "/*-------------------------------------------------------------------",
      " * Function to process CUDA errors",
      " * @param err [IN] CUDA error to process (usually the code returned",
      " *	 by the cuda function)",
      " * @param line [IN] line of source code where function is called",
      " * @param file [IN] name of source file where function is called",
      " * @return on error, the function terminates the process with ",
      " * 		EXIT_FAILURE code.",
      " * source: \"CUDA by Example: An Introduction to General-Purpose \"",
      " * GPU Programming\", Jason Sanders, Edward Kandrot, NVIDIA, July 2010",
      " * @note: the function should be called through the ",
      " * 	macro 'HANDLE_ERROR'",
      " *------------------------------------------------------------------*/",
      "static void HandleError( cudaError_t err,",
      "                         const char *file,",
      "                         int line ) {",
      "    if (err != cudaSuccess) ",
      "    {",
      "        printf( \"[ERROR] '%s' (%d) in '%s' at line '%d'\\n\",",
      "		cudaGetErrorString(err),err,file,line);",
      "        exit( EXIT_FAILURE );",
      "    }",
      "}",
      "/* The HANDLE_ERROR macro */",
      "#define HANDLE_ERROR(err) (HandleError(err, __FILE__, __LINE__ ))",
      "",
      "/* ",
      " * Function that check a kernel execution, exiting ",
      " * if execution errors are found. The function should not be ",
      " * called directly, it should be called through the CHECK_KERNEL_EXEC",
      " * macro.",
      " */",
      "static void CheckKernelExec(const char *file,const int line){",
      "        cudaError_t err;",
      "        err = cudaGetLastError();",
      "        if( err != cudaSuccess ){",
      "                fprintf(stderr,\"[ERROR] '%s' (%d) in '%s' at line "
      "'%d'\\n\",",
      "                                cudaGetErrorString(err),err,file,line);",
      "                exit( EXIT_FAILURE );",
      "        }",
      "}",
      "",
      "#define CHECK_KERNEL_EXEC()     CheckKernelExec(__FILE__,__LINE__)",
      "",
      "#endif"};
  return buildString(string, 47);
}


x86 assembly (clang, -O0):
<handleError>:
push   %rbp
mov    %rsp,%rbp
sub    $0x180,%rsp
lea    -0x180(%rbp),%rdi
lea    0x2b67(%rip),%rsi
mov    $0x178,%edx
call   1040 <memcpy@plt>
lea    -0x180(%rbp),%rdi
mov    $0x2f,%esi
call   1030 <buildString@plt>
add    $0x180,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handleError>:
push   %rbx
sub    $0x180,%rsp
lea    0x2b71(%rip),%rsi
mov    %rsp,%rbx
mov    $0x178,%edx
mov    %rbx,%rdi
call   1040 <memcpy@plt>
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1030 <buildString@plt>
add    $0x180,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [27 x i8] c"#ifndef __HANDLE_ERROR_H__\00"
@.str.1 = [27 x i8] c"#define __HANDLE_ERROR_H__\00"
@.str.2 = [70 x i8] c"/*-------------------------------------------------------------------\00"
@.str.3 = [35 x i8] c" * Function to process CUDA errors\00"
@.str.4 = [68 x i8] c" * @param err [IN] CUDA error to process (usually the code returned\00"
@.str.5 = [26 x i8] c" *\09 by the cuda function)\00"
@.str.6 = [65 x i8] c" * @param line [IN] line of source code where function is called\00"
@.str.7 = [65 x i8] c" * @param file [IN] name of source file where function is called\00"
@.str.8 = [63 x i8] c" * @return on error, the function terminates the process with \00"
@.str.9 = [24 x i8] c" * \09\09EXIT_FAILURE code.\00"
@.str.10 = [66 x i8] c" * source: \22CUDA by Example: An Introduction to General-Purpose \22\00"
@.str.11 = [70 x i8] c" * GPU Programming\22, Jason Sanders, Edward Kandrot, NVIDIA, July 2010\00"
@.str.12 = [53 x i8] c" * @note: the function should be called through the \00"
@.str.13 = [25 x i8] c" * \09macro 'HANDLE_ERROR'\00"
@.str.14 = [71 x i8] c" *------------------------------------------------------------------*/\00"
@.str.15 = [42 x i8] c"static void HandleError( cudaError_t err,\00"
@.str.16 = [43 x i8] c" const char *file,\00"
@.str.17 = [38 x i8] c" int line ) {\00"
@.str.18 = [29 x i8] c" if (err != cudaSuccess) \00"
@.str.19 = [6 x i8] c" {\00"
@.str.20 = [60 x i8] c" printf( \22[ERROR] '%s' (%d) in '%s' at line '%d'\\n\22,\00"
@.str.21 = [42 x i8] c"\09\09cudaGetErrorString(err),err,file,line);\00"
@.str.22 = [30 x i8] c" exit( EXIT_FAILURE );\00"
@.str.23 = [6 x i8] c" }\00"
@.str.24 = [2 x i8] c"}\00"
@.str.25 = [29 x i8] c"/* The HANDLE_ERROR macro */\00"
@.str.26 = [66 x i8] c"#define HANDLE_ERROR(err) (HandleError(err, __FILE__, __LINE__ ))\00"
@.str.27 = [1 x i8] zeroinitializer
@.str.28 = [4 x i8] c"/* \00"
@.str.29 = [52 x i8] c" * Function that check a kernel execution, exiting \00"
@.str.30 = [62 x i8] c" * if execution errors are found. The function should not be \00"
@.str.31 = [70 x i8] c" * called directly, it should be called through the CHECK_KERNEL_EXEC\00"
@.str.32 = [10 x i8] c" * macro.\00"
@.str.33 = [4 x i8] c" */\00"
@.str.34 = [62 x i8] c"static void CheckKernelExec(const char *file,const int line){\00"
@.str.35 = [25 x i8] c" cudaError_t err;\00"
@.str.36 = [34 x i8] c" err = cudaGetLastError();\00"
@.str.37 = [34 x i8] c" if( err != cudaSuccess ){\00"
@.str.38 = [75 x i8] c" fprintf(stderr,\22[ERROR] '%s' (%d) in '%s' at line '%d'\\n\22,\00"
@.str.39 = [72 x i8] c" cudaGetErrorString(err),err,file,line);\00"
@.str.40 = [38 x i8] c" exit( EXIT_FAILURE );\00"
@.str.41 = [10 x i8] c" }\00"
@.str.42 = [67 x i8] c"#define CHECK_KERNEL_EXEC() CheckKernelExec(__FILE__,__LINE__)\00"
@.str.43 = [7 x i8] c"#endif\00"
@__const.handleError.string = [47 x i8*] [i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([26 x i8], [26 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 ([65 x i8], [65 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.15, i32 0, i32 0), i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.16, i32 0, i32 0), i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.17, i32 0, i32 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.18, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.19, i32 0, i32 0), i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.20, i32 0, i32 0), i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.21, i32 0, i32 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.22, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.23, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.24, i32 0, i32 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.25, i32 0, i32 0), i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.26, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.27, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.28, i32 0, i32 0), i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.29, i32 0, i32 0), i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.30, i32 0, i32 0), i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.31, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.32, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.33, i32 0, i32 0), i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.34, i32 0, i32 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.35, i32 0, i32 0), i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.36, i32 0, i32 0), i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.37, i32 0, i32 0), i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.38, i32 0, i32 0), i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.39, i32 0, i32 0), i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.40, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.41, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.24, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.27, i32 0, i32 0), i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.42, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.27, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.43, i32 0, i32 0)]
define i8* @handleError() {
%1 = alloca [47 x i8*]
%2 = bitcast [47 x i8*]* %1 to i8*
%3 = getelementptr inbounds [47 x i8*], [47 x i8*]* %1, i64 0, i64 0
%4 = call i8* @buildString(i8** %3, i32 47)
ret i8* %4
}

LLVM IR (-O2):
@.str = [27 x i8] c"#ifndef __HANDLE_ERROR_H__\00"
@.str.1 = [27 x i8] c"#define __HANDLE_ERROR_H__\00"
@.str.2 = [70 x i8] c"/*-------------------------------------------------------------------\00"
@.str.3 = [35 x i8] c" * Function to process CUDA errors\00"
@.str.4 = [68 x i8] c" * @param err [IN] CUDA error to process (usually the code returned\00"
@.str.5 = [26 x i8] c" *\09 by the cuda function)\00"
@.str.6 = [65 x i8] c" * @param line [IN] line of source code where function is called\00"
@.str.7 = [65 x i8] c" * @param file [IN] name of source file where function is called\00"
@.str.8 = [63 x i8] c" * @return on error, the function terminates the process with \00"
@.str.9 = [24 x i8] c" * \09\09EXIT_FAILURE code.\00"
@.str.10 = [66 x i8] c" * source: \22CUDA by Example: An Introduction to General-Purpose \22\00"
@.str.11 = [70 x i8] c" * GPU Programming\22, Jason Sanders, Edward Kandrot, NVIDIA, July 2010\00"
@.str.12 = [53 x i8] c" * @note: the function should be called through the \00"
@.str.13 = [25 x i8] c" * \09macro 'HANDLE_ERROR'\00"
@.str.14 = [71 x i8] c" *------------------------------------------------------------------*/\00"
@.str.15 = [42 x i8] c"static void HandleError( cudaError_t err,\00"
@.str.16 = [43 x i8] c" const char *file,\00"
@.str.17 = [38 x i8] c" int line ) {\00"
@.str.18 = [29 x i8] c" if (err != cudaSuccess) \00"
@.str.19 = [6 x i8] c" {\00"
@.str.20 = [60 x i8] c" printf( \22[ERROR] '%s' (%d) in '%s' at line '%d'\\n\22,\00"
@.str.21 = [42 x i8] c"\09\09cudaGetErrorString(err),err,file,line);\00"
@.str.22 = [30 x i8] c" exit( EXIT_FAILURE );\00"
@.str.23 = [6 x i8] c" }\00"
@.str.24 = [2 x i8] c"}\00"
@.str.25 = [29 x i8] c"/* The HANDLE_ERROR macro */\00"
@.str.26 = [66 x i8] c"#define HANDLE_ERROR(err) (HandleError(err, __FILE__, __LINE__ ))\00"
@.str.27 = [1 x i8] zeroinitializer
@.str.28 = [4 x i8] c"/* \00"
@.str.29 = [52 x i8] c" * Function that check a kernel execution, exiting \00"
@.str.30 = [62 x i8] c" * if execution errors are found. The function should not be \00"
@.str.31 = [70 x i8] c" * called directly, it should be called through the CHECK_KERNEL_EXEC\00"
@.str.32 = [10 x i8] c" * macro.\00"
@.str.33 = [4 x i8] c" */\00"
@.str.34 = [62 x i8] c"static void CheckKernelExec(const char *file,const int line){\00"
@.str.35 = [25 x i8] c" cudaError_t err;\00"
@.str.36 = [34 x i8] c" err = cudaGetLastError();\00"
@.str.37 = [34 x i8] c" if( err != cudaSuccess ){\00"
@.str.38 = [75 x i8] c" fprintf(stderr,\22[ERROR] '%s' (%d) in '%s' at line '%d'\\n\22,\00"
@.str.39 = [72 x i8] c" cudaGetErrorString(err),err,file,line);\00"
@.str.40 = [38 x i8] c" exit( EXIT_FAILURE );\00"
@.str.41 = [10 x i8] c" }\00"
@.str.42 = [67 x i8] c"#define CHECK_KERNEL_EXEC() CheckKernelExec(__FILE__,__LINE__)\00"
@.str.43 = [7 x i8] c"#endif\00"
@__const.handleError.string = [47 x i8*] [i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([26 x i8], [26 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 ([65 x i8], [65 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.15, i32 0, i32 0), i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.16, i32 0, i32 0), i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.17, i32 0, i32 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.18, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.19, i32 0, i32 0), i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.20, i32 0, i32 0), i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.21, i32 0, i32 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.22, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.23, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.24, i32 0, i32 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.25, i32 0, i32 0), i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.26, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.27, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.28, i32 0, i32 0), i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.29, i32 0, i32 0), i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.30, i32 0, i32 0), i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.31, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.32, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.33, i32 0, i32 0), i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.34, i32 0, i32 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.35, i32 0, i32 0), i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.36, i32 0, i32 0), i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.37, i32 0, i32 0), i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.38, i32 0, i32 0), i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.39, i32 0, i32 0), i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.40, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.41, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.24, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.27, i32 0, i32 0), i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.42, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.27, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.43, i32 0, i32 0)]
define i8* @handleError() {
%1 = alloca [47 x i8*]
%2 = bitcast [47 x i8*]* %1 to i8*
%3 = getelementptr inbounds [47 x i8*], [47 x i8*]* %1, i64 0, i64 0
%4 = call i8* @buildString(i8** %3, i32 47)
ret i8* %4
}