#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 int *);
unsigned int *malloc(float);
scalar_t__ naturalNumber(float);
unsigned int *primes(float);
unsigned int *realloc(unsigned int *, int);
unsigned int *primeFactorization(float a) {
  int ln, l = 1, i = 1;
  unsigned int *result, *prime;
  if (a < 1)
    return NULL;
  result = malloc(a * sizeof(unsigned int));
  if (result) {
    prime = primes(a);
    ln = prime[0];
    while (a != 1) {
      if (naturalNumber((float)(a / prime[i]))) {
        a /= prime[i];
        result[l++] = prime[i];
      } else {
        i += 1;
      }
    }
    free(prime);
    result[0] = l;
    result = realloc(result, l * sizeof(unsigned int));
  }
  return result;
}


x86 assembly (clang, -O0):
<primeFactorization>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0xc(%rbp)
movl   $0x1,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
movss  0xe8d(%rip),%xmm0
ucomiss -0xc(%rbp),%xmm0
jbe    118a <primeFactorization+0x3a>
movq   $0x0,-0x8(%rbp)
jmp    128d <primeFactorization+0x13d>
movss  0xe72(%rip),%xmm0
mulss  -0xc(%rbp),%xmm0
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1285 <primeFactorization+0x135>
movss  -0xc(%rbp),%xmm0
call   1070 <primes@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
movss  -0xc(%rbp),%xmm0
movss  0xe31(%rip),%xmm1
ucomiss %xmm1,%xmm0
jne    11e3 <primeFactorization+0x93>
jp     11e3 <primeFactorization+0x93>
jmp    125c <primeFactorization+0x10c>
movss  -0xc(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cvtsi2ss %rax,%xmm1
divss  %xmm1,%xmm0
call   1060 <naturalNumber@plt>
cmp    $0x0,%rax
je     124e <primeFactorization+0xfe>
mov    -0x28(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cvtsi2ss %rax,%xmm1
movss  -0xc(%rbp),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x20(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x14(%rbp)
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
jmp    1257 <primeFactorization+0x107>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11c2 <primeFactorization+0x72>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x14(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rdi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%esi
call   1050 <realloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<primeFactorization>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
movaps %xmm0,%xmm1
movss  0xe99(%rip),%xmm0
ucomiss %xmm1,%xmm0
ja     122d <primeFactorization+0xdd>
movss  0xe8c(%rip),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm1,0xc(%rsp)
call   1040 <malloc@plt>
movss  0xc(%rsp),%xmm0
test   %rax,%rax
je     122d <primeFactorization+0xdd>
mov    %rax,%r14
call   1070 <primes@plt>
movss  0xc(%rsp),%xmm0
mov    %rax,%r15
ucomiss 0xe52(%rip),%xmm0
jne    11b6 <primeFactorization+0x66>
jnp    123c <primeFactorization+0xec>
mov    $0x1,%r12d
mov    $0x1,%ebp
jmp    11e5 <primeFactorization+0x95>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%r12d
movss  0xc(%rsp),%xmm0
ucomiss 0xe1f(%rip),%xmm0
jne    11e5 <primeFactorization+0x95>
jnp    1241 <primeFactorization+0xf1>
movss  %xmm0,0xc(%rsp)
movslq %r12d,%rbx
mov    (%r15,%rbx,4),%eax
xorps  %xmm1,%xmm1
cvtsi2ss %rax,%xmm1
divss  %xmm1,%xmm0
call   1060 <naturalNumber@plt>
test   %rax,%rax
je     11d0 <primeFactorization+0x80>
mov    (%r15,%rbx,4),%eax
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
movss  0xc(%rsp),%xmm1
divss  %xmm0,%xmm1
movslq %ebp,%rcx
add    $0x1,%ebp
mov    %eax,(%r14,%rcx,4)
movaps %xmm1,%xmm0
jmp    11da <primeFactorization+0x8a>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%ebp
mov    %r15,%rdi
call   1030 <free@plt>
mov    %ebp,(%r14)
shl    $0x2,%ebp
mov    %r14,%rdi
mov    %ebp,%esi
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <realloc@plt>

LLVM IR (-O0):
define i32* @primeFactorization(float %0) {
%2 = alloca i32*
%3 = alloca float
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32*
store float %0, float* %3
store i32 1, i32* %5
store i32 1, i32* %6
%9 = load float, float* %3
%10 = fcmp olt float %9, 1.000000e+00
br i1 %10, label %11, label %12
11: ; preds = %1
store i32* null, i32** %2
br label %75
12: ; preds = %1
%13 = load float, float* %3
%14 = fmul float %13, 4.000000e+00
%15 = call i32* @malloc(float %14)
store i32* %15, i32** %7
%16 = load i32*, i32** %7
%17 = icmp ne i32* %16, null
br i1 %17, label %18, label %73
18: ; preds = %12
%19 = load float, float* %3
%20 = call i32* @primes(float %19)
store i32* %20, i32** %8
%21 = load i32*, i32** %8
%22 = getelementptr inbounds i32, i32* %21, i64 0
%23 = load i32, i32* %22
store i32 %23, i32* %4
br label %24
24: ; preds = %60, %18
%25 = load float, float* %3
%26 = fcmp une float %25, 1.000000e+00
br i1 %26, label %27, label %61
27: ; preds = %24
%28 = load float, float* %3
%29 = load i32*, i32** %8
%30 = load i32, i32* %6
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32, i32* %29, i64 %31
%33 = load i32, i32* %32
%34 = uitofp i32 %33 to float
%35 = fdiv float %28, %34
%36 = call i64 @naturalNumber(float %35)
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %57
38: ; preds = %27
%39 = load i32*, i32** %8
%40 = load i32, i32* %6
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i32, i32* %39, i64 %41
%43 = load i32, i32* %42
%44 = uitofp i32 %43 to float
%45 = load float, float* %3
%46 = fdiv float %45, %44
store float %46, float* %3
%47 = load i32*, i32** %8
%48 = load i32, i32* %6
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i32, i32* %47, i64 %49
%51 = load i32, i32* %50
%52 = load i32*, i32** %7
%53 = load i32, i32* %5
%54 = add nsw i32 %53, 1
store i32 %54, i32* %5
%55 = sext i32 %53 to i64
%56 = getelementptr inbounds i32, i32* %52, i64 %55
store i32 %51, i32* %56
br label %60
57: ; preds = %27
%58 = load i32, i32* %6
%59 = add nsw i32 %58, 1
store i32 %59, i32* %6
br label %60
60: ; preds = %57, %38
br label %24
61: ; preds = %24
%62 = load i32*, i32** %8
%63 = call i32 @free(i32* %62)
%64 = load i32, i32* %5
%65 = load i32*, i32** %7
%66 = getelementptr inbounds i32, i32* %65, i64 0
store i32 %64, i32* %66
%67 = load i32*, i32** %7
%68 = load i32, i32* %5
%69 = sext i32 %68 to i64
%70 = mul i64 %69, 4
%71 = trunc i64 %70 to i32
%72 = call i32* @realloc(i32* %67, i32 %71)
store i32* %72, i32** %7
br label %73
73: ; preds = %61, %12
%74 = load i32*, i32** %7
store i32* %74, i32** %2
br label %75
75: ; preds = %73, %11
%76 = load i32*, i32** %2
ret i32* %76
}

LLVM IR (-O2):
define i32* @primeFactorization(float %0) {
%2 = fcmp olt float %0, 1.000000e+00
br i1 %2, label %40, label %3
3: ; preds = %1
%4 = fmul float %0, 4.000000e+00
%5 = tail call i32* @malloc(float %4)
%6 = icmp eq i32* %5, null
br i1 %6, label %40, label %7
7: ; preds = %3
%8 = tail call i32* @primes(float %0)
%9 = fcmp une float %0, 1.000000e+00
br i1 %9, label %10, label %35
10: ; preds = %7, %30
%11 = phi i32 [ %33, %30 ], [ 1, %7 ]
%12 = phi i32 [ %32, %30 ], [ 1, %7 ]
%13 = phi float [ %31, %30 ], [ %0, %7 ]
%14 = sext i32 %11 to i64
%15 = getelementptr inbounds i32, i32* %8, i64 %14
%16 = load i32, i32* %15
%17 = uitofp i32 %16 to float
%18 = fdiv float %13, %17
%19 = tail call i64 @naturalNumber(float %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %28, label %21
21: ; preds = %10
%22 = load i32, i32* %15
%23 = uitofp i32 %22 to float
%24 = fdiv float %13, %23
%25 = add nsw i32 %12, 1
%26 = sext i32 %12 to i64
%27 = getelementptr inbounds i32, i32* %5, i64 %26
store i32 %22, i32* %27
br label %30
28: ; preds = %10
%29 = add nsw i32 %11, 1
br label %30
30: ; preds = %28, %21
%31 = phi float [ %24, %21 ], [ %13, %28 ]
%32 = phi i32 [ %25, %21 ], [ %12, %28 ]
%33 = phi i32 [ %11, %21 ], [ %29, %28 ]
%34 = fcmp une float %31, 1.000000e+00
br i1 %34, label %10, label %35
35: ; preds = %30, %7
%36 = phi i32 [ 1, %7 ], [ %32, %30 ]
%37 = tail call i32 @free(i32* %8)
store i32 %36, i32* %5
%38 = shl i32 %36, 2
%39 = tail call i32* @realloc(i32* %5, i32 %38)
br label %40
40: ; preds = %3, %35, %1
%41 = phi i32* [ null, %1 ], [ %39, %35 ], [ null, %3 ]
ret i32* %41
}