#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ my_func(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int main() {
  printf("Hello World!\n");
  {
    char *hello = "Hello";
    char *world = "World!";
    char *hello_world = (char *)malloc(strlen(hello) + strlen(world) + 2);
    strcpy(hello_world, hello);
    hello_world[strlen(hello)] = ' ';
    strcpy(hello_world + strlen(hello) + 1, world);
    printf("%s\n", hello_world);
  }
  my_func("foo", 7);
  my_func("Scott Meyers", 42);
  my_func("Bjarne Stroustrup", 99);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xea1(%rip),%rax
mov    %rax,-0x8(%rbp)
lea    0xe9c(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x2c(%rbp),%edi
add    %eax,%edi
add    $0x2,%edi
call   1070 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
movb   $0x20,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x20(%rbp),%rdi
cltq
add    %rax,%rdi
add    $0x1,%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rsi
lea    0xe1c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe12(%rip),%rdi
mov    $0x7,%esi
call   1050 <my_func@plt>
lea    0xe05(%rip),%rdi
mov    $0x2a,%esi
call   1050 <my_func@plt>
lea    0xe01(%rip),%rdi
mov    $0x63,%esi
call   1050 <my_func@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
lea    0xecd(%rip),%rdi
call   1040 <puts@plt>
lea    0xe98(%rip),%r15
mov    %r15,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebx
lea    0xeb6(%rip),%r14
mov    %r14,%rdi
call   1050 <strlen@plt>
lea    (%rbx,%rax,1),%edi
add    $0x2,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
mov    %r15,%rdi
call   1050 <strlen@plt>
cltq
movb   $0x20,(%rbx,%rax,1)
mov    %r15,%rdi
call   1050 <strlen@plt>
cltq
lea    (%rbx,%rax,1),%rdi
add    $0x1,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
lea    0xe35(%rip),%rdi
mov    $0x7,%esi
call   1060 <my_func@plt>
lea    0xe28(%rip),%rdi
mov    $0x2a,%esi
call   1060 <my_func@plt>
lea    0xe24(%rip),%rdi
mov    $0x63,%esi
call   1060 <my_func@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [14 x i8] c"Hello World!\0A\00"
@.str.1 = [6 x i8] c"Hello\00"
@.str.2 = [7 x i8] c"World!\00"
@.str.3 = [4 x i8] c"%s\0A\00"
@.str.4 = [4 x i8] c"foo\00"
@.str.5 = [13 x i8] c"Scott Meyers\00"
@.str.6 = [18 x i8] c"Bjarne Stroustrup\00"
define i32 @main() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca i8*
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8** %1
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8** %2
%5 = load i8*, i8** %1
%6 = call i32 @strlen(i8* %5)
%7 = load i8*, i8** %2
%8 = call i32 @strlen(i8* %7)
%9 = add nsw i32 %6, %8
%10 = add nsw i32 %9, 2
%11 = call i64 @malloc(i32 %10)
%12 = inttoptr i64 %11 to i8*
store i8* %12, i8** %3
%13 = load i8*, i8** %3
%14 = load i8*, i8** %1
%15 = call i32 @strcpy(i8* %13, i8* %14)
%16 = load i8*, i8** %3
%17 = load i8*, i8** %1
%18 = call i32 @strlen(i8* %17)
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %16, i64 %19
store i8 32, i8* %20
%21 = load i8*, i8** %3
%22 = load i8*, i8** %1
%23 = call i32 @strlen(i8* %22)
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %21, i64 %24
%26 = getelementptr inbounds i8, i8* %25, i64 1
%27 = load i8*, i8** %2
%28 = call i32 @strcpy(i8* %26, i8* %27)
%29 = load i8*, i8** %3
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %29)
%31 = call i32 @my_func(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 7)
%32 = call i32 @my_func(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i32 42)
%33 = call i32 @my_func(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i32 99)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [6 x i8] c"Hello\00"
@.str.2 = [7 x i8] c"World!\00"
@.str.4 = [4 x i8] c"foo\00"
@.str.5 = [13 x i8] c"Scott Meyers\00"
@.str.6 = [18 x i8] c"Bjarne Stroustrup\00"
@str = [13 x i8] c"Hello World!\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%4 = add i32 %2, 2
%5 = add i32 %4, %3
%6 = tail call i64 @malloc(i32 %5)
%7 = inttoptr i64 %6 to i8*
%8 = tail call i32 @strcpy(i8* %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%9 = tail call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %7, i64 %10
store i8 32, i8* %11
%12 = tail call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %7, i64 %13
%15 = getelementptr inbounds i8, i8* %14, i64 1
%16 = tail call i32 @strcpy(i8* %15, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%17 = tail call i32 @puts(i8* dereferenceable(1) %7)
%18 = tail call i32 @my_func(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 7)
%19 = tail call i32 @my_func(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i32 42)
%20 = tail call i32 @my_func(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i32 99)
ret i32 0
}