#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 */
typedef int /*<<< orphan*/ p;
typedef int /*<<< orphan*/ b;
typedef int /*<<< orphan*/ a;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *, int, ...);
void foo(int n, int a[n][n]) {
  double b[n];
  a[0][n - 1] = 0;
  b[n - 1] = 0.0;
  printf("sizeof(a) = %d, sizeof(b) = %d\n", sizeof(a), sizeof(b));
  int(*p)[n] = a;
  p++;
  if (sizeof(a) != sizeof(p)) {
    printf("Error %d\n", (int)2);
    exit(2);
  };
  if (sizeof(b) != (n * sizeof(double))) {
    printf("Error %d\n", (int)3);
    exit(3);
  };
}


x86 assembly (clang, -O0):
<foo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,%esi
mov    %rsi,%rdx
mov    %rdx,-0x30(%rbp)
mov    %rsp,%rax
mov    %rax,-0x18(%rbp)
lea    0xf(,%rsi,8),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rax
sub    %rcx,%rax
mov    %rax,%rsp
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rcx
imul   $0x0,%rsi,%rsi
shl    $0x2,%rsi
add    %rsi,%rcx
mov    -0x4(%rbp),%esi
sub    $0x1,%esi
movslq %esi,%rsi
movl   $0x0,(%rcx,%rsi,4)
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
shl    $0x3,%rdx
lea    0xe6a(%rip),%rdi
mov    $0x8,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%rax
mov    -0x4(%rbp),%ecx
mov    -0x10(%rbp),%rdx
mov    %rdx,-0x28(%rbp)
shl    $0x2,%rcx
add    -0x28(%rbp),%rcx
mov    %rcx,-0x28(%rbp)
shl    $0x3,%rax
movslq -0x4(%rbp),%rcx
shl    $0x3,%rcx
cmp    %rcx,%rax
je     11ef <foo+0xcf>
lea    0xe47(%rip),%rdi
mov    $0x3,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x3,%edi
call   1040 <exit@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<foo>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%r14d
movslq %edi,%rbx
movl   $0x0,-0x4(%rsi,%rbx,4)
shl    $0x3,%r14
lea    0xec3(%rip),%rdi
mov    $0x8,%esi
mov    %r14,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
shl    $0x3,%rbx
cmp    %rbx,%r14
jne    115d <foo+0x3d>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xebc(%rip),%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x3,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [32 x i8] c"sizeof(a) = %d, sizeof(b) = %d\0A\00"
@.str.1 = [10 x i8] c"Error %d\0A\00"
define void @foo(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i64
%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* %3
%11 = zext i32 %10 to i64
%12 = load i32, i32* %3
%13 = zext i32 %12 to i64
%14 = call i8* @llvm.stacksave()
store i8* %14, i8** %5
%15 = alloca double, i64 %13
store i64 %13, i64* %6
%16 = load i32*, i32** %4
%17 = mul nsw i64 0, %11
%18 = getelementptr inbounds i32, i32* %16, i64 %17
%19 = load i32, i32* %3
%20 = sub nsw i32 %19, 1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %18, i64 %21
store i32 0, i32* %22
%23 = load i32, i32* %3
%24 = sub nsw i32 %23, 1
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds double, double* %15, i64 %25
store double 0.000000e+00, double* %26
%27 = mul nuw i64 8, %13
%28 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 8, i64 %27)
%29 = load i32, i32* %3
%30 = zext i32 %29 to i64
%31 = load i32*, i32** %4
store i32* %31, i32** %7
%32 = load i32*, i32** %7
%33 = getelementptr inbounds i32, i32* %32, i64 %30
store i32* %33, i32** %7
%34 = mul nuw i64 8, %13
%35 = load i32, i32* %3
%36 = sext i32 %35 to i64
%37 = mul i64 %36, 8
%38 = icmp ne i64 %34, %37
br i1 %38, label %39, label %42
39: ; preds = %2
%40 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 3)
%41 = call i32 @exit(i32 3)
unreachable
42: ; preds = %2
%43 = load i8*, i8** %5
ret void
}

LLVM IR (-O2):
@.str = [32 x i8] c"sizeof(a) = %d, sizeof(b) = %d\0A\00"
@.str.1 = [10 x i8] c"Error %d\0A\00"
define void @foo(i32 %0, i32* nocapture writeonly %1) {
%3 = zext i32 %0 to i64
%4 = add nsw i32 %0, -1
%5 = sext i32 %4 to i64
%6 = getelementptr inbounds i32, i32* %1, i64 %5
store i32 0, i32* %6
%7 = shl nuw nsw i64 %3, 3
%8 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 8, i64 %7)
%9 = sext i32 %0 to i64
%10 = shl nsw i64 %9, 3
%11 = icmp eq i64 %7, %10
br i1 %11, label %15, label %12
12: ; preds = %2
%13 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 3)
%14 = tail call i32 @exit(i32 3)
unreachable
15: ; preds = %2
ret void
}