#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 test1() {
  int count = 10;
  void *addr[10];
  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):
<test1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0xa,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x4(%rbp)
cmp    $0x0,%eax
je     1181 <test1+0x61>
xor    %eax,%eax
call   1030 <f@plt>
mov    %eax,%eax
mov    %rsp,%rcx
mov    %rcx,-0x68(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,%rsp
mov    %rax,-0x70(%rbp)
movslq -0x4(%rbp),%rax
mov    %rcx,-0x60(%rbp,%rax,8)
mov    -0x68(%rbp),%rax
mov    %rax,%rsp
jmp    112f <test1+0xf>
mov    -0x18(%rbp),%rax
cmp    -0x60(%rbp),%rax
jne    11a0 <test1+0x80>
lea    0xe6e(%rip),%rdi
call   1040 <printf@plt>
jmp    11ac <test1+0x8c>
lea    0xe59(%rip),%rdi
call   1040 <printf@plt>
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test1>:
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 @test1() {
%1 = alloca i32
%2 = alloca [10 x i8*]
%3 = alloca i8*
%4 = alloca i64
store i32 10, i32* %1
br label %5
5: ; preds = %9, %0
%6 = load i32, i32* %1
%7 = add nsw i32 %6, -1
store i32 %7, i32* %1
%8 = icmp ne i32 %6, 0
br i1 %8, label %9, label %19
9: ; preds = %5
%10 = call i32 (...) @f()
%11 = zext i32 %10 to i64
%12 = call i8* @llvm.stacksave()
store i8* %12, i8** %3
%13 = alloca i32, i64 %11
store i64 %11, i64* %4
%14 = bitcast i32* %13 to i8*
%15 = load i32, i32* %1
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [10 x i8*], [10 x i8*]* %2, i64 0, i64 %16
store i8* %14, i8** %17
%18 = load i8*, i8** %3
br label %5
19: ; preds = %5
%20 = getelementptr inbounds [10 x i8*], [10 x i8*]* %2, i64 0, i64 9
%21 = load i8*, i8** %20
%22 = getelementptr inbounds [10 x i8*], [10 x i8*]* %2, i64 0, i64 0
%23 = load i8*, i8** %22
%24 = icmp eq i8* %21, %23
br i1 %24, label %25, label %27
25: ; preds = %19
%26 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %29
27: ; preds = %19
%28 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %29
29: ; preds = %27, %25
ret void
}

LLVM IR (-O2):
@str = [7 x i8] c"NOT OK\00"
define void @test1() {
%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
}