#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*/ assert(int);
void example1(void) {
  for (int i = 1; i < 10; i++) {
    int a[i];
    a[i - 1] = 0;
    assert(a[i - 1] == 0);
  }
}


x86 assembly (clang, -O0):
<example1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x1,-0x4(%rbp)
cmpl   $0xa,-0x4(%rbp)
jge    118d <example1+0x7d>
mov    -0x4(%rbp),%eax
mov    %eax,%ecx
mov    %rsp,%rax
mov    %rax,-0x10(%rbp)
lea    0xf(,%rcx,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rax
sub    %rdx,%rax
mov    %rax,%rsp
mov    %rcx,-0x18(%rbp)
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
cmpl   $0x0,(%rax,%rcx,4)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    111f <example1+0xf>
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<example1>:
push   %rbx
mov    %rsp,%rbx
mov    $0x1,%edi
call   1030 <assert@plt>
mov    %rbx,%rsp
mov    %rsp,%rbx
mov    $0x1,%edi
call   1030 <assert@plt>
mov    %rbx,%rsp
mov    %rsp,%rbx
mov    $0x1,%edi
call   1030 <assert@plt>
mov    %rbx,%rsp
mov    %rsp,%rbx
mov    $0x1,%edi
call   1030 <assert@plt>
mov    %rbx,%rsp
mov    %rsp,%rbx
mov    $0x1,%edi
call   1030 <assert@plt>
mov    %rbx,%rsp
mov    %rsp,%rbx
mov    $0x1,%edi
call   1030 <assert@plt>
mov    %rbx,%rsp
mov    %rsp,%rbx
mov    $0x1,%edi
call   1030 <assert@plt>
mov    %rbx,%rsp
mov    %rsp,%rbx
mov    $0x1,%edi
call   1030 <assert@plt>
mov    %rbx,%rsp
mov    $0x1,%edi
pop    %rbx
jmp    1030 <assert@plt>

LLVM IR (-O0):
define void @example1() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i64
store i32 1, i32* %1
br label %4
4: ; preds = %25, %0
%5 = load i32, i32* %1
%6 = icmp slt i32 %5, 10
br i1 %6, label %7, label %28
7: ; preds = %4
%8 = load i32, i32* %1
%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 = load i32, i32* %1
%13 = sub nsw i32 %12, 1
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i32, i32* %11, i64 %14
store i32 0, i32* %15
%16 = load i32, i32* %1
%17 = sub nsw i32 %16, 1
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i32, i32* %11, i64 %18
%20 = load i32, i32* %19
%21 = icmp eq i32 %20, 0
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
%24 = load i8*, i8** %2
br label %25
25: ; preds = %7
%26 = load i32, i32* %1
%27 = add nsw i32 %26, 1
store i32 %27, i32* %1
br label %4
28: ; preds = %4
ret void
}

LLVM IR (-O2):
define void @example1() {
%1 = tail call i8* @llvm.stacksave()
%2 = tail call i32 @assert(i32 1)
tail call void @llvm.stackrestore(i8* %1)
%3 = tail call i8* @llvm.stacksave()
%4 = tail call i32 @assert(i32 1)
tail call void @llvm.stackrestore(i8* %3)
%5 = tail call i8* @llvm.stacksave()
%6 = tail call i32 @assert(i32 1)
tail call void @llvm.stackrestore(i8* %5)
%7 = tail call i8* @llvm.stacksave()
%8 = tail call i32 @assert(i32 1)
tail call void @llvm.stackrestore(i8* %7)
%9 = tail call i8* @llvm.stacksave()
%10 = tail call i32 @assert(i32 1)
tail call void @llvm.stackrestore(i8* %9)
%11 = tail call i8* @llvm.stacksave()
%12 = tail call i32 @assert(i32 1)
tail call void @llvm.stackrestore(i8* %11)
%13 = tail call i8* @llvm.stacksave()
%14 = tail call i32 @assert(i32 1)
tail call void @llvm.stackrestore(i8* %13)
%15 = tail call i8* @llvm.stacksave()
%16 = tail call i32 @assert(i32 1)
tail call void @llvm.stackrestore(i8* %15)
%17 = tail call i32 @assert(i32 1)
ret void
}