#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int fnisPrime(int iX) {
  int iLimit = iX - 1;
  int i;
  if (1 == iX) {
    printf("\n1 is neither prime nor composite\n");
    exit(0);
  }
  for (i = 2; i <= iLimit; i++) {
    if (0 == iX % i) {
      return 0;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<fnisPrime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    $0x1,%eax
cmp    -0x8(%rbp),%eax
jne    1155 <fnisPrime+0x35>
lea    0xeb7(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1040 <exit@plt>
movl   $0x2,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     1198 <fnisPrime+0x78>
mov    -0x8(%rbp),%eax
cltd
idivl  -0x10(%rbp)
xor    %eax,%eax
cmp    %edx,%eax
jne    1185 <fnisPrime+0x65>
movl   $0x0,-0x4(%rbp)
jmp    119f <fnisPrime+0x7f>
jmp    118a <fnisPrime+0x6a>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    115c <fnisPrime+0x3c>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fnisPrime>:
cmp    $0x1,%edi
je     1158 <fnisPrime+0x38>
mov    $0x1,%ecx
cmp    $0x3,%edi
jl     1150 <fnisPrime+0x30>
mov    $0x2,%esi
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %edi,%eax
cltd
idiv   %esi
test   %edx,%edx
je     1153 <fnisPrime+0x33>
add    $0x1,%esi
cmp    %esi,%edi
jne    1140 <fnisPrime+0x20>
mov    %ecx,%eax
ret
xor    %ecx,%ecx
mov    %ecx,%eax
ret
push   %rax
lea    0xea0(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [35 x i8] c"\0A1 is neither prime nor composite\0A\00"
define i32 @fnisPrime(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
%6 = load i32, i32* %3
%7 = sub nsw i32 %6, 1
store i32 %7, i32* %4
%8 = load i32, i32* %3
%9 = icmp eq i32 1, %8
br i1 %9, label %10, label %13
10: ; preds = %1
%11 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @exit(i32 0)
unreachable
13: ; preds = %1
store i32 2, i32* %5
br label %14
14: ; preds = %25, %13
%15 = load i32, i32* %5
%16 = load i32, i32* %4
%17 = icmp sle i32 %15, %16
br i1 %17, label %18, label %28
18: ; preds = %14
%19 = load i32, i32* %3
%20 = load i32, i32* %5
%21 = srem i32 %19, %20
%22 = icmp eq i32 0, %21
br i1 %22, label %23, label %24
23: ; preds = %18
store i32 0, i32* %2
br label %29
24: ; preds = %18
br label %25
25: ; preds = %24
%26 = load i32, i32* %5
%27 = add nsw i32 %26, 1
store i32 %27, i32* %5
br label %14
28: ; preds = %14
store i32 1, i32* %2
br label %29
29: ; preds = %28, %23
%30 = load i32, i32* %2
ret i32 %30
}

LLVM IR (-O2):
@str = [34 x i8] c"\0A1 is neither prime nor composite\00"
define i32 @fnisPrime(i32 %0) {
%2 = icmp eq i32 %0, 1
br i1 %2, label %5, label %3
3: ; preds = %1
%4 = icmp sgt i32 %0, 2
br i1 %4, label %10, label %15
5: ; preds = %1
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 @exit(i32 0)
unreachable
8: ; preds = %10
%9 = icmp eq i32 %14, %0
br i1 %9, label %15, label %10
10: ; preds = %3, %8
%11 = phi i32 [ %14, %8 ], [ 2, %3 ]
%12 = srem i32 %0, %11
%13 = icmp eq i32 %12, 0
%14 = add nuw nsw i32 %11, 1
br i1 %13, label %15, label %8
15: ; preds = %10, %8, %3
%16 = phi i32 [ 1, %3 ], [ 1, %8 ], [ 0, %10 ]
ret i32 %16
}