#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*/ printf(char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int main() {
  char s1[] = "Test";
  char s2[] = "string";
  char result[40 + 1];
  strcpy(result, s1);
  strcat(result, " ");
  strcat(result, s2);
  printf("result: '%s'\n", result);
  strcat(result, " and more!");
  printf("result: '%s'\n\n", result);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xebb(%rip),%eax
mov    %eax,-0x9(%rbp)
mov    0xeb6(%rip),%al
mov    %al,-0x5(%rbp)
mov    0xeae(%rip),%eax
mov    %eax,-0x10(%rbp)
mov    0xea8(%rip),%ax
mov    %ax,-0xc(%rbp)
mov    0xea0(%rip),%al
mov    %al,-0xa(%rbp)
lea    -0x40(%rbp),%rdi
lea    -0x9(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x40(%rbp),%rdi
lea    0xe86(%rip),%rsi
call   1050 <strcat@plt>
lea    -0x40(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <strcat@plt>
lea    -0x40(%rbp),%rsi
lea    0xe6b(%rip),%rdi
call   1040 <printf@plt>
lea    -0x40(%rbp),%rdi
lea    0xe69(%rip),%rsi
call   1050 <strcat@plt>
lea    -0x40(%rbp),%rsi
lea    0xe64(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40,%rsp
movb   $0x0,0x4(%rsp)
movl   $0x74736554,(%rsp)
movl   $0x676e69,0xb(%rsp)
movl   $0x69727473,0x8(%rsp)
69
lea    0x10(%rsp),%rbx
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
lea    0xea4(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcat@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <strcat@plt>
lea    0xe8a(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
lea    0xe89(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcat@plt>
lea    0xe85(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.s1 = [5 x i8] c"Test\00"
@__const.main.s2 = [7 x i8] c"string\00"
@.str = [2 x i8] c" \00"
@.str.1 = [14 x i8] c"result: '%s'\0A\00"
@.str.2 = [11 x i8] c" and more!\00"
@.str.3 = [15 x i8] c"result: '%s'\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x i8]
%3 = alloca [7 x i8]
%4 = alloca [41 x i8]
store i32 0, i32* %1
%5 = bitcast [5 x i8]* %2 to i8*
%6 = bitcast [7 x i8]* %3 to i8*
%7 = getelementptr inbounds [41 x i8], [41 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%9 = call i32 @strcpy(i8* %7, i8* %8)
%10 = getelementptr inbounds [41 x i8], [41 x i8]* %4, i64 0, i64 0
%11 = call i32 @strcat(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = getelementptr inbounds [41 x i8], [41 x i8]* %4, i64 0, i64 0
%13 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 0
%14 = call i32 @strcat(i8* %12, i8* %13)
%15 = getelementptr inbounds [41 x i8], [41 x i8]* %4, i64 0, i64 0
%16 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%17 = getelementptr inbounds [41 x i8], [41 x i8]* %4, i64 0, i64 0
%18 = call i32 @strcat(i8* %17, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%19 = getelementptr inbounds [41 x i8], [41 x i8]* %4, i64 0, i64 0
%20 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* %19)
ret i32 0
}

LLVM IR (-O2):
@__const.main.s1 = [5 x i8] c"Test\00"
@__const.main.s2 = [7 x i8] c"string\00"
@.str = [2 x i8] c" \00"
@.str.1 = [14 x i8] c"result: '%s'\0A\00"
@.str.2 = [11 x i8] c" and more!\00"
@.str.3 = [15 x i8] c"result: '%s'\0A\0A\00"
define i32 @main() {
%1 = alloca [5 x i8]
%2 = alloca [7 x i8]
%3 = alloca [41 x i8]
%4 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 0
%7 = call i32 @strcpy(i8* %6, i8* %4)
%8 = call i32 @strcat(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @strcat(i8* %6, i8* %5)
%10 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%11 = call i32 @strcat(i8* %6, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* %6)
ret i32 0
}