#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 main() {
  for (;;) {
    long long int x;
    printf("Enter your number: ");
    scanf("%lld", &x);
    if (x <= 0) {
      printf("\aError!\a\a");
      return 0;
    }
    printf("\n\n");
    long long int y;
    int z = 1;
    for (y = 2; y <= x / 2; y++) {
      if (x % y == 0) {
        printf("%lld,  ", y);
        z = 0;
      }
    }
    if (z == 1)
      printf("\aThis is a prime number.\a");
    printf("\n\n");
    int d = 1;
    printf("Do you want to continue? 1(y) 0(n).");
    scanf(" %d", &d);
    if (!d)
      break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed0(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
cmpq   $0x0,-0x10(%rbp)
jg     1174 <main+0x54>
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1262 <main+0x142>
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x1c(%rbp)
movq   $0x2,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
jg     11fa <main+0xda>
mov    -0x10(%rbp),%rax
cqto
idivq  -0x18(%rbp)
cmp    $0x0,%rdx
jne    11e4 <main+0xc4>
mov    -0x18(%rbp),%rsi
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
jmp    11e9 <main+0xc9>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1191 <main+0x71>
cmpl   $0x1,-0x1c(%rbp)
jne    1212 <main+0xf2>
lea    0xe23(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x20(%rbp)
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe30(%rip),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
cmpl   $0x0,-0x20(%rbp)
jne    1256 <main+0x136>
jmp    125b <main+0x13b>
jmp    112f <main+0xf>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xebb(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec1(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmpq   $0x0,0x8(%rsp)
jle    12bc <main+0x18c>
lea    0xefb(%rip),%rbx
lea    0xecc(%rip),%r12
lea    0xee9(%rip),%r15
lea    0x14(%rsp),%r13
lea    0xe74(%rip),%rbp
lea    0xe90(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    0x8(%rsp),%rcx
cmp    $0x4,%rcx
jl     1257 <main+0x127>
mov    %r15,%rbx
mov    $0x1,%r15d
mov    $0x1,%ebp
jmp    11e2 <main+0xb2>
nopw   0x0(%rax,%rax,1)
mov    %rcx,%rax
shr    $0x3f,%rax
add    %rcx,%rax
sar    %rax
cmp    %rax,%rbp
jge    1240 <main+0x110>
add    $0x1,%rbp
mov    %rcx,%rax
or     %rbp,%rax
shr    $0x20,%rax
je     1210 <main+0xe0>
mov    %rcx,%rax
cqto
idiv   %rbp
test   %rdx,%rdx
jne    11d0 <main+0xa0>
jmp    121b <main+0xeb>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ecx,%eax
xor    %edx,%edx
div    %ebp
test   %rdx,%rdx
jne    11d0 <main+0xa0>
xor    %r15d,%r15d
mov    %r14,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%rcx
jmp    11d0 <main+0xa0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmp    $0x1,%r15d
mov    %rbx,%r15
lea    0xe1f(%rip),%rbx
lea    0xdab(%rip),%rbp
jne    1265 <main+0x135>
lea    0xdcd(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
movl   $0x1,0x14(%rsp)
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmpl   $0x0,0x14(%rsp)
je     12ca <main+0x19a>
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xd70(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmpq   $0x0,0x8(%rsp)
jg     11a0 <main+0x70>
lea    0xd56(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Enter your number: \00"
@.str.1 = [5 x i8] c"%lld\00"
@.str.2 = [10 x i8] c"\07Error!\07\07\00"
@.str.3 = [3 x i8] c"\0A\0A\00"
@.str.4 = [8 x i8] c"%lld, \00"
@.str.5 = [26 x i8] c"\07This is a prime number.\07\00"
@.str.6 = [36 x i8] c"Do you want to continue? 1(y) 0(n).\00"
@.str.7 = [4 x i8] c" %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
br label %6
6: ; preds = %44, %0
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64* %2)
%9 = load i64, i64* %2
%10 = icmp sle i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %6
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %46
13: ; preds = %6
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %4
store i64 2, i64* %3
br label %15
15: ; preds = %29, %13
%16 = load i64, i64* %3
%17 = load i64, i64* %2
%18 = sdiv i64 %17, 2
%19 = icmp sle i64 %16, %18
br i1 %19, label %20, label %32
20: ; preds = %15
%21 = load i64, i64* %2
%22 = load i64, i64* %3
%23 = srem i64 %21, %22
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %20
%26 = load i64, i64* %3
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i64 %26)
store i32 0, i32* %4
br label %28
28: ; preds = %25, %20
br label %29
29: ; preds = %28
%30 = load i64, i64* %3
%31 = add nsw i64 %30, 1
store i64 %31, i64* %3
br label %15
32: ; preds = %15
%33 = load i32, i32* %4
%34 = icmp eq i32 %33, 1
br i1 %34, label %35, label %37
35: ; preds = %32
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
br label %37
37: ; preds = %35, %32
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %5
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0))
%40 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32* %5)
%41 = load i32, i32* %5
%42 = icmp ne i32 %41, 0
br i1 %42, label %44, label %43
43: ; preds = %37
br label %45
44: ; preds = %37
br label %6
45: ; preds = %43
store i32 0, i32* %1
br label %46
46: ; preds = %45, %11
%47 = load i32, i32* %1
ret i32 %47
}

LLVM IR (-O2):
@.str = [20 x i8] c"Enter your number: \00"
@.str.1 = [5 x i8] c"%lld\00"
@.str.2 = [10 x i8] c"\07Error!\07\07\00"
@.str.4 = [8 x i8] c"%lld, \00"
@.str.5 = [26 x i8] c"\07This is a prime number.\07\00"
@.str.6 = [36 x i8] c"Do you want to continue? 1(y) 0(n).\00"
@.str.7 = [4 x i8] c" %d\00"
@str.8 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca i32
%3 = bitcast i64* %1 to i8*
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64* %1)
%6 = load i64, i64* %1
%7 = icmp slt i64 %6, 1
br i1 %7, label %10, label %8
8: ; preds = %0
%9 = bitcast i32* %2 to i8*
br label %12
10: ; preds = %41, %0
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
br label %46
12: ; preds = %8, %41
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.8, i64 0, i64 0))
%14 = load i64, i64* %1
%15 = icmp slt i64 %14, 4
br i1 %15, label %33, label %16
16: ; preds = %12, %25
%17 = phi i64 [ %26, %25 ], [ %14, %12 ]
%18 = phi i32 [ %27, %25 ], [ 1, %12 ]
%19 = phi i64 [ %28, %25 ], [ 2, %12 ]
%20 = srem i64 %17, %19
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %16
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i64 %19)
%24 = load i64, i64* %1
br label %25
25: ; preds = %16, %22
%26 = phi i64 [ %24, %22 ], [ %17, %16 ]
%27 = phi i32 [ 0, %22 ], [ %18, %16 ]
%28 = add nuw nsw i64 %19, 1
%29 = sdiv i64 %26, 2
%30 = icmp slt i64 %19, %29
br i1 %30, label %16, label %31
31: ; preds = %25
%32 = icmp eq i32 %27, 1
br i1 %32, label %33, label %35
33: ; preds = %12, %31
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
br label %35
35: ; preds = %33, %31
%36 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.8, i64 0, i64 0))
store i32 1, i32* %2
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0))
%38 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32* %2)
%39 = load i32, i32* %2
%40 = icmp eq i32 %39, 0
br i1 %40, label %46, label %41
41: ; preds = %35
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%43 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64* %1)
%44 = load i64, i64* %1
%45 = icmp slt i64 %44, 1
br i1 %45, label %10, label %12
46: ; preds = %35, %10
ret i32 0
}