#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*/ memmove(char *, char *, int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
main() {
  char s1[20] = "abcdefgh";
  char s2[15];
  strcpy(s2, s1 + 2);
  printf("%s\n", s2);
  strcat(s1 + 2, s2 + 1);
  printf("%s\n", s1);
  strcpy(s2 + 2, s1 + 3);
  printf("%s\n", s2);
  strcpy(s1 + 2, s1 + 4);
  printf("%s\n", s1);
  memmove(s2 + 11, s2 + 1, 6);
  printf("%s\n", s2);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0xeb1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeae(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xeac(%rip),%eax
mov    %eax,-0x10(%rbp)
lea    -0x2f(%rbp),%rdi
lea    -0x20(%rbp),%rsi
add    $0x2,%rsi
call   1030 <strcpy@plt>
lea    -0x2f(%rbp),%rsi
lea    0xe91(%rip),%rdi
call   1040 <printf@plt>
lea    -0x20(%rbp),%rdi
add    $0x2,%rdi
lea    -0x2f(%rbp),%rsi
add    $0x1,%rsi
call   1060 <strcat@plt>
lea    -0x20(%rbp),%rsi
lea    0xe6c(%rip),%rdi
call   1040 <printf@plt>
lea    -0x2f(%rbp),%rdi
add    $0x2,%rdi
lea    -0x20(%rbp),%rsi
add    $0x3,%rsi
call   1030 <strcpy@plt>
lea    -0x2f(%rbp),%rsi
lea    0xe47(%rip),%rdi
call   1040 <printf@plt>
lea    -0x20(%rbp),%rdi
add    $0x2,%rdi
lea    -0x20(%rbp),%rsi
add    $0x4,%rsi
call   1030 <strcpy@plt>
lea    -0x20(%rbp),%rsi
lea    0xe22(%rip),%rdi
call   1040 <printf@plt>
lea    -0x2f(%rbp),%rdi
add    $0xb,%rdi
lea    -0x2f(%rbp),%rsi
add    $0x1,%rsi
mov    $0x6,%edx
call   1050 <memmove@plt>
lea    -0x2f(%rbp),%rsi
lea    0xdf8(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x30,%rsp
movaps 0xeac(%rip),%xmm0
movaps %xmm0,(%rsp)
movl   $0x0,0x10(%rsp)
lea    0x2(%rsp),%r15
lea    0x21(%rsp),%r14
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
lea    0xe98(%rip),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
lea    0x22(%rsp),%r12
mov    %r15,%rdi
mov    %r12,%rsi
call   1060 <strcat@plt>
mov    %rsp,%r13
mov    %rbx,%rdi
mov    %r13,%rsi
call   1040 <printf@plt>
lea    0x23(%rsp),%rdi
lea    0x3(%rsp),%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
lea    0x4(%rsp),%rsi
mov    %r15,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1040 <printf@plt>
lea    0x2c(%rsp),%rdi
mov    %r12,%rsi
mov    $0x6,%edx
call   1050 <memmove@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@__const.main.s1 = [20 x i8] c"abcdefgh\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = alloca [15 x i8]
%3 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 2
%6 = call i32 @strcpy(i8* %4, i8* %5)
%7 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %4)
%8 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 1
%9 = call i32 @strcat(i8* %5, i8* %8)
%10 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %3)
%11 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 2
%12 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 3
%13 = call i32 @strcpy(i8* %11, i8* %12)
%14 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %4)
%15 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 4
%16 = call i32 @strcpy(i8* %5, i8* %15)
%17 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %3)
%18 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 11
%19 = call i32 @memmove(i8* %18, i8* %8, i32 6)
%20 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %4)
ret i32 0
}