#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 *);
char *substring(char *, int);
int main(int argc, char const *argv[]) {
  char name[] = "Hello World";
  printf("'%s'\n", name);
  printf("'%s'\n", substring(name, 6));
  char *new = substring(name, 6);
  printf("'%s'\n ", new);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xec3(%rip),%rax
mov    %rax,-0x1c(%rbp)
mov    0xec1(%rip),%eax
mov    %eax,-0x14(%rbp)
lea    -0x1c(%rbp),%rsi
lea    0xeb7(%rip),%rdi
call   1030 <printf@plt>
lea    -0x1c(%rbp),%rdi
mov    $0x6,%esi
call   1040 <substring@plt>
mov    %rax,%rsi
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
lea    -0x1c(%rbp),%rdi
mov    $0x6,%esi
call   1040 <substring@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rsi
lea    0xe7e(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movabs $0x6f57206f6c6c6548,%rax
20 57 6f
mov    %rax,0x8(%rsp)
movl   $0x646c72,0x10(%rsp)
lea    0xec7(%rip),%r14
lea    0x8(%rsp),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
call   1040 <substring@plt>
mov    %r14,%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
call   1040 <substring@plt>
lea    0xe91(%rip),%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.name = [12 x i8] c"Hello World\00"
@.str = [6 x i8] c"'%s'\0A\00"
@.str.1 = [7 x i8] c"'%s'\0A \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [12 x i8]
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = bitcast [12 x i8]* %6 to i8*
%9 = getelementptr inbounds [12 x i8], [12 x i8]* %6, i64 0, i64 0
%10 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = getelementptr inbounds [12 x i8], [12 x i8]* %6, i64 0, i64 0
%12 = call i8* @substring(i8* %11, i32 6)
%13 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = getelementptr inbounds [12 x i8], [12 x i8]* %6, i64 0, i64 0
%15 = call i8* @substring(i8* %14, i32 6)
store i8* %15, i8** %7
%16 = load i8*, i8** %7
%17 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %16)
ret i32 0
}

LLVM IR (-O2):
@__const.main.name = [12 x i8] c"Hello World\00"
@.str = [6 x i8] c"'%s'\0A\00"
@.str.1 = [7 x i8] c"'%s'\0A \00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [12 x i8]
%4 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 0
%5 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = call i8* @substring(i8* %4, i32 6)
%7 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = call i8* @substring(i8* %4, i32 6)
%9 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %8)
ret i32 0
}