#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 */
typedef int /*<<< orphan*/ hbuf;

/* Variables and functions */
int /*<<< orphan*/ memcpy(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ memset(char *, char, int);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strlen(char *);
int hello(char *instr, char *outstr) {
  char hbuf[10240];
  char *hello = "hello!";
  memset(hbuf, '\0', sizeof(hbuf));
  memcpy(hbuf, instr, strlen(instr));
  strcat(hbuf, hello);
  strcpy(outstr, hbuf);
  return 0;
}


x86 assembly (clang, -O0):
<hello>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2830,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe96(%rip),%rax
mov    %rax,-0x2818(%rbp)
lea    -0x2810(%rbp),%rdi
xor    %esi,%esi
mov    $0x2800,%edx
call   1050 <memset@plt>
lea    -0x2810(%rbp),%rax
mov    %rax,-0x2828(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x2820(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x2828(%rbp),%rdi
mov    -0x2820(%rbp),%rsi
mov    %eax,%edx
call   1060 <memcpy@plt>
lea    -0x2810(%rbp),%rdi
mov    -0x2818(%rbp),%rsi
call   1070 <strcat@plt>
mov    -0x10(%rbp),%rdi
lea    -0x2810(%rbp),%rsi
call   1030 <strcpy@plt>
xor    %eax,%eax
add    $0x2830,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hello>:
push   %r15
push   %r14
push   %rbx
sub    $0x2800,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsp,%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x2800,%edx
call   1050 <memset@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1060 <memcpy@plt>
lea    0xe70(%rip),%rsi
mov    %r15,%rdi
call   1070 <strcat@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
xor    %eax,%eax
add    $0x2800,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [7 x i8] c"hello!\00"
define i32 @hello(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [10240 x i8]
%6 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8** %6
%7 = getelementptr inbounds [10240 x i8], [10240 x i8]* %5, i64 0, i64 0
%8 = call i32 @memset(i8* %7, i8 signext 0, i32 10240)
%9 = getelementptr inbounds [10240 x i8], [10240 x i8]* %5, i64 0, i64 0
%10 = load i8*, i8** %3
%11 = load i8*, i8** %3
%12 = call i32 @strlen(i8* %11)
%13 = call i32 @memcpy(i8* %9, i8* %10, i32 %12)
%14 = getelementptr inbounds [10240 x i8], [10240 x i8]* %5, i64 0, i64 0
%15 = load i8*, i8** %6
%16 = call i32 @strcat(i8* %14, i8* %15)
%17 = load i8*, i8** %4
%18 = getelementptr inbounds [10240 x i8], [10240 x i8]* %5, i64 0, i64 0
%19 = call i32 @strcpy(i8* %17, i8* %18)
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"hello!\00"
define i32 @hello(i8* %0, i8* %1) {
%3 = alloca [10240 x i8]
%4 = getelementptr inbounds [10240 x i8], [10240 x i8]* %3, i64 0, i64 0
%5 = call i32 @memset(i8* %4, i8 signext 0, i32 10240)
%6 = call i32 @strlen(i8* %0)
%7 = call i32 @memcpy(i8* %4, i8* %0, i32 %6)
%8 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @strcpy(i8* %1, i8* %4)
ret i32 0
}