#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int num;
  int coc;
  int a;
  int i = 0;
  int base = 0;
  int vector[10] = {0};
  printf("Dame el numero para descomponer: ");
  scanf("%d", &num);
  coc = num;
  while (coc != 0) {
    printf("%d %d %d %d\n", vector[0], coc, base, i);
    vector[i] = ((coc % 10) * 10 ^ (base));
    coc = (coc / 10);
    base++;
    i++;
    printf("%d %d %d %d\n", vector[i], coc, base, i);
  }
  printf("La descomposicion de %d es: ", num);
  for (a = 0; a < i; a++) {
    printf("%d + ", vector[a]);
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1040 <memset@plt>
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb0(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1204 <main+0xd4>
mov    -0x40(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x14(%rbp),%r8d
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
imul   $0xa,%edx,%ecx
xor    -0x18(%rbp),%ecx
movslq -0x14(%rbp),%rax
mov    %ecx,-0x40(%rbp,%rax,4)
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
movslq -0x14(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%esi
mov    -0xc(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x14(%rbp),%r8d
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1181 <main+0x51>
mov    -0x8(%rbp),%esi
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    124c <main+0x11c>
movslq -0x10(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%esi
lea    0xe18(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    121c <main+0xec>
lea    0xddd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x38,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movq   $0x0,0x30(%rsp)
lea    0xea8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xebc(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%ebx
test   %ebx,%ebx
je     1249 <main+0x119>
lea    0xea2(%rip),%r15
xor    %esi,%esi
xor    %r14d,%r14d
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %ebx,%edx
mov    %r14d,%ecx
mov    %r14d,%r8d
xor    %eax,%eax
call   1040 <printf@plt>
movslq %ebx,%r12
imul   $0x66666667,%r12,%rbx
mov    %rbx,%rax
shr    $0x3f,%rax
sar    $0x22,%rbx
add    %eax,%ebx
lea    (%rbx,%rbx,1),%eax
lea    (%rax,%rax,4),%eax
mov    %r12d,%ecx
sub    %eax,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%eax
xor    %r14d,%eax
mov    %eax,0x10(%rsp,%r14,4)
lea    0x1(%r14),%ecx
mov    0x14(%rsp,%r14,4),%esi
mov    %r15,%rdi
mov    %ebx,%edx
mov    %ecx,%r8d
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x9,%r12d
cmp    $0x13,%r12d
jb     11fd <main+0xcd>
mov    0x10(%rsp),%esi
add    $0x1,%r14
jmp    1190 <main+0x60>
mov    0xc(%rsp),%esi
lea    0xe2a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0xffffffff,%r14d
je     1259 <main+0x129>
add    $0x1,%r14
mov    %r14d,%r15d
lea    0xe2c(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x10(%rsp,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1230 <main+0x100>
jmp    1259 <main+0x129>
lea    0xde2(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [34 x i8] c"Dame el numero para descomponer: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [13 x i8] c"%d %d %d %d\0A\00"
@.str.3 = [29 x i8] c"La descomposicion de %d es: \00"
@.str.4 = [6 x i8] c"%d + \00"
@.str.5 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [10 x i32]
store i32 0, i32* %1
store i32 0, i32* %5
store i32 0, i32* %6
%8 = bitcast [10 x i32]* %7 to i8*
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%11 = load i32, i32* %2
store i32 %11, i32* %3
br label %12
12: ; preds = %15, %0
%13 = load i32, i32* %3
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %44
15: ; preds = %12
%16 = getelementptr inbounds [10 x i32], [10 x i32]* %7, i64 0, i64 0
%17 = load i32, i32* %16
%18 = load i32, i32* %3
%19 = load i32, i32* %6
%20 = load i32, i32* %5
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %17, i32 %18, i32 %19, i32 %20)
%22 = load i32, i32* %3
%23 = srem i32 %22, 10
%24 = mul nsw i32 %23, 10
%25 = load i32, i32* %6
%26 = xor i32 %24, %25
%27 = load i32, i32* %5
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [10 x i32], [10 x i32]* %7, i64 0, i64 %28
store i32 %26, i32* %29
%30 = load i32, i32* %3
%31 = sdiv i32 %30, 10
store i32 %31, i32* %3
%32 = load i32, i32* %6
%33 = add nsw i32 %32, 1
store i32 %33, i32* %6
%34 = load i32, i32* %5
%35 = add nsw i32 %34, 1
store i32 %35, i32* %5
%36 = load i32, i32* %5
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [10 x i32], [10 x i32]* %7, i64 0, i64 %37
%39 = load i32, i32* %38
%40 = load i32, i32* %3
%41 = load i32, i32* %6
%42 = load i32, i32* %5
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %39, i32 %40, i32 %41, i32 %42)
br label %12
44: ; preds = %12
%45 = load i32, i32* %2
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i32 %45)
store i32 0, i32* %4
br label %47
47: ; preds = %57, %44
%48 = load i32, i32* %4
%49 = load i32, i32* %5
%50 = icmp slt i32 %48, %49
br i1 %50, label %51, label %60
51: ; preds = %47
%52 = load i32, i32* %4
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [10 x i32], [10 x i32]* %7, i64 0, i64 %53
%55 = load i32, i32* %54
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %55)
br label %57
57: ; preds = %51
%58 = load i32, i32* %4
%59 = add nsw i32 %58, 1
store i32 %59, i32* %4
br label %47
60: ; preds = %47
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [34 x i8] c"Dame el numero para descomponer: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [13 x i8] c"%d %d %d %d\0A\00"
@.str.3 = [29 x i8] c"La descomposicion de %d es: \00"
@.str.4 = [6 x i8] c"%d + \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i32]
%3 = bitcast i32* %1 to i8*
%4 = bitcast [10 x i32]* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i32 0)
br label %47
11: ; preds = %0
%12 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
br label %13
13: ; preds = %31, %11
%14 = phi i32 [ 0, %11 ], [ %32, %31 ]
%15 = phi i64 [ 0, %11 ], [ %24, %31 ]
%16 = phi i32 [ %7, %11 ], [ %23, %31 ]
%17 = trunc i64 %15 to i32
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %14, i32 %16, i32 %17, i32 %17)
%19 = srem i32 %16, 10
%20 = mul nsw i32 %19, 10
%21 = xor i32 %20, %17
%22 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %15
store i32 %21, i32* %22
%23 = sdiv i32 %16, 10
%24 = add nuw i64 %15, 1
%25 = trunc i64 %24 to i32
%26 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %24
%27 = load i32, i32* %26
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %27, i32 %23, i32 %25, i32 %25)
%29 = add i32 %16, 9
%30 = icmp ult i32 %29, 19
br i1 %30, label %33, label %31
31: ; preds = %13
%32 = load i32, i32* %12
br label %13
33: ; preds = %13
%34 = trunc i64 %24 to i32
%35 = load i32, i32* %1
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i32 %35)
%37 = icmp eq i32 %34, 0
br i1 %37, label %47, label %38
38: ; preds = %33
%39 = and i64 %24, 4294967295
br label %40
40: ; preds = %38, %40
%41 = phi i64 [ 0, %38 ], [ %45, %40 ]
%42 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %41
%43 = load i32, i32* %42
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 %43)
%45 = add nuw nsw i64 %41, 1
%46 = icmp eq i64 %45, %39
br i1 %46, label %47, label %40
47: ; preds = %40, %9, %33
%48 = call i32 @putchar(i32 10)
ret i32 0
}