#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 sumOfEven() {
  int result = 0;
  printf("Now I print the sum of even number:\n\n");
  for (int i = 0; i <= 1000; i++) {
    if (i % 2 == 0) {
      result += i;
    }
  }
  return result;
}


x86 assembly (clang, -O0):
<sumOfEven>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeda(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x3e8,-0x8(%rbp)
jg     116f <sumOfEven+0x5f>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    115c <sumOfEven+0x4c>
mov    -0x8(%rbp),%eax
add    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1161 <sumOfEven+0x51>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1132 <sumOfEven+0x22>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sumOfEven>:
push   %rax
lea    0xf48(%rip),%rdi
call   1030 <puts@plt>
pxor   %xmm8,%xmm8
movdqa 0xed6(%rip),%xmm5
mov    $0x3e0,%eax
movdqa 0xed8(%rip),%xmm10
movdqa 0xee0(%rip),%xmm3
movdqa 0xee7(%rip),%xmm9
movdqa 0xeee(%rip),%xmm11
movdqa 0xef6(%rip),%xmm6
pxor   %xmm1,%xmm1
pxor   %xmm7,%xmm7
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movdqa %xmm5,%xmm0
paddd  %xmm10,%xmm0
movdqa %xmm5,%xmm4
pand   %xmm3,%xmm4
pcmpeqd %xmm8,%xmm4
movdqa %xmm4,%xmm2
pand   %xmm5,%xmm2
paddd  %xmm1,%xmm2
pand   %xmm4,%xmm0
paddd  %xmm7,%xmm0
test   %eax,%eax
je     11c9 <sumOfEven+0xb9>
movdqa %xmm5,%xmm1
paddd  %xmm9,%xmm1
movdqa %xmm5,%xmm7
paddd  %xmm11,%xmm7
pand   %xmm4,%xmm1
pand   %xmm4,%xmm7
paddd  %xmm2,%xmm1
paddd  %xmm0,%xmm7
paddd  %xmm6,%xmm5
add    $0xfffffff0,%eax
jmp    1170 <sumOfEven+0x60>
paddd  %xmm2,%xmm0
pshufd $0xee,%xmm0,%xmm1
paddd  %xmm0,%xmm1
pshufd $0x55,%xmm1,%xmm0
paddd  %xmm1,%xmm0
movd   %xmm0,%eax
add    $0x3e8,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [38 x i8] c"Now I print the sum of even number:\0A\0A\00"
define i32 @sumOfEven() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
br label %4
4: ; preds = %16, %0
%5 = load i32, i32* %2
%6 = icmp sle i32 %5, 1000
br i1 %6, label %7, label %19
7: ; preds = %4
%8 = load i32, i32* %2
%9 = srem i32 %8, 2
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %7
%12 = load i32, i32* %2
%13 = load i32, i32* %1
%14 = add nsw i32 %13, %12
store i32 %14, i32* %1
br label %15
15: ; preds = %11, %7
br label %16
16: ; preds = %15
%17 = load i32, i32* %2
%18 = add nsw i32 %17, 1
store i32 %18, i32* %2
br label %4
19: ; preds = %4
%20 = load i32, i32* %1
ret i32 %20
}

LLVM IR (-O2):
@str = [37 x i8] c"Now I print the sum of even number:\0A\00"
define i32 @sumOfEven() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
br label %2
2: ; preds = %17, %0
%3 = phi i32 [ 0, %0 ], [ %28, %17 ]
%4 = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %0 ], [ %29, %17 ]
%5 = phi <4 x i32> [ zeroinitializer, %0 ], [ %26, %17 ]
%6 = phi <4 x i32> [ zeroinitializer, %0 ], [ %27, %17 ]
%7 = add <4 x i32> %4, <i32 4, i32 4, i32 4, i32 4>
%8 = and <4 x i32> %4, <i32 1, i32 1, i32 1, i32 1>
%9 = and <4 x i32> %4, <i32 1, i32 1, i32 1, i32 1>
%10 = icmp eq <4 x i32> %8, zeroinitializer
%11 = icmp eq <4 x i32> %9, zeroinitializer
%12 = select <4 x i1> %10, <4 x i32> %4, <4 x i32> zeroinitializer
%13 = select <4 x i1> %11, <4 x i32> %7, <4 x i32> zeroinitializer
%14 = add <4 x i32> %12, %5
%15 = add <4 x i32> %13, %6
%16 = icmp eq i32 %3, 992
br i1 %16, label %30, label %17
17: ; preds = %2
%18 = add <4 x i32> %4, <i32 8, i32 8, i32 8, i32 8>
%19 = add <4 x i32> %4, <i32 12, i32 12, i32 12, i32 12>
%20 = and <4 x i32> %4, <i32 1, i32 1, i32 1, i32 1>
%21 = and <4 x i32> %4, <i32 1, i32 1, i32 1, i32 1>
%22 = icmp eq <4 x i32> %20, zeroinitializer
%23 = icmp eq <4 x i32> %21, zeroinitializer
%24 = select <4 x i1> %22, <4 x i32> %18, <4 x i32> zeroinitializer
%25 = select <4 x i1> %23, <4 x i32> %19, <4 x i32> zeroinitializer
%26 = add <4 x i32> %24, %14
%27 = add <4 x i32> %25, %15
%28 = add nuw nsw i32 %3, 16
%29 = add <4 x i32> %4, <i32 16, i32 16, i32 16, i32 16>
br label %2
30: ; preds = %2
%31 = add <4 x i32> %15, %14
%32 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %31)
%33 = add nuw nsw i32 %32, 1000
ret i32 %33
}