#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);
int /*<<< orphan*/ __VERIFIER_assume(int);
int *foo(int, int);
int nd();
int main() {
  int *a = foo(10, 5);
  int b[10];
  int i;
  for (i = 0; i < 10; i++) {
    b[i] = a[i];
  }
  int j = nd();
  __VERIFIER_assume(j >= 0 && j < 10);
  int x = b[j];
  __CRAB_assert(x == 5);
  return 42;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0xa,%edi
mov    $0x5,%esi
call   1050 <foo@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x44(%rbp)
cmpl   $0xa,-0x44(%rbp)
jge    1194 <main+0x54>
mov    -0x10(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
movslq -0x44(%rbp),%rax
mov    %ecx,-0x40(%rbp,%rax,4)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1169 <main+0x29>
mov    $0x0,%al
call   1030 <nd@plt>
mov    %eax,-0x48(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x48(%rbp)
mov    %al,-0x4d(%rbp)
jl     11b7 <main+0x77>
cmpl   $0xa,-0x48(%rbp)
setl   %al
mov    %al,-0x4d(%rbp)
mov    -0x4d(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <__VERIFIER_assume@plt>
movslq -0x48(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%eax
mov    %eax,-0x4c(%rbp)
cmpl   $0x5,-0x4c(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <__CRAB_assert@plt>
mov    $0x2a,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
mov    $0xa,%edi
mov    $0x5,%esi
call   1050 <foo@plt>
mov    0x20(%rax),%rcx
mov    %rcx,0x20(%rsp)
movups (%rax),%xmm0
movups 0x10(%rax),%xmm1
movaps %xmm1,0x10(%rsp)
movaps %xmm0,(%rsp)
xor    %eax,%eax
call   1030 <nd@plt>
mov    %eax,%ebx
xor    %edi,%edi
cmp    $0xa,%eax
setb   %dil
call   1060 <__VERIFIER_assume@plt>
movslq %ebx,%rax
xor    %edi,%edi
cmpl   $0x5,(%rsp,%rax,4)
sete   %dil
call   1040 <__CRAB_assert@plt>
mov    $0x2a,%eax
add    $0x30,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
define i32 @main() {
%1 = alloca [10 x i32]
%2 = bitcast [10 x i32]* %1 to i8*
%3 = tail call i32* @foo(i32 10, i32 5)
%4 = bitcast i32* %3 to i8*
%5 = tail call i32 (...) @nd()
%6 = icmp ult i32 %5, 10
%7 = zext i1 %6 to i32
%8 = tail call i32 @__VERIFIER_assume(i32 %7)
%9 = sext i32 %5 to i64
%10 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %9
%11 = load i32, i32* %10
%12 = icmp eq i32 %11, 5
%13 = zext i1 %12 to i32
%14 = tail call i32 @__CRAB_assert(i32 %13)
ret i32 42
}