#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*/ foo(long, int **);
int main() {
  long N = 2;
  int v[N][N];
  v[N - 1][N - 1] = -1;
  foo(N, v);
  assert(v[N - 1][N - 1] == 2);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movq   $0x2,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    %rax,%rcx
mov    %rsp,%rdx
mov    %rdx,-0x10(%rbp)
mov    %rax,%rdx
imul   %rdx,%rdx
lea    0xf(,%rdx,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rsi
sub    %rdx,%rsi
mov    %rsi,-0x28(%rbp)
mov    %rsi,%rsp
mov    %rcx,-0x18(%rbp)
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rcx
sub    $0x1,%rcx
imul   %rax,%rcx
shl    $0x2,%rcx
mov    %rsi,%rax
add    %rcx,%rax
mov    -0x8(%rbp),%rcx
sub    $0x1,%rcx
movl   $0xffffffff,(%rax,%rcx,4)
mov    -0x8(%rbp),%rdi
call   1040 <foo@plt>
mov    -0x30(%rbp),%rdx
mov    -0x28(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    $0x1,%rcx
imul   %rdx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    -0x8(%rbp),%rcx
sub    $0x1,%rcx
cmpl   $0x2,(%rax,%rcx,4)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
xor    %eax,%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
movl   $0xffffffff,0xc(%rsp)
ff
mov    %rsp,%rsi
mov    $0x2,%edi
call   1040 <foo@plt>
xor    %edi,%edi
cmpl   $0x2,0xc(%rsp)
sete   %dil
call   1030 <assert@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i64
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i64
store i64 2, i64* %1
%5 = load i64, i64* %1
%6 = load i64, i64* %1
%7 = call i8* @llvm.stacksave()
store i8* %7, i8** %2
%8 = mul nuw i64 %5, %6
%9 = alloca i32, i64 %8
store i64 %5, i64* %3
store i64 %6, i64* %4
%10 = load i64, i64* %1
%11 = sub nsw i64 %10, 1
%12 = mul nsw i64 %11, %6
%13 = getelementptr inbounds i32, i32* %9, i64 %12
%14 = load i64, i64* %1
%15 = sub nsw i64 %14, 1
%16 = getelementptr inbounds i32, i32* %13, i64 %15
store i32 -1, i32* %16
%17 = load i64, i64* %1
%18 = bitcast i32* %9 to i32**
%19 = call i32 @foo(i64 %17, i32** %18)
%20 = load i64, i64* %1
%21 = sub nsw i64 %20, 1
%22 = mul nsw i64 %21, %6
%23 = getelementptr inbounds i32, i32* %9, i64 %22
%24 = load i64, i64* %1
%25 = sub nsw i64 %24, 1
%26 = getelementptr inbounds i32, i32* %23, i64 %25
%27 = load i32, i32* %26
%28 = icmp eq i32 %27, 2
%29 = zext i1 %28 to i32
%30 = call i32 @assert(i32 %29)
%31 = load i8*, i8** %2
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = alloca [4 x i32]
%2 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 3
store i32 -1, i32* %2
%3 = bitcast [4 x i32]* %1 to i32**
%4 = call i32 @foo(i64 2, i32** %3)
%5 = load i32, i32* %2
%6 = icmp eq i32 %5, 2
%7 = zext i1 %6 to i32
%8 = call i32 @assert(i32 %7)
ret i32 0
}