#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 uint32_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void divide(uint32_t N0) {
  uint32_t N = N0;
  printf("%d =", N0);
  for (uint32_t k = 2; (k <= N0 / 2) && (N > 1);) {
    if (N % k == 0) {
      if (N != N0)
        printf(" *");
      N /= k;
      printf(" %d", k);
    } else
      k++;
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<divide>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%esi
lea    0xed5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x2,-0xc(%rbp)
mov    -0xc(%rbp),%ecx
mov    -0x4(%rbp),%eax
mov    $0x2,%esi
cltd
idiv   %esi
mov    %eax,%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0xd(%rbp)
jg     1160 <divide+0x50>
cmpl   $0x1,-0x8(%rbp)
setg   %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    1170 <divide+0x60>
jmp    11ca <divide+0xba>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    11bc <divide+0xac>
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
je     119a <divide+0x8a>
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c5 <divide+0xb5>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1139 <divide+0x29>
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<divide>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%r12d
lea    0xecb(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x4,%r12d
jl     11b9 <divide+0x99>
mov    %r12d,%r13d
shr    $0x1f,%r13d
add    %r12d,%r13d
sar    %r13d
mov    $0x2,%ebp
lea    0xeaa(%rip),%r14
lea    0xea0(%rip),%r15
mov    %r12d,%ecx
nopl   0x0(%rax,%rax,1)
mov    %ecx,%eax
cltd
idiv   %ebp
test   %edx,%edx
je     1190 <divide+0x70>
add    $0x1,%ebp
cmp    %r13d,%ebp
jle    11b4 <divide+0x94>
jmp    11b9 <divide+0x99>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %eax,%ebx
cmp    %r12d,%ecx
je     11a1 <divide+0x81>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%ecx
cmp    %r13d,%ebp
jg     11b9 <divide+0x99>
cmp    $0x1,%ecx
jg     1170 <divide+0x50>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

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

LLVM IR (-O2):
@.str = [5 x i8] c"%d =\00"
@.str.1 = [3 x i8] c" *\00"
@.str.2 = [4 x i8] c" %d\00"
define void @divide(i32 %0) {
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %0)
%3 = sdiv i32 %0, 2
%4 = icmp sgt i32 %0, 3
br i1 %4, label %7, label %5
5: ; preds = %21, %1
%6 = tail call i32 @putchar(i32 10)
ret void
7: ; preds = %1, %21
%8 = phi i32 [ %23, %21 ], [ 2, %1 ]
%9 = phi i32 [ %22, %21 ], [ %0, %1 ]
%10 = srem i32 %9, %8
%11 = sdiv i32 %9, %8
%12 = icmp eq i32 %10, 0
br i1 %12, label %13, label %19
13: ; preds = %7
%14 = icmp eq i32 %9, %0
br i1 %14, label %17, label %15
15: ; preds = %13
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %17
17: ; preds = %15, %13
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %8)
br label %21
19: ; preds = %7
%20 = add nsw i32 %8, 1
br label %21
21: ; preds = %19, %17
%22 = phi i32 [ %11, %17 ], [ %9, %19 ]
%23 = phi i32 [ %8, %17 ], [ %20, %19 ]
%24 = icmp sle i32 %23, %3
%25 = icmp sgt i32 %22, 1
%26 = select i1 %24, i1 %25, i1 false
br i1 %26, label %7, label %5
}