#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 */
typedef int uint64_t;

/* Variables and functions */
scalar_t__ is_prime(int);
int /*<<< orphan*/ printf(char *, int);
void *print_prime_factors(void *p) {
  uint64_t n = (uint64_t)p;
  printf("%d:", n);
  uint64_t i;
  for (i = (uint64_t)2; is_prime(n) == 0; i++) {
    if (((int)n) % i == 0) {
      printf(" %d", i);
      n = (uint64_t)((int)n / (int)i);
      i = (uint64_t)1;
    }
  }
  printf(" %d\n", n);
}


x86 assembly (clang, -O0):
<print_prime_factors>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xec3(%rip),%rdi
call   1030 <printf@plt>
movl   $0x2,-0x18(%rbp)
mov    -0x14(%rbp),%edi
call   1040 <is_prime@plt>
cmp    $0x0,%rax
jne    119e <print_prime_factors+0x7e>
mov    -0x14(%rbp),%eax
cltd
idivl  -0x18(%rbp)
cmp    $0x0,%edx
jne    118b <print_prime_factors+0x6b>
mov    -0x18(%rbp),%esi
lea    0xe8f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
cltd
idivl  -0x18(%rbp)
mov    %eax,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
jmp    1190 <print_prime_factors+0x70>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1149 <print_prime_factors+0x29>
mov    -0x14(%rbp),%esi
lea    0xe60(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_prime_factors>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r15
lea    0xecf(%rip),%rdi
mov    %r15d,%esi
call   1030 <printf@plt>
mov    %r15d,%edi
call   1040 <is_prime@plt>
test   %rax,%rax
je     115f <print_prime_factors+0x3f>
lea    0xebb(%rip),%rdi
mov    %r15d,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>
mov    $0x2,%ebp
lea    0xe99(%rip),%r14
jmp    1180 <print_prime_factors+0x60>
nopl   (%rax)
add    $0x1,%ebp
mov    %r15d,%edi
call   1040 <is_prime@plt>
test   %rax,%rax
jne    1146 <print_prime_factors+0x26>
mov    %r15d,%eax
cltd
idiv   %ebp
test   %edx,%edx
jne    1170 <print_prime_factors+0x50>
mov    %eax,%ebx
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
mov    $0x1,%ebp
mov    %ebx,%r15d
jmp    1170 <print_prime_factors+0x50>

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

LLVM IR (-O2):
@.str = [4 x i8] c"%d:\00"
@.str.1 = [4 x i8] c" %d\00"
@.str.2 = [5 x i8] c" %d\0A\00"
define noalias i8* @print_prime_factors(i8* %0) {
%2 = ptrtoint i8* %0 to i64
%3 = trunc i64 %2 to i32
%4 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = tail call i64 @is_prime(i32 %3)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %21
7: ; preds = %1, %15
%8 = phi i32 [ %18, %15 ], [ 2, %1 ]
%9 = phi i32 [ %16, %15 ], [ %3, %1 ]
%10 = srem i32 %9, %8
%11 = sdiv i32 %9, %8
%12 = icmp eq i32 %10, 0
br i1 %12, label %13, label %15
13: ; preds = %7
%14 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %8)
br label %15
15: ; preds = %7, %13
%16 = phi i32 [ %11, %13 ], [ %9, %7 ]
%17 = phi i32 [ 1, %13 ], [ %8, %7 ]
%18 = add nsw i32 %17, 1
%19 = tail call i64 @is_prime(i32 %16)
%20 = icmp eq i64 %19, 0
br i1 %20, label %7, label %21
21: ; preds = %15, %1
%22 = phi i32 [ %3, %1 ], [ %16, %15 ]
%23 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %22)
ret i8* undef
}