#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 *timing() {
  char *string[20] = {
      "/* Variables declaration */",
      "float ElapsedTime;",
      "",
      "/* Create timer */",
      "cudaEvent_t start, stop;",
      "HANDLE_ERROR( cudaEventCreate( &start ) );",
      "HANDLE_ERROR( cudaEventCreate( &stop ) );",
      "",
      "/* Start timer */",
      "HANDLE_ERROR( cudaEventRecord( start, 0 ) );",
      "",
      "/* Code goes here */",
      "",
      "/* Terminate timer */",
      "HANDLE_ERROR( cudaEventRecord( stop, 0 ) );",
      "HANDLE_ERROR( cudaEventSynchronize( stop ) );",
      "HANDLE_ERROR( cudaEventElapsedTime( &ElapsedTime, start, stop) );",
      "HANDLE_ERROR( cudaEventDestroy( start ) );",
      "HANDLE_ERROR( cudaEventDestroy( stop ) );",
      "printf(\"ElapsedTime:%3.6f\\n\", ElapsedTime);"};
  return buildString(string, 20);
}


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

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

LLVM IR (-O0):
@.str = [28 x i8] c"/* Variables declaration */\00"
@.str.1 = [19 x i8] c"float ElapsedTime;\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [19 x i8] c"/* Create timer */\00"
@.str.4 = [25 x i8] c"cudaEvent_t start, stop;\00"
@.str.5 = [43 x i8] c"HANDLE_ERROR( cudaEventCreate( &start ) );\00"
@.str.6 = [42 x i8] c"HANDLE_ERROR( cudaEventCreate( &stop ) );\00"
@.str.7 = [18 x i8] c"/* Start timer */\00"
@.str.8 = [45 x i8] c"HANDLE_ERROR( cudaEventRecord( start, 0 ) );\00"
@.str.9 = [21 x i8] c"/* Code goes here */\00"
@.str.10 = [22 x i8] c"/* Terminate timer */\00"
@.str.11 = [44 x i8] c"HANDLE_ERROR( cudaEventRecord( stop, 0 ) );\00"
@.str.12 = [46 x i8] c"HANDLE_ERROR( cudaEventSynchronize( stop ) );\00"
@.str.13 = [66 x i8] c"HANDLE_ERROR( cudaEventElapsedTime( &ElapsedTime, start, stop) );\00"
@.str.14 = [43 x i8] c"HANDLE_ERROR( cudaEventDestroy( start ) );\00"
@.str.15 = [42 x i8] c"HANDLE_ERROR( cudaEventDestroy( stop ) );\00"
@.str.16 = [44 x i8] c"printf(\22ElapsedTime:%3.6f\\n\22, ElapsedTime);\00"
@__const.timing.string = [20 x i8*] [i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([43 x i8], [43 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 ([44 x i8], [44 x i8]* @.str.16, i32 0, i32 0)]
define i8* @timing() {
%1 = alloca [20 x i8*]
%2 = bitcast [20 x i8*]* %1 to i8*
%3 = getelementptr inbounds [20 x i8*], [20 x i8*]* %1, i64 0, i64 0
%4 = call i8* @buildString(i8** %3, i32 20)
ret i8* %4
}

LLVM IR (-O2):
@.str = [28 x i8] c"/* Variables declaration */\00"
@.str.1 = [19 x i8] c"float ElapsedTime;\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [19 x i8] c"/* Create timer */\00"
@.str.4 = [25 x i8] c"cudaEvent_t start, stop;\00"
@.str.5 = [43 x i8] c"HANDLE_ERROR( cudaEventCreate( &start ) );\00"
@.str.6 = [42 x i8] c"HANDLE_ERROR( cudaEventCreate( &stop ) );\00"
@.str.7 = [18 x i8] c"/* Start timer */\00"
@.str.8 = [45 x i8] c"HANDLE_ERROR( cudaEventRecord( start, 0 ) );\00"
@.str.9 = [21 x i8] c"/* Code goes here */\00"
@.str.10 = [22 x i8] c"/* Terminate timer */\00"
@.str.11 = [44 x i8] c"HANDLE_ERROR( cudaEventRecord( stop, 0 ) );\00"
@.str.12 = [46 x i8] c"HANDLE_ERROR( cudaEventSynchronize( stop ) );\00"
@.str.13 = [66 x i8] c"HANDLE_ERROR( cudaEventElapsedTime( &ElapsedTime, start, stop) );\00"
@.str.14 = [43 x i8] c"HANDLE_ERROR( cudaEventDestroy( start ) );\00"
@.str.15 = [42 x i8] c"HANDLE_ERROR( cudaEventDestroy( stop ) );\00"
@.str.16 = [44 x i8] c"printf(\22ElapsedTime:%3.6f\\n\22, ElapsedTime);\00"
@__const.timing.string = [20 x i8*] [i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([43 x i8], [43 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 ([44 x i8], [44 x i8]* @.str.16, i32 0, i32 0)]
define i8* @timing() {
%1 = alloca [20 x i8*]
%2 = bitcast [20 x i8*]* %1 to i8*
%3 = getelementptr inbounds [20 x i8*], [20 x i8*]* %1, i64 0, i64 0
%4 = call i8* @buildString(i8** %3, i32 20)
ret i8* %4
}