#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 *concatenate_string(char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int main(int argc, char **argv) {
  char *original = "Hello ";
  char *add = "world";
  char *temp = concatenate_string(original, add);
  char test[] = "fred";
  char *conversion = (char *)test;
  printf("%s\n", conversion);
  printf("%s\n", temp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xec3(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xebf(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <concatenate_string@plt>
mov    %rax,-0x28(%rbp)
mov    0xeaa(%rip),%eax
mov    %eax,-0x2d(%rbp)
mov    0xea5(%rip),%al
mov    %al,-0x29(%rbp)
lea    -0x2d(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rsi
lea    0xe90(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%rsi
lea    0xe80(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xed5(%rip),%rdi
lea    0xed5(%rip),%rsi
call   1040 <concatenate_string@plt>
mov    %rax,%rbx
movb   $0x0,0x4(%rsp)
movl   $0x64657266,(%rsp)
lea    0xec5(%rip),%r14
mov    %rsp,%rsi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [7 x i8] c"Hello \00"
@.str.1 = [6 x i8] c"world\00"
@__const.main.test = [5 x i8] c"fred\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca [5 x i8]
%10 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8** %6
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8** %7
%11 = load i8*, i8** %6
%12 = load i8*, i8** %7
%13 = call i8* @concatenate_string(i8* %11, i8* %12)
store i8* %13, i8** %8
%14 = bitcast [5 x i8]* %9 to i8*
%15 = getelementptr inbounds [5 x i8], [5 x i8]* %9, i64 0, i64 0
store i8* %15, i8** %10
%16 = load i8*, i8** %10
%17 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %16)
%18 = load i8*, i8** %8
%19 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %18)
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"Hello \00"
@.str.1 = [6 x i8] c"world\00"
@__const.main.test = [5 x i8] c"fred\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [5 x i8]
%4 = tail call i8* @concatenate_string(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%5 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%6 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%7 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %4)
ret i32 0
}