#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*/ free(unsigned long *);
unsigned long *malloc(int);
int /*<<< orphan*/ printf(char *, unsigned long, unsigned long);
scalar_t__ sqrt(unsigned long);
long factorValue(unsigned long valueToFactor, unsigned long **sFactors,
                 unsigned long **tFactors) {
  unsigned long *sTemp =
      malloc(sizeof(long) * (unsigned long)sqrt(valueToFactor));
  unsigned long *tTemp =
      malloc(sizeof(long) * (unsigned long)sqrt(valueToFactor));
  unsigned long nextValue = 1;
  unsigned long factorsFound = 0;
  while (nextValue < (long)sqrt(valueToFactor) + 1) {
    if (valueToFactor % nextValue == 0) {
      sTemp[factorsFound] = nextValue;
      tTemp[factorsFound] = valueToFactor / nextValue;
      factorsFound++;
    }
    nextValue++;
  }
  printf("Found %ld-Factors Allocating %ld-longs for the following factors\n",
         factorsFound, factorsFound);
  unsigned long *sTrimmedFactors = malloc(sizeof(long) * factorsFound);
  unsigned long *tTrimmedFactors = malloc(sizeof(long) * factorsFound);
  for (long a = 0; a < factorsFound; ++a) {
    sTrimmedFactors[a] = sTemp[a];
    tTrimmedFactors[a] = tTemp[a];
    printf("s=%lu : t=%lu\n", sTrimmedFactors[a], tTrimmedFactors[a]);
  }
  *sFactors = sTrimmedFactors;
  *tFactors = tTrimmedFactors;
  free(sTemp);
  free(tTemp);
  return factorsFound;
}


