#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 foo2(int n, int (*a)[n]) {
  int x;
  int y;
  int *ptr = *(a + 7);
  assert(ptr[13] == 23);
  x = (*(a + 29))[7];
  assert(x == 23);
  y = (*(a + 7))[13];
  assert(y == 23);
  return;
}


x86 assembly (clang, -O0):
<foo2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rax
imul   $0x7,%rcx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpl   $0x17,0x34(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x28(%rbp),%rcx
mov    -0x10(%rbp),%rax
imul   $0x1d,%rcx,%rcx
mov    0x1c(%rax,%rcx,4),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x17,-0x14(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x28(%rbp),%rcx
mov    -0x10(%rbp),%rax
imul   $0x7,%rcx,%rcx
mov    0x34(%rax,%rcx,4),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x17,-0x18(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<foo2>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %edi,%r15d
lea    (%r15,%r15,8),%rax
lea    (%rax,%rax,2),%rbx
add    %r15,%rbx
xor    %edi,%edi
cmpl   $0x17,0x34(%rsi,%rbx,1)
sete   %dil
call   1030 <assert@plt>
imul   $0x74,%r15,%rax
xor    %edi,%edi
cmpl   $0x17,0x1c(%r14,%rax,1)
sete   %dil
call   1030 <assert@plt>
xor    %edi,%edi
cmpl   $0x17,0x34(%r14,%rbx,1)
sete   %dil
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <assert@plt>

LLVM IR (-O0):
define void @foo2(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32*
store i32 %0, i32* %3
store i32* %1, i32** %4
%8 = load i32, i32* %3
%9 = zext i32 %8 to i64
%10 = load i32*, i32** %4
%11 = mul nsw i64 7, %9
%12 = getelementptr inbounds i32, i32* %10, i64 %11
store i32* %12, i32** %7
%13 = load i32*, i32** %7
%14 = getelementptr inbounds i32, i32* %13, i64 13
%15 = load i32, i32* %14
%16 = icmp eq i32 %15, 23
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = load i32*, i32** %4
%20 = mul nsw i64 29, %9
%21 = getelementptr inbounds i32, i32* %19, i64 %20
%22 = getelementptr inbounds i32, i32* %21, i64 7
%23 = load i32, i32* %22
store i32 %23, i32* %5
%24 = load i32, i32* %5
%25 = icmp eq i32 %24, 23
%26 = zext i1 %25 to i32
%27 = call i32 @assert(i32 %26)
%28 = load i32*, i32** %4
%29 = mul nsw i64 7, %9
%30 = getelementptr inbounds i32, i32* %28, i64 %29
%31 = getelementptr inbounds i32, i32* %30, i64 13
%32 = load i32, i32* %31
store i32 %32, i32* %6
%33 = load i32, i32* %6
%34 = icmp eq i32 %33, 23
%35 = zext i1 %34 to i32
%36 = call i32 @assert(i32 %35)
ret void
}

LLVM IR (-O2):
define void @foo2(i32 %0, i32* nocapture %1) {
%3 = zext i32 %0 to i64
%4 = mul nuw nsw i64 %3, 7
%5 = getelementptr inbounds i32, i32* %1, i64 %4
%6 = getelementptr inbounds i32, i32* %5, i64 13
%7 = load i32, i32* %6
%8 = icmp eq i32 %7, 23
%9 = zext i1 %8 to i32
%10 = tail call i32 @assert(i32 %9)
%11 = mul nuw nsw i64 %3, 29
%12 = getelementptr inbounds i32, i32* %1, i64 %11
%13 = getelementptr inbounds i32, i32* %12, i64 7
%14 = load i32, i32* %13
%15 = icmp eq i32 %14, 23
%16 = zext i1 %15 to i32
%17 = tail call i32 @assert(i32 %16)
%18 = load i32, i32* %6
%19 = icmp eq i32 %18, 23
%20 = zext i1 %19 to i32
%21 = tail call i32 @assert(i32 %20)
ret void
}