#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 INT_MAX;
scalar_t__ is_integer(double);
int count_factors(long product) {
  register int number_of_factors;
  register long factor;
  if (product == 0)
    return INT_MAX;
  if (product < 0)
    product = -product;
  number_of_factors = 0;
  for (factor = 1; factor - 1 < product; factor++)
    number_of_factors += is_integer((double)product / (double)factor);
  return (number_of_factors);
}


x86 assembly (clang, -O0):
<count_factors>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1138 <count_factors+0x28>
mov    0x2eba(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11a7 <count_factors+0x97>
cmpq   $0x0,-0x10(%rbp)
jge    114d <count_factors+0x3d>
xor    %eax,%eax
sub    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movq   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%rax
sub    $0x1,%rax
cmp    -0x10(%rbp),%rax
jge    11a1 <count_factors+0x91>
cvtsi2sdq -0x10(%rbp),%xmm0
cvtsi2sdq -0x20(%rbp),%xmm1
divsd  %xmm1,%xmm0
call   1030 <is_integer@plt>
mov    %rax,%rcx
movslq -0x14(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    115c <count_factors+0x4c>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<count_factors>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
test   %rdi,%rdi
je     116d <count_factors+0x5d>
mov    %rdi,%r14
neg    %r14
cmovs  %rdi,%r14
cvtsi2sd %r14,%xmm0
movsd  %xmm0,0x8(%rsp)
neg    %r14
xor    %ebp,%ebp
mov    $0x1,%ebx
nopl   0x0(%rax)
xorps  %xmm1,%xmm1
cvtsi2sd %rbx,%xmm1
movsd  0x8(%rsp),%xmm0
divsd  %xmm1,%xmm0
call   1030 <is_integer@plt>
add    %eax,%ebp
lea    (%r14,%rbx,1),%rax
add    $0x1,%rax
add    $0x1,%rbx
cmp    $0x1,%rax
jne    1140 <count_factors+0x30>
jmp    1176 <count_factors+0x66>
mov    0x2e74(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@INT_MAX = global i32 0
define i32 @count_factors(i64 %0) {
%2 = alloca i32
%3 = alloca i64
%4 = alloca i32
%5 = alloca i64
store i64 %0, i64* %3
%6 = load i64, i64* %3
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = load i32, i32* @INT_MAX
store i32 %9, i32* %2
br label %38
10: ; preds = %1
%11 = load i64, i64* %3
%12 = icmp slt i64 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = load i64, i64* %3
%15 = sub nsw i64 0, %14
store i64 %15, i64* %3
br label %16
16: ; preds = %13, %10
store i32 0, i32* %4
store i64 1, i64* %5
br label %17
17: ; preds = %33, %16
%18 = load i64, i64* %5
%19 = sub nsw i64 %18, 1
%20 = load i64, i64* %3
%21 = icmp slt i64 %19, %20
br i1 %21, label %22, label %36
22: ; preds = %17
%23 = load i64, i64* %3
%24 = sitofp i64 %23 to double
%25 = load i64, i64* %5
%26 = sitofp i64 %25 to double
%27 = fdiv double %24, %26
%28 = call i64 @is_integer(double %27)
%29 = load i32, i32* %4
%30 = sext i32 %29 to i64
%31 = add nsw i64 %30, %28
%32 = trunc i64 %31 to i32
store i32 %32, i32* %4
br label %33
33: ; preds = %22
%34 = load i64, i64* %5
%35 = add nsw i64 %34, 1
store i64 %35, i64* %5
br label %17
36: ; preds = %17
%37 = load i32, i32* %4
store i32 %37, i32* %2
br label %38
38: ; preds = %36, %8
%39 = load i32, i32* %2
ret i32 %39
}

LLVM IR (-O2):
@INT_MAX = global i32 0
define i32 @count_factors(i64 %0) {
%2 = icmp eq i64 %0, 0
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = load i32, i32* @INT_MAX
br label %18
5: ; preds = %1
%6 = tail call i64 @llvm.abs.i64(i64 %0, i1 true)
%7 = sitofp i64 %6 to double
br label %8
8: ; preds = %5, %8
%9 = phi i64 [ 1, %5 ], [ %16, %8 ]
%10 = phi i32 [ 0, %5 ], [ %15, %8 ]
%11 = sitofp i64 %9 to double
%12 = fdiv double %7, %11
%13 = tail call i64 @is_integer(double %12)
%14 = trunc i64 %13 to i32
%15 = add i32 %10, %14
%16 = add nuw i64 %9, 1
%17 = icmp eq i64 %9, %6
br i1 %17, label %18, label %8
18: ; preds = %8, %3
%19 = phi i32 [ %4, %3 ], [ %15, %8 ]
ret i32 %19
}