#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 long long kTeiler(long long);
int /*<<< orphan*/ printf(char *, ...);
void prim(long long n) {
  unsigned long long kleinster;
  if (n != 0) {
    printf("%I64d = ", n);
    if (n == 1) {
      printf("1");
    }
    while (n > 1) {
      kleinster = kTeiler(n);
      printf(" %I64d ", kleinster);
      n /= kleinster;
      if (n != 1) {
        printf("*");
      }
    }
    printf("\n\n");
  }
}


x86 assembly (clang, -O0):
<prim>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11ce <prim+0xae>
mov    -0x8(%rbp),%rsi
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpq   $0x1,-0x8(%rbp)
jne    1162 <prim+0x42>
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1167 <prim+0x47>
cmpq   $0x1,-0x8(%rbp)
jle    11c0 <prim+0xa0>
mov    -0x8(%rbp),%rdi
call   1030 <kTeiler@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rcx
mov    -0x8(%rbp),%rax
xor    %edx,%edx
div    %rcx
mov    %rax,-0x8(%rbp)
cmpq   $0x1,-0x8(%rbp)
je     11bb <prim+0x9b>
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1167 <prim+0x47>
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prim>:
test   %rdi,%rdi
je     1173 <prim+0x33>
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xea9(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
cmp    $0x1,%rbx
jne    1174 <prim+0x34>
mov    $0x31,%edi
call   1030 <putchar@plt>
jmp    11e2 <prim+0xa2>
ret
jle    11e2 <prim+0xa2>
lea    0xe8c(%rip),%r14
nopl   (%rax)
mov    %rbx,%rdi
call   1040 <kTeiler@plt>
mov    %rax,%r15
mov    %r14,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rax
or     %r15,%rax
shr    $0x20,%rax
je     11c0 <prim+0x80>
mov    %rbx,%rax
xor    %edx,%edx
div    %r15
mov    %rax,%r12
cmp    $0x1,%r12
jne    11d0 <prim+0x90>
jmp    11e2 <prim+0xa2>
nopw   0x0(%rax,%rax,1)
mov    %ebx,%eax
xor    %edx,%edx
div    %r15d
mov    %eax,%r12d
cmp    $0x1,%r12
je     11e2 <prim+0xa2>
mov    $0x2a,%edi
call   1030 <putchar@plt>
cmp    %rbx,%r15
mov    %r12,%rbx
jbe    1180 <prim+0x40>
lea    0xe28(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1050 <puts@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"%I64d = \00"
@.str.1 = [2 x i8] c"1\00"
@.str.2 = [8 x i8] c" %I64d \00"
@.str.3 = [2 x i8] c"*\00"
@.str.4 = [3 x i8] c"\0A\0A\00"
define void @prim(i64 %0) {
%2 = alloca i64
%3 = alloca i64
store i64 %0, i64* %2
%4 = load i64, i64* %2
%5 = icmp ne i64 %4, 0
br i1 %5, label %6, label %32
6: ; preds = %1
%7 = load i64, i64* %2
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i64 %7)
%9 = load i64, i64* %2
%10 = icmp eq i64 %9, 1
br i1 %10, label %11, label %13
11: ; preds = %6
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %13
13: ; preds = %11, %6
br label %14
14: ; preds = %29, %13
%15 = load i64, i64* %2
%16 = icmp sgt i64 %15, 1
br i1 %16, label %17, label %30
17: ; preds = %14
%18 = load i64, i64* %2
%19 = call i64 @kTeiler(i64 %18)
store i64 %19, i64* %3
%20 = load i64, i64* %3
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i64 %20)
%22 = load i64, i64* %3
%23 = load i64, i64* %2
%24 = udiv i64 %23, %22
store i64 %24, i64* %2
%25 = load i64, i64* %2
%26 = icmp ne i64 %25, 1
br i1 %26, label %27, label %29
27: ; preds = %17
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %29
29: ; preds = %27, %17
br label %14
30: ; preds = %14
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %32
32: ; preds = %30, %1
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"%I64d = \00"
@.str.2 = [8 x i8] c" %I64d \00"
@str = [2 x i8] c"\0A\00"
define void @prim(i64 %0) {
%2 = icmp eq i64 %0, 0
br i1 %2, label %21, label %3
3: ; preds = %1
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i64 %0)
%5 = icmp eq i64 %0, 1
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = tail call i32 @putchar(i32 49)
br label %19
8: ; preds = %3
%9 = icmp sgt i64 %0, 1
br i1 %9, label %10, label %19
10: ; preds = %8, %16
%11 = phi i64 [ %14, %16 ], [ %0, %8 ]
%12 = tail call i64 @kTeiler(i64 %11)
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i64 %12)
%14 = udiv i64 %11, %12
%15 = icmp eq i64 %14, 1
br i1 %15, label %19, label %16
16: ; preds = %10
%17 = tail call i32 @putchar(i32 42)
%18 = icmp ugt i64 %12, %11
br i1 %18, label %19, label %10
19: ; preds = %10, %16, %6, %8
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
br label %21
21: ; preds = %19, %1
ret void
}