#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*/ print_array(int *, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sum_arrays(int *, int *);
int sum_boxes(long *p) {
  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");
  return 0;
}


x86 assembly (clang, -O0):
<sum_boxes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x280,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x1a0(%rbp),%rdi
call   1050 <clean_array@plt>
lea    -0x270(%rbp),%rdi
call   1050 <clean_array@plt>
movl   $0x0,-0x274(%rbp)
cmpl   $0x5,-0x274(%rbp)
jge    1257 <sum_boxes+0xf7>
lea    -0xd0(%rbp),%rdi
call   1050 <clean_array@plt>
mov    -0x8(%rbp),%rax
movslq -0x274(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x270(%rbp),%rsi
call   1060 <convert_long@plt>
mov    %eax,-0x278(%rbp)
lea    -0x270(%rbp),%rdi
lea    0xe27(%rip),%rsi
call   1030 <print_array@plt>
lea    -0xd0(%rbp),%rdi
lea    -0x270(%rbp),%rsi
imul   $0x3,-0x274(%rbp),%edx
mov    -0x278(%rbp),%ecx
call   1070 <copyto_array@plt>
lea    -0xd0(%rbp),%rdi
lea    0xdfe(%rip),%rsi
call   1030 <print_array@plt>
lea    -0x1a0(%rbp),%rdi
lea    -0xd0(%rbp),%rsi
call   1080 <sum_arrays@plt>
lea    -0x1a0(%rbp),%rdi
lea    0xddc(%rip),%rsi
call   1030 <print_array@plt>
lea    0xde4(%rip),%rdi
call   1040 <printf@plt>
mov    -0x274(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x274(%rbp)
jmp    1191 <sum_boxes+0x31>
lea    -0x1a0(%rbp),%rdi
lea    0xde0(%rip),%rsi
call   1030 <print_array@plt>
xor    %eax,%eax
add    $0x280,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sum_boxes>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x268,%rsp
mov    %rdi,%rbp
mov    %rsp,%r14
mov    %r14,%rdi
call   1050 <clean_array@plt>
lea    0xd0(%rsp),%r15
mov    %r15,%rdi
call   1050 <clean_array@plt>
lea    0x1a0(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <clean_array@plt>
mov    0x0(%rbp),%rdi
mov    %rbp,%r13
mov    %r15,%rsi
call   1060 <convert_long@plt>
mov    %eax,%ebp
lea    0xe49(%rip),%rsi
mov    %r15,%rdi
call   1040 <print_array@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
xor    %edx,%edx
mov    %ebp,%ecx
call   1070 <copyto_array@plt>
lea    0xe35(%rip),%r12
mov    %rbx,%rdi
mov    %r12,%rsi
call   1040 <print_array@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1080 <sum_arrays@plt>
lea    0xe1c(%rip),%rsi
mov    %r14,%rdi
call   1040 <print_array@plt>
lea    0xe34(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1050 <clean_array@plt>
mov    0x8(%r13),%rdi
mov    %r13,%rbp
mov    %r15,%rsi
call   1060 <convert_long@plt>
mov    %eax,%r13d
mov    %r15,%rdi
lea    0xdd6(%rip),%rsi
call   1040 <print_array@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x3,%edx
mov    %r13d,%ecx
call   1070 <copyto_array@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1040 <print_array@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1080 <sum_arrays@plt>
mov    %r14,%rdi
lea    0xdac(%rip),%rsi
call   1040 <print_array@plt>
lea    0xdc7(%rip),%r12
mov    %r12,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1050 <clean_array@plt>
mov    %rbp,%r14
mov    0x10(%rbp),%rdi
mov    %r15,%rsi
call   1060 <convert_long@plt>
mov    %eax,%ebp
mov    %r15,%rdi
lea    0xd67(%rip),%r13
mov    %r13,%rsi
call   1040 <print_array@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x6,%edx
mov    %ebp,%ecx
call   1070 <copyto_array@plt>
mov    %rbx,%rdi
lea    0xd4d(%rip),%rsi
call   1040 <print_array@plt>
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1080 <sum_arrays@plt>
mov    %rbp,%rdi
lea    0xd34(%rip),%rsi
call   1040 <print_array@plt>
mov    %r12,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1050 <clean_array@plt>
mov    0x18(%r14),%rdi
mov    %r15,%rsi
call   1060 <convert_long@plt>
mov    %eax,%ebp
mov    %r15,%rdi
mov    %r13,%rsi
call   1040 <print_array@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x9,%edx
mov    %ebp,%ecx
call   1070 <copyto_array@plt>
mov    %rbx,%rdi
lea    0xce6(%rip),%rsi
call   1040 <print_array@plt>
mov    %rsp,%r12
mov    %r12,%rdi
mov    %rbx,%rsi
call   1080 <sum_arrays@plt>
mov    %r12,%rdi
lea    0xccd(%rip),%r13
mov    %r13,%rsi
call   1040 <print_array@plt>
lea    0xce5(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1050 <clean_array@plt>
mov    0x20(%r14),%rdi
mov    %r15,%rsi
call   1060 <convert_long@plt>
mov    %eax,%ebp
mov    %r15,%rdi
lea    0xc8b(%rip),%rsi
call   1040 <print_array@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0xc,%edx
mov    %ebp,%ecx
call   1070 <copyto_array@plt>
mov    %rbx,%rdi
lea    0xc74(%rip),%rsi
call   1040 <print_array@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1080 <sum_arrays@plt>
mov    %r12,%rdi
mov    %r13,%rsi
call   1040 <print_array@plt>
lea    0xc7d(%rip),%rdi
call   1030 <puts@plt>
lea    0xc5e(%rip),%rsi
mov    %r12,%rdi
call   1040 <print_array@plt>
xor    %eax,%eax
add    $0x268,%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) {
%2 = alloca i64*
%3 = alloca [50 x i32]
%4 = alloca [50 x i32]
%5 = alloca [50 x i32]
%6 = alloca i32
%7 = alloca i32
store i64* %0, i64** %2
%8 = getelementptr inbounds [50 x i32], [50 x i32]* %4, i64 0, i64 0
%9 = call i32 @clean_array(i32* %8)
%10 = getelementptr inbounds [50 x i32], [50 x i32]* %5, i64 0, i64 0
%11 = call i32 @clean_array(i32* %10)
store i32 0, i32* %6
br label %12
12: ; preds = %41, %1
%13 = load i32, i32* %6
%14 = icmp slt i32 %13, 5
br i1 %14, label %15, label %44
15: ; preds = %12
%16 = getelementptr inbounds [50 x i32], [50 x i32]* %3, i64 0, i64 0
%17 = call i32 @clean_array(i32* %16)
%18 = load i64*, i64** %2
%19 = load i32, i32* %6
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i64, i64* %18, i64 %20
%22 = load i64, i64* %21
%23 = getelementptr inbounds [50 x i32], [50 x i32]* %5, i64 0, i64 0
%24 = call i32 @convert_long(i64 %22, i32* %23)
store i32 %24, i32* %7
%25 = getelementptr inbounds [50 x i32], [50 x i32]* %5, i64 0, i64 0
%26 = call i32 @print_array(i32* %25, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%27 = getelementptr inbounds [50 x i32], [50 x i32]* %3, i64 0, i64 0
%28 = getelementptr inbounds [50 x i32], [50 x i32]* %5, i64 0, i64 0
%29 = load i32, i32* %6
%30 = mul nsw i32 %29, 3
%31 = load i32, i32* %7
%32 = call i32 @copyto_array(i32* %27, i32* %28, i32 %30, i32 %31)
%33 = getelementptr inbounds [50 x i32], [50 x i32]* %3, i64 0, i64 0
%34 = call i32 @print_array(i32* %33, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%35 = getelementptr inbounds [50 x i32], [50 x i32]* %4, i64 0, i64 0
%36 = getelementptr inbounds [50 x i32], [50 x i32]* %3, i64 0, i64 0
%37 = call i32 @sum_arrays(i32* %35, i32* %36)
%38 = getelementptr inbounds [50 x i32], [50 x i32]* %4, i64 0, i64 0
%39 = call i32 @print_array(i32* %38, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%40 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
br label %41
41: ; preds = %15
%42 = load i32, i32* %6
%43 = add nsw i32 %42, 1
store i32 %43, i32* %6
br label %12
44: ; preds = %12
%45 = getelementptr inbounds [50 x i32], [50 x i32]* %4, i64 0, i64 0
%46 = call i32 @print_array(i32* %45, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
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) {
%2 = alloca [50 x i32]
%3 = alloca [50 x i32]
%4 = alloca [50 x i32]
%5 = bitcast [50 x i32]* %2 to i8*
%6 = bitcast [50 x i32]* %3 to i8*
%7 = bitcast [50 x i32]* %4 to i8*
%8 = getelementptr inbounds [50 x i32], [50 x i32]* %3, i64 0, i64 0
%9 = call i32 @clean_array(i32* %8)
%10 = getelementptr inbounds [50 x i32], [50 x i32]* %4, i64 0, i64 0
%11 = call i32 @clean_array(i32* %10)
%12 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 0
%13 = call i32 @clean_array(i32* %12)
%14 = load i64, i64* %0
%15 = call i32 @convert_long(i64 %14, i32* %10)
%16 = call i32 @print_array(i32* %10, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%17 = call i32 @copyto_array(i32* %12, i32* %10, i32 0, i32 %15)
%18 = call i32 @print_array(i32* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%19 = call i32 @sum_arrays(i32* %8, i32* %12)
%20 = call i32 @print_array(i32* %8, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
%22 = call i32 @clean_array(i32* %12)
%23 = getelementptr inbounds i64, i64* %0, i64 1
%24 = load i64, i64* %23
%25 = call i32 @convert_long(i64 %24, i32* %10)
%26 = call i32 @print_array(i32* %10, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%27 = call i32 @copyto_array(i32* %12, i32* %10, i32 3, i32 %25)
%28 = call i32 @print_array(i32* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%29 = call i32 @sum_arrays(i32* %8, i32* %12)
%30 = call i32 @print_array(i32* %8, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
%32 = call i32 @clean_array(i32* %12)
%33 = getelementptr inbounds i64, i64* %0, i64 2
%34 = load i64, i64* %33
%35 = call i32 @convert_long(i64 %34, i32* %10)
%36 = call i32 @print_array(i32* %10, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%37 = call i32 @copyto_array(i32* %12, i32* %10, i32 6, i32 %35)
%38 = call i32 @print_array(i32* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%39 = call i32 @sum_arrays(i32* %8, i32* %12)
%40 = call i32 @print_array(i32* %8, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%41 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
%42 = call i32 @clean_array(i32* %12)
%43 = getelementptr inbounds i64, i64* %0, i64 3
%44 = load i64, i64* %43
%45 = call i32 @convert_long(i64 %44, i32* %10)
%46 = call i32 @print_array(i32* %10, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%47 = call i32 @copyto_array(i32* %12, i32* %10, i32 9, i32 %45)
%48 = call i32 @print_array(i32* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%49 = call i32 @sum_arrays(i32* %8, i32* %12)
%50 = call i32 @print_array(i32* %8, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%51 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
%52 = call i32 @clean_array(i32* %12)
%53 = getelementptr inbounds i64, i64* %0, i64 4
%54 = load i64, i64* %53
%55 = call i32 @convert_long(i64 %54, i32* %10)
%56 = call i32 @print_array(i32* %10, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%57 = call i32 @copyto_array(i32* %12, i32* %10, i32 12, i32 %55)
%58 = call i32 @print_array(i32* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%59 = call i32 @sum_arrays(i32* %8, i32* %12)
%60 = call i32 @print_array(i32* %8, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%61 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
%62 = call i32 @print_array(i32* %8, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}