#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 *);
main() {
  void strcat(char *, char *);
  void strcopy(char *, char *);
  char begin[1000];
  char front[] = "I'm at the front";
  char end[] = " add me to the end";
  strcopy(begin, front);
  printf("Starting string: %s\n", begin);
  strcat(begin, end);
  printf("Final string: %s\n", begin);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    0xebe(%rip),%rax
mov    %rax,-0x410(%rbp)
mov    0xeb8(%rip),%rax
mov    %rax,-0x408(%rbp)
mov    0xeb3(%rip),%al
mov    %al,-0x400(%rbp)
mov    0xeb6(%rip),%rax
mov    %rax,-0x430(%rbp)
mov    0xeb0(%rip),%rax
mov    %rax,-0x428(%rbp)
mov    0xeaa(%rip),%ax
mov    %ax,-0x420(%rbp)
mov    0xe9f(%rip),%al
mov    %al,-0x41e(%rbp)
lea    -0x3f0(%rbp),%rdi
lea    -0x410(%rbp),%rsi
call   1040 <strcopy@plt>
lea    -0x3f0(%rbp),%rsi
lea    0xe79(%rip),%rdi
call   1030 <printf@plt>
lea    -0x3f0(%rbp),%rdi
lea    -0x430(%rbp),%rsi
call   1050 <strcat@plt>
lea    -0x3f0(%rbp),%rsi
lea    0xe68(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x430,%rsp
movaps 0xec1(%rip),%xmm0
movaps %xmm0,(%rsp)
movb   $0x0,0x10(%rsp)
movaps 0xed1(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movl   $0x646e65,0x2f(%rsp)
lea    0x40(%rsp),%rbx
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1040 <strcopy@plt>
lea    0xec0(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
lea    0x20(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <strcat@plt>
lea    0xeb9(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x430,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.front = [17 x i8] c"I'm at the front\00"
@__const.main.end = [19 x i8] c" add me to the end\00"
@.str = [21 x i8] c"Starting string: %s\0A\00"
@.str.1 = [18 x i8] c"Final string: %s\0A\00"
define i32 @main() {
%1 = alloca [1000 x i8]
%2 = alloca [17 x i8]
%3 = alloca [19 x i8]
%4 = bitcast [17 x i8]* %2 to i8*
%5 = bitcast [19 x i8]* %3 to i8*
%6 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%7 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 0
%8 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%9 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%11 = getelementptr inbounds [19 x i8], [19 x i8]* %3, i64 0, i64 0
%12 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%13 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %12)
ret i32 0
}

LLVM IR (-O2):
@__const.main.front = [17 x i8] c"I'm at the front\00"
@__const.main.end = [19 x i8] c" add me to the end\00"
@.str = [21 x i8] c"Starting string: %s\0A\00"
@.str.1 = [18 x i8] c"Final string: %s\0A\00"
define i32 @main() {
%1 = alloca [1000 x i8]
%2 = alloca [17 x i8]
%3 = alloca [19 x i8]
%4 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [19 x i8], [19 x i8]* %3, i64 0, i64 0
%7 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %4)
%8 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %4)
ret i32 0
}