#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 */
unsigned int sqrt(unsigned long);
unsigned int GetFactors(unsigned long number) {
  unsigned int factors = 0;
  unsigned int max = sqrt(number);
  short int offset = (number % 2 == 0 ? 1 : 2);
  for (int factor = 1; factor < max; factor += offset) {
    if (number % factor == 0) {
      factors += 2;
    }
  }
  return factors;
}


x86 assembly (clang, -O0):
<GetFactors>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <sqrt@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdx
and    $0x1,%rdx
mov    $0x2,%eax
mov    $0x1,%ecx
cmp    $0x0,%rdx
cmove  %ecx,%eax
mov    %ax,-0x12(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jae    1193 <GetFactors+0x83>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
xor    %edx,%edx
div    %rcx
cmp    $0x0,%rdx
jne    117f <GetFactors+0x6f>
mov    -0xc(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xc(%rbp)
jmp    1184 <GetFactors+0x74>
movswl -0x12(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    1153 <GetFactors+0x43>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetFactors>:
push   %rbx
mov    %rdi,%rbx
call   1030 <sqrt@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x2,%ecx
jb     116f <GetFactors+0x5f>
mov    %ebx,%esi
and    $0x1,%esi
add    $0x1,%rsi
mov    %ecx,%r8d
xor    %ecx,%ecx
mov    $0x1,%edi
jmp    115b <GetFactors+0x4b>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rax
xor    %edx,%edx
div    %rdi
lea    0x2(%rcx),%eax
test   %rdx,%rdx
cmovne %ecx,%eax
add    %rsi,%rdi
mov    %eax,%ecx
cmp    %r8,%rdi
jae    116f <GetFactors+0x5f>
mov    %rbx,%rax
or     %rdi,%rax
shr    $0x20,%rax
jne    1140 <GetFactors+0x30>
mov    %ebx,%eax
xor    %edx,%edx
div    %edi
jmp    1148 <GetFactors+0x38>
pop    %rbx
ret

LLVM IR (-O0):
define i32 @GetFactors(i64 %0) {
%2 = alloca i64
%3 = alloca i32
%4 = alloca i32
%5 = alloca i16
%6 = alloca i32
store i64 %0, i64* %2
store i32 0, i32* %3
%7 = load i64, i64* %2
%8 = call i32 @sqrt(i64 %7)
store i32 %8, i32* %4
%9 = load i64, i64* %2
%10 = urem i64 %9, 2
%11 = icmp eq i64 %10, 0
%12 = zext i1 %11 to i64
%13 = select i1 %11, i32 1, i32 2
%14 = trunc i32 %13 to i16
store i16 %14, i16* %5
store i32 1, i32* %6
br label %15
15: ; preds = %29, %1
%16 = load i32, i32* %6
%17 = load i32, i32* %4
%18 = icmp ult i32 %16, %17
br i1 %18, label %19, label %34
19: ; preds = %15
%20 = load i64, i64* %2
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = urem i64 %20, %22
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %19
%26 = load i32, i32* %3
%27 = add i32 %26, 2
store i32 %27, i32* %3
br label %28
28: ; preds = %25, %19
br label %29
29: ; preds = %28
%30 = load i16, i16* %5
%31 = sext i16 %30 to i32
%32 = load i32, i32* %6
%33 = add nsw i32 %32, %31
store i32 %33, i32* %6
br label %15
34: ; preds = %15
%35 = load i32, i32* %3
ret i32 %35
}

LLVM IR (-O2):
define i32 @GetFactors(i64 %0) {
%2 = tail call i32 @sqrt(i64 %0)
%3 = icmp ugt i32 %2, 1
br i1 %3, label %4, label %9
4: ; preds = %1
%5 = and i64 %0, 1
%6 = icmp eq i64 %5, 0
%7 = select i1 %6, i64 1, i64 2
%8 = zext i32 %2 to i64
br label %11
9: ; preds = %11, %1
%10 = phi i32 [ 0, %1 ], [ %17, %11 ]
ret i32 %10
11: ; preds = %4, %11
%12 = phi i64 [ 1, %4 ], [ %18, %11 ]
%13 = phi i32 [ 0, %4 ], [ %17, %11 ]
%14 = urem i64 %0, %12
%15 = icmp eq i64 %14, 0
%16 = add i32 %13, 2
%17 = select i1 %15, i32 %16, i32 %13
%18 = add nuw nsw i64 %12, %7
%19 = icmp ult i64 %18, %8
br i1 %19, label %11, label %9
}