#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 *DigitList(int, int *);
int /*<<< orphan*/ printf(char *, int, ...);
int main() {
  int n = 2340987, len, i;
  int *list = DigitList(n, &len);
  printf("List of digits of %d are:\n", n);
  for (i = 0; i < len; ++i)
    printf("%d%s", list[i], i == len - 1 ? "\n" : ", ");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x23b87b,-0x8(%rbp)
mov    -0x8(%rbp),%edi
lea    -0xc(%rbp),%rsi
call   1040 <DigitList@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%esi
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11ae <main+0x8e>
mov    -0x18(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
mov    -0x10(%rbp),%ecx
mov    -0xc(%rbp),%edi
sub    $0x1,%edi
lea    0xe9b(%rip),%rdx
lea    0xe8d(%rip),%rax
cmp    %edi,%ecx
cmove  %rax,%rdx
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    115e <main+0x3e>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xc(%rsp),%rsi
mov    $0x23b87b,%edi
call   1040 <DigitList@plt>
mov    %rax,%r13
lea    0xeba(%rip),%rdi
mov    $0x23b87b,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    11aa <main+0x8a>
lea    0xeb8(%rip),%r15
lea    0xeb8(%rip),%r12
lea    0xeac(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x0(%r13,%rbx,4),%esi
add    $0xffffffff,%eax
cmp    %rax,%rbx
mov    %r12,%rdx
cmove  %r15,%rdx
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     1180 <main+0x60>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [27 x i8] c"List of digits of %d are:\0A\00"
@.str.1 = [5 x i8] c"%d%s\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [3 x i8] c", \00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32* @DigitList(i32 2340987, i32* %1)
%4 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 2340987)
%5 = load i32, i32* %1
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %21
7: ; preds = %0, %7
%8 = phi i64 [ %17, %7 ], [ 0, %0 ]
%9 = phi i32 [ %18, %7 ], [ %5, %0 ]
%10 = getelementptr inbounds i32, i32* %3, i64 %8
%11 = load i32, i32* %10
%12 = add nsw i32 %9, -1
%13 = zext i32 %12 to i64
%14 = icmp eq i64 %8, %13
%15 = select i1 %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0)
%16 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %11, i8* %15)
%17 = add nuw nsw i64 %8, 1
%18 = load i32, i32* %1
%19 = sext i32 %18 to i64
%20 = icmp slt i64 %17, %19
br i1 %20, label %7, label %21
21: ; preds = %7, %0
ret i32 0
}