#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 sqrt(int);
int isfun(int n) {
  int m = sqrt(n), i;
  if (n < 2)
    return 0;
  for (i = 2; i <= m; i++)
    if (n % i == 0)
      return 0;
  return 1;
}


x86 assembly (clang, -O0):
<isfun>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <sqrt@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    113c <isfun+0x2c>
movl   $0x0,-0x4(%rbp)
jmp    1185 <isfun+0x75>
movl   $0x2,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     117e <isfun+0x6e>
mov    -0x8(%rbp),%eax
cltd
idivl  -0x10(%rbp)
cmp    $0x0,%edx
jne    116b <isfun+0x5b>
movl   $0x0,-0x4(%rbp)
jmp    1185 <isfun+0x75>
jmp    1170 <isfun+0x60>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1143 <isfun+0x33>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isfun>:
push   %rbx
mov    %edi,%ebx
call   1030 <sqrt@plt>
xor    %ecx,%ecx
cmp    $0x2,%ebx
jl     1150 <isfun+0x40>
mov    %eax,%esi
cmp    $0x2,%eax
jl     114b <isfun+0x3b>
neg    %esi
mov    $0x2,%edi
nopl   (%rax)
mov    %ebx,%eax
cltd
idiv   %edi
test   %edx,%edx
je     1150 <isfun+0x40>
lea    (%rsi,%rdi,1),%eax
add    $0x1,%eax
mov    %edi,%edx
add    $0x1,%edx
mov    %edx,%edi
cmp    $0x1,%eax
jne    1130 <isfun+0x20>
mov    $0x1,%ecx
mov    %ecx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @isfun(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 = call i32 @sqrt(i32 %6)
store i32 %7, i32* %4
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %11
10: ; preds = %1
store i32 0, i32* %2
br label %27
11: ; preds = %1
store i32 2, i32* %5
br label %12
12: ; preds = %23, %11
%13 = load i32, i32* %5
%14 = load i32, i32* %4
%15 = icmp sle i32 %13, %14
br i1 %15, label %16, label %26
16: ; preds = %12
%17 = load i32, i32* %3
%18 = load i32, i32* %5
%19 = srem i32 %17, %18
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %16
store i32 0, i32* %2
br label %27
22: ; preds = %16
br label %23
23: ; preds = %22
%24 = load i32, i32* %5
%25 = add nsw i32 %24, 1
store i32 %25, i32* %5
br label %12
26: ; preds = %12
store i32 1, i32* %2
br label %27
27: ; preds = %26, %21, %10
%28 = load i32, i32* %2
ret i32 %28
}

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