#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 MINUS(int, int);
int PRIMEp(int N) {
  int output = 0;
  int cell0 = 0;
  if (N == 0)
    goto quit0;
  cell0 = 2;
  {
    int ctr1;
    for (ctr1 = (MINUS(N, 2)); ctr1 > 0; ctr1--) {
      if ((((N) % (cell0))) == 0)
        goto quit0;
      cell0 = (cell0 + 1);
    }
  }
  output = 1;
quit0:
  return output;
}


x86 assembly (clang, -O0):
<PRIMEp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1138 <PRIMEp+0x28>
jmp    118c <PRIMEp+0x7c>
movl   $0x2,-0xc(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x2,%esi
call   1030 <MINUS@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jle    1185 <PRIMEp+0x75>
mov    -0x4(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    116e <PRIMEp+0x5e>
jmp    118c <PRIMEp+0x7c>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    114f <PRIMEp+0x3f>
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PRIMEp>:
push   %rbp
push   %r14
push   %rbx
xor    %r14d,%r14d
test   %edi,%edi
je     1161 <PRIMEp+0x51>
mov    %edi,%ebp
mov    $0x2,%ebx
mov    $0x2,%esi
call   1030 <MINUS@plt>
test   %eax,%eax
jle    115b <PRIMEp+0x4b>
mov    %eax,%ecx
neg    %ecx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebp,%eax
cltd
idiv   %ebx
test   %edx,%edx
je     1161 <PRIMEp+0x51>
lea    (%rcx,%rbx,1),%eax
add    $0x1,%eax
mov    %ebx,%edx
add    $0x1,%edx
mov    %edx,%ebx
cmp    $0x2,%eax
jne    1140 <PRIMEp+0x30>
mov    $0x1,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @PRIMEp(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
%6 = load i32, i32* %2
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %1
br label %28
9: ; preds = %1
store i32 2, i32* %4
%10 = load i32, i32* %2
%11 = call i32 @MINUS(i32 %10, i32 2)
store i32 %11, i32* %5
br label %12
12: ; preds = %24, %9
%13 = load i32, i32* %5
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %27
15: ; preds = %12
%16 = load i32, i32* %2
%17 = load i32, i32* %4
%18 = srem i32 %16, %17
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %15
br label %28
21: ; preds = %15
%22 = load i32, i32* %4
%23 = add nsw i32 %22, 1
store i32 %23, i32* %4
br label %24
24: ; preds = %21
%25 = load i32, i32* %5
%26 = add nsw i32 %25, -1
store i32 %26, i32* %5
br label %12
27: ; preds = %12
store i32 1, i32* %3
br label %28
28: ; preds = %27, %20, %8
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
define i32 @PRIMEp(i32 %0) {
%2 = icmp eq i32 %0, 0
br i1 %2, label %15, label %3
3: ; preds = %1
%4 = tail call i32 @MINUS(i32 %0, i32 2)
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %15
6: ; preds = %3
%7 = add i32 %4, 1
br label %8
8: ; preds = %6, %12
%9 = phi i32 [ %13, %12 ], [ 2, %6 ]
%10 = srem i32 %0, %9
%11 = icmp eq i32 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %8
%13 = add nuw i32 %9, 1
%14 = icmp eq i32 %9, %7
br i1 %14, label %15, label %8
15: ; preds = %12, %8, %3, %1
%16 = phi i32 [ 0, %1 ], [ 1, %3 ], [ 1, %12 ], [ 0, %8 ]
ret i32 %16
}