void f(void) {
  int a[4];
  int *b = malloc(16);
  int *c;
  int i;
  printf("1: a = %p, b = %p, c = %p\n", a, b, c);
  c = a;
  for (i = 0; i < 4; i++) {
    a[i] = 100 + i;
  }
  c[0] = 200;
  printf("2: a[0] = %d, a[1] = %d, a[2] = %d, a[3] = %d\n", a[0], a[1], a[2],
         a[3]);
  c[1] = 300;
  *(c + 2) = 301;
  3 [c] = 302;
  printf("3: a[0] = %d, a[1] = %d, a[2] = %d, a[3] = %d\n", a[0], a[1], a[2],
         a[3]);
  c = c + 1;
  *c = 400;
  printf("4: a[0] = %d, a[1] = %d, a[2] = %d, a[3] = %d\n", a[0], a[1], a[2],
         a[3]);
  c = (int *)((char *)c + 1);
  *c = 500;
  printf("5: a[0] = %d, a[1] = %d, a[2] = %d, a[3] = %d\n", a[0], a[1], a[2],
         a[3]);
  b = (int *)a + 1;
  c = (int *)((char *)a + 1);
  printf("6: a = %p, b = %p, c = %p\n", a, b, c);
}


x86 assembly (clang, -O0):
<f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    $0x10,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
lea    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x4,-0x24(%rbp)
jge    1185 <f+0x65>
mov    -0x24(%rbp),%ecx
add    $0x64,%ecx
movslq -0x24(%rbp),%rax
mov    %ecx,-0x10(%rbp,%rax,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    115f <f+0x3f>
mov    -0x20(%rbp),%rax
movl   $0xc8,(%rax)
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%ecx
mov    -0x4(%rbp),%r8d
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
movl   $0x12c,0x4(%rax)
mov    -0x20(%rbp),%rax
movl   $0x12d,0x8(%rax)
mov    -0x20(%rbp),%rax
movl   $0x12e,0xc(%rax)
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%ecx
mov    -0x4(%rbp),%r8d
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movl   $0x190,(%rax)
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%ecx
mov    -0x4(%rbp),%r8d
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movl   $0x1f4,(%rax)
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%ecx
mov    -0x4(%rbp),%r8d
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x10(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
lea    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
lea    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    $0x10,%edi
call   1040 <malloc@plt>
lea    0xed8(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x4(%rsp),%r14
movaps 0xeac(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xecc(%rip),%rdi
mov    $0xc8,%esi
mov    $0x65,%edx
mov    $0x66,%ecx
mov    $0x67,%r8d
xor    %eax,%eax
call   1030 <printf@plt>
movabs $0x12d0000012c,%rax
mov    %rax,0x4(%rsp)
movl   $0x12e,0xc(%rsp)
mov    (%rsp),%esi
lea    0xebe(%rip),%rdi
mov    $0x12c,%edx
mov    $0x12d,%ecx
mov    $0x12e,%r8d
xor    %eax,%eax
call   1030 <printf@plt>
movl   $0x190,0x4(%rsp)
mov    (%rsp),%esi
mov    0x8(%rsp),%ecx
mov    0xc(%rsp),%r8d
lea    0xebb(%rip),%rdi
mov    $0x190,%edx
xor    %eax,%eax
call   1030 <printf@plt>
movl   $0x1f4,0x5(%rsp)
mov    0x4(%rsp),%edx
mov    0x8(%rsp),%ecx
mov    (%rsp),%esi
mov    0xc(%rsp),%r8d
lea    0xebf(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x1(%rsp),%rcx
lea    0xedb(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [27 x i8] c"1: a = %p, b = %p, c = %p\0A\00"
@.str.1 = [47 x i8] c"2: a[0] = %d, a[1] = %d, a[2] = %d, a[3] = %d\0A\00"
@.str.2 = [47 x i8] c"3: a[0] = %d, a[1] = %d, a[2] = %d, a[3] = %d\0A\00"
@.str.3 = [47 x i8] c"4: a[0] = %d, a[1] = %d, a[2] = %d, a[3] = %d\0A\00"
@.str.4 = [47 x i8] c"5: a[0] = %d, a[1] = %d, a[2] = %d, a[3] = %d\0A\00"
@.str.5 = [27 x i8] c"6: a = %p, b = %p, c = %p\0A\00"
define void @f() {
%1 = alloca [4 x i32]
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i32
%5 = call i8* @malloc(i64 16)
%6 = bitcast i8* %5 to i32*
store i32* %6, i32** %2
%7 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
%8 = load i32*, i32** %2
%9 = load i32*, i32** %3
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32* %7, i32* %8, i32* %9)
%11 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
store i32* %11, i32** %3
store i32 0, i32* %4
br label %12
12: ; preds = %21, %0
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 4
br i1 %14, label %15, label %24
15: ; preds = %12
%16 = load i32, i32* %4
%17 = add nsw i32 100, %16
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 %19
store i32 %17, i32* %20
br label %21
21: ; preds = %15
%22 = load i32, i32* %4
%23 = add nsw i32 %22, 1
store i32 %23, i32* %4
br label %12
24: ; preds = %12
%25 = load i32*, i32** %3
%26 = getelementptr inbounds i32, i32* %25, i64 0
store i32 200, i32* %26
%27 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
%28 = load i32, i32* %27
%29 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 1
%30 = load i32, i32* %29
%31 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 2
%32 = load i32, i32* %31
%33 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 3
%34 = load i32, i32* %33
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i32 %28, i32 %30, i32 %32, i32 %34)
%36 = load i32*, i32** %3
%37 = getelementptr inbounds i32, i32* %36, i64 1
store i32 300, i32* %37
%38 = load i32*, i32** %3
%39 = getelementptr inbounds i32, i32* %38, i64 2
store i32 301, i32* %39
%40 = load i32*, i32** %3
%41 = getelementptr inbounds i32, i32* %40, i64 3
store i32 302, i32* %41
%42 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
%43 = load i32, i32* %42
%44 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 1
%45 = load i32, i32* %44
%46 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 2
%47 = load i32, i32* %46
%48 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 3
%49 = load i32, i32* %48
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0), i32 %43, i32 %45, i32 %47, i32 %49)
%51 = load i32*, i32** %3
%52 = getelementptr inbounds i32, i32* %51, i64 1
store i32* %52, i32** %3
%53 = load i32*, i32** %3
store i32 400, i32* %53
%54 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
%55 = load i32, i32* %54
%56 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 1
%57 = load i32, i32* %56
%58 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 2
%59 = load i32, i32* %58
%60 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 3
%61 = load i32, i32* %60
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0), i32 %55, i32 %57, i32 %59, i32 %61)
%63 = load i32*, i32** %3
%64 = bitcast i32* %63 to i8*
%65 = getelementptr inbounds i8, i8* %64, i64 1
%66 = bitcast i8* %65 to i32*
store i32* %66, i32** %3
%67 = load i32*, i32** %3
store i32 500, i32* %67
%68 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
%69 = load i32, i32* %68
%70 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 1
%71 = load i32, i32* %70
%72 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 2
%73 = load i32, i32* %72
%74 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 3
%75 = load i32, i32* %74
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0), i32 %69, i32 %71, i32 %73, i32 %75)
%77 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
%78 = getelementptr inbounds i32, i32* %77, i64 1
store i32* %78, i32** %2
%79 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
%80 = bitcast i32* %79 to i8*
%81 = getelementptr inbounds i8, i8* %80, i64 1
%82 = bitcast i8* %81 to i32*
store i32* %82, i32** %3
%83 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
%84 = load i32*, i32** %2
%85 = load i32*, i32** %3
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i32* %83, i32* %84, i32* %85)
ret void
}

