#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);
int /*<<< orphan*/ printf(char *, int);
void fooo(int n, int a[n][n]) {
  assert(a[29][7] == 42);
  int *ptr = a[29];
  int x = *(ptr + 7);
  printf("x is %d", x);
  assert(x == 42);
}


x86 assembly (clang, -O0):
<fooo>:
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   $0x1d,%rcx,%rcx
cmpl   $0x2a,0x1c(%rax,%rcx,4)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x28(%rbp),%rcx
mov    -0x10(%rbp),%rax
imul   $0x1d,%rcx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    0x1c(%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xe83(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x2a,-0x1c(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fooo>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%eax
imul   $0x74,%rax,%rbx
xor    %edi,%edi
cmpl   $0x2a,0x1c(%rsi,%rbx,1)
sete   %dil
call   1040 <assert@plt>
mov    0x1c(%r14,%rbx,1),%ebx
lea    0xeb7(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %edi,%edi
cmp    $0x2a,%ebx
sete   %dil
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <assert@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"x is %d\00"
define void @fooo(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32
store i32 %0, i32* %3
store i32* %1, i32** %4
%7 = load i32, i32* %3
%8 = zext i32 %7 to i64
%9 = load i32, i32* %3
%10 = zext i32 %9 to i64
%11 = load i32*, i32** %4
%12 = mul nsw i64 29, %10
%13 = getelementptr inbounds i32, i32* %11, i64 %12
%14 = getelementptr inbounds i32, i32* %13, i64 7
%15 = load i32, i32* %14
%16 = icmp eq i32 %15, 42
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = load i32*, i32** %4
%20 = mul nsw i64 29, %10
%21 = getelementptr inbounds i32, i32* %19, i64 %20
store i32* %21, i32** %5
%22 = load i32*, i32** %5
%23 = getelementptr inbounds i32, i32* %22, i64 7
%24 = load i32, i32* %23
store i32 %24, i32* %6
%25 = load i32, i32* %6
%26 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %25)
%27 = load i32, i32* %6
%28 = icmp eq i32 %27, 42
%29 = zext i1 %28 to i32
%30 = call i32 @assert(i32 %29)
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"x is %d\00"
define void @fooo(i32 %0, i32* nocapture %1) {
%3 = zext i32 %0 to i64
%4 = mul nuw nsw i64 %3, 29
%5 = getelementptr inbounds i32, i32* %1, i64 %4
%6 = getelementptr inbounds i32, i32* %5, i64 7
%7 = load i32, i32* %6
%8 = icmp eq i32 %7, 42
%9 = zext i1 %8 to i32
%10 = tail call i32 @assert(i32 %9)
%11 = load i32, i32* %6
%12 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = icmp eq i32 %11, 42
%14 = zext i1 %13 to i32
%15 = tail call i32 @assert(i32 %14)
ret void
}