#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*/ abort();
int /*<<< orphan*/ memset(short **, int, int);
f(int n) {
  short vla[4][n];
  memset(vla, 9, sizeof vla);
  typedef short(*ptr_n)[n];
  ptr_n a, b = vla + 2;
  a = vla;
  a++;
  ++b;
  (*a)[1] = 2;
  (*b)[3] = 7;
  if (vla[1][1] != 2)
    abort();
  if (vla[3][3] != 7)
    abort();
}


x86 assembly (clang, -O0):
<f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %rax,-0x38(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
lea    0xf(,%rax,8),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x30(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x18(%rbp)
shl    $0x2,%rax
shl    $0x1,%rax
mov    %eax,%edx
mov    $0x9,%esi
call   1040 <memset@plt>
mov    -0x38(%rbp),%rcx
mov    -0x30(%rbp),%rax
mov    -0x8(%rbp),%edx
mov    %rcx,%rdi
shl    $0x1,%rdi
shl    $0x1,%rdi
mov    %rax,%rsi
add    %rdi,%rsi
mov    %rsi,-0x28(%rbp)
mov    %rax,-0x20(%rbp)
mov    %rdx,%rsi
shl    $0x1,%rsi
add    -0x20(%rbp),%rsi
mov    %rsi,-0x20(%rbp)
shl    $0x1,%rdx
add    -0x28(%rbp),%rdx
mov    %rdx,-0x28(%rbp)
mov    -0x20(%rbp),%rdx
movw   $0x2,0x2(%rdx)
mov    -0x28(%rbp),%rdx
movw   $0x7,0x6(%rdx)
shl    $0x0,%rcx
movswl 0x2(%rax,%rcx,2),%eax
cmp    $0x2,%eax
je     11d6 <f+0xb6>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x30(%rbp),%rax
mov    -0x38(%rbp),%rcx
imul   $0x3,%rcx,%rcx
movswl 0x6(%rax,%rcx,2),%eax
cmp    $0x7,%eax
je     11f7 <f+0xd7>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,%ecx
mov    %rsp,%rax
lea    0xf(,%rcx,8),%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%rax
mov    %rax,%rsp
lea    0x0(,%rdi,8),%edx
mov    %rax,%rdi
mov    $0x9,%esi
call   1030 <memset@plt>
mov    %rbp,%rsp
pop    %rbp
ret

LLVM IR (-O0):
define i32 @f(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i16*
%7 = alloca i16*
store i32 %0, i32* %3
%8 = load i32, i32* %3
%9 = zext i32 %8 to i64
%10 = call i8* @llvm.stacksave()
store i8* %10, i8** %4
%11 = mul nuw i64 4, %9
%12 = alloca i16, i64 %11
store i64 %9, i64* %5
%13 = bitcast i16* %12 to i16**
%14 = mul nuw i64 4, %9
%15 = mul nuw i64 2, %14
%16 = trunc i64 %15 to i32
%17 = call i32 @memset(i16** %13, i32 9, i32 %16)
%18 = load i32, i32* %3
%19 = zext i32 %18 to i64
%20 = mul nsw i64 2, %9
%21 = getelementptr inbounds i16, i16* %12, i64 %20
store i16* %21, i16** %7
store i16* %12, i16** %6
%22 = load i16*, i16** %6
%23 = getelementptr inbounds i16, i16* %22, i64 %19
store i16* %23, i16** %6
%24 = load i16*, i16** %7
%25 = getelementptr inbounds i16, i16* %24, i64 %19
store i16* %25, i16** %7
%26 = load i16*, i16** %6
%27 = getelementptr inbounds i16, i16* %26, i64 1
store i16 2, i16* %27
%28 = load i16*, i16** %7
%29 = getelementptr inbounds i16, i16* %28, i64 3
store i16 7, i16* %29
%30 = mul nsw i64 1, %9
%31 = getelementptr inbounds i16, i16* %12, i64 %30
%32 = getelementptr inbounds i16, i16* %31, i64 1
%33 = load i16, i16* %32
%34 = sext i16 %33 to i32
%35 = icmp ne i32 %34, 2
br i1 %35, label %36, label %38
36: ; preds = %1
%37 = call i32 (...) @abort()
unreachable
38: ; preds = %1
%39 = mul nsw i64 3, %9
%40 = getelementptr inbounds i16, i16* %12, i64 %39
%41 = getelementptr inbounds i16, i16* %40, i64 3
%42 = load i16, i16* %41
%43 = sext i16 %42 to i32
%44 = icmp ne i32 %43, 7
br i1 %44, label %45, label %47
45: ; preds = %38
%46 = call i32 (...) @abort()
unreachable
47: ; preds = %38
%48 = load i8*, i8** %4
%49 = load i32, i32* %2
ret i32 %49
}

LLVM IR (-O2):
define i32 @f(i32 %0) {
%2 = zext i32 %0 to i64
%3 = alloca i16*, i64 %2
%4 = shl i32 %0, 3
%5 = call i32 @memset(i16** %3, i32 9, i32 %4)
ret i32 undef
}