LLVM IR (-O2):
@.str = [27 x i8] c"1: a = %p, b = %p, c = %p\0A\00"
@.str.1 = [47 x i8] c"2: a[0] = %d, a[1] = %d, a[2] = %d, a[3] = %d\0A\00"
@.str.2 = [47 x i8] c"3: a[0] = %d, a[1] = %d, a[2] = %d, a[3] = %d\0A\00"
@.str.3 = [47 x i8] c"4: a[0] = %d, a[1] = %d, a[2] = %d, a[3] = %d\0A\00"
@.str.4 = [47 x i8] c"5: a[0] = %d, a[1] = %d, a[2] = %d, a[3] = %d\0A\00"
@.str.5 = [27 x i8] c"6: a = %p, b = %p, c = %p\0A\00"
define void @f() {
%1 = alloca [4 x i32]
%2 = bitcast [4 x i32]* %1 to i8*
%3 = tail call dereferenceable_or_null(16) i8* @malloc(i64 16)
%4 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32* %4, i8* %3, i32* undef)
%6 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 1
store i32 101, i32* %6
%7 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 2
store i32 102, i32* %7
%8 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 3
store i32 103, i32* %8
store i32 200, i32* %4
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i32 200, i32 101, i32 102, i32 103)
store i32 300, i32* %6
store i32 301, i32* %7
store i32 302, i32* %8
%10 = load i32, i32* %4
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0), i32 %10, i32 300, i32 301, i32 302)
store i32 400, i32* %6
%12 = load i32, i32* %4
%13 = load i32, i32* %7
%14 = load i32, i32* %8
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0), i32 %12, i32 400, i32 %13, i32 %14)
%16 = bitcast i32* %6 to i8*
%17 = getelementptr inbounds i8, i8* %16, i64 1
%18 = bitcast i8* %17 to i32*
store i32 500, i32* %18
%19 = load i32, i32* %4
%20 = load i32, i32* %6
%21 = load i32, i32* %7
%22 = load i32, i32* %8
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0), i32 %19, i32 %20, i32 %21, i32 %22)
%24 = getelementptr inbounds i8, i8* %2, i64 1
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i32* %4, i32* %6, i8* %24)
ret void
}