#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 primenumber() {
  int n, i, m = 0, k;
  printf("Enter a positive integer: ");
  scanf("%d", &n);
  for (i = 2; i <= n / 2; ++i) {
    m = n % i;
  }
  k = n;
  while (n >= 0) {
    printf("%d\n", n);
    n = n - 2;
  }
  if (m == 0) {
    printf("%d This is not a prime no.", k);
  } else {
    printf("%d This is a prime no.\n", k);
  }
}


x86 assembly (clang, -O0):
<primenumber>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x10(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed7(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x2,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jg     118a <primenumber+0x6a>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1154 <primenumber+0x34>
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     11b9 <primenumber+0x99>
mov    -0x8(%rbp),%esi
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x8(%rbp)
jmp    1190 <primenumber+0x70>
cmpl   $0x0,-0x10(%rbp)
jne    11d9 <primenumber+0xb9>
mov    -0x14(%rbp),%esi
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ea <primenumber+0xca>
mov    -0x14(%rbp),%esi
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<primenumber>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
xor    %r14d,%r14d
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xedb(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%ebx
cmp    $0x4,%ebx
jge    1160 <primenumber+0x40>
test   %ebx,%ebx
jns    116d <primenumber+0x4d>
lea    0xec4(%rip),%rdi
jmp    11af <primenumber+0x8f>
mov    %ebx,%ecx
shr    %ecx
mov    %ebx,%eax
xor    %edx,%edx
div    %ecx
mov    %edx,%r14d
lea    0xeaa(%rip),%rbp
mov    %ebx,%esi
cs nopw 0x0(%rax,%rax,1)
mov    %rbp,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0xc(%rsp),%eax
lea    -0x2(%rax),%esi
mov    %esi,0xc(%rsp)
cmp    $0x1,%eax
jg     1180 <primenumber+0x60>
test   %r14d,%r14d
lea    0xe7e(%rip),%rax
lea    0xe92(%rip),%rdi
cmove  %rax,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [27 x i8] c"Enter a positive integer: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@.str.3 = [27 x i8] c"%d This is not a prime no.\00"
@.str.4 = [24 x i8] c"%d This is a prime no.\0A\00"
define i32 @primenumber() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %4
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 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* %2)
store i32 2, i32* %3
br label %8
8: ; preds = %17, %0
%9 = load i32, i32* %3
%10 = load i32, i32* %2
%11 = sdiv i32 %10, 2
%12 = icmp sle i32 %9, %11
br i1 %12, label %13, label %20
13: ; preds = %8
%14 = load i32, i32* %2
%15 = load i32, i32* %3
%16 = srem i32 %14, %15
store i32 %16, i32* %4
br label %17
17: ; preds = %13
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 1
store i32 %19, i32* %3
br label %8
20: ; preds = %8
%21 = load i32, i32* %2
store i32 %21, i32* %5
br label %22
22: ; preds = %25, %20
%23 = load i32, i32* %2
%24 = icmp sge i32 %23, 0
br i1 %24, label %25, label %30
25: ; preds = %22
%26 = load i32, i32* %2
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %26)
%28 = load i32, i32* %2
%29 = sub nsw i32 %28, 2
store i32 %29, i32* %2
br label %22
30: ; preds = %22
%31 = load i32, i32* %4
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %30
%34 = load i32, i32* %5
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %34)
br label %39
36: ; preds = %30
%37 = load i32, i32* %5
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i32 %37)
br label %39
39: ; preds = %36, %33
%40 = load i32, i32* %1
ret i32 %40
}

LLVM IR (-O2):
@.str = [27 x i8] c"Enter a positive integer: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@.str.3 = [27 x i8] c"%d This is not a prime no.\00"
@.str.4 = [24 x i8] c"%d This is a prime no.\0A\00"
define i32 @primenumber() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 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, 4
br i1 %6, label %10, label %7
7: ; preds = %0
%8 = lshr i32 %5, 1
%9 = urem i32 %5, %8
br label %12
10: ; preds = %0
%11 = icmp sgt i32 %5, -1
br i1 %11, label %12, label %23
12: ; preds = %7, %10
%13 = phi i32 [ %9, %7 ], [ 0, %10 ]
br label %14
14: ; preds = %12, %14
%15 = phi i32 [ %18, %14 ], [ %5, %12 ]
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = load i32, i32* %1
%18 = add nsw i32 %17, -2
store i32 %18, i32* %1
%19 = icmp sgt i32 %17, 1
br i1 %19, label %14, label %20
20: ; preds = %14
%21 = icmp eq i32 %13, 0
%22 = select i1 %21, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0)
br label %23
23: ; preds = %20, %10
%24 = phi i8* [ getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), %10 ], [ %22, %20 ]
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %24, i32 %5)
ret i32 undef
}