#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) {
  int a[42];
  int i = 0;
  int top;
  while (i < 42) {
    a[i] = 0;
    assert(a[i] == 0);
    assert(a[0] == 0);
    assert(a[17] == 0);
    i++;
  }
  assert(a[0] == 0);
  assert(a[7] == 0);
  assert(a[41] == 0);
}


x86 assembly (clang, -O0):
<example1>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0xb4(%rbp)
cmpl   $0x2a,-0xb4(%rbp)
jge    1199 <example1+0x89>
movslq -0xb4(%rbp),%rax
movl   $0x0,-0xb0(%rbp,%rax,4)
movslq -0xb4(%rbp),%rax
cmpl   $0x0,-0xb0(%rbp,%rax,4)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x0,-0xb0(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x0,-0x6c(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
jmp    1125 <example1+0x15>
cmpl   $0x0,-0xb0(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x0,-0x94(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x0,-0xc(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<example1>:
push   %r14
push   %rbx
sub    $0xa8,%rsp
xor    %r14d,%r14d
nopl   (%rax)
movl   $0x0,(%rsp,%r14,4)
mov    $0x1,%edi
call   1030 <assert@plt>
xor    %ebx,%ebx
cmpl   $0x0,(%rsp)
sete   %bl
mov    %ebx,%edi
call   1030 <assert@plt>
xor    %edi,%edi
cmpl   $0x0,0x44(%rsp)
sete   %dil
call   1030 <assert@plt>
add    $0x1,%r14
cmp    $0x2a,%r14
jne    1120 <example1+0x10>
mov    %ebx,%edi
call   1030 <assert@plt>
xor    %edi,%edi
cmpl   $0x0,0x1c(%rsp)
sete   %dil
call   1030 <assert@plt>
xor    %edi,%edi
cmpl   $0x0,0xa4(%rsp)
sete   %dil
add    $0xa8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <assert@plt>

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

LLVM IR (-O2):
define void @example1() {
%1 = alloca [42 x i32]
%2 = bitcast [42 x i32]* %1 to i8*
%3 = getelementptr inbounds [42 x i32], [42 x i32]* %1, i64 0, i64 0
%4 = getelementptr inbounds [42 x i32], [42 x i32]* %1, i64 0, i64 17
br label %5
5: ; preds = %0, %5
%6 = phi i64 [ 0, %0 ], [ %17, %5 ]
%7 = getelementptr inbounds [42 x i32], [42 x i32]* %1, i64 0, i64 %6
store i32 0, i32* %7
%8 = tail call i32 @assert(i32 1)
%9 = load i32, i32* %3
%10 = icmp eq i32 %9, 0
%11 = zext i1 %10 to i32
%12 = tail call i32 @assert(i32 %11)
%13 = load i32, i32* %4
%14 = icmp eq i32 %13, 0
%15 = zext i1 %14 to i32
%16 = tail call i32 @assert(i32 %15)
%17 = add nuw nsw i64 %6, 1
%18 = icmp eq i64 %17, 42
br i1 %18, label %19, label %5
19: ; preds = %5
%20 = tail call i32 @assert(i32 %11)
%21 = getelementptr inbounds [42 x i32], [42 x i32]* %1, i64 0, i64 7
%22 = load i32, i32* %21
%23 = icmp eq i32 %22, 0
%24 = zext i1 %23 to i32
%25 = tail call i32 @assert(i32 %24)
%26 = getelementptr inbounds [42 x i32], [42 x i32]* %1, i64 0, i64 41
%27 = load i32, i32* %26
%28 = icmp eq i32 %27, 0
%29 = zext i1 %28 to i32
%30 = tail call i32 @assert(i32 %29)
ret void
}