#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*/ abort();
int /*<<< orphan*/ check_vect();
int /*<<< orphan*/ foo(int *);
int main(void) {
  int i, j;
  int sum;
  int a[40];
  check_vect();
  for (i = 0; i < 40; i++)
    a[i] = i;
  foo(a);
  for (i = 0; i < 40; i++) {
    sum = 0;
    for (j = 0; j < 40; j++)
      sum += j;
    if (a[i] != sum)
      abort();
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <check_vect@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x28,-0x8(%rbp)
jge    1176 <main+0x46>
mov    -0x8(%rbp),%ecx
movslq -0x8(%rbp),%rax
mov    %ecx,-0xb0(%rbp,%rax,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1150 <main+0x20>
lea    -0xb0(%rbp),%rdi
call   1050 <foo@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x28,-0x8(%rbp)
jge    11f0 <main+0xc0>
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x28,-0xc(%rbp)
jge    11c2 <main+0x92>
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11a1 <main+0x71>
movslq -0x8(%rbp),%rax
mov    -0xb0(%rbp,%rax,4),%eax
cmp    -0x10(%rbp),%eax
je     11dd <main+0xad>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    11e2 <main+0xb2>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1189 <main+0x59>
xor    %eax,%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0xa8,%rsp
xor    %eax,%eax
call   1040 <check_vect@plt>
movaps 0xebb(%rip),%xmm0
movaps %xmm0,(%rsp)
movaps 0xec0(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xec4(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xec8(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xecc(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xed0(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xed4(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xed8(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xedc(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
movaps 0xedd(%rip),%xmm0
movaps %xmm0,0x90(%rsp)
mov    %rsp,%rdi
call   1050 <foo@plt>
mov    $0x4,%eax
nopl   0x0(%rax,%rax,1)
cmpl   $0x30c,-0x10(%rsp,%rax,4)
jne    1215 <main+0xe5>
cmpl   $0x30c,-0xc(%rsp,%rax,4)
jne    1215 <main+0xe5>
cmpl   $0x30c,-0x8(%rsp,%rax,4)
jne    1215 <main+0xe5>
cmpl   $0x30c,-0x4(%rsp,%rax,4)
jne    1215 <main+0xe5>
cmpl   $0x30c,(%rsp,%rax,4)
jne    1215 <main+0xe5>
add    $0x5,%rax
cmp    $0x2c,%rax
jne    11d0 <main+0xa0>
xor    %eax,%eax
add    $0xa8,%rsp
ret
xor    %eax,%eax
call   1030 <abort@plt>

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

LLVM IR (-O2):
define i32 @main() {
%1 = alloca [40 x i32]
%2 = bitcast [40 x i32]* %1 to i8*
%3 = tail call i32 (...) @check_vect()
%4 = getelementptr inbounds [40 x i32], [40 x i32]* %1, i64 0, i64 0
%5 = bitcast [40 x i32]* %1 to <4 x i32>*
store <4 x i32> <i32 0, i32 1, i32 2, i32 3>, <4 x i32>* %5
%6 = getelementptr inbounds [40 x i32], [40 x i32]* %1, i64 0, i64 4
%7 = bitcast i32* %6 to <4 x i32>*
store <4 x i32> <i32 4, i32 5, i32 6, i32 7>, <4 x i32>* %7
%8 = getelementptr inbounds [40 x i32], [40 x i32]* %1, i64 0, i64 8
%9 = bitcast i32* %8 to <4 x i32>*
store <4 x i32> <i32 8, i32 9, i32 10, i32 11>, <4 x i32>* %9
%10 = getelementptr inbounds [40 x i32], [40 x i32]* %1, i64 0, i64 12
%11 = bitcast i32* %10 to <4 x i32>*
store <4 x i32> <i32 12, i32 13, i32 14, i32 15>, <4 x i32>* %11
%12 = getelementptr inbounds [40 x i32], [40 x i32]* %1, i64 0, i64 16
%13 = bitcast i32* %12 to <4 x i32>*
store <4 x i32> <i32 16, i32 17, i32 18, i32 19>, <4 x i32>* %13
%14 = getelementptr inbounds [40 x i32], [40 x i32]* %1, i64 0, i64 20
%15 = bitcast i32* %14 to <4 x i32>*
store <4 x i32> <i32 20, i32 21, i32 22, i32 23>, <4 x i32>* %15
%16 = getelementptr inbounds [40 x i32], [40 x i32]* %1, i64 0, i64 24
%17 = bitcast i32* %16 to <4 x i32>*
store <4 x i32> <i32 24, i32 25, i32 26, i32 27>, <4 x i32>* %17
%18 = getelementptr inbounds [40 x i32], [40 x i32]* %1, i64 0, i64 28
%19 = bitcast i32* %18 to <4 x i32>*
store <4 x i32> <i32 28, i32 29, i32 30, i32 31>, <4 x i32>* %19
%20 = getelementptr inbounds [40 x i32], [40 x i32]* %1, i64 0, i64 32
%21 = bitcast i32* %20 to <4 x i32>*
store <4 x i32> <i32 32, i32 33, i32 34, i32 35>, <4 x i32>* %21
%22 = getelementptr inbounds [40 x i32], [40 x i32]* %1, i64 0, i64 36
%23 = bitcast i32* %22 to <4 x i32>*
store <4 x i32> <i32 36, i32 37, i32 38, i32 39>, <4 x i32>* %23
%24 = call i32 @foo(i32* %4)
br label %48
25: ; preds = %48
%26 = add nuw nsw i64 %49, 1
%27 = getelementptr inbounds [40 x i32], [40 x i32]* %1, i64 0, i64 %26
%28 = load i32, i32* %27
%29 = icmp eq i32 %28, 780
br i1 %29, label %30, label %53
30: ; preds = %25
%31 = add nuw nsw i64 %49, 2
%32 = getelementptr inbounds [40 x i32], [40 x i32]* %1, i64 0, i64 %31
%33 = load i32, i32* %32
%34 = icmp eq i32 %33, 780
br i1 %34, label %35, label %53
35: ; preds = %30
%36 = add nuw nsw i64 %49, 3
%37 = getelementptr inbounds [40 x i32], [40 x i32]* %1, i64 0, i64 %36
%38 = load i32, i32* %37
%39 = icmp eq i32 %38, 780
br i1 %39, label %40, label %53
40: ; preds = %35
%41 = add nuw nsw i64 %49, 4
%42 = getelementptr inbounds [40 x i32], [40 x i32]* %1, i64 0, i64 %41
%43 = load i32, i32* %42
%44 = icmp eq i32 %43, 780
br i1 %44, label %45, label %53
45: ; preds = %40
%46 = add nuw nsw i64 %49, 5
%47 = icmp eq i64 %46, 40
br i1 %47, label %55, label %48
48: ; preds = %45, %0
%49 = phi i64 [ 0, %0 ], [ %46, %45 ]
%50 = getelementptr inbounds [40 x i32], [40 x i32]* %1, i64 0, i64 %49
%51 = load i32, i32* %50
%52 = icmp eq i32 %51, 780
br i1 %52, label %25, label %53
53: ; preds = %40, %35, %30, %25, %48
%54 = call i32 (...) @abort()
unreachable
55: ; preds = %45
ret i32 0
}