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


x86 assembly (clang, -O0):
<test3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%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,-0x48(%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     11fa <test3+0xda>
mov    $0x0,%al
call   1030 <f@plt>
mov    %eax,%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
mov    %rax,-0x28(%rbp)
cmpl   $0x0,-0x4(%rbp)
jl     11d2 <test3+0xb2>
xor    %eax,%eax
call   1030 <f@plt>
mov    %eax,%ecx
mov    -0x48(%rbp),%rax
mov    %ecx,%ecx
mov    %rsp,%rdx
mov    %rdx,-0x30(%rbp)
lea    0xf(,%rcx,4),%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,%rsp
mov    %rcx,-0x38(%rbp)
movslq -0x4(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
movl   $0x2,-0x3c(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
jmp    11d9 <test3+0xb9>
movl   $0x0,-0x3c(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x3c(%rbp),%eax
test   %eax,%eax
je     11f5 <test3+0xd5>
jmp    11f0 <test3+0xd0>
jmp    1156 <test3+0x36>
jmp    1156 <test3+0x36>
mov    -0x48(%rbp),%rcx
mov    0x48(%rcx),%rax
cmp    (%rcx),%rax
jne    121c <test3+0xfc>
lea    0xdf2(%rip),%rdi
call   1040 <printf@plt>
jmp    1228 <test3+0x108>
lea    0xddd(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test3>:
push   %rbx
xor    %eax,%eax
call   1040 <f@plt>
mov    %rsp,%rbx
xor    %eax,%eax
call   1040 <f@plt>
mov    %rbx,%rsp
xor    %eax,%eax
call   1040 <f@plt>
mov    %rsp,%rbx
xor    %eax,%eax
call   1040 <f@plt>
mov    %rbx,%rsp
xor    %eax,%eax
call   1040 <f@plt>
mov    %rsp,%rbx
xor    %eax,%eax
call   1040 <f@plt>
mov    %rbx,%rsp
xor    %eax,%eax
call   1040 <f@plt>
mov    %rsp,%rbx
xor    %eax,%eax
call   1040 <f@plt>
mov    %rbx,%rsp
xor    %eax,%eax
call   1040 <f@plt>
mov    %rsp,%rbx
xor    %eax,%eax
call   1040 <f@plt>
mov    %rbx,%rsp
xor    %eax,%eax
call   1040 <f@plt>
mov    %rsp,%rbx
xor    %eax,%eax
call   1040 <f@plt>
mov    %rbx,%rsp
xor    %eax,%eax
call   1040 <f@plt>
mov    %rsp,%rbx
xor    %eax,%eax
call   1040 <f@plt>
mov    %rbx,%rsp
xor    %eax,%eax
call   1040 <f@plt>
mov    %rsp,%rbx
xor    %eax,%eax
call   1040 <f@plt>
mov    %rbx,%rsp
xor    %eax,%eax
call   1040 <f@plt>
mov    %rsp,%rbx
xor    %eax,%eax
call   1040 <f@plt>
mov    %rbx,%rsp
xor    %eax,%eax
call   1040 <f@plt>
mov    %rsp,%rbx
xor    %eax,%eax
call   1040 <f@plt>
mov    %rbx,%rsp
lea    0xe10(%rip),%rdi
call   1030 <puts@plt>
pop    %rbx
ret

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

LLVM IR (-O2):
@str = [7 x i8] c"NOT OK\00"
define void @test3() {
%1 = call i32 (...) @f()
%2 = call i8* @llvm.stacksave()
%3 = call i32 (...) @f()
%4 = call i32 (...) @f()
%5 = call i8* @llvm.stacksave()
%6 = call i32 (...) @f()
%7 = call i32 (...) @f()
%8 = call i8* @llvm.stacksave()
%9 = call i32 (...) @f()
%10 = call i32 (...) @f()
%11 = call i8* @llvm.stacksave()
%12 = call i32 (...) @f()
%13 = call i32 (...) @f()
%14 = call i8* @llvm.stacksave()
%15 = call i32 (...) @f()
%16 = call i32 (...) @f()
%17 = call i8* @llvm.stacksave()
%18 = call i32 (...) @f()
%19 = call i32 (...) @f()
%20 = call i8* @llvm.stacksave()
%21 = call i32 (...) @f()
%22 = call i32 (...) @f()
%23 = call i8* @llvm.stacksave()
%24 = call i32 (...) @f()
%25 = call i32 (...) @f()
%26 = call i8* @llvm.stacksave()
%27 = call i32 (...) @f()
%28 = call i32 (...) @f()
%29 = call i8* @llvm.stacksave()
%30 = call i32 (...) @f()
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
ret void
}