int main() {
  char a[5] = {'A', 'B', 'C', 'D'};
  char *p = "12345";
  char(*p1)[5] = &a;
  char(*p2)[5] = a;
  char(*p3)[5] = &p;
  char(*p4)[5] = p;
  printf("&a = %x\n", &a);
  printf("a = %x\n", a);
  printf("p1 = %x\n", p1);
  printf("p2 = %x\n", p2);
  printf("p3 = %x\n", p3);
  printf("p4 = %x\n", p4);
  printf("p1 + 1 = %x\n", p1 + 1);
  printf("p2 + 1 = %x\n", p2 + 1);
  printf("p3 + 1 = %x\n", p3 + 1);
  printf("p4 + 1 = %x\n", p4 + 1);
  test();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xecb(%rip),%eax
mov    %eax,-0x9(%rbp)
mov    0xec6(%rip),%al
mov    %al,-0x5(%rbp)
lea    0xebd(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    -0x9(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    -0x9(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
lea    0xe98(%rip),%rdi
lea    -0x9(%rbp),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x9(%rbp),%rsi
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rsi
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%rsi
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%rsi
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rsi
add    $0x5,%rsi
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rsi
add    $0x5,%rsi
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%rsi
add    $0x5,%rsi
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%rsi
add    $0x5,%rsi
lea    0xe36(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <test@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movb   $0x0,0xc(%rsp)
movl   $0x44434241,0x8(%rsp)
44
lea    0xeca(%rip),%r14
mov    %r14,0x10(%rsp)
lea    0xec4(%rip),%rdi
lea    0x8(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeaf(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xea6(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe9e(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe96(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe8c(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xd(%rsp),%rbx
lea    0xe7f(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe7b(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x15(%rsp),%rsi
lea    0xe72(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe71(%rip),%rdi
lea    0xe15(%rip),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <test@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@__const.main.a = [5 x i8] c"ABCD\00"
@.str = [6 x i8] c"12345\00"
@.str.1 = [9 x i8] c"&a = %x\0A\00"
@.str.2 = [8 x i8] c"a = %x\0A\00"
@.str.3 = [9 x i8] c"p1 = %x\0A\00"
@.str.4 = [9 x i8] c"p2 = %x\0A\00"
@.str.5 = [9 x i8] c"p3 = %x\0A\00"
@.str.6 = [9 x i8] c"p4 = %x\0A\00"
@.str.7 = [13 x i8] c"p1 + 1 = %x\0A\00"
@.str.8 = [13 x i8] c"p2 + 1 = %x\0A\00"
@.str.9 = [13 x i8] c"p3 + 1 = %x\0A\00"
@.str.10 = [13 x i8] c"p4 + 1 = %x\0A\00"
define i32 @main() {
%1 = alloca [5 x i8]
%2 = alloca i8*
%3 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%4 = bitcast i8** %2 to i8*
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %2
%5 = bitcast i8** %2 to [5 x i8]*
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), [5 x i8]* %1)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), [5 x i8]* %1)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), [5 x i8]* %1)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8** %2)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), [5 x i8]* bitcast ([6 x i8]* @.str to [5 x i8]*))
%12 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 1
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), [5 x i8]* %12)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), [5 x i8]* %12)
%15 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 1
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0), [5 x i8]* %15)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0), [5 x i8]* bitcast (i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 5) to [5 x i8]*))
%18 = call i32 (...) @test()
ret i32 0
}