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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x20(%rbp),%rdi
mov    $0x5,%esi
mov    $0x14,%edx
call   1040 <memset@plt>
movl   $0x0,-0x44(%rbp)
cmpl   $0x5,-0x44(%rbp)
jge    119f <main+0x7f>
mov    $0x0,%al
call   1030 <nd@plt>
cmp    $0x0,%rax
je     1179 <main+0x59>
movslq -0x44(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%ecx
movslq -0x44(%rbp),%rax
mov    %ecx,-0x40(%rbp,%rax,4)
jmp    118c <main+0x6c>
movslq -0x44(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%ecx
add    $0x1,%ecx
movslq -0x44(%rbp),%rax
mov    %ecx,-0x40(%rbp,%rax,4)
jmp    1191 <main+0x71>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1149 <main+0x29>
mov    -0x44(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0x40(%rbp,%rax,4),%eax
mov    %eax,-0x48(%rbp)
mov    -0x48(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
mov    %rsp,%rdi
mov    $0x5,%esi
mov    $0x14,%edx
call   1040 <memset@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>
mov    0x10(%rsp),%ecx
cmp    $0x1,%rax
adc    $0x0,%ecx
mov    %ecx,%eax
add    $0x18,%rsp
ret

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

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