#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 number, counter = 2;
  printf("Number:");
  scanf("%d", &number);
  if (number <= 1) {
    printf(" -1");
  } else {
    do {
      counter++;
    } while (number % counter != 0);
    if (counter == number)
      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    0xec6(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1,-0x4(%rbp)
jg     1166 <is_prime+0x46>
lea    0xeaf(%rip),%rdi
call   1030 <printf@plt>
jmp    11b2 <is_prime+0x92>
jmp    116b <is_prime+0x4b>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
cmp    $0x0,%edx
jne    116b <is_prime+0x4b>
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jne    11a1 <is_prime+0x81>
lea    0xe76(%rip),%rdi
call   1030 <printf@plt>
jmp    11ad <is_prime+0x8d>
lea    0xe67(%rip),%rdi
call   1030 <printf@plt>
jmp    11b2 <is_prime+0x92>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_prime>:
push   %rax
lea    0xec8(%rip),%rdi
call   1040 <printf@plt>
lea    0xec4(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%ecx
cmp    $0x2,%ecx
jge    1165 <is_prime+0x35>
lea    0xead(%rip),%rdi
call   1040 <printf@plt>
jmp    1194 <is_prime+0x64>
mov    $0x3,%esi
nopw   0x0(%rax,%rax,1)
mov    %ecx,%eax
cltd
idiv   %esi
add    $0x1,%esi
test   %edx,%edx
jne    1170 <is_prime+0x40>
sub    %ecx,%esi
cmp    $0x1,%esi
jne    118a <is_prime+0x5a>
mov    $0x31,%edi
jmp    118f <is_prime+0x5f>
mov    $0x30,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
pop    %rcx
ret

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

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