#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*/ printf(char *, int);
int main(void) {
  int array[1024] = {1, 2, 3, 4};
  int i = 0, sum = 0;
  for (i = 0; i < 4; i++) {
    if (array[i] % 2 == 0) {
      sum += array[i];
    }
  }
  printf("%d", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1020,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x1010(%rbp),%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1040 <memset@plt>
movl   $0x1,-0x1010(%rbp)
movl   $0x2,-0x100c(%rbp)
movl   $0x3,-0x1008(%rbp)
movl   $0x4,-0x1004(%rbp)
movl   $0x0,-0x1014(%rbp)
movl   $0x0,-0x1018(%rbp)
movl   $0x0,-0x1014(%rbp)
cmpl   $0x4,-0x1014(%rbp)
jge    11ea <main+0xca>
movslq -0x1014(%rbp),%rax
mov    -0x1010(%rbp,%rax,4),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11d1 <main+0xb1>
movslq -0x1014(%rbp),%rax
mov    -0x1010(%rbp,%rax,4),%eax
add    -0x1018(%rbp),%eax
mov    %eax,-0x1018(%rbp)
jmp    11d6 <main+0xb6>
mov    -0x1014(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1014(%rbp)
jmp    118b <main+0x6b>
mov    -0x1018(%rbp),%esi
lea    0xe09(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x1020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xee8(%rip),%rdi
mov    $0x6,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1024 x i32]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = bitcast [1024 x i32]* %2 to i8*
%6 = bitcast i8* %5 to <{ i32, i32, i32, i32, [1020 x i32] }>*
%7 = getelementptr inbounds <{ i32, i32, i32, i32, [1020 x i32] }>, <{ i32, i32, i32, i32, [1020 x i32] }>* %6, i32 0, i32 0
store i32 1, i32* %7
%8 = getelementptr inbounds <{ i32, i32, i32, i32, [1020 x i32] }>, <{ i32, i32, i32, i32, [1020 x i32] }>* %6, i32 0, i32 1
store i32 2, i32* %8
%9 = getelementptr inbounds <{ i32, i32, i32, i32, [1020 x i32] }>, <{ i32, i32, i32, i32, [1020 x i32] }>* %6, i32 0, i32 2
store i32 3, i32* %9
%10 = getelementptr inbounds <{ i32, i32, i32, i32, [1020 x i32] }>, <{ i32, i32, i32, i32, [1020 x i32] }>* %6, i32 0, i32 3
store i32 4, i32* %10
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %3
br label %11
11: ; preds = %29, %0
%12 = load i32, i32* %3
%13 = icmp slt i32 %12, 4
br i1 %13, label %14, label %32
14: ; preds = %11
%15 = load i32, i32* %3
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [1024 x i32], [1024 x i32]* %2, i64 0, i64 %16
%18 = load i32, i32* %17
%19 = srem i32 %18, 2
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %28
21: ; preds = %14
%22 = load i32, i32* %3
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [1024 x i32], [1024 x i32]* %2, i64 0, i64 %23
%25 = load i32, i32* %24
%26 = load i32, i32* %4
%27 = add nsw i32 %26, %25
store i32 %27, i32* %4
br label %28
28: ; preds = %21, %14
br label %29
29: ; preds = %28
%30 = load i32, i32* %3
%31 = add nsw i32 %30, 1
store i32 %31, i32* %3
br label %11
32: ; preds = %11
%33 = load i32, i32* %4
%34 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %33)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 6)
ret i32 0
}