#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 /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
long *malloc(int);
size_t num_count(long);
double pow(int, long);
int /*<<< orphan*/ printf(char *, long, ...);
long *num2array(long number, long *array, size_t *i) {
  long i_temp = 0, j = 0, temp1 = 0;
  double temp2 = number;
  *i = num_count(number);
  i_temp = *i;
  printf("i_temp initial : %ld et *i : %d\n\n", i_temp, *i);
  array = malloc(sizeof(*array) * i_temp);
  if (!array)
    exit(EXIT_FAILURE);
  for (j = 0; j < *i; j++) {
    temp2 = temp2 / pow(10, i_temp - 1);
    printf("temp 2 div : %lf\n", temp2);
    temp1 = (long)temp2;
    printf("temp 1 : %ld\n", temp1);
    *(array + j) = temp1;
    printf("array : %ld, j : %ld", array[j], j);
    temp2 = (temp2 - (long)temp2) * pow(10, i_temp - 1);
    printf("temp 2 arith : %lf\n", temp2);
    printf("i_temp : %ld\n", i_temp);
    i_temp -= 1;
    printf("i_temp : %ld\n\n", i_temp);
  }
  return array;
}


x86 assembly (clang, -O0):
<num2array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
cvtsi2sdq -0x8(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <num_count@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rax
mov    (%rax),%rdx
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11ea <num2array+0x9a>
mov    0x2dfd(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%rax
jae    131f <num2array+0x1cf>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x20(%rbp),%rsi
sub    $0x1,%rsi
mov    $0xa,%edi
call   1060 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
cvttsd2si -0x38(%rbp),%rsi
lea    0xde5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cvttsd2si -0x38(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rsi
lea    0xddb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%rdx
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x28(%rbp),%rdx
lea    0xdbb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsd  -0x38(%rbp),%xmm0
cvttsd2si -0x38(%rbp),%rax
cvtsi2sd %rax,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x20(%rbp),%rsi
sub    $0x1,%rsi
mov    $0xa,%edi
call   1060 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
cvttsd2si -0x38(%rbp),%rsi
lea    0xd80(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xd82(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rax
sub    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xd72(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    11f2 <num2array+0xa2>
mov    -0x10(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<num2array>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rdi,%rbx
call   1030 <num_count@plt>
mov    %rax,%r13
mov    %rax,(%r14)
lea    0xe8d(%rip),%rdi
mov    %rax,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x0(,%r13,8),%edi
call   1050 <malloc@plt>
test   %rax,%rax
je     1296 <num2array+0x146>
mov    %rax,%r15
cmpq   $0x0,(%r14)
je     1284 <num2array+0x134>
cvtsi2sd %rbx,%xmm0
movsd  %xmm0,(%rsp)
xor    %r12d,%r12d
lea    -0x1(%r13),%rbx
mov    $0xa,%edi
mov    %rbx,%rsi
call   1060 <pow@plt>
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
cvttsd2si %xmm1,%rbp
lea    0xe47(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe48(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,(%r15,%r12,8)
lea    0xe41(%rip),%rdi
mov    %rbp,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rbp,%xmm0
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
mov    $0xa,%edi
mov    %rbx,%rsi
call   1060 <pow@plt>
movsd  (%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
cvttsd2si %xmm1,%rsi
lea    0xe0c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe12(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe0f(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r12
mov    %rbx,%r13
cmp    (%r14),%r12
jb     11b0 <num2array+0x60>
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d43(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [34 x i8] c"i_temp initial : %ld et *i : %d\0A\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [18 x i8] c"temp 2 div : %lf\0A\00"
@.str.2 = [14 x i8] c"temp 1 : %ld\0A\00"
@.str.3 = [21 x i8] c"array : %ld, j : %ld\00"
@.str.4 = [20 x i8] c"temp 2 arith : %lf\0A\00"
@.str.5 = [14 x i8] c"i_temp : %ld\0A\00"
@.str.6 = [15 x i8] c"i_temp : %ld\0A\0A\00"
define i64* @num2array(i64 %0, i64* %1, i64* %2) {
%4 = alloca i64
%5 = alloca i64*
%6 = alloca i64*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca double
store i64 %0, i64* %4
store i64* %1, i64** %5
store i64* %2, i64** %6
store i64 0, i64* %7
store i64 0, i64* %8
store i64 0, i64* %9
%11 = load i64, i64* %4
%12 = sitofp i64 %11 to double
store double %12, double* %10
%13 = load i64, i64* %4
%14 = call i64 @num_count(i64 %13)
%15 = load i64*, i64** %6
store i64 %14, i64* %15
%16 = load i64*, i64** %6
%17 = load i64, i64* %16
store i64 %17, i64* %7
%18 = load i64, i64* %7
%19 = load i64*, i64** %6
%20 = load i64, i64* %19
%21 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i64 %18, i64 %20)
%22 = load i64, i64* %7
%23 = mul i64 8, %22
%24 = trunc i64 %23 to i32
%25 = call i64* @malloc(i32 %24)
store i64* %25, i64** %5
%26 = load i64*, i64** %5
%27 = icmp ne i64* %26, null
br i1 %27, label %31, label %28
28: ; preds = %3
%29 = load i32, i32* @EXIT_FAILURE
%30 = call i32 @exit(i32 %29)
unreachable
31: ; preds = %3
store i64 0, i64* %8
br label %32
32: ; preds = %78, %31
%33 = load i64, i64* %8
%34 = load i64*, i64** %6
%35 = load i64, i64* %34
%36 = icmp ult i64 %33, %35
br i1 %36, label %37, label %81
37: ; preds = %32
%38 = load double, double* %10
%39 = load i64, i64* %7
%40 = sub nsw i64 %39, 1
%41 = call double @pow(i32 10, i64 %40)
%42 = fdiv double %38, %41
store double %42, double* %10
%43 = load double, double* %10
%44 = fptosi double %43 to i64
%45 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i64 %44)
%46 = load double, double* %10
%47 = fptosi double %46 to i64
store i64 %47, i64* %9
%48 = load i64, i64* %9
%49 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i64 %48)
%50 = load i64, i64* %9
%51 = load i64*, i64** %5
%52 = load i64, i64* %8
%53 = getelementptr inbounds i64, i64* %51, i64 %52
store i64 %50, i64* %53
%54 = load i64*, i64** %5
%55 = load i64, i64* %8
%56 = getelementptr inbounds i64, i64* %54, i64 %55
%57 = load i64, i64* %56
%58 = load i64, i64* %8
%59 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i64 %57, i64 %58)
%60 = load double, double* %10
%61 = load double, double* %10
%62 = fptosi double %61 to i64
%63 = sitofp i64 %62 to double
%64 = fsub double %60, %63
%65 = load i64, i64* %7
%66 = sub nsw i64 %65, 1
%67 = call double @pow(i32 10, i64 %66)
%68 = fmul double %64, %67
store double %68, double* %10
%69 = load double, double* %10
%70 = fptosi double %69 to i64
%71 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i64 %70)
%72 = load i64, i64* %7
%73 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i64 %72)
%74 = load i64, i64* %7
%75 = sub nsw i64 %74, 1
store i64 %75, i64* %7
%76 = load i64, i64* %7
%77 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i64 %76)
br label %78
78: ; preds = %37
%79 = load i64, i64* %8
%80 = add nsw i64 %79, 1
store i64 %80, i64* %8
br label %32
81: ; preds = %32
%82 = load i64*, i64** %5
ret i64* %82
}

LLVM IR (-O2):
@.str = [34 x i8] c"i_temp initial : %ld et *i : %d\0A\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [18 x i8] c"temp 2 div : %lf\0A\00"
@.str.2 = [14 x i8] c"temp 1 : %ld\0A\00"
@.str.3 = [21 x i8] c"array : %ld, j : %ld\00"
@.str.4 = [20 x i8] c"temp 2 arith : %lf\0A\00"
@.str.5 = [14 x i8] c"i_temp : %ld\0A\00"
@.str.6 = [15 x i8] c"i_temp : %ld\0A\0A\00"
define noalias i64* @num2array(i64 %0, i64* nocapture readnone %1, i64* nocapture %2) {
%4 = tail call i64 @num_count(i64 %0)
store i64 %4, i64* %2
%5 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i64 %4, i64 %4)
%6 = trunc i64 %4 to i32
%7 = shl i32 %6, 3
%8 = tail call i64* @malloc(i32 %7)
%9 = icmp eq i64* %8, null
br i1 %9, label %10, label %13
10: ; preds = %3
%11 = load i32, i32* @EXIT_FAILURE
%12 = tail call i32 @exit(i32 %11)
unreachable
13: ; preds = %3
%14 = load i64, i64* %2
%15 = icmp eq i64 %14, 0
br i1 %15, label %41, label %16
16: ; preds = %13
%17 = sitofp i64 %0 to double
br label %18
18: ; preds = %16, %18
%19 = phi double [ %33, %18 ], [ %17, %16 ]
%20 = phi i64 [ %38, %18 ], [ 0, %16 ]
%21 = phi i64 [ %22, %18 ], [ %4, %16 ]
%22 = add nsw i64 %21, -1
%23 = tail call double @pow(i32 10, i64 %22)
%24 = fdiv double %19, %23
%25 = fptosi double %24 to i64
%26 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i64 %25)
%27 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i64 %25)
%28 = getelementptr inbounds i64, i64* %8, i64 %20
store i64 %25, i64* %28
%29 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i64 %25, i64 %20)
%30 = sitofp i64 %25 to double
%31 = fsub double %24, %30
%32 = tail call double @pow(i32 10, i64 %22)
%33 = fmul double %31, %32
%34 = fptosi double %33 to i64
%35 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i64 %34)
%36 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i64 %21)
%37 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i64 %22)
%38 = add nuw nsw i64 %20, 1
%39 = load i64, i64* %2
%40 = icmp ult i64 %38, %39
br i1 %40, label %18, label %41
41: ; preds = %18, %13
ret i64* %8
}