#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 main() {
  char a[] = "hello world";
  char *ap = (char *)&a[0];
  char *bp = (char *)&a;
  char *cp = (char *)&a[6];
  printf("ap: \"%s\"\n", ap);
  printf("bp: \"%s\"\n", bp);
  printf("cp: \"%s\"\n", cp);
  a[5] = '\0';
  printf("ap: \"%s\"\n", ap);
  printf("bp: \"%s\"\n", bp);
  printf("cp: \"%s\"\n", cp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeda(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xed8(%rip),%eax
mov    %eax,-0x8(%rbp)
lea    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    -0x10(%rbp),%rax
add    $0x6,%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xeb2(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xeac(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%rsi
lea    0xea6(%rip),%rdi
call   1030 <printf@plt>
movb   $0x0,-0xb(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe7e(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xe78(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%rsi
lea    0xe72(%rip),%rdi
call   1030 <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    $0x10,%rsp
movabs $0x6f77206f6c6c6568,%rax
20 77 6f
mov    %rax,(%rsp)
movl   $0x646c72,0x8(%rsp)
lea    0x6(%rsp),%r14
lea    0xecd(%rip),%r15
mov    %rsp,%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
lea    0xec2(%rip),%r12
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
lea    0xeba(%rip),%r13
mov    %r13,%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
movb   $0x0,0x5(%rsp)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    %r13,%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.a = [12 x i8] c"hello world\00"
@.str = [10 x i8] c"ap: \22%s\22\0A\00"
@.str.1 = [10 x i8] c"bp: \22%s\22\0A\00"
@.str.2 = [10 x i8] c"cp: \22%s\22\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [12 x i8]
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i32 0, i32* %1
%6 = bitcast [12 x i8]* %2 to i8*
%7 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 0
store i8* %7, i8** %3
%8 = bitcast [12 x i8]* %2 to i8*
store i8* %8, i8** %4
%9 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 6
store i8* %9, i8** %5
%10 = load i8*, i8** %3
%11 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = load i8*, i8** %4
%13 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = load i8*, i8** %5
%15 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %14)
%16 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 5
store i8 0, i8* %16
%17 = load i8*, i8** %3
%18 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = load i8*, i8** %4
%20 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %19)
%21 = load i8*, i8** %5
%22 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %21)
ret i32 0
}

LLVM IR (-O2):
@__const.main.a = [12 x i8] c"hello world\00"
@.str = [10 x i8] c"ap: \22%s\22\0A\00"
@.str.1 = [10 x i8] c"bp: \22%s\22\0A\00"
@.str.2 = [10 x i8] c"cp: \22%s\22\0A\00"
define i32 @main() {
%1 = alloca [12 x i8]
%2 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 0
%3 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 6
%4 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %2)
%5 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%6 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%7 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 5
store i8 0, i8* %7
%8 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %2)
%9 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%10 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %3)
ret i32 0
}