void example1(void) {
  int top;
  int a[42];
  int *ptr = &a;
  *ptr = 42;
  ptr++;
  assert(a[0] == 42);
  assert(a[1] == 42);
  *ptr = 42;
  assert(a[0] == 42);
  assert(a[1] == 42);
  ptr++;
  *ptr = 42;
  ptr++;
  *ptr = 42;
  ptr++;
  *ptr = 42;
  ptr++;
  *ptr = 42;
  ptr++;
  int i = 5;
  assert(a[i] == 42);
  if (top) {
    i++;
  }
  assert(a[i] == 42);
}


x86 assembly (clang, -O0):
<example1>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
lea    -0xb0(%rbp),%rax
mov    %rax,-0xb8(%rbp)
mov    -0xb8(%rbp),%rax
movl   $0x2a,(%rax)
mov    -0xb8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0xb8(%rbp)
cmpl   $0x2a,-0xb0(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1030 <assert@plt>
cmpl   $0x2a,-0xac(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1030 <assert@plt>
mov    -0xb8(%rbp),%rax
movl   $0x2a,(%rax)
cmpl   $0x2a,-0xb0(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1030 <assert@plt>
cmpl   $0x2a,-0xac(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1030 <assert@plt>
mov    -0xb8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0xb8(%rbp)
mov    -0xb8(%rbp),%rax
movl   $0x2a,(%rax)
mov    -0xb8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0xb8(%rbp)
mov    -0xb8(%rbp),%rax
movl   $0x2a,(%rax)
mov    -0xb8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0xb8(%rbp)
mov    -0xb8(%rbp),%rax
movl   $0x2a,(%rax)
mov    -0xb8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0xb8(%rbp)
mov    -0xb8(%rbp),%rax
movl   $0x2a,(%rax)
mov    -0xb8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0xb8(%rbp)
movl   $0x5,-0xbc(%rbp)
movslq -0xbc(%rbp),%rax
cmpl   $0x2a,-0xb0(%rbp,%rax,4)
2a
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1030 <assert@plt>
cmpl   $0x0,-0x4(%rbp)
je     127c <example1+0x16c>
mov    -0xbc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xbc(%rbp)
movslq -0xbc(%rbp),%rax
cmpl   $0x2a,-0xb0(%rbp,%rax,4)
2a
sete   %al
and    $0x1,%al
movzbl %al,%edi
mov    $0x0,%al
call   1030 <assert@plt>
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<example1>:
push   %rax
mov    $0x1,%edi
xor    %eax,%eax
call   1030 <assert@plt>
mov    $0x1,%edi
xor    %eax,%eax
call   1030 <assert@plt>
mov    $0x1,%edi
xor    %eax,%eax
call   1030 <assert@plt>
mov    $0x1,%edi
xor    %eax,%eax
call   1030 <assert@plt>
mov    $0x1,%edi
xor    %eax,%eax
call   1030 <assert@plt>
mov    $0x1,%edi
xor    %eax,%eax
pop    %rcx
jmp    1030 <assert@plt>

LLVM IR (-O0):
define void @example1() {
%1 = alloca i32
%2 = alloca [42 x i32]
%3 = alloca i32*
%4 = alloca i32
%5 = bitcast [42 x i32]* %2 to i32*
store i32* %5, i32** %3
%6 = load i32*, i32** %3
store i32 42, i32* %6
%7 = load i32*, i32** %3
%8 = getelementptr inbounds i32, i32* %7, i32 1
store i32* %8, i32** %3
%9 = getelementptr inbounds [42 x i32], [42 x i32]* %2, i64 0, i64 0
%10 = load i32, i32* %9
%11 = icmp eq i32 %10, 42
%12 = zext i1 %11 to i32
%13 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %12)
%14 = getelementptr inbounds [42 x i32], [42 x i32]* %2, i64 0, i64 1
%15 = load i32, i32* %14
%16 = icmp eq i32 %15, 42
%17 = zext i1 %16 to i32
%18 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %17)
%19 = load i32*, i32** %3
store i32 42, i32* %19
%20 = getelementptr inbounds [42 x i32], [42 x i32]* %2, i64 0, i64 0
%21 = load i32, i32* %20
%22 = icmp eq i32 %21, 42
%23 = zext i1 %22 to i32
%24 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %23)
%25 = getelementptr inbounds [42 x i32], [42 x i32]* %2, i64 0, i64 1
%26 = load i32, i32* %25
%27 = icmp eq i32 %26, 42
%28 = zext i1 %27 to i32
%29 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %28)
%30 = load i32*, i32** %3
%31 = getelementptr inbounds i32, i32* %30, i32 1
store i32* %31, i32** %3
%32 = load i32*, i32** %3
store i32 42, i32* %32
%33 = load i32*, i32** %3
%34 = getelementptr inbounds i32, i32* %33, i32 1
store i32* %34, i32** %3
%35 = load i32*, i32** %3
store i32 42, i32* %35
%36 = load i32*, i32** %3
%37 = getelementptr inbounds i32, i32* %36, i32 1
store i32* %37, i32** %3
%38 = load i32*, i32** %3
store i32 42, i32* %38
%39 = load i32*, i32** %3
%40 = getelementptr inbounds i32, i32* %39, i32 1
store i32* %40, i32** %3
%41 = load i32*, i32** %3
store i32 42, i32* %41
%42 = load i32*, i32** %3
%43 = getelementptr inbounds i32, i32* %42, i32 1
store i32* %43, i32** %3
store i32 5, i32* %4
%44 = load i32, i32* %4
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [42 x i32], [42 x i32]* %2, i64 0, i64 %45
%47 = load i32, i32* %46
%48 = icmp eq i32 %47, 42
%49 = zext i1 %48 to i32
%50 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %49)
%51 = load i32, i32* %1
%52 = icmp ne i32 %51, 0
br i1 %52, label %53, label %56
53: ; preds = %0
%54 = load i32, i32* %4
%55 = add nsw i32 %54, 1
store i32 %55, i32* %4
br label %56
56: ; preds = %53, %0
%57 = load i32, i32* %4
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [42 x i32], [42 x i32]* %2, i64 0, i64 %58
%60 = load i32, i32* %59
%61 = icmp eq i32 %60, 42
%62 = zext i1 %61 to i32
%63 = call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 %62)
ret void
}

LLVM IR (-O2):
define void @example1() {
%1 = tail call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 1)
%2 = tail call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 1)
%3 = tail call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 1)
%4 = tail call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 1)
%5 = tail call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 1)
%6 = tail call i32 (i32, ...) bitcast (i32 (...)* @assert to i32 (i32, ...)*)(i32 1)
ret void
}