#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 f();
int /*<<< orphan*/ printf(char *);
void test2() {
  int count = 10;
  void *addr[count];
  for (; count--;) {
    int a[f()];
    addr[count] = a;
    continue;
  }
  if (addr[9] == addr[0]) {
    printf("OK\n");
  } else {
    printf("NOT OK\n");
  }
}


x86 assembly (clang, -O0):
<test2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0xa,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x18(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x4(%rbp)
cmp    $0x0,%eax
je     11ad <test2+0x8d>
xor    %eax,%eax
call   1030 <f@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,%ecx
mov    %rsp,%rdx
mov    %rdx,-0x20(%rbp)
lea    0xf(,%rcx,4),%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,%rsp
mov    %rcx,-0x28(%rbp)
movslq -0x4(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
jmp    1156 <test2+0x36>
mov    -0x30(%rbp),%rcx
mov    0x48(%rcx),%rax
cmp    (%rcx),%rax
jne    11cf <test2+0xaf>
lea    0xe3f(%rip),%rdi
call   1040 <printf@plt>
jmp    11db <test2+0xbb>
lea    0xe2a(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test2>:
push   %rax
xor    %eax,%eax
call   1040 <f@plt>
xor    %eax,%eax
call   1040 <f@plt>
xor    %eax,%eax
call   1040 <f@plt>
xor    %eax,%eax
call   1040 <f@plt>
xor    %eax,%eax
call   1040 <f@plt>
xor    %eax,%eax
call   1040 <f@plt>
xor    %eax,%eax
call   1040 <f@plt>
xor    %eax,%eax
call   1040 <f@plt>
xor    %eax,%eax
call   1040 <f@plt>
xor    %eax,%eax
call   1040 <f@plt>
lea    0xe92(%rip),%rdi
call   1030 <puts@plt>
pop    %rax
ret

LLVM IR (-O0):
@.str = [4 x i8] c"OK\0A\00"
@.str.1 = [8 x i8] c"NOT OK\0A\00"
define void @test2() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i64
store i32 10, i32* %1
%6 = load i32, i32* %1
%7 = zext i32 %6 to i64
%8 = call i8* @llvm.stacksave()
store i8* %8, i8** %2
%9 = alloca i8*, i64 %7
store i64 %7, i64* %3
br label %10
10: ; preds = %14, %0
%11 = load i32, i32* %1
%12 = add nsw i32 %11, -1
store i32 %12, i32* %1
%13 = icmp ne i32 %11, 0
br i1 %13, label %14, label %24
14: ; preds = %10
%15 = call i32 (...) @f()
%16 = zext i32 %15 to i64
%17 = call i8* @llvm.stacksave()
store i8* %17, i8** %4
%18 = alloca i32, i64 %16
store i64 %16, i64* %5
%19 = bitcast i32* %18 to i8*
%20 = load i32, i32* %1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8*, i8** %9, i64 %21
store i8* %19, i8** %22
%23 = load i8*, i8** %4
br label %10
24: ; preds = %10
%25 = getelementptr inbounds i8*, i8** %9, i64 9
%26 = load i8*, i8** %25
%27 = getelementptr inbounds i8*, i8** %9, i64 0
%28 = load i8*, i8** %27
%29 = icmp eq i8* %26, %28
br i1 %29, label %30, label %32
30: ; preds = %24
%31 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %34
32: ; preds = %24
%33 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %34
34: ; preds = %32, %30
%35 = load i8*, i8** %2
ret void
}

LLVM IR (-O2):
@str = [7 x i8] c"NOT OK\00"
define void @test2() {
%1 = call i32 (...) @f()
%2 = call i32 (...) @f()
%3 = call i32 (...) @f()
%4 = call i32 (...) @f()
%5 = call i32 (...) @f()
%6 = call i32 (...) @f()
%7 = call i32 (...) @f()
%8 = call i32 (...) @f()
%9 = call i32 (...) @f()
%10 = call i32 (...) @f()
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
ret void
}