#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;
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int is_integer(double const);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ stdout;
int enum_factors(long *factors, long product) {
  register int number_of_factors;
  register double factor, product_f;
  if (product < 0)
    product = -product;
  product_f = (double)product;
  putchar('{');
  if (product == 0)
    printf(" ... infinitely many ... ");
  for (factor = 1., number_of_factors = 0;
       factor <= product_f && number_of_factors < INT_MAX;
       factor += 1., number_of_factors++) {
    const double ratio = product_f / factor;
    const int whole_number = is_integer(ratio);
    if (whole_number == 0)
      continue;
    if (number_of_factors > 0)
      fputs(", ", stdout);
    factors[number_of_factors] = (long)ratio;
    if (product != 0)
      printf("%ld", factors[number_of_factors]);
  }
  putchar('}');
  putchar('\n');
  return (number_of_factors);
}


x86 assembly (clang, -O0):
<enum_factors>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jge    1165 <enum_factors+0x25>
xor    %eax,%eax
sub    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
cvtsi2sdq -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    $0x7b,%edi
call   1030 <putchar@plt>
cmpq   $0x0,-0x10(%rbp)
jne    1193 <enum_factors+0x53>
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movsd  0xe65(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
xor    %eax,%eax
ucomisd %xmm1,%xmm0
mov    %al,-0x35(%rbp)
jb     11d2 <enum_factors+0x92>
mov    -0x14(%rbp),%eax
mov    0x2e1e(%rip),%rcx
cmp    (%rcx),%eax
setl   %al
mov    %al,-0x35(%rbp)
mov    -0x35(%rbp),%al
test   $0x1,%al
jne    11e2 <enum_factors+0xa2>
jmp    1288 <enum_factors+0x148>
movsd  -0x28(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1040 <is_integer@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jne    120d <enum_factors+0xcd>
jmp    1268 <enum_factors+0x128>
cmpl   $0x0,-0x14(%rbp)
jle    122c <enum_factors+0xec>
mov    0x2dba(%rip),%rax
mov    (%rax),%esi
lea    0xdfb(%rip),%rdi
call   1060 <fputs@plt>
cvttsd2si -0x30(%rbp),%rdx
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
cmpq   $0x0,-0x10(%rbp)
je     1263 <enum_factors+0x123>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xdc9(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1268 <enum_factors+0x128>
movsd  0xd90(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a7 <enum_factors+0x67>
mov    $0x7d,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x14(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<enum_factors>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rbp
neg    %rbp
cmovs  %rsi,%rbp
mov    $0x7b,%edi
call   1030 <putchar@plt>
test   %rbx,%rbx
je     1251 <enum_factors+0x111>
mov    0x2e70(%rip),%r13
cmpl   $0x0,0x0(%r13)
jle    1263 <enum_factors+0x123>
cvtsi2sd %rbp,%xmm0
movsd  %xmm0,(%rsp)
call   1040 <is_integer@plt>
test   %eax,%eax
je     11ad <enum_factors+0x6d>
cvttsd2si (%rsp),%rsi
mov    %rsi,(%r14)
lea    0xe87(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%ebx
cmp    $0x2,%rbp
jb     1265 <enum_factors+0x125>
cmpl   $0x2,0x0(%r13)
jl     1265 <enum_factors+0x125>
movsd  0xe31(%rip),%xmm1
mov    $0x1,%ebx
mov    0x2dfd(%rip),%rbp
lea    0xe48(%rip),%r15
lea    0xe44(%rip),%r12
movsd  (%rsp),%xmm0
xchg   %ax,%ax
movsd  %xmm1,0x10(%rsp)
divsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
call   1040 <is_integer@plt>
test   %eax,%eax
je     1229 <enum_factors+0xe9>
mov    0x0(%rbp),%esi
mov    %r15,%rdi
call   1060 <fputs@plt>
cvttsd2si 0x8(%rsp),%rsi
mov    %rsi,(%r14,%rbx,8)
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movsd  0x10(%rsp),%xmm1
addsd  0xdd1(%rip),%xmm1
add    $0x1,%rbx
movsd  (%rsp),%xmm0
ucomisd %xmm1,%xmm0
jb     1265 <enum_factors+0x125>
movslq 0x0(%r13),%rax
cmp    %rax,%rbx
jl     11f0 <enum_factors+0xb0>
jmp    1265 <enum_factors+0x125>
lea    0xdb8(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1265 <enum_factors+0x125>
xor    %ebx,%ebx
mov    $0x7d,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c" ... infinitely many ... \00"
@INT_MAX = global i32 0
@.str.1 = [3 x i8] c", \00"
@stdout = global i32 0
@.str.2 = [4 x i8] c"%ld\00"
define i32 @enum_factors(i64* %0, i64 %1) {
%3 = alloca i64*
%4 = alloca i64
%5 = alloca i32
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca i32
store i64* %0, i64** %3
store i64 %1, i64* %4
%10 = load i64, i64* %4
%11 = icmp slt i64 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = load i64, i64* %4
%14 = sub nsw i64 0, %13
store i64 %14, i64* %4
br label %15
15: ; preds = %12, %2
%16 = load i64, i64* %4
%17 = sitofp i64 %16 to double
store double %17, double* %7
%18 = call i32 @putchar(i8 signext 123)
%19 = load i64, i64* %4
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %15
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %23
23: ; preds = %21, %15
store double 1.000000e+00, double* %6
store i32 0, i32* %5
br label %24
24: ; preds = %66, %23
%25 = load double, double* %6
%26 = load double, double* %7
%27 = fcmp ole double %25, %26
br i1 %27, label %28, label %32
28: ; preds = %24
%29 = load i32, i32* %5
%30 = load i32, i32* @INT_MAX
%31 = icmp slt i32 %29, %30
br label %32
32: ; preds = %28, %24
%33 = phi i1 [ false, %24 ], [ %31, %28 ]
br i1 %33, label %34, label %71
34: ; preds = %32
%35 = load double, double* %7
%36 = load double, double* %6
%37 = fdiv double %35, %36
store double %37, double* %8
%38 = load double, double* %8
%39 = call i32 @is_integer(double %38)
store i32 %39, i32* %9
%40 = load i32, i32* %9
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %43
42: ; preds = %34
br label %66
43: ; preds = %34
%44 = load i32, i32* %5
%45 = icmp sgt i32 %44, 0
br i1 %45, label %46, label %49
46: ; preds = %43
%47 = load i32, i32* @stdout
%48 = call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %47)
br label %49
49: ; preds = %46, %43
%50 = load double, double* %8
%51 = fptosi double %50 to i64
%52 = load i64*, i64** %3
%53 = load i32, i32* %5
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i64, i64* %52, i64 %54
store i64 %51, i64* %55
%56 = load i64, i64* %4
%57 = icmp ne i64 %56, 0
br i1 %57, label %58, label %65
58: ; preds = %49
%59 = load i64*, i64** %3
%60 = load i32, i32* %5
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i64, i64* %59, i64 %61
%63 = load i64, i64* %62
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64 %63)
br label %65
65: ; preds = %58, %49
br label %66
66: ; preds = %65, %42
%67 = load double, double* %6
%68 = fadd double %67, 1.000000e+00
store double %68, double* %6
%69 = load i32, i32* %5
%70 = add nsw i32 %69, 1
store i32 %70, i32* %5
br label %24
71: ; preds = %32
%72 = call i32 @putchar(i8 signext 125)
%73 = call i32 @putchar(i8 signext 10)
%74 = load i32, i32* %5
ret i32 %74
}

LLVM IR (-O2):
@.str = [26 x i8] c" ... infinitely many ... \00"
@INT_MAX = global i32 0
@.str.1 = [3 x i8] c", \00"
@stdout = global i32 0
@.str.2 = [4 x i8] c"%ld\00"
define i32 @enum_factors(i64* nocapture writeonly %0, i64 %1) {
%3 = tail call i64 @llvm.abs.i64(i64 %1, i1 true)
%4 = sitofp i64 %3 to double
%5 = tail call i32 @putchar(i8 signext 123)
%6 = icmp eq i64 %1, 0
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %45
9: ; preds = %2
%10 = load i32, i32* @INT_MAX
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %45
12: ; preds = %9
%13 = tail call i32 @is_integer(double %4)
%14 = icmp eq i32 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %12
%16 = fptosi double %4 to i64
store i64 %16, i64* %0
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64 %16)
br label %18
18: ; preds = %15, %12
%19 = icmp ugt i64 %3, 1
%20 = load i32, i32* @INT_MAX
%21 = icmp sgt i32 %20, 1
%22 = select i1 %19, i1 %21, i1 false
br i1 %22, label %23, label %45
23: ; preds = %18, %35
%24 = phi i64 [ %37, %35 ], [ 1, %18 ]
%25 = phi double [ %36, %35 ], [ 2.000000e+00, %18 ]
%26 = fdiv double %4, %25
%27 = tail call i32 @is_integer(double %26)
%28 = icmp eq i32 %27, 0
br i1 %28, label %35, label %29
29: ; preds = %23
%30 = load i32, i32* @stdout
%31 = tail call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %30)
%32 = fptosi double %26 to i64
%33 = getelementptr inbounds i64, i64* %0, i64 %24
store i64 %32, i64* %33
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i64 %32)
br label %35
35: ; preds = %29, %23
%36 = fadd double %25, 1.000000e+00
%37 = add nuw nsw i64 %24, 1
%38 = fcmp ole double %36, %4
%39 = load i32, i32* @INT_MAX
%40 = sext i32 %39 to i64
%41 = icmp slt i64 %37, %40
%42 = select i1 %38, i1 %41, i1 false
br i1 %42, label %23, label %43
43: ; preds = %35
%44 = trunc i64 %37 to i32
br label %45
45: ; preds = %18, %43, %7, %9
%46 = phi i32 [ 0, %9 ], [ 0, %7 ], [ 1, %18 ], [ %44, %43 ]
%47 = tail call i32 @putchar(i8 signext 125)
%48 = tail call i32 @putchar(i8 signext 10)
ret i32 %46
}