#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 *);
void main(void) {
  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);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec5(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,-0x4(%rbp)
jg     116c <main+0x3c>
movl   $0xffffffff,-0x8(%rbp)
jmp    1192 <main+0x62>
cmpl   $0x1,-0x4(%rbp)
jne    1182 <main+0x52>
movl   $0x1,-0x8(%rbp)
jmp    118d <main+0x5d>
mov    -0x4(%rbp),%edi
call   1040 <is_prime@plt>
mov    %eax,-0x8(%rbp)
jmp    1192 <main+0x62>
mov    -0x8(%rbp),%esi
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
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>
pop    %rax
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 void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 (i8*, ...) @printf(i8* 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 sle i32 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %0
store i32 -1, i32* %2
br label %16
8: ; preds = %0
%9 = load i32, i32* %1
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %12
11: ; preds = %8
store i32 1, i32* %2
br label %15
12: ; preds = %8
%13 = load i32, i32* %1
%14 = call i32 @is_prime(i32 %13)
store i32 %14, i32* %2
br label %15
15: ; preds = %12, %11
br label %16
16: ; preds = %15, %7
%17 = load i32, i32* %2
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %17)
ret void
}

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 void @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 void
}