#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 */
long *factor(long);
int /*<<< orphan*/ free(long *);
int /*<<< orphan*/ printf(char *, long);
long strtol(char *, char **, int);
int main(int argc, char *argv[]) {
  char *ptr;
  long n = strtol(argv[1], &ptr, 10);
  long *p = factor(n);
  for (size_t i = 0; p[i] != -1; i++) {
    printf("%li\n", p[i]);
  }
  free(p);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x18(%rbp),%rsi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <factor@plt>
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x30(%rbp),%rcx
cmpq   $0xffffffffffffffff,(%rax,%rcx,8)
je     11c1 <main+0x81>
mov    -0x28(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe55(%rip),%rdi
call   1040 <printf@plt>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1185 <main+0x45>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    0x8(%rsi),%rdi
lea    0x8(%rsp),%rsi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %rax,%rdi
call   1060 <factor@plt>
mov    %rax,%r14
mov    (%rax),%rsi
cmp    $0xffffffffffffffff,%rsi
je     1195 <main+0x55>
mov    %r14,%rbx
add    $0x8,%rbx
lea    0xe82(%rip),%r15
xchg   %ax,%ax
mov    %r15,%rdi
call   1040 <printf@plt>
mov    (%rbx),%rsi
add    $0x8,%rbx
cmp    $0xffffffffffffffff,%rsi
jne    1180 <main+0x40>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c"%li\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = call i64 @strtol(i8* %6, i8** %3, i32 10)
%8 = tail call i64* @factor(i64 %7)
%9 = load i64, i64* %8
%10 = icmp eq i64 %9, -1
br i1 %10, label %11, label %13
11: ; preds = %13, %2
%12 = tail call i32 @free(i64* %8)
ret i32 0
13: ; preds = %2, %13
%14 = phi i64 [ %19, %13 ], [ %9, %2 ]
%15 = phi i64 [ %17, %13 ], [ 0, %2 ]
%16 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 %14)
%17 = add i64 %15, 1
%18 = getelementptr inbounds i64, i64* %8, i64 %17
%19 = load i64, i64* %18
%20 = icmp eq i64 %19, -1
br i1 %20, label %11, label %13
}