#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*/ __CRAB_assert(int);
scalar_t__ nd();
int main() {
  int a[10];
  int i;
  for (i = 0; i < 10; i++) {
    if (nd())
      a[i] = 0;
    else
      a[i] = 5;
  }
  int res = a[i - 1];
  __CRAB_assert(res >= 0 && res <= 5);
  return res;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0xa,-0x34(%rbp)
jge    1181 <main+0x61>
mov    $0x0,%al
call   1030 <nd@plt>
cmp    $0x0,%rax
je     1162 <main+0x42>
movslq -0x34(%rbp),%rax
movl   $0x0,-0x30(%rbp,%rax,4)
jmp    116e <main+0x4e>
movslq -0x34(%rbp),%rax
movl   $0x5,-0x30(%rbp,%rax,4)
jmp    1173 <main+0x53>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1136 <main+0x16>
mov    -0x34(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0x30(%rbp,%rax,4),%eax
mov    %eax,-0x38(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x38(%rbp)
mov    %al,-0x39(%rbp)
jl     11a9 <main+0x89>
cmpl   $0x5,-0x38(%rbp)
setle  %al
mov    %al,-0x39(%rbp)
mov    -0x39(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <__CRAB_assert@plt>
mov    -0x38(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1030 <nd@plt>
xor    %eax,%eax
call   1030 <nd@plt>
xor    %eax,%eax
call   1030 <nd@plt>
xor    %eax,%eax
call   1030 <nd@plt>
xor    %eax,%eax
call   1030 <nd@plt>
xor    %eax,%eax
call   1030 <nd@plt>
xor    %eax,%eax
call   1030 <nd@plt>
xor    %eax,%eax
call   1030 <nd@plt>
xor    %eax,%eax
call   1030 <nd@plt>
xor    %eax,%eax
call   1030 <nd@plt>
xor    %ecx,%ecx
test   %rax,%rax
sete   %cl
lea    (%rcx,%rcx,4),%ebx
mov    $0x1,%edi
call   1040 <__CRAB_assert@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i32]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
br label %5
5: ; preds = %20, %0
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 10
br i1 %7, label %8, label %23
8: ; preds = %5
%9 = call i64 (...) @nd()
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %8
%12 = load i32, i32* %3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %13
store i32 0, i32* %14
br label %19
15: ; preds = %8
%16 = load i32, i32* %3
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %17
store i32 5, i32* %18
br label %19
19: ; preds = %15, %11
br label %20
20: ; preds = %19
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
br label %5
23: ; preds = %5
%24 = load i32, i32* %3
%25 = sub nsw i32 %24, 1
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %26
%28 = load i32, i32* %27
store i32 %28, i32* %4
%29 = load i32, i32* %4
%30 = icmp sge i32 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %23
%32 = load i32, i32* %4
%33 = icmp sle i32 %32, 5
br label %34
34: ; preds = %31, %23
%35 = phi i1 [ false, %23 ], [ %33, %31 ]
%36 = zext i1 %35 to i32
%37 = call i32 @__CRAB_assert(i32 %36)
%38 = load i32, i32* %4
ret i32 %38
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i64 (...) @nd()
%2 = tail call i64 (...) @nd()
%3 = tail call i64 (...) @nd()
%4 = tail call i64 (...) @nd()
%5 = tail call i64 (...) @nd()
%6 = tail call i64 (...) @nd()
%7 = tail call i64 (...) @nd()
%8 = tail call i64 (...) @nd()
%9 = tail call i64 (...) @nd()
%10 = tail call i64 (...) @nd()
%11 = icmp eq i64 %10, 0
%12 = select i1 %11, i32 5, i32 0
%13 = tail call i32 @__CRAB_assert(i32 1)
ret i32 %12
}