#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*/ mystrcat(char *, char *);
int /*<<< orphan*/ mystrjoin(char *, char *, char *);
int /*<<< orphan*/ printf(char *, char *, ...);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int main(void) {
  char t1[] = "hello";
  char t2[] = " world";
  char t3[50];
  char t4[50];
  int n = strlen(t1);
  printf("%s%s\n", t1, t2);
  mystrjoin(t3, t1, t2);
  printf("%s\n", t3);
  strcpy(t4, t1);
  mystrcat(t1, t2);
  printf("%s\n", t1);
  strcat(t4, t2);
  printf("%s\n", t4);
  strcpy(t1 + n, " and goodbye");
  printf("%s\n", t1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe88(%rip),%eax
mov    %eax,-0xa(%rbp)
mov    0xe82(%rip),%ax
mov    %ax,-0x6(%rbp)
mov    0xe7a(%rip),%eax
mov    %eax,-0x11(%rbp)
mov    0xe74(%rip),%ax
mov    %ax,-0xd(%rbp)
mov    0xe6c(%rip),%al
mov    %al,-0xb(%rbp)
lea    -0xa(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x94(%rbp)
lea    -0xa(%rbp),%rsi
lea    -0x11(%rbp),%rdx
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x50(%rbp),%rdi
lea    -0xa(%rbp),%rsi
lea    -0x11(%rbp),%rdx
call   1080 <mystrjoin@plt>
lea    -0x50(%rbp),%rsi
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x90(%rbp),%rdi
lea    -0xa(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0xa(%rbp),%rdi
lea    -0x11(%rbp),%rsi
call   1060 <mystrcat@plt>
lea    -0xa(%rbp),%rsi
lea    0xdfc(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x90(%rbp),%rdi
lea    -0x11(%rbp),%rsi
call   1070 <strcat@plt>
lea    -0x90(%rbp),%rsi
lea    0xdd7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0xa(%rbp),%rdi
movslq -0x94(%rbp),%rax
add    %rax,%rdi
lea    0xdbf(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0xa(%rbp),%rsi
lea    0xdab(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x90,%rsp
movw   $0x6f,0x4(%rsp)
movl   $0x6c6c6568,(%rsp)
movl   $0x646c72,0xb(%rsp)
movl   $0x726f7720,0x8(%rsp)
72
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %eax,%r14d
lea    0xe6b(%rip),%rdi
lea    0x8(%rsp),%r12
mov    %rbx,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x50(%rsp),%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r12,%rdx
call   1080 <mystrjoin@plt>
lea    0xe41(%rip),%r15
mov    %r15,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <mystrcat@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
call   1070 <strcat@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
movslq %r14d,%rax
lea    (%rsp,%rax,1),%rdi
lea    0xdea(%rip),%rsi
call   1030 <strcpy@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.t1 = [6 x i8] c"hello\00"
@__const.main.t2 = [7 x i8] c" world\00"
@.str = [6 x i8] c"%s%s\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [13 x i8] c" and goodbye\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [6 x i8]
%3 = alloca [7 x i8]
%4 = alloca [50 x i8]
%5 = alloca [50 x i8]
%6 = alloca i32
store i32 0, i32* %1
%7 = bitcast [6 x i8]* %2 to i8*
%8 = bitcast [7 x i8]* %3 to i8*
%9 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%10 = call i32 @strlen(i8* %9)
store i32 %10, i32* %6
%11 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%12 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 0
%13 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %11, i8* %12)
%14 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%15 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%16 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 0
%17 = call i32 @mystrjoin(i8* %14, i8* %15, i8* %16)
%18 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%19 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%20 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%21 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%22 = call i32 @strcpy(i8* %20, i8* %21)
%23 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%24 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 0
%25 = call i32 @mystrcat(i8* %23, i8* %24)
%26 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%27 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %26)
%28 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%29 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 0
%30 = call i32 @strcat(i8* %28, i8* %29)
%31 = getelementptr inbounds [50 x i8], [50 x i8]* %5, i64 0, i64 0
%32 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %31)
%33 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%34 = load i32, i32* %6
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
%37 = call i32 @strcpy(i8* %36, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%38 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%39 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %38)
ret i32 0
}

LLVM IR (-O2):
@__const.main.t1 = [6 x i8] c"hello\00"
@__const.main.t2 = [7 x i8] c" world\00"
@.str = [6 x i8] c"%s%s\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [13 x i8] c" and goodbye\00"
define i32 @main() {
%1 = alloca [6 x i8]
%2 = alloca [7 x i8]
%3 = alloca [50 x i8]
%4 = alloca [50 x i8]
%5 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%6 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%9 = call i32 @strlen(i8* %5)
%10 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %5, i8* %6)
%11 = call i32 @mystrjoin(i8* %7, i8* %5, i8* %6)
%12 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%13 = call i32 @strcpy(i8* %8, i8* %5)
%14 = call i32 @mystrcat(i8* %5, i8* %6)
%15 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%16 = call i32 @strcat(i8* %8, i8* %6)
%17 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%18 = sext i32 %9 to i64
%19 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 %18
%20 = call i32 @strcpy(i8* %19, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%21 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %5)
ret i32 0
}