#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 sqrt(int);
void Primes(int num) {
  int limit = sqrt(num);
  for (int factor = 2; factor < limit; factor += 1) {
    if ((num % factor) == 0) {
      printf("false");
    }
  }
  printf("true");
}


x86 assembly (clang, -O0):
<Primes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <sqrt@plt>
mov    %eax,-0x8(%rbp)
movl   $0x2,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1178 <Primes+0x58>
mov    -0x4(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    1165 <Primes+0x45>
lea    0xea0(%rip),%rdi
call   1030 <printf@plt>
jmp    116a <Primes+0x4a>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    113d <Primes+0x1d>
lea    0xe87(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Primes>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%r15d
call   1040 <sqrt@plt>
cmp    $0x3,%eax
jl     116b <Primes+0x4b>
mov    %eax,%ebp
mov    $0x2,%ebx
lea    0xebe(%rip),%r14
jmp    1157 <Primes+0x37>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%ebx
cmp    %ebx,%ebp
je     116b <Primes+0x4b>
mov    %r15d,%eax
cltd
idiv   %ebx
test   %edx,%edx
jne    1150 <Primes+0x30>
mov    %r14,%rdi
call   1030 <printf@plt>
jmp    1150 <Primes+0x30>
lea    0xe94(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"false\00"
@.str.1 = [5 x i8] c"true\00"
define void @Primes(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = call i32 @sqrt(i32 %5)
store i32 %6, i32* %3
store i32 2, i32* %4
br label %7
7: ; preds = %19, %1
%8 = load i32, i32* %4
%9 = load i32, i32* %3
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %22
11: ; preds = %7
%12 = load i32, i32* %2
%13 = load i32, i32* %4
%14 = srem i32 %12, %13
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %11
%17 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %18
18: ; preds = %16, %11
br label %19
19: ; preds = %18
%20 = load i32, i32* %4
%21 = add nsw i32 %20, 1
store i32 %21, i32* %4
br label %7
22: ; preds = %7
%23 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
ret void
}

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