#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 scanf(char *, int *);
int main(void) {
  int x, z;
  if (scanf("%d", &x) != 1) {
    printf("-1");
    return 0;
  }
  z = is_prime(x);
  if (z == 1) {
    printf("1");
  }
  if (z == 0) {
    printf("0");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
cmp    $0x1,%eax
je     1170 <main+0x40>
lea    0xea4(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11ae <main+0x7e>
mov    -0x8(%rbp),%edi
call   1040 <is_prime@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jne    1191 <main+0x61>
lea    0xe78(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x0,-0xc(%rbp)
jne    11a7 <main+0x77>
lea    0xe64(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xeb8(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
cmp    $0x1,%eax
jne    1170 <main+0x30>
mov    0x4(%rsp),%edi
call   1050 <is_prime@plt>
test   %eax,%eax
je     117e <main+0x3e>
cmp    $0x1,%eax
jne    1188 <main+0x48>
mov    $0x31,%edi
jmp    1183 <main+0x43>
lea    0xe8c(%rip),%rdi
call   1040 <printf@plt>
jmp    1188 <main+0x48>
mov    $0x30,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"-1\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = icmp eq i32 %3, 1
br i1 %4, label %7, label %5
5: ; preds = %0
%6 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %14
7: ; preds = %0
%8 = load i32, i32* %1
%9 = call i32 @is_prime(i32 %8)
switch i32 %9, label %14 [
i32 1, label %10
i32 0, label %12
]
10: ; preds = %7
%11 = call i32 @putchar(i32 49)
br label %14
12: ; preds = %7
%13 = call i32 @putchar(i32 48)
br label %14
14: ; preds = %10, %12, %7, %5
ret i32 0
}