#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*/ assert(int);
void example7(void) {
  int top;
  int arr1[42];
  int arr2[42];
  int *ptr;
  for (int i = 0; i < 42; i++) {
    arr1[i] = 4;
    arr2[i] = 4;
  }
  ptr = &arr1[7];
  if (top) {
    ptr = &arr2[7];
  }
  *ptr = 9;
  int x = arr1[7];
  assert(x == 3);
  assert(x == 4);
  assert(x == 9);
  assert(x == 10);
}


x86 assembly (clang, -O0):
<example7>:
push   %rbp
mov    %rsp,%rbp
sub    $0x170,%rsp
movl   $0x0,-0x16c(%rbp)
cmpl   $0x2a,-0x16c(%rbp)
jge    116a <example7+0x5a>
movslq -0x16c(%rbp),%rax
movl   $0x4,-0xb0(%rbp,%rax,4)
movslq -0x16c(%rbp),%rax
movl   $0x4,-0x160(%rbp,%rax,4)
mov    -0x16c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x16c(%rbp)
jmp    1125 <example7+0x15>
lea    -0xb0(%rbp),%rax
add    $0x1c,%rax
mov    %rax,-0x168(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     1198 <example7+0x88>
lea    -0x160(%rbp),%rax
add    $0x1c,%rax
mov    %rax,-0x168(%rbp)
mov    -0x168(%rbp),%rax
movl   $0x9,(%rax)
mov    -0x94(%rbp),%eax
mov    %eax,-0x170(%rbp)
cmpl   $0x3,-0x170(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x4,-0x170(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x9,-0x170(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0xa,-0x170(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
add    $0x170,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
define void @example7() {
%1 = alloca i32
%2 = alloca [42 x i32]
%3 = alloca [42 x i32]
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %5
br label %7
7: ; preds = %17, %0
%8 = load i32, i32* %5
%9 = icmp slt i32 %8, 42
br i1 %9, label %10, label %20
10: ; preds = %7
%11 = load i32, i32* %5
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [42 x i32], [42 x i32]* %2, i64 0, i64 %12
store i32 4, i32* %13
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [42 x i32], [42 x i32]* %3, i64 0, i64 %15
store i32 4, i32* %16
br label %17
17: ; preds = %10
%18 = load i32, i32* %5
%19 = add nsw i32 %18, 1
store i32 %19, i32* %5
br label %7
20: ; preds = %7
%21 = getelementptr inbounds [42 x i32], [42 x i32]* %2, i64 0, i64 7
store i32* %21, i32** %4
%22 = load i32, i32* %1
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = getelementptr inbounds [42 x i32], [42 x i32]* %3, i64 0, i64 7
store i32* %25, i32** %4
br label %26
26: ; preds = %24, %20
%27 = load i32*, i32** %4
store i32 9, i32* %27
%28 = getelementptr inbounds [42 x i32], [42 x i32]* %2, i64 0, i64 7
%29 = load i32, i32* %28
store i32 %29, i32* %6
%30 = load i32, i32* %6
%31 = icmp eq i32 %30, 3
%32 = zext i1 %31 to i32
%33 = call i32 @assert(i32 %32)
%34 = load i32, i32* %6
%35 = icmp eq i32 %34, 4
%36 = zext i1 %35 to i32
%37 = call i32 @assert(i32 %36)
%38 = load i32, i32* %6
%39 = icmp eq i32 %38, 9
%40 = zext i1 %39 to i32
%41 = call i32 @assert(i32 %40)
%42 = load i32, i32* %6
%43 = icmp eq i32 %42, 10
%44 = zext i1 %43 to i32
%45 = call i32 @assert(i32 %44)
ret void
}

LLVM IR (-O2):
define void @example7() {
%1 = tail call i32 @assert(i32 0)
%2 = tail call i32 @assert(i32 0)
%3 = tail call i32 @assert(i32 1)
%4 = tail call i32 @assert(i32 0)
ret void
}