#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 not_prime(int num) {
  for (int i = 2; i <= sqrt(num); ++i) {
    if (num % i == 0)
      return 1;
  }
  if (num == 0)
    return 1;
  else
    return 0;
}


x86 assembly (clang, -O0):
<not_prime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
movl   $0x2,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <sqrt@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
cmp    %ecx,%eax
jg     116c <not_prime+0x5c>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    1159 <not_prime+0x49>
movl   $0x1,-0x4(%rbp)
jmp    1189 <not_prime+0x79>
jmp    115e <not_prime+0x4e>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1122 <not_prime+0x12>
cmpl   $0x0,-0x8(%rbp)
jne    1182 <not_prime+0x72>
movl   $0x1,-0x4(%rbp)
jmp    1189 <not_prime+0x79>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<not_prime>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%r14d
call   1030 <sqrt@plt>
cmp    $0x2,%eax
jge    1125 <not_prime+0x15>
xor    %ebx,%ebx
jmp    114c <not_prime+0x3c>
mov    $0x1,%ebp
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebp
mov    %r14d,%eax
cltd
idiv   %ebp
test   %edx,%edx
sete   %bl
je     114c <not_prime+0x3c>
mov    %r14d,%edi
call   1030 <sqrt@plt>
cmp    %eax,%ebp
jl     1130 <not_prime+0x20>
test   %r14d,%r14d
sete   %al
or     %bl,%al
movzbl %al,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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