#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 is_prime() {
  int n, i = 2;
  printf("\n Number:");
  scanf("%d", &n);
  while (n % i != 0)
    i++;
  if (i == n)
    printf(" -1");
  else
    printf(" -0");
  return 0;
}


x86 assembly (clang, -O0):
<is_prime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x2,-0x8(%rbp)
lea    0xeca(%rip),%rdi
call   1030 <printf@plt>
lea    0xec8(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
cmp    $0x0,%edx
je     1169 <is_prime+0x49>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    114b <is_prime+0x2b>
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jne    1186 <is_prime+0x66>
lea    0xe91(%rip),%rdi
call   1030 <printf@plt>
jmp    1192 <is_prime+0x72>
lea    0xe84(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_prime>:
push   %rax
lea    0xed8(%rip),%rdi
call   1030 <printf@plt>
lea    0xed6(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    $0x2,%esi
mov    0x4(%rsp),%ecx
nopw   0x0(%rax,%rax,1)
mov    %ecx,%eax
cltd
idiv   %esi
add    $0x1,%esi
test   %edx,%edx
jne    1150 <is_prime+0x30>
sub    %ecx,%esi
cmp    $0x1,%esi
lea    0xea5(%rip),%rax
lea    0xea2(%rip),%rdi
cmove  %rax,%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [10 x i8] c"\0A Number:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c" -1\00"
@.str.3 = [4 x i8] c" -0\00"
define i32 @is_prime() {
%1 = alloca i32
%2 = alloca i32
store i32 2, i32* %2
%3 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 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)
br label %5
5: ; preds = %10, %0
%6 = load i32, i32* %1
%7 = load i32, i32* %2
%8 = srem i32 %6, %7
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %5
%11 = load i32, i32* %2
%12 = add nsw i32 %11, 1
store i32 %12, i32* %2
br label %5
13: ; preds = %5
%14 = load i32, i32* %2
%15 = load i32, i32* %1
%16 = icmp eq i32 %14, %15
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %21
19: ; preds = %13
%20 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %21
21: ; preds = %19, %17
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"\0A Number:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c" -1\00"
@.str.3 = [4 x i8] c" -0\00"
define i32 @is_prime() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 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
br label %6
6: ; preds = %6, %0
%7 = phi i32 [ 2, %0 ], [ %10, %6 ]
%8 = srem i32 %5, %7
%9 = icmp eq i32 %8, 0
%10 = add nuw nsw i32 %7, 1
br i1 %9, label %11, label %6
11: ; preds = %6
%12 = icmp eq i32 %7, %5
%13 = select i1 %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0)
%14 = call i32 @printf(i8* dereferenceable(1) %13)
ret i32 0
}