#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 test5() {
  int count = 10;
  int a[f()];
  int c[f()];
  c[0] = 42;
  for (; count--;) {
    int b[f()];
    int i;
    for (i = 0; i < f(); i++) {
      b[i] = count;
    }
  }
  if (c[0] == 42) {
    printf("OK\n");
  } else {
    printf("NOT OK\n");
  }
}


x86 assembly (clang, -O0):
<test5>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0xa,-0x4(%rbp)
xor    %eax,%eax
mov    %al,-0x41(%rbp)
call   1030 <f@plt>
mov    %eax,%ecx
mov    -0x41(%rbp),%al
mov    %ecx,%ecx
mov    %rsp,%rdx
mov    %rdx,-0x10(%rbp)
lea    0xf(,%rcx,4),%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,%rsp
mov    %rcx,-0x18(%rbp)
call   1030 <f@plt>
mov    %eax,%eax
mov    %eax,%ecx
lea    0xf(,%rcx,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rax
sub    %rdx,%rax
mov    %rax,-0x40(%rbp)
mov    %rax,%rsp
mov    %rcx,-0x20(%rbp)
movl   $0x2a,(%rax)
mov    -0x4(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x4(%rbp)
cmp    $0x0,%eax
je     1216 <test5+0xf6>
xor    %eax,%eax
call   1030 <f@plt>
mov    %eax,%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x50(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    $0x0,%al
call   1030 <f@plt>
mov    %eax,%ecx
mov    -0x54(%rbp),%eax
cmp    %ecx,%eax
jge    120a <test5+0xea>
mov    -0x50(%rbp),%rax
mov    -0x4(%rbp),%edx
movslq -0x34(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11d4 <test5+0xb4>
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
jmp    118c <test5+0x6c>
mov    -0x40(%rbp),%rax
cmpl   $0x2a,(%rax)
jne    1234 <test5+0x114>
lea    0xdda(%rip),%rdi
call   1040 <printf@plt>
jmp    1240 <test5+0x120>
lea    0xdc5(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test5>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <f@plt>
xor    %eax,%eax
call   1040 <f@plt>
xor    %eax,%eax
call   1040 <f@plt>
mov    %rsp,%rbx
mov    $0xffffffff,%ebp
xor    %eax,%eax
call   1040 <f@plt>
add    $0x1,%ebp
cmp    %eax,%ebp
jl     1140 <test5+0x20>
mov    %rbx,%rsp
xor    %eax,%eax
call   1040 <f@plt>
mov    %rsp,%rbx
mov    $0xffffffff,%ebp
xor    %eax,%eax
call   1040 <f@plt>
add    $0x1,%ebp
cmp    %eax,%ebp
jl     1160 <test5+0x40>
mov    %rbx,%rsp
xor    %eax,%eax
call   1040 <f@plt>
mov    %rsp,%rbx
mov    $0xffffffff,%ebp
xor    %eax,%eax
call   1040 <f@plt>
add    $0x1,%ebp
cmp    %eax,%ebp
jl     1180 <test5+0x60>
mov    %rbx,%rsp
xor    %eax,%eax
call   1040 <f@plt>
mov    %rsp,%rbx
mov    $0xffffffff,%ebp
xor    %eax,%eax
call   1040 <f@plt>
add    $0x1,%ebp
cmp    %eax,%ebp
jl     11a0 <test5+0x80>
mov    %rbx,%rsp
xor    %eax,%eax
call   1040 <f@plt>
mov    %rsp,%rbx
mov    $0xffffffff,%ebp
xor    %eax,%eax
call   1040 <f@plt>
add    $0x1,%ebp
cmp    %eax,%ebp
jl     11c0 <test5+0xa0>
mov    %rbx,%rsp
xor    %eax,%eax
call   1040 <f@plt>
mov    %rsp,%rbx
mov    $0xffffffff,%ebp
xor    %eax,%eax
call   1040 <f@plt>
add    $0x1,%ebp
cmp    %eax,%ebp
jl     11e0 <test5+0xc0>
mov    %rbx,%rsp
xor    %eax,%eax
call   1040 <f@plt>
mov    %rsp,%rbx
mov    $0xffffffff,%ebp
xor    %eax,%eax
call   1040 <f@plt>
add    $0x1,%ebp
cmp    %eax,%ebp
jl     1200 <test5+0xe0>
mov    %rbx,%rsp
xor    %eax,%eax
call   1040 <f@plt>
mov    %rsp,%rbx
mov    $0xffffffff,%ebp
xor    %eax,%eax
call   1040 <f@plt>
add    $0x1,%ebp
cmp    %eax,%ebp
jl     1220 <test5+0x100>
mov    %rbx,%rsp
xor    %eax,%eax
call   1040 <f@plt>
mov    %rsp,%rbx
mov    $0xffffffff,%ebp
xor    %eax,%eax
call   1040 <f@plt>
add    $0x1,%ebp
cmp    %eax,%ebp
jl     1240 <test5+0x120>
mov    %rbx,%rsp
xor    %eax,%eax
call   1040 <f@plt>
mov    %rsp,%rbx
mov    $0xffffffff,%ebp
xor    %eax,%eax
call   1040 <f@plt>
add    $0x1,%ebp
cmp    %eax,%ebp
jl     1260 <test5+0x140>
mov    %rbx,%rsp
lea    0xd88(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <puts@plt>

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

LLVM IR (-O2):
@str = [3 x i8] c"OK\00"
define void @test5() {
%1 = tail call i32 (...) @f()
%2 = tail call i32 (...) @f()
%3 = tail call i32 (...) @f()
%4 = tail call i8* @llvm.stacksave()
br label %5
5: ; preds = %5, %0
%6 = phi i32 [ 0, %0 ], [ %9, %5 ]
%7 = tail call i32 (...) @f()
%8 = icmp slt i32 %6, %7
%9 = add nuw nsw i32 %6, 1
br i1 %8, label %5, label %10
10: ; preds = %5
tail call void @llvm.stackrestore(i8* %4)
%11 = tail call i32 (...) @f()
%12 = tail call i8* @llvm.stacksave()
br label %13
13: ; preds = %13, %10
%14 = phi i32 [ 0, %10 ], [ %17, %13 ]
%15 = tail call i32 (...) @f()
%16 = icmp slt i32 %14, %15
%17 = add nuw nsw i32 %14, 1
br i1 %16, label %13, label %18
18: ; preds = %13
tail call void @llvm.stackrestore(i8* %12)
%19 = tail call i32 (...) @f()
%20 = tail call i8* @llvm.stacksave()
br label %21
21: ; preds = %21, %18
%22 = phi i32 [ 0, %18 ], [ %25, %21 ]
%23 = tail call i32 (...) @f()
%24 = icmp slt i32 %22, %23
%25 = add nuw nsw i32 %22, 1
br i1 %24, label %21, label %26
26: ; preds = %21
tail call void @llvm.stackrestore(i8* %20)
%27 = tail call i32 (...) @f()
%28 = tail call i8* @llvm.stacksave()
br label %29
29: ; preds = %29, %26
%30 = phi i32 [ 0, %26 ], [ %33, %29 ]
%31 = tail call i32 (...) @f()
%32 = icmp slt i32 %30, %31
%33 = add nuw nsw i32 %30, 1
br i1 %32, label %29, label %34
34: ; preds = %29
tail call void @llvm.stackrestore(i8* %28)
%35 = tail call i32 (...) @f()
%36 = tail call i8* @llvm.stacksave()
br label %37
37: ; preds = %37, %34
%38 = phi i32 [ 0, %34 ], [ %41, %37 ]
%39 = tail call i32 (...) @f()
%40 = icmp slt i32 %38, %39
%41 = add nuw nsw i32 %38, 1
br i1 %40, label %37, label %42
42: ; preds = %37
tail call void @llvm.stackrestore(i8* %36)
%43 = tail call i32 (...) @f()
%44 = tail call i8* @llvm.stacksave()
br label %45
45: ; preds = %45, %42
%46 = phi i32 [ 0, %42 ], [ %49, %45 ]
%47 = tail call i32 (...) @f()
%48 = icmp slt i32 %46, %47
%49 = add nuw nsw i32 %46, 1
br i1 %48, label %45, label %50
50: ; preds = %45
tail call void @llvm.stackrestore(i8* %44)
%51 = tail call i32 (...) @f()
%52 = tail call i8* @llvm.stacksave()
br label %53
53: ; preds = %53, %50
%54 = phi i32 [ 0, %50 ], [ %57, %53 ]
%55 = tail call i32 (...) @f()
%56 = icmp slt i32 %54, %55
%57 = add nuw nsw i32 %54, 1
br i1 %56, label %53, label %58
58: ; preds = %53
tail call void @llvm.stackrestore(i8* %52)
%59 = tail call i32 (...) @f()
%60 = tail call i8* @llvm.stacksave()
br label %61
61: ; preds = %61, %58
%62 = phi i32 [ 0, %58 ], [ %65, %61 ]
%63 = tail call i32 (...) @f()
%64 = icmp slt i32 %62, %63
%65 = add nuw nsw i32 %62, 1
br i1 %64, label %61, label %66
66: ; preds = %61
tail call void @llvm.stackrestore(i8* %60)
%67 = tail call i32 (...) @f()
%68 = tail call i8* @llvm.stacksave()
br label %69
69: ; preds = %69, %66
%70 = phi i32 [ 0, %66 ], [ %73, %69 ]
%71 = tail call i32 (...) @f()
%72 = icmp slt i32 %70, %71
%73 = add nuw nsw i32 %70, 1
br i1 %72, label %69, label %74
74: ; preds = %69
tail call void @llvm.stackrestore(i8* %68)
%75 = tail call i32 (...) @f()
%76 = tail call i8* @llvm.stacksave()
br label %77
77: ; preds = %77, %74
%78 = phi i32 [ 0, %74 ], [ %81, %77 ]
%79 = tail call i32 (...) @f()
%80 = icmp slt i32 %78, %79
%81 = add nuw nsw i32 %78, 1
br i1 %80, label %77, label %82
82: ; preds = %77
tail call void @llvm.stackrestore(i8* %76)
%83 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
ret void
}