#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*/ fgets(char *, int, int /*<<< orphan*/);
char *mystrcat(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int main() {
  char prefix[512] = "Hello ";
  char name[512];
  printf("What is your name? ");
  fgets(name, 512, stdin);
  char *final = mystrcat(prefix, name);
  printf("%s", final);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
lea    -0x200(%rbp),%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1040 <memset@plt>
movb   $0x48,-0x200(%rbp)
movb   $0x65,-0x1ff(%rbp)
movb   $0x6c,-0x1fe(%rbp)
movb   $0x6c,-0x1fd(%rbp)
movb   $0x6f,-0x1fc(%rbp)
movb   $0x20,-0x1fb(%rbp)
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x400(%rbp),%rdi
mov    0x2e44(%rip),%rax
mov    (%rax),%edx
mov    $0x200,%esi
call   1050 <fgets@plt>
lea    -0x200(%rbp),%rdi
lea    -0x400(%rbp),%rsi
call   1060 <mystrcat@plt>
mov    %rax,-0x408(%rbp)
mov    -0x408(%rbp),%rsi
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x408,%rsp
mov    %rsp,%r14
mov    $0x200,%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
movl   $0x6c6c6548,(%rsp)
movw   $0x206f,0x4(%rsp)
lea    0xe8f(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2e69(%rip),%rax
mov    (%rax),%edx
lea    0x200(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x200,%esi
call   1050 <fgets@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <mystrcat@plt>
lea    0xe6c(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [20 x i8] c"What is your name? \00"
@stdin = global i32 0
@.str.1 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [512 x i8]
%2 = alloca [512 x i8]
%3 = alloca i8*
%4 = bitcast [512 x i8]* %1 to i8*
%5 = bitcast i8* %4 to [512 x i8]*
%6 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i32 0, i32 0
store i8 72, i8* %6
%7 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i32 0, i32 1
store i8 101, i8* %7
%8 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i32 0, i32 2
store i8 108, i8* %8
%9 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i32 0, i32 3
store i8 108, i8* %9
%10 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i32 0, i32 4
store i8 111, i8* %10
%11 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i32 0, i32 5
store i8 32, i8* %11
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%13 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%14 = load i32, i32* @stdin
%15 = call i32 @fgets(i8* %13, i32 512, i32 %14)
%16 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%17 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%18 = call i8* @mystrcat(i8* %16, i8* %17)
store i8* %18, i8** %3
%19 = load i8*, i8** %3
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %19)
ret i32 0
}

LLVM IR (-O2):
@.str = [20 x i8] c"What is your name? \00"
@stdin = global i32 0
@.str.1 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [512 x i8]
%2 = alloca [512 x i8]
%3 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
store i8 72, i8* %3
%4 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 1
store i8 101, i8* %4
%5 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 2
store i8 108, i8* %5
%6 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 3
store i8 108, i8* %6
%7 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 4
store i8 111, i8* %7
%8 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 5
store i8 32, i8* %8
%9 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* @stdin
%12 = call i32 @fgets(i8* %9, i32 512, i32 %11)
%13 = call i8* @mystrcat(i8* %3, i8* %9)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %13)
ret i32 0
}