#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 is_prime(int n) {
  int i = 2;
  while (n % i != 0) {
    i++;
  }
  if (i == n) {
    printf("1");
  }
  if (i != n) {
    if (n <= 0) {
      printf("-1");
    }
    if (n > 0) {
      printf("0");
    }
  }
}


x86 assembly (clang, -O0):
<is_prime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
movl   $0x2,-0xc(%rbp)
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
je     1140 <is_prime+0x30>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1122 <is_prime+0x12>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    1158 <is_prime+0x48>
lea    0xeae(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
je     1195 <is_prime+0x85>
cmpl   $0x0,-0x8(%rbp)
jg     117a <is_prime+0x6a>
lea    0xe8b(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
jle    1190 <is_prime+0x80>
lea    0xe78(%rip),%rdi
call   1030 <printf@plt>
jmp    1195 <is_prime+0x85>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_prime>:
mov    $0x2,%ecx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %edi,%eax
cltd
idiv   %ecx
add    $0x1,%ecx
test   %edx,%edx
jne    1130 <is_prime+0x10>
push   %rax
sub    %edi,%ecx
cmp    $0x1,%ecx
jne    114b <is_prime+0x2b>
mov    $0x31,%edi
jmp    1154 <is_prime+0x34>
test   %edi,%edi
jle    115b <is_prime+0x3b>
mov    $0x30,%edi
call   1030 <putchar@plt>
pop    %rcx
ret
lea    0xe9e(%rip),%rdi
call   1040 <printf@plt>
pop    %rcx
ret

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

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