#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*/ clean_array(int *);
int convert_long(long, int *);
int /*<<< orphan*/ copyto_array(int *, int *, int, int);
int /*<<< orphan*/ memcpy(int *, int *, int);
int /*<<< orphan*/ print_array(int *, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sum_arrays(int *, int *);
int sum_boxes(long *p, int *resultados) {
  int aux[50];
  int cumulated[50];
  int converted[50];
  int i, converted_size;
  clean_array(cumulated);
  clean_array(converted);
  for (i = 0; i < 5; i++) {
    clean_array(aux);
    converted_size = convert_long(p[i], converted);
    print_array(converted, "converted");
    copyto_array(aux, converted, i * 3, converted_size);
    print_array(aux, "aux");
    sum_arrays(cumulated, aux);
    print_array(cumulated, "acumulados en ciclo");
    printf("---------------------------------\n");
  }
  print_array(cumulated, "acumulados totales");
  memcpy(resultados, cumulated, 50);
  return 0;
}


x86 assembly (clang, -O0):
<sum_boxes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x290,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x1b0(%rbp),%rdi
call   1050 <clean_array@plt>
lea    -0x280(%rbp),%rdi
call   1050 <clean_array@plt>
movl   $0x0,-0x284(%rbp)
cmpl   $0x5,-0x284(%rbp)
jge    126b <sum_boxes+0xfb>
lea    -0xe0(%rbp),%rdi
call   1050 <clean_array@plt>
mov    -0x8(%rbp),%rax
movslq -0x284(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x280(%rbp),%rsi
call   1060 <convert_long@plt>
mov    %eax,-0x288(%rbp)
lea    -0x280(%rbp),%rdi
lea    0xe13(%rip),%rsi
call   1030 <print_array@plt>
lea    -0xe0(%rbp),%rdi
lea    -0x280(%rbp),%rsi
imul   $0x3,-0x284(%rbp),%edx
mov    -0x288(%rbp),%ecx
call   1070 <copyto_array@plt>
lea    -0xe0(%rbp),%rdi
lea    0xdea(%rip),%rsi
call   1030 <print_array@plt>
lea    -0x1b0(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
call   1090 <sum_arrays@plt>
lea    -0x1b0(%rbp),%rdi
lea    0xdc8(%rip),%rsi
call   1030 <print_array@plt>
lea    0xdd0(%rip),%rdi
call   1040 <printf@plt>
mov    -0x284(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x284(%rbp)
jmp    11a5 <sum_boxes+0x35>
lea    -0x1b0(%rbp),%rdi
lea    0xdcc(%rip),%rsi
call   1030 <print_array@plt>
mov    -0x10(%rbp),%rdi
lea    -0x1b0(%rbp),%rsi
mov    $0x32,%edx
call   1080 <memcpy@plt>
xor    %eax,%eax
add    $0x290,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sum_boxes>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x278,%rsp
mov    %rsi,0x8(%rsp)
mov    %rdi,%r13
lea    0xe0(%rsp),%r15
mov    %r15,%rdi
call   1050 <clean_array@plt>
lea    0x10(%rsp),%r12
mov    %r12,%rdi
call   1050 <clean_array@plt>
lea    0x1b0(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <clean_array@plt>
mov    0x0(%r13),%rdi
mov    %r12,%rsi
call   1060 <convert_long@plt>
mov    %eax,%ebp
lea    0xe35(%rip),%rsi
mov    %r12,%rdi
call   1040 <print_array@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
xor    %edx,%edx
mov    %ebp,%ecx
call   1070 <copyto_array@plt>
lea    0xe21(%rip),%rsi
mov    %rbx,%rdi
call   1040 <print_array@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1090 <sum_arrays@plt>
lea    0xe0b(%rip),%rsi
mov    %r15,%rdi
call   1040 <print_array@plt>
lea    0xe23(%rip),%r14
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1050 <clean_array@plt>
mov    0x8(%r13),%rdi
mov    %r12,%rsi
call   1060 <convert_long@plt>
mov    %eax,%ebp
mov    %r12,%rdi
lea    0xdc6(%rip),%rsi
call   1040 <print_array@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x3,%edx
mov    %ebp,%ecx
call   1070 <copyto_array@plt>
mov    %rbx,%rdi
lea    0xdaf(%rip),%rsi
call   1040 <print_array@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1090 <sum_arrays@plt>
mov    %r15,%rdi
lea    0xd99(%rip),%rsi
call   1040 <print_array@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1050 <clean_array@plt>
mov    0x10(%r13),%rdi
mov    %r12,%rsi
call   1060 <convert_long@plt>
mov    %eax,%ebp
mov    %r12,%rdi
lea    0xd5e(%rip),%rsi
call   1040 <print_array@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x6,%edx
mov    %ebp,%ecx
call   1070 <copyto_array@plt>
mov    %rbx,%rdi
lea    0xd47(%rip),%rsi
call   1040 <print_array@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1090 <sum_arrays@plt>
mov    %r15,%rdi
lea    0xd31(%rip),%rsi
call   1040 <print_array@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1050 <clean_array@plt>
mov    0x18(%r13),%rdi
mov    %r12,%rsi
call   1060 <convert_long@plt>
mov    %eax,%ebp
mov    %r12,%rdi
lea    0xcf6(%rip),%rsi
call   1040 <print_array@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x9,%edx
mov    %ebp,%ecx
call   1070 <copyto_array@plt>
mov    %rbx,%rdi
lea    0xcdf(%rip),%rsi
call   1040 <print_array@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1090 <sum_arrays@plt>
mov    %r15,%rdi
lea    0xcc9(%rip),%rsi
call   1040 <print_array@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1050 <clean_array@plt>
mov    0x20(%r13),%rdi
mov    %r12,%rsi
call   1060 <convert_long@plt>
mov    %eax,%ebp
mov    %r12,%rdi
lea    0xc8e(%rip),%rsi
call   1040 <print_array@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0xc,%edx
mov    %ebp,%ecx
call   1070 <copyto_array@plt>
mov    %rbx,%rdi
lea    0xc77(%rip),%rsi
call   1040 <print_array@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1090 <sum_arrays@plt>
mov    %r15,%rdi
lea    0xc61(%rip),%rsi
call   1040 <print_array@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
lea    0xc61(%rip),%rsi
mov    %r15,%rdi
call   1040 <print_array@plt>
mov    0x8(%rsp),%rdi
mov    %r15,%rsi
mov    $0x32,%edx
call   1080 <memcpy@plt>
xor    %eax,%eax
add    $0x278,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"converted\00"
@.str.1 = [4 x i8] c"aux\00"
@.str.2 = [20 x i8] c"acumulados en ciclo\00"
@.str.3 = [35 x i8] c"---------------------------------\0A\00"
@.str.4 = [19 x i8] c"acumulados totales\00"
define i32 @sum_boxes(i64* %0, i32* %1) {
%3 = alloca i64*
%4 = alloca i32*
%5 = alloca [50 x i32]
%6 = alloca [50 x i32]
%7 = alloca [50 x i32]
%8 = alloca i32
%9 = alloca i32
store i64* %0, i64** %3
store i32* %1, i32** %4
%10 = getelementptr inbounds [50 x i32], [50 x i32]* %6, i64 0, i64 0
%11 = call i32 @clean_array(i32* %10)
%12 = getelementptr inbounds [50 x i32], [50 x i32]* %7, i64 0, i64 0
%13 = call i32 @clean_array(i32* %12)
store i32 0, i32* %8
br label %14
14: ; preds = %43, %2
%15 = load i32, i32* %8
%16 = icmp slt i32 %15, 5
br i1 %16, label %17, label %46
17: ; preds = %14
%18 = getelementptr inbounds [50 x i32], [50 x i32]* %5, i64 0, i64 0
%19 = call i32 @clean_array(i32* %18)
%20 = load i64*, i64** %3
%21 = load i32, i32* %8
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i64, i64* %20, i64 %22
%24 = load i64, i64* %23
%25 = getelementptr inbounds [50 x i32], [50 x i32]* %7, i64 0, i64 0
%26 = call i32 @convert_long(i64 %24, i32* %25)
store i32 %26, i32* %9
%27 = getelementptr inbounds [50 x i32], [50 x i32]* %7, i64 0, i64 0
%28 = call i32 @print_array(i32* %27, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%29 = getelementptr inbounds [50 x i32], [50 x i32]* %5, i64 0, i64 0
%30 = getelementptr inbounds [50 x i32], [50 x i32]* %7, i64 0, i64 0
%31 = load i32, i32* %8
%32 = mul nsw i32 %31, 3
%33 = load i32, i32* %9
%34 = call i32 @copyto_array(i32* %29, i32* %30, i32 %32, i32 %33)
%35 = getelementptr inbounds [50 x i32], [50 x i32]* %5, i64 0, i64 0
%36 = call i32 @print_array(i32* %35, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%37 = getelementptr inbounds [50 x i32], [50 x i32]* %6, i64 0, i64 0
%38 = getelementptr inbounds [50 x i32], [50 x i32]* %5, i64 0, i64 0
%39 = call i32 @sum_arrays(i32* %37, i32* %38)
%40 = getelementptr inbounds [50 x i32], [50 x i32]* %6, i64 0, i64 0
%41 = call i32 @print_array(i32* %40, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%42 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
br label %43
43: ; preds = %17
%44 = load i32, i32* %8
%45 = add nsw i32 %44, 1
store i32 %45, i32* %8
br label %14
46: ; preds = %14
%47 = getelementptr inbounds [50 x i32], [50 x i32]* %6, i64 0, i64 0
%48 = call i32 @print_array(i32* %47, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
%49 = load i32*, i32** %4
%50 = getelementptr inbounds [50 x i32], [50 x i32]* %6, i64 0, i64 0
%51 = call i32 @memcpy(i32* %49, i32* %50, i32 50)
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"converted\00"
@.str.1 = [4 x i8] c"aux\00"
@.str.2 = [20 x i8] c"acumulados en ciclo\00"
@.str.4 = [19 x i8] c"acumulados totales\00"
@str = [34 x i8] c"---------------------------------\00"
define i32 @sum_boxes(i64* nocapture %0, i32* %1) {
%3 = alloca [50 x i32]
%4 = alloca [50 x i32]
%5 = alloca [50 x i32]
%6 = bitcast [50 x i32]* %3 to i8*
%7 = bitcast [50 x i32]* %4 to i8*
%8 = bitcast [50 x i32]* %5 to i8*
%9 = getelementptr inbounds [50 x i32], [50 x i32]* %4, i64 0, i64 0
%10 = call i32 @clean_array(i32* %9)
%11 = getelementptr inbounds [50 x i32], [50 x i32]* %5, i64 0, i64 0
%12 = call i32 @clean_array(i32* %11)
%13 = getelementptr inbounds [50 x i32], [50 x i32]* %3, i64 0, i64 0
%14 = call i32 @clean_array(i32* %13)
%15 = load i64, i64* %0
%16 = call i32 @convert_long(i64 %15, i32* %11)
%17 = call i32 @print_array(i32* %11, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%18 = call i32 @copyto_array(i32* %13, i32* %11, i32 0, i32 %16)
%19 = call i32 @print_array(i32* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%20 = call i32 @sum_arrays(i32* %9, i32* %13)
%21 = call i32 @print_array(i32* %9, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
%23 = call i32 @clean_array(i32* %13)
%24 = getelementptr inbounds i64, i64* %0, i64 1
%25 = load i64, i64* %24
%26 = call i32 @convert_long(i64 %25, i32* %11)
%27 = call i32 @print_array(i32* %11, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%28 = call i32 @copyto_array(i32* %13, i32* %11, i32 3, i32 %26)
%29 = call i32 @print_array(i32* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%30 = call i32 @sum_arrays(i32* %9, i32* %13)
%31 = call i32 @print_array(i32* %9, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
%33 = call i32 @clean_array(i32* %13)
%34 = getelementptr inbounds i64, i64* %0, i64 2
%35 = load i64, i64* %34
%36 = call i32 @convert_long(i64 %35, i32* %11)
%37 = call i32 @print_array(i32* %11, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%38 = call i32 @copyto_array(i32* %13, i32* %11, i32 6, i32 %36)
%39 = call i32 @print_array(i32* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%40 = call i32 @sum_arrays(i32* %9, i32* %13)
%41 = call i32 @print_array(i32* %9, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%42 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
%43 = call i32 @clean_array(i32* %13)
%44 = getelementptr inbounds i64, i64* %0, i64 3
%45 = load i64, i64* %44
%46 = call i32 @convert_long(i64 %45, i32* %11)
%47 = call i32 @print_array(i32* %11, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%48 = call i32 @copyto_array(i32* %13, i32* %11, i32 9, i32 %46)
%49 = call i32 @print_array(i32* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%50 = call i32 @sum_arrays(i32* %9, i32* %13)
%51 = call i32 @print_array(i32* %9, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%52 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
%53 = call i32 @clean_array(i32* %13)
%54 = getelementptr inbounds i64, i64* %0, i64 4
%55 = load i64, i64* %54
%56 = call i32 @convert_long(i64 %55, i32* %11)
%57 = call i32 @print_array(i32* %11, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%58 = call i32 @copyto_array(i32* %13, i32* %11, i32 12, i32 %56)
%59 = call i32 @print_array(i32* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%60 = call i32 @sum_arrays(i32* %9, i32* %13)
%61 = call i32 @print_array(i32* %9, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%62 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
%63 = call i32 @print_array(i32* %9, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
%64 = call i32 @memcpy(i32* %1, i32* %9, i32 50)
ret i32 0
}