#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*/ buf;

/* Variables and functions */
int /*<<< orphan*/ memmove(char *, char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strlen(char *);
int main(void) {
  char buf[20] = "hello world\n";
  printf("%lu %lu", sizeof(buf) / sizeof(char), strlen(buf));
  memmove(buf + 1, buf, 13);
  printf("%s", buf);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeba(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeb7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xeb5(%rip),%eax
mov    %eax,-0x10(%rbp)
lea    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%edx
lea    0xea4(%rip),%rdi
mov    $0x14,%esi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x20(%rbp),%rdi
add    $0x1,%rdi
lea    -0x20(%rbp),%rsi
mov    $0xd,%edx
call   1050 <memmove@plt>
lea    -0x20(%rbp),%rsi
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
movaps 0xec4(%rip),%xmm0
movaps %xmm0,(%rsp)
movl   $0x0,0x10(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
lea    0xeba(%rip),%rdi
mov    $0x14,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x1(%rsp),%rdi
mov    %rbx,%rsi
mov    $0xd,%edx
call   1050 <memmove@plt>
lea    0xe9b(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.buf = [20 x i8] c"hello world\0A\00\00\00\00\00\00\00\00"
@.str = [8 x i8] c"%lu %lu\00"
@.str.1 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x i8]
store i32 0, i32* %1
%3 = bitcast [20 x i8]* %2 to i8*
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%5 = call i32 @strlen(i8* %4)
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64 20, i32 %5)
%7 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%8 = getelementptr inbounds i8, i8* %7, i64 1
%9 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%10 = call i32 @memmove(i8* %8, i8* %9, i32 13)
%11 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %11)
ret i32 0
}

LLVM IR (-O2):
@__const.main.buf = [20 x i8] c"hello world\0A\00\00\00\00\00\00\00\00"
@.str = [8 x i8] c"%lu %lu\00"
@.str.1 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%3 = call i32 @strlen(i8* %2)
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64 20, i32 %3)
%5 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 1
%6 = call i32 @memmove(i8* %5, i8* %2, i32 13)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
ret i32 0
}