#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() {
  int i, startNum, endNum;
  int sum;
  sum = 0;
  startNum = 1;
  endNum = 1000;
  for (i = startNum; i <= endNum; i++) {
    if (i % 2 == 1) {
      sum = sum + i;
    }
  }
  printf("1+3+...+999=%d\n", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x3e8,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     1176 <main+0x66>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
jne    1163 <main+0x53>
mov    -0x14(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    1168 <main+0x58>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    113a <main+0x2a>
mov    -0x14(%rbp),%esi
lea    0xe80(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movdqa 0xee7(%rip),%xmm3
pxor   %xmm8,%xmm8
mov    $0x3e0,%eax
movdqa 0xee4(%rip),%xmm10
movdqa 0xeeb(%rip),%xmm12
movdqa 0xef2(%rip),%xmm9
movdqa 0xef9(%rip),%xmm11
movdqa 0xf01(%rip),%xmm6
pxor   %xmm1,%xmm1
pxor   %xmm5,%xmm5
nopw   0x0(%rax,%rax,1)
movdqa %xmm3,%xmm0
paddd  %xmm10,%xmm0
movdqa %xmm3,%xmm7
pand   %xmm12,%xmm7
pcmpeqd %xmm8,%xmm7
movdqa %xmm7,%xmm2
pandn  %xmm3,%xmm2
paddd  %xmm1,%xmm2
movdqa %xmm7,%xmm4
pandn  %xmm0,%xmm4
paddd  %xmm5,%xmm4
test   %eax,%eax
je     11c6 <main+0xb6>
movdqa %xmm3,%xmm0
paddd  %xmm9,%xmm0
movdqa %xmm3,%xmm5
paddd  %xmm11,%xmm5
movdqa %xmm7,%xmm1
pandn  %xmm0,%xmm1
pandn  %xmm5,%xmm7
paddd  %xmm2,%xmm1
paddd  %xmm4,%xmm7
paddd  %xmm6,%xmm3
add    $0xfffffff0,%eax
movdqa %xmm7,%xmm5
jmp    1160 <main+0x50>
paddd  %xmm2,%xmm4
pshufd $0xee,%xmm4,%xmm0
paddd  %xmm4,%xmm0
pshufd $0x55,%xmm0,%xmm1
paddd  %xmm0,%xmm1
movd   %xmm1,%esi
lea    0xe79(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [16 x i8] c"1+3+...+999=%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %5
store i32 1, i32* %3
store i32 1000, i32* %4
%6 = load i32, i32* %3
store i32 %6, i32* %2
br label %7
7: ; preds = %20, %0
%8 = load i32, i32* %2
%9 = load i32, i32* %4
%10 = icmp sle i32 %8, %9
br i1 %10, label %11, label %23
11: ; preds = %7
%12 = load i32, i32* %2
%13 = srem i32 %12, 2
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %19
15: ; preds = %11
%16 = load i32, i32* %5
%17 = load i32, i32* %2
%18 = add nsw i32 %16, %17
store i32 %18, i32* %5
br label %19
19: ; preds = %15, %11
br label %20
20: ; preds = %19
%21 = load i32, i32* %2
%22 = add nsw i32 %21, 1
store i32 %22, i32* %2
br label %7
23: ; preds = %7
%24 = load i32, i32* %5
%25 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %24)
ret i32 0
}

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