#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 /*<<< orphan*/ scanf(char *, int *);
int main() {
  int i, n, sume = 0, sumo = 0;
  printf("Enter the number upto which the sum is to be calculated: ");
  scanf("%d", &n);
  for (i = 0; i <= n; i++) {
    if (i % 2 == 0) {
      sume = sume + i;
    } else {
      sumo = sumo + i;
    }
  }
  printf("The sum of even natural number is %d \n", sume);
  printf("The sum of odd natural number is %d", sumo);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf30(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     11ac <main+0x8c>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1190 <main+0x70>
mov    -0x10(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    1199 <main+0x79>
mov    -0x14(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    119e <main+0x7e>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1162 <main+0x42>
mov    -0x10(%rbp),%esi
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xf16(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf88(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%eax
mov    $0x0,%ebp
test   %eax,%eax
js     124f <main+0x12f>
add    $0x1,%eax
xor    %ebp,%ebp
mov    $0x0,%ebx
mov    $0x0,%ecx
cmp    $0x8,%eax
jb     1233 <main+0x113>
mov    %eax,%ecx
and    $0xfffffff8,%ecx
movdqa 0xe86(%rip),%xmm5
pxor   %xmm8,%xmm8
movdqa 0xe88(%rip),%xmm9
movdqa 0xe8f(%rip),%xmm10
movdqa 0xe96(%rip),%xmm11
mov    %ecx,%edx
pxor   %xmm1,%xmm1
pxor   %xmm0,%xmm0
pxor   %xmm3,%xmm3
pxor   %xmm6,%xmm6
nopl   0x0(%rax)
movdqa %xmm5,%xmm7
paddd  %xmm9,%xmm7
movdqa %xmm5,%xmm4
pand   %xmm10,%xmm4
pcmpeqd %xmm8,%xmm4
movdqa %xmm4,%xmm2
pand   %xmm5,%xmm2
paddd  %xmm2,%xmm3
movdqa %xmm4,%xmm2
pand   %xmm7,%xmm2
paddd  %xmm2,%xmm6
movdqa %xmm4,%xmm2
pandn  %xmm5,%xmm2
paddd  %xmm2,%xmm1
pandn  %xmm7,%xmm4
paddd  %xmm4,%xmm0
paddd  %xmm11,%xmm5
add    $0xfffffff8,%edx
jne    11b0 <main+0x90>
paddd  %xmm3,%xmm6
pshufd $0xee,%xmm6,%xmm2
paddd  %xmm6,%xmm2
pshufd $0x55,%xmm2,%xmm3
paddd  %xmm2,%xmm3
movd   %xmm3,%ebx
paddd  %xmm1,%xmm0
pshufd $0xee,%xmm0,%xmm1
paddd  %xmm0,%xmm1
pshufd $0x55,%xmm1,%xmm0
paddd  %xmm1,%xmm0
movd   %xmm0,%ebp
jmp    124b <main+0x12b>
mov    %ecx,%edx
and    $0x1,%edx
neg    %edx
mov    $0x0,%esi
cmovae %ecx,%esi
add    %esi,%ebx
and    %ecx,%edx
add    %edx,%ebp
add    $0x1,%ecx
cmp    %ecx,%eax
jne    1233 <main+0x113>
lea    0xe24(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe3b(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [58 x i8] c"Enter the number upto which the sum is to be calculated: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [39 x i8] c"The sum of even natural number is %d \0A\00"
@.str.3 = [36 x i8] c"The sum of odd natural number is %d\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* %4
store i32 0, i32* %5
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
store i32 0, i32* %2
br label %8
8: ; preds = %25, %0
%9 = load i32, i32* %2
%10 = load i32, i32* %3
%11 = icmp sle i32 %9, %10
br i1 %11, label %12, label %28
12: ; preds = %8
%13 = load i32, i32* %2
%14 = srem i32 %13, 2
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %12
%17 = load i32, i32* %4
%18 = load i32, i32* %2
%19 = add nsw i32 %17, %18
store i32 %19, i32* %4
br label %24
20: ; preds = %12
%21 = load i32, i32* %5
%22 = load i32, i32* %2
%23 = add nsw i32 %21, %22
store i32 %23, i32* %5
br label %24
24: ; preds = %20, %16
br label %25
25: ; preds = %24
%26 = load i32, i32* %2
%27 = add nsw i32 %26, 1
store i32 %27, i32* %2
br label %8
28: ; preds = %8
%29 = load i32, i32* %4
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 %29)
%31 = load i32, i32* %5
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i32 %31)
ret i32 0
}

LLVM IR (-O2):
@.str = [58 x i8] c"Enter the number upto which the sum is to be calculated: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [39 x i8] c"The sum of even natural number is %d \0A\00"
@.str.3 = [36 x i8] c"The sum of odd natural number is %d\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp slt i32 %5, 0
br i1 %6, label %57, label %7
7: ; preds = %0
%8 = add i32 %5, 1
%9 = icmp ult i32 %8, 8
br i1 %9, label %41, label %10
10: ; preds = %7
%11 = and i32 %8, -8
br label %12
12: ; preds = %12, %10
%13 = phi i32 [ 0, %10 ], [ %32, %12 ]
%14 = phi <4 x i32> [ zeroinitializer, %10 ], [ %30, %12 ]
%15 = phi <4 x i32> [ zeroinitializer, %10 ], [ %31, %12 ]
%16 = phi <4 x i32> [ zeroinitializer, %10 ], [ %26, %12 ]
%17 = phi <4 x i32> [ zeroinitializer, %10 ], [ %27, %12 ]
%18 = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %10 ], [ %33, %12 ]
%19 = add <4 x i32> %18, <i32 4, i32 4, i32 4, i32 4>
%20 = and <4 x i32> %18, <i32 1, i32 1, i32 1, i32 1>
%21 = and <4 x i32> %18, <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, %16
%27 = add <4 x i32> %25, %17
%28 = select <4 x i1> %22, <4 x i32> zeroinitializer, <4 x i32> %18
%29 = select <4 x i1> %23, <4 x i32> zeroinitializer, <4 x i32> %19
%30 = add <4 x i32> %28, %14
%31 = add <4 x i32> %29, %15
%32 = add nuw i32 %13, 8
%33 = add <4 x i32> %18, <i32 8, i32 8, i32 8, i32 8>
%34 = icmp eq i32 %32, %11
br i1 %34, label %35, label %12
35: ; preds = %12
%36 = add <4 x i32> %27, %26
%37 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %36)
%38 = add <4 x i32> %31, %30
%39 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %38)
%40 = icmp eq i32 %8, %11
br i1 %40, label %57, label %41
41: ; preds = %7, %35
%42 = phi i32 [ 0, %7 ], [ %39, %35 ]
%43 = phi i32 [ 0, %7 ], [ %37, %35 ]
%44 = phi i32 [ 0, %7 ], [ %11, %35 ]
br label %45
45: ; preds = %41, %45
%46 = phi i32 [ %54, %45 ], [ %42, %41 ]
%47 = phi i32 [ %52, %45 ], [ %43, %41 ]
%48 = phi i32 [ %55, %45 ], [ %44, %41 ]
%49 = and i32 %48, 1
%50 = icmp eq i32 %49, 0
%51 = select i1 %50, i32 %48, i32 0
%52 = add nuw nsw i32 %51, %47
%53 = select i1 %50, i32 0, i32 %48
%54 = add nuw nsw i32 %53, %46
%55 = add nuw i32 %48, 1
%56 = icmp eq i32 %48, %5
br i1 %56, label %57, label %45
57: ; preds = %45, %35, %0
%58 = phi i32 [ 0, %0 ], [ %37, %35 ], [ %52, %45 ]
%59 = phi i32 [ 0, %0 ], [ %39, %35 ], [ %54, %45 ]
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 %58)
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i32 %59)
ret i32 0
}