#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 is_prime(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int n, res;
  printf("\n input number:");
  scanf("%d", &n);
  if (n <= 0)
    res = -1;
  else {
    if (n == 1)
      res = 1;
    else
      res = is_prime(n);
  }
  printf("\n %d", res);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebe(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jg     1173 <main+0x43>
movl   $0xffffffff,-0xc(%rbp)
jmp    1199 <main+0x69>
cmpl   $0x1,-0x8(%rbp)
jne    1189 <main+0x59>
movl   $0x1,-0xc(%rbp)
jmp    1194 <main+0x64>
mov    -0x8(%rbp),%edi
call   1040 <is_prime@plt>
mov    %eax,-0xc(%rbp)
jmp    1199 <main+0x69>
mov    -0xc(%rbp),%esi
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xec8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xecc(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%edi
test   %edi,%edi
jle    116b <main+0x3b>
mov    $0x1,%esi
cmp    $0x1,%edi
je     1170 <main+0x40>
call   1040 <is_prime@plt>
mov    %eax,%esi
jmp    1170 <main+0x40>
mov    $0xffffffff,%esi
lea    0xe99(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [16 x i8] c"\0A input number:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [5 x i8] c"\0A %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%6 = load i32, i32* %2
%7 = icmp sle i32 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %0
store i32 -1, i32* %3
br label %17
9: ; preds = %0
%10 = load i32, i32* %2
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %13
12: ; preds = %9
store i32 1, i32* %3
br label %16
13: ; preds = %9
%14 = load i32, i32* %2
%15 = call i32 @is_prime(i32 %14)
store i32 %15, i32* %3
br label %16
16: ; preds = %13, %12
br label %17
17: ; preds = %16, %8
%18 = load i32, i32* %3
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %18)
ret i32 0
}

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