x86 assembly (clang, -O0):
<factorValue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <sqrt@plt>
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <sqrt@plt>
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
movq   $0x1,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <sqrt@plt>
mov    %rax,%rcx
mov    -0x58(%rbp),%rax
add    $0x1,%rcx
cmp    %rcx,%rax
jae    1217 <factorValue+0xd7>
mov    -0x8(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x30(%rbp)
cmp    $0x0,%rdx
jne    1206 <factorValue+0xc6>
mov    -0x30(%rbp),%rdx
mov    -0x20(%rbp),%rax
mov    -0x38(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x8(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x30(%rbp)
mov    %rax,%rdx
mov    -0x28(%rbp),%rax
mov    -0x38(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1194 <factorValue+0x54>
mov    -0x38(%rbp),%rsi
mov    -0x38(%rbp),%rdx
lea    0xdda(%rip),%rdi
call   1040 <printf@plt>
mov    -0x38(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x48(%rbp)
movq   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%rax
cmp    -0x38(%rbp),%rax
jae    12cc <factorValue+0x18c>
mov    -0x20(%rbp),%rax
mov    -0x50(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x40(%rbp),%rax
mov    -0x50(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x28(%rbp),%rax
mov    -0x50(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x48(%rbp),%rax
mov    -0x50(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x40(%rbp),%rax
mov    -0x50(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x48(%rbp),%rax
mov    -0x50(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xd8c(%rip),%rdi
call   1040 <printf@plt>
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
jmp    1259 <factorValue+0x119>
mov    -0x40(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x48(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<factorValue>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,0x10(%rsp)
mov    %rsi,0x8(%rsp)
mov    %rdi,%rbp
call   1060 <sqrt@plt>
lea    0x0(,%rax,8),%edi
call   1050 <malloc@plt>
mov    %rax,%r13
mov    %rbp,%rdi
call   1060 <sqrt@plt>
lea    0x0(,%rax,8),%edi
call   1050 <malloc@plt>
mov    %rax,%r15
mov    %rbp,%rdi
call   1060 <sqrt@plt>
add    $0xffffffffffffffff,%rax
cmp    $0xfffffffffffffffd,%rax
ja     11fa <factorValue+0xba>
mov    $0x1,%ebx
xor    %r12d,%r12d
jmp    11c5 <factorValue+0x85>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%rbx
mov    %rbp,%rdi
call   1060 <sqrt@plt>
add    $0x1,%rax
cmp    %rax,%rbx
jae    11fd <factorValue+0xbd>
mov    %rbp,%rax
or     %rbx,%rax
shr    $0x20,%rax
je     11e0 <factorValue+0xa0>
mov    %rbp,%rax
xor    %edx,%edx
div    %rbx
test   %rdx,%rdx
jne    11b0 <factorValue+0x70>
jmp    11eb <factorValue+0xab>
mov    %ebp,%eax
xor    %edx,%edx
div    %ebx
test   %rdx,%rdx
jne    11b0 <factorValue+0x70>
mov    %rbx,0x0(%r13,%r12,8)
mov    %rax,(%r15,%r12,8)
add    $0x1,%r12
jmp    11b0 <factorValue+0x70>
xor    %r12d,%r12d
lea    0xdfc(%rip),%rdi
mov    %r12,%rsi
mov    %r12,%rdx
call   1040 <printf@plt>
lea    0x0(,%r12,8),%r14d
mov    %r14d,%edi
call   1050 <malloc@plt>
mov    %rax,%rbp
mov    %r14d,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
test   %r12,%r12
je     1267 <factorValue+0x127>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x0(%r13,%rbx,8),%rsi
mov    %rsi,0x0(%rbp,%rbx,8)
mov    (%r15,%rbx,8),%rdx
mov    %rdx,(%r14,%rbx,8)
lea    0xde9(%rip),%rdi
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1240 <factorValue+0x100>
mov    0x8(%rsp),%rax
mov    %rbp,(%rax)
mov    0x10(%rsp),%rax
mov    %r14,(%rax)
mov    %r13,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r12,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [66 x i8] c"Found %ld-Factors Allocating %ld-longs for the following factors\0A\00"
@.str.1 = [15 x i8] c"s=%lu : t=%lu\0A\00"
define i64 @factorValue(i64 %0, i64** %1, i64** %2) {
%4 = alloca i64
%5 = alloca i64**
%6 = alloca i64**
%7 = alloca i64*
%8 = alloca i64*
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64*
%12 = alloca i64*
%13 = alloca i64
store i64 %0, i64* %4
store i64** %1, i64*** %5
store i64** %2, i64*** %6
%14 = load i64, i64* %4
%15 = call i64 @sqrt(i64 %14)
%16 = mul i64 8, %15
%17 = trunc i64 %16 to i32
%18 = call i64* @malloc(i32 %17)
store i64* %18, i64** %7
%19 = load i64, i64* %4
%20 = call i64 @sqrt(i64 %19)
%21 = mul i64 8, %20
%22 = trunc i64 %21 to i32
%23 = call i64* @malloc(i32 %22)
store i64* %23, i64** %8
store i64 1, i64* %9
store i64 0, i64* %10
br label %24
24: ; preds = %48, %3
%25 = load i64, i64* %9
%26 = load i64, i64* %4
%27 = call i64 @sqrt(i64 %26)
%28 = add nsw i64 %27, 1
%29 = icmp ult i64 %25, %28
br i1 %29, label %30, label %51
30: ; preds = %24
%31 = load i64, i64* %4
%32 = load i64, i64* %9
%33 = urem i64 %31, %32
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %48
35: ; preds = %30
%36 = load i64, i64* %9
%37 = load i64*, i64** %7
%38 = load i64, i64* %10
%39 = getelementptr inbounds i64, i64* %37, i64 %38
store i64 %36, i64* %39
%40 = load i64, i64* %4
%41 = load i64, i64* %9
%42 = udiv i64 %40, %41
%43 = load i64*, i64** %8
%44 = load i64, i64* %10
%45 = getelementptr inbounds i64, i64* %43, i64 %44
store i64 %42, i64* %45
%46 = load i64, i64* %10
%47 = add i64 %46, 1
store i64 %47, i64* %10
br label %48
48: ; preds = %35, %30
%49 = load i64, i64* %9
%50 = add i64 %49, 1
store i64 %50, i64* %9
br label %24
51: ; preds = %24
%52 = load i64, i64* %10
%53 = load i64, i64* %10
%54 = call i32 @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0), i64 %52, i64 %53)
%55 = load i64, i64* %10
%56 = mul i64 8, %55
%57 = trunc i64 %56 to i32
%58 = call i64* @malloc(i32 %57)
store i64* %58, i64** %11
%59 = load i64, i64* %10
%60 = mul i64 8, %59
%61 = trunc i64 %60 to i32
%62 = call i64* @malloc(i32 %61)
store i64* %62, i64** %12
store i64 0, i64* %13
br label %63
63: ; preds = %91, %51
%64 = load i64, i64* %13
%65 = load i64, i64* %10
%66 = icmp ult i64 %64, %65
br i1 %66, label %67, label %94
67: ; preds = %63
%68 = load i64*, i64** %7
%69 = load i64, i64* %13
%70 = getelementptr inbounds i64, i64* %68, i64 %69
%71 = load i64, i64* %70
%72 = load i64*, i64** %11
%73 = load i64, i64* %13
%74 = getelementptr inbounds i64, i64* %72, i64 %73
store i64 %71, i64* %74
%75 = load i64*, i64** %8
%76 = load i64, i64* %13
%77 = getelementptr inbounds i64, i64* %75, i64 %76
%78 = load i64, i64* %77
%79 = load i64*, i64** %12
%80 = load i64, i64* %13
%81 = getelementptr inbounds i64, i64* %79, i64 %80
store i64 %78, i64* %81
%82 = load i64*, i64** %11
%83 = load i64, i64* %13
%84 = getelementptr inbounds i64, i64* %82, i64 %83
%85 = load i64, i64* %84
%86 = load i64*, i64** %12
%87 = load i64, i64* %13
%88 = getelementptr inbounds i64, i64* %86, i64 %87
%89 = load i64, i64* %88
%90 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i64 %85, i64 %89)
br label %91
91: ; preds = %67
%92 = load i64, i64* %13
%93 = add nsw i64 %92, 1
store i64 %93, i64* %13
br label %63
94: ; preds = %63
%95 = load i64*, i64** %11
%96 = load i64**, i64*** %5
store i64* %95, i64** %96
%97 = load i64*, i64** %12
%98 = load i64**, i64*** %6
store i64* %97, i64** %98
%99 = load i64*, i64** %7
%100 = call i32 @free(i64* %99)
%101 = load i64*, i64** %8
%102 = call i32 @free(i64* %101)
%103 = load i64, i64* %10
ret i64 %103
}

LLVM IR (-O2):
@.str = [66 x i8] c"Found %ld-Factors Allocating %ld-longs for the following factors\0A\00"
@.str.1 = [15 x i8] c"s=%lu : t=%lu\0A\00"
define i64 @factorValue(i64 %0, i64** nocapture writeonly %1, i64** nocapture writeonly %2) {
%4 = tail call i64 @sqrt(i64 %0)
%5 = trunc i64 %4 to i32
%6 = shl i32 %5, 3
%7 = tail call i64* @malloc(i32 %6)
%8 = tail call i64 @sqrt(i64 %0)
%9 = trunc i64 %8 to i32
%10 = shl i32 %9, 3
%11 = tail call i64* @malloc(i32 %10)
%12 = tail call i64 @sqrt(i64 %0)
%13 = add i64 %12, -1
%14 = icmp ult i64 %13, -2
br i1 %14, label %15, label %31
15: ; preds = %3, %25
%16 = phi i64 [ %27, %25 ], [ 1, %3 ]
%17 = phi i64 [ %26, %25 ], [ 0, %3 ]
%18 = urem i64 %0, %16
%19 = udiv i64 %0, %16
%20 = icmp eq i64 %18, 0
br i1 %20, label %21, label %25
21: ; preds = %15
%22 = getelementptr inbounds i64, i64* %7, i64 %17
store i64 %16, i64* %22
%23 = getelementptr inbounds i64, i64* %11, i64 %17
store i64 %19, i64* %23
%24 = add i64 %17, 1
br label %25
25: ; preds = %21, %15
%26 = phi i64 [ %24, %21 ], [ %17, %15 ]
%27 = add nuw i64 %16, 1
%28 = tail call i64 @sqrt(i64 %0)
%29 = add nsw i64 %28, 1
%30 = icmp ult i64 %27, %29
br i1 %30, label %15, label %31
31: ; preds = %25, %3
%32 = phi i64 [ 0, %3 ], [ %26, %25 ]
%33 = tail call i32 @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0), i64 %32, i64 %32)
%34 = trunc i64 %32 to i32
%35 = shl i32 %34, 3
%36 = tail call i64* @malloc(i32 %35)
%37 = tail call i64* @malloc(i32 %35)
%38 = icmp eq i64 %32, 0
br i1 %38, label %39, label %42
39: ; preds = %42, %31
store i64* %36, i64** %1
store i64* %37, i64** %2
%40 = tail call i32 @free(i64* %7)
%41 = tail call i32 @free(i64* %11)
ret i64 %32
42: ; preds = %31, %42
%43 = phi i64 [ %51, %42 ], [ 0, %31 ]
%44 = getelementptr inbounds i64, i64* %7, i64 %43
%45 = load i64, i64* %44
%46 = getelementptr inbounds i64, i64* %36, i64 %43
store i64 %45, i64* %46
%47 = getelementptr inbounds i64, i64* %11, i64 %43
%48 = load i64, i64* %47
%49 = getelementptr inbounds i64, i64* %37, i64 %43
store i64 %48, i64* %49
%50 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i64 %45, i64 %48)
%51 = add nuw i64 %43, 1
%52 = icmp eq i64 %51, %32
br i1 %52, label %39, label %42
}