#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 */
scalar_t__ isPrime(int);
int findTotalDistinctPrimeFactors(int num) {
  int pointer = 2;
  int result = 0;
  while (isPrime(pointer) && pointer <= num / 2) {
    if (num % pointer == 0) {
      result++;
    }
    pointer++;
  }
  return result;
}


x86 assembly (clang, -O0):
<findTotalDistinctPrimeFactors>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x2,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <isPrime@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0xd(%rbp)
je     1161 <findTotalDistinctPrimeFactors+0x51>
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cmp    %ecx,%eax
setle  %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    1171 <findTotalDistinctPrimeFactors+0x61>
jmp    1198 <findTotalDistinctPrimeFactors+0x88>
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
cmp    $0x0,%edx
jne    118a <findTotalDistinctPrimeFactors+0x7a>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1129 <findTotalDistinctPrimeFactors+0x19>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<findTotalDistinctPrimeFactors>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edi,%r14d
mov    $0x2,%edi
call   1030 <isPrime@plt>
xor    %r12d,%r12d
cmp    $0x4,%r14d
jl     1173 <findTotalDistinctPrimeFactors+0x63>
test   %rax,%rax
je     1173 <findTotalDistinctPrimeFactors+0x63>
mov    %r14d,%r15d
shr    $0x1f,%r15d
add    %r14d,%r15d
sar    %r15d
mov    $0x2,%ebx
xor    %r12d,%r12d
nopl   0x0(%rax,%rax,1)
mov    %ebx,%ebp
mov    %r14d,%eax
cltd
idiv   %ebx
cmp    $0x1,%edx
adc    $0x0,%r12d
lea    0x1(%rbp),%ebx
mov    %ebx,%edi
call   1030 <isPrime@plt>
cmp    %r15d,%ebp
jge    1173 <findTotalDistinctPrimeFactors+0x63>
test   %rax,%rax
jne    1150 <findTotalDistinctPrimeFactors+0x40>
mov    %r12d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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