#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 n = 0, i = 0, sum = 1;
  printf("Enter integer value for N: ");
  scanf("%d", &n);
  if (n > 10000)
    printf("ERROR: Value too large");
  else if (n < 0)
    printf("ERROR: negative value");
  else if (!n % 2)
    printf("ERROR: Not an odd number");
  else {
    printf("1");
    for (i = 3; i <= n; i += 2) {
      printf(" + %d", i);
      sum += i;
    }
    printf("\n=%d", sum);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf0e(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x2710,-0x8(%rbp)
jle    1182 <main+0x62>
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1235 <main+0x115>
cmpl   $0x0,-0x8(%rbp)
jge    119f <main+0x7f>
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1230 <main+0x110>
cmpl   $0x0,-0x8(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     11d1 <main+0xb1>
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    122b <main+0x10b>
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x3,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     121a <main+0xfa>
mov    -0xc(%rbp),%esi
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xc(%rbp)
jmp    11e6 <main+0xc6>
mov    -0x10(%rbp),%esi
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1230 <main+0x110>
jmp    1235 <main+0x115>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0xc(%rsp)
lea    0xeb9(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf10(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x2711,%eax
jl     1173 <main+0x43>
lea    0xeab(%rip),%rdi
jmp    11d9 <main+0xa9>
test   %eax,%eax
js     11c9 <main+0x99>
je     11d2 <main+0xa2>
mov    $0x31,%edi
call   1030 <putchar@plt>
mov    $0x1,%ebx
cmpl   $0x3,0xc(%rsp)
jl     11b7 <main+0x87>
mov    $0x3,%ebp
mov    $0x1,%ebx
lea    0xec2(%rip),%r14
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    %ebp,%ebx
add    $0x2,%ebp
cmp    0xc(%rsp),%ebp
jle    11a0 <main+0x70>
lea    0xeaa(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11e0 <main+0xb0>
lea    0xe63(%rip),%rdi
jmp    11d9 <main+0xa9>
lea    0xe70(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Enter integer value for N: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [23 x i8] c"ERROR: Value too large\00"
@.str.3 = [22 x i8] c"ERROR: negative value\00"
@.str.4 = [25 x i8] c"ERROR: Not an odd number\00"
@.str.5 = [2 x i8] c"1\00"
@.str.6 = [6 x i8] c" + %d\00"
@.str.7 = [5 x i8] c"\0A=%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 1, i32* %4
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = load i32, i32* %2
%8 = icmp sgt i32 %7, 10000
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
br label %45
11: ; preds = %0
%12 = load i32, i32* %2
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
br label %44
16: ; preds = %11
%17 = load i32, i32* %2
%18 = icmp ne i32 %17, 0
%19 = xor i1 %18, true
%20 = zext i1 %19 to i32
%21 = srem i32 %20, 2
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %16
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
br label %43
25: ; preds = %16
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32 3, i32* %3
br label %27
27: ; preds = %37, %25
%28 = load i32, i32* %3
%29 = load i32, i32* %2
%30 = icmp sle i32 %28, %29
br i1 %30, label %31, label %40
31: ; preds = %27
%32 = load i32, i32* %3
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 %32)
%34 = load i32, i32* %3
%35 = load i32, i32* %4
%36 = add nsw i32 %35, %34
store i32 %36, i32* %4
br label %37
37: ; preds = %31
%38 = load i32, i32* %3
%39 = add nsw i32 %38, 2
store i32 %39, i32* %3
br label %27
40: ; preds = %27
%41 = load i32, i32* %4
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 %41)
br label %43
43: ; preds = %40, %23
br label %44
44: ; preds = %43, %14
br label %45
45: ; preds = %44, %9
ret i32 0
}

LLVM IR (-O2):
@.str = [28 x i8] c"Enter integer value for N: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [23 x i8] c"ERROR: Value too large\00"
@.str.3 = [22 x i8] c"ERROR: negative value\00"
@.str.4 = [25 x i8] c"ERROR: Not an odd number\00"
@.str.6 = [6 x i8] c" + %d\00"
@.str.7 = [5 x i8] c"\0A=%d\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 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 sgt i32 %5, 10000
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
br label %32
9: ; preds = %0
%10 = icmp slt i32 %5, 0
br i1 %10, label %11, label %13
11: ; preds = %9
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
br label %32
13: ; preds = %9
%14 = icmp eq i32 %5, 0
br i1 %14, label %15, label %17
15: ; preds = %13
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
br label %32
17: ; preds = %13
%18 = call i32 @putchar(i32 49)
%19 = load i32, i32* %1
%20 = icmp slt i32 %19, 3
br i1 %20, label %29, label %21
21: ; preds = %17, %21
%22 = phi i32 [ %25, %21 ], [ 1, %17 ]
%23 = phi i32 [ %26, %21 ], [ 3, %17 ]
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 %23)
%25 = add nuw nsw i32 %22, %23
%26 = add nuw nsw i32 %23, 2
%27 = load i32, i32* %1
%28 = icmp sgt i32 %26, %27
br i1 %28, label %29, label %21
29: ; preds = %21, %17
%30 = phi i32 [ 1, %17 ], [ %25, %21 ]
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 %30)
br label %32
32: ; preds = %11, %29, %15, %7
ret i32 0
}