#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*/ imprimir_arreglo(int *);
int /*<<< orphan*/ mergesort(int *, int, int *);
int /*<<< orphan*/ printf(char *, int /*<<< orphan*/);
int main() {
  int arreglo[10] = {1, 4, 20, 10, 3, 8, 9, 14, 21, 6};
  int iteracion = 1;
  printf("Iteracion #%03d ", iteracion++);
  imprimir_arreglo(arreglo);
  mergesort(arreglo, 10, &iteracion);
  printf("Iteracion #%03d ", iteracion++);
  imprimir_arreglo(arreglo);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xea6(%rip),%rsi
mov    $0x28,%edx
call   1040 <memcpy@plt>
movl   $0x1,-0x34(%rbp)
mov    -0x34(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
lea    0xeab(%rip),%rdi
call   1030 <printf@plt>
lea    -0x30(%rbp),%rdi
call   1050 <imprimir_arreglo@plt>
lea    -0x30(%rbp),%rdi
mov    $0xa,%esi
lea    -0x34(%rbp),%rdx
call   1060 <mergesort@plt>
mov    -0x34(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
lea    0xe79(%rip),%rdi
call   1030 <printf@plt>
lea    -0x30(%rbp),%rdi
call   1050 <imprimir_arreglo@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    0xee2(%rip),%rax
mov    %rax,0x30(%rsp)
movaps 0xec6(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xeaa(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movl   $0x2,0xc(%rsp)
lea    0xebe(%rip),%r14
mov    %r14,%rdi
mov    $0x1,%esi
call   1030 <printf@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <imprimir_arreglo@plt>
lea    0xc(%rsp),%rdx
mov    %rbx,%rdi
mov    $0xa,%esi
call   1050 <mergesort@plt>
mov    0xc(%rsp),%esi
lea    0x1(%rsi),%eax
mov    %eax,0xc(%rsp)
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1040 <imprimir_arreglo@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.arreglo = [10 x i32] [i32 1, i32 4, i32 20, i32 10, i32 3, i32 8, i32 9, i32 14, i32 21, i32 6]
@.str = [17 x i8] c"Iteracion #%03d \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i32]
%3 = alloca i32
store i32 0, i32* %1
%4 = bitcast [10 x i32]* %2 to i8*
store i32 1, i32* %3
%5 = load i32, i32* %3
%6 = add nsw i32 %5, 1
store i32 %6, i32* %3
%7 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %5)
%8 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%9 = call i32 @imprimir_arreglo(i32* %8)
%10 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%11 = call i32 @mergesort(i32* %10, i32 10, i32* %3)
%12 = load i32, i32* %3
%13 = add nsw i32 %12, 1
store i32 %13, i32* %3
%14 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %12)
%15 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%16 = call i32 @imprimir_arreglo(i32* %15)
ret i32 0
}

LLVM IR (-O2):
@__const.main.arreglo = [10 x i32] [i32 1, i32 4, i32 20, i32 10, i32 3, i32 8, i32 9, i32 14, i32 21, i32 6]
@.str = [17 x i8] c"Iteracion #%03d \00"
define i32 @main() {
%1 = alloca [10 x i32]
%2 = alloca i32
%3 = bitcast [10 x i32]* %1 to i8*
%4 = bitcast i32* %2 to i8*
store i32 2, i32* %2
%5 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 1)
%6 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%7 = call i32 @imprimir_arreglo(i32* %6)
%8 = call i32 @mergesort(i32* %6, i32 10, i32* %2)
%9 = load i32, i32* %2
%10 = add nsw i32 %9, 1
store i32 %10, i32* %2
%11 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %9)
%12 = call i32 @imprimir_arreglo(i32* %6)
ret i32 0
}