#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_s(char *, int *);
int /*<<< orphan*/ system(char *);
int main() {
  int number, i, sum = 0, k, flag;
  printf("Enter the number : ");
  scanf_s("%d", &number);
  for (i = 2; i <= number; i++) {
    flag = 1;
    for (k = 2; k <= i / 2; k++) {
      if (i % k == 0) {
        flag = 0;
        break;
      }
    }
    if (flag == 1) {
      sum = sum + i;
    }
  }
  printf("Sum = %d\n\n", sum);
  system("pause");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb9(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf_s@plt>
movl   $0x2,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11f8 <main+0xc8>
movl   $0x1,-0x18(%rbp)
movl   $0x2,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jg     11d2 <main+0xa2>
mov    -0xc(%rbp),%eax
cltd
idivl  -0x14(%rbp)
cmp    $0x0,%edx
jne    11bf <main+0x8f>
movl   $0x0,-0x18(%rbp)
jmp    11d2 <main+0xa2>
jmp    11c4 <main+0x94>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1185 <main+0x55>
cmpl   $0x1,-0x18(%rbp)
jne    11e5 <main+0xb5>
mov    -0x10(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    11ea <main+0xba>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    116b <main+0x3b>
mov    -0x10(%rbp),%esi
lea    0xe15(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe12(%rip),%rdi
call   1030 <system@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xec6(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeca(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf_s@plt>
mov    0x4(%rsp),%r9d
cmp    $0x2,%r9d
jge    1184 <main+0x54>
lea    0xeb1(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeac(%rip),%rdi
call   1030 <system@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    $0x2,%r8d
xor    %ebp,%ebp
mov    $0x2,%edi
jmp    11ac <main+0x7c>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    %ebx,%ebp
lea    0x1(%rdi),%eax
cmp    %r9d,%edi
mov    %eax,%edi
je     115f <main+0x2f>
mov    %edi,%ecx
shr    %ecx
cmp    $0x3,%ecx
cmovb  %r8d,%ecx
mov    %edi,%ebx
cmp    $0x4,%edi
jb     11a0 <main+0x70>
neg    %ecx
mov    $0x2,%esi
cs nopw 0x0(%rax,%rax,1)
nop
xor    %ebx,%ebx
mov    %edi,%eax
xor    %edx,%edx
div    %esi
test   %edx,%edx
je     11a0 <main+0x70>
lea    (%rcx,%rsi,1),%eax
add    $0x1,%eax
mov    %esi,%edx
add    $0x1,%edx
mov    %edx,%esi
cmp    $0x1,%eax
jne    11d0 <main+0xa0>
mov    %edi,%ebx
jmp    11a0 <main+0x70>

LLVM IR (-O0):
@.str = [20 x i8] c"Enter the number : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [11 x i8] c"Sum = %d\0A\0A\00"
@.str.3 = [6 x i8] c"pause\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf_s(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
store i32 2, i32* %3
br label %9
9: ; preds = %37, %0
%10 = load i32, i32* %3
%11 = load i32, i32* %2
%12 = icmp sle i32 %10, %11
br i1 %12, label %13, label %40
13: ; preds = %9
store i32 1, i32* %6
store i32 2, i32* %5
br label %14
14: ; preds = %26, %13
%15 = load i32, i32* %5
%16 = load i32, i32* %3
%17 = sdiv i32 %16, 2
%18 = icmp sle i32 %15, %17
br i1 %18, label %19, label %29
19: ; preds = %14
%20 = load i32, i32* %3
%21 = load i32, i32* %5
%22 = srem i32 %20, %21
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %19
store i32 0, i32* %6
br label %29
25: ; preds = %19
br label %26
26: ; preds = %25
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 1
store i32 %28, i32* %5
br label %14
29: ; preds = %24, %14
%30 = load i32, i32* %6
%31 = icmp eq i32 %30, 1
br i1 %31, label %32, label %36
32: ; preds = %29
%33 = load i32, i32* %4
%34 = load i32, i32* %3
%35 = add nsw i32 %33, %34
store i32 %35, i32* %4
br label %36
36: ; preds = %32, %29
br label %37
37: ; preds = %36
%38 = load i32, i32* %3
%39 = add nsw i32 %38, 1
store i32 %39, i32* %3
br label %9
40: ; preds = %9
%41 = load i32, i32* %4
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %41)
%43 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%44 = load i32, i32* %1
ret i32 %44
}

LLVM IR (-O2):
@.str = [20 x i8] c"Enter the number : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [11 x i8] c"Sum = %d\0A\0A\00"
@.str.3 = [6 x i8] c"pause\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf_s(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, 2
br i1 %6, label %25, label %7
7: ; preds = %0, %20
%8 = phi i32 [ %22, %20 ], [ 0, %0 ]
%9 = phi i32 [ %23, %20 ], [ 2, %0 ]
%10 = lshr i32 %9, 1
%11 = call i32 @llvm.umax.i32(i32 %10, i32 2)
%12 = icmp ult i32 %9, 4
br i1 %12, label %20, label %16
13: ; preds = %16
%14 = add nuw nsw i32 %17, 1
%15 = icmp eq i32 %17, %11
br i1 %15, label %20, label %16
16: ; preds = %7, %13
%17 = phi i32 [ %14, %13 ], [ 2, %7 ]
%18 = urem i32 %9, %17
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %13
20: ; preds = %13, %16, %7
%21 = phi i32 [ %9, %7 ], [ 0, %16 ], [ %9, %13 ]
%22 = add nuw nsw i32 %21, %8
%23 = add nuw i32 %9, 1
%24 = icmp eq i32 %9, %5
br i1 %24, label %25, label %7
25: ; preds = %20, %0
%26 = phi i32 [ 0, %0 ], [ %22, %20 ]
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %26)
%28 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}