#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 */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int main() {
  char first[] = "George ";
  char last[] = "Washington";
  char *buffer;
  buffer = (char *)malloc(sizeof(char) * (strlen(first) + strlen(last)) + 1);
  if (buffer == NULL) {
    fprintf(stderr, "Unable to allocate buffer\n");
    exit(1);
  }
  strcpy(buffer, first);
  strcat(buffer, last);
  printf("Hello, %s\n", buffer);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe7a(%rip),%rax
mov    %rax,-0xc(%rbp)
mov    0xe77(%rip),%rax
mov    %rax,-0x17(%rbp)
mov    0xe74(%rip),%ax
mov    %ax,-0xf(%rbp)
mov    0xe6c(%rip),%al
mov    %al,-0xd(%rbp)
lea    -0xc(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x24(%rbp)
lea    -0x17(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
add    %ecx,%eax
cltq
shl    $0x0,%rax
add    $0x1,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1204 <main+0x94>
mov    0x2df4(%rip),%rax
mov    (%rax),%edi
lea    0xe1e(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x20(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x20(%rbp),%rdi
lea    -0x17(%rbp),%rsi
call   1080 <strcat@plt>
mov    -0x20(%rbp),%rsi
lea    0xe05(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
movabs $0x206567726f6547,%rax
mov    %rax,0x8(%rsp)
movabs $0x74676e6968736157,%rax
6e 67 74
mov    %rax,0x10(%rsp)
movl   $0x6e6f74,0x17(%rsp)
lea    0x8(%rsp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ebx
lea    0x10(%rsp),%rdi
call   1040 <strlen@plt>
lea    (%rbx,%rax,1),%edi
add    $0x1,%edi
call   1070 <malloc@plt>
test   %rax,%rax
je     11f5 <main+0x85>
mov    %rax,%rbx
lea    0x8(%rsp),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <strcat@plt>
lea    0xe41(%rip),%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret
mov    0x2de4(%rip),%rax
mov    (%rax),%edi
lea    0xe06(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@__const.main.first = [8 x i8] c"George \00"
@__const.main.last = [11 x i8] c"Washington\00"
@stderr = global i32 0
@.str = [27 x i8] c"Unable to allocate buffer\0A\00"
@.str.1 = [11 x i8] c"Hello, %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [8 x i8]
%3 = alloca [11 x i8]
%4 = alloca i8*
store i32 0, i32* %1
%5 = bitcast [8 x i8]* %2 to i8*
%6 = bitcast [11 x i8]* %3 to i8*
%7 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%8 = call i32 @strlen(i8* %7)
%9 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 0
%10 = call i32 @strlen(i8* %9)
%11 = add nsw i32 %8, %10
%12 = sext i32 %11 to i64
%13 = mul i64 1, %12
%14 = add i64 %13, 1
%15 = trunc i64 %14 to i32
%16 = call i64 @malloc(i32 %15)
%17 = inttoptr i64 %16 to i8*
store i8* %17, i8** %4
%18 = load i8*, i8** %4
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %24
20: ; preds = %0
%21 = load i32, i32* @stderr
%22 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%23 = call i32 @exit(i32 1)
unreachable
24: ; preds = %0
%25 = load i8*, i8** %4
%26 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%27 = call i32 @strcpy(i8* %25, i8* %26)
%28 = load i8*, i8** %4
%29 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 0
%30 = call i32 @strcat(i8* %28, i8* %29)
%31 = load i8*, i8** %4
%32 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %31)
ret i32 0
}

LLVM IR (-O2):
@__const.main.last = [11 x i8] c"Washington\00"
@stderr = global i32 0
@.str = [27 x i8] c"Unable to allocate buffer\0A\00"
@.str.1 = [11 x i8] c"Hello, %s\0A\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca [11 x i8]
%3 = bitcast i64* %1 to i8*
store i64 9118694230680903, i64* %1
%4 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 0
%5 = call i32 @strlen(i8* %3)
%6 = call i32 @strlen(i8* %4)
%7 = add i32 %5, 1
%8 = add i32 %7, %6
%9 = call i64 @malloc(i32 %8)
%10 = inttoptr i64 %9 to i8*
%11 = icmp eq i64 %9, 0
br i1 %11, label %12, label %16
12: ; preds = %0
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %0
%17 = call i32 @strcpy(i8* %10, i8* %3)
%18 = call i32 @strcat(i8* %10, i8* %4)
%19 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %10)
ret i32 0
}