#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*/ putchar(char);
int rand();
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
void crearArreglo(int *arreglo, int cantidad) {
  int x = 0, cont = 0;
  srand((unsigned)time(NULL));
  for (x = 0; x < cantidad; x++)
    arreglo[x] = (rand() % 2001) - 1000;
  printf("El orden del arreglo original es:\n");
  for (x = 0; x < cantidad; x++) {
    if (cont % 10 == 0)
      putchar('\n');
    printf("%5d  ", arreglo[x]);
    cont++;
  }
  printf("\n\n");
}


x86 assembly (clang, -O0):
<crearArreglo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11be <crearArreglo+0x6e>
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x7d1,%ecx
cltd
idiv   %ecx
sub    $0x3e8,%edx
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1184 <crearArreglo+0x34>
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    122d <crearArreglo+0xdd>
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11fd <crearArreglo+0xad>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11d3 <crearArreglo+0x83>
lea    0xdf5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<crearArreglo>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %rdi,%r12
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
test   %r14d,%r14d
jle    1229 <crearArreglo+0xc9>
mov    %r14d,%r13d
xor    %ebx,%ebx
nopl   (%rax)
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0x4180d4e3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x29,%rcx
add    %edx,%ecx
imul   $0x7d1,%ecx,%ecx
neg    %ecx
add    %ecx,%eax
add    $0xfffffc18,%eax
mov    %eax,(%r12,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1190 <crearArreglo+0x30>
lea    0xe36(%rip),%rdi
call   1040 <puts@plt>
test   %r14d,%r14d
jle    1235 <crearArreglo+0xd5>
mov    $0xcccccccd,%r15d
lea    0xe19(%rip),%r14
xor    %ebx,%ebx
xor    %ebp,%ebp
jmp    120a <crearArreglo+0xaa>
nopl   (%rax)
mov    (%r12,%rbp,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbp
add    $0xffffffff,%ebx
cmp    %rbp,%r13
je     1235 <crearArreglo+0xd5>
mov    %ebp,%eax
imul   %r15,%rax
shr    $0x23,%rax
lea    (%rax,%rax,4),%eax
add    %eax,%eax
add    %ebx,%eax
jne    11f0 <crearArreglo+0x90>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    11f0 <crearArreglo+0x90>
lea    0xdd6(%rip),%rdi
call   1040 <puts@plt>
lea    0xdec(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>

LLVM IR (-O0):
@.str = [35 x i8] c"El orden del arreglo original es:\0A\00"
@.str.1 = [6 x i8] c"%5d \00"
@.str.2 = [3 x i8] c"\0A\0A\00"
define void @crearArreglo(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
%7 = call i64 @time(i32* null)
%8 = trunc i64 %7 to i32
%9 = call i32 @srand(i32 %8)
store i32 0, i32* %5
br label %10
10: ; preds = %22, %2
%11 = load i32, i32* %5
%12 = load i32, i32* %4
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %25
14: ; preds = %10
%15 = call i32 (...) @rand()
%16 = srem i32 %15, 2001
%17 = sub nsw i32 %16, 1000
%18 = load i32*, i32** %3
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %18, i64 %20
store i32 %17, i32* %21
br label %22
22: ; preds = %14
%23 = load i32, i32* %5
%24 = add nsw i32 %23, 1
store i32 %24, i32* %5
br label %10
25: ; preds = %10
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %5
br label %27
27: ; preds = %46, %25
%28 = load i32, i32* %5
%29 = load i32, i32* %4
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %49
31: ; preds = %27
%32 = load i32, i32* %6
%33 = srem i32 %32, 10
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %31
%36 = call i32 @putchar(i8 signext 10)
br label %37
37: ; preds = %35, %31
%38 = load i32*, i32** %3
%39 = load i32, i32* %5
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i32, i32* %38, i64 %40
%42 = load i32, i32* %41
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %42)
%44 = load i32, i32* %6
%45 = add nsw i32 %44, 1
store i32 %45, i32* %6
br label %46
46: ; preds = %37
%47 = load i32, i32* %5
%48 = add nsw i32 %47, 1
store i32 %48, i32* %5
br label %27
49: ; preds = %27
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.1 = [6 x i8] c"%5d \00"
@str = [34 x i8] c"El orden del arreglo original es:\00"
@str.3 = [2 x i8] c"\0A\00"
define void @crearArreglo(i32* nocapture %0, i32 %1) {
%3 = tail call i64 @time(i32* null)
%4 = trunc i64 %3 to i32
%5 = tail call i32 @srand(i32 %4)
%6 = icmp sgt i32 %1, 0
br i1 %6, label %9, label %7
7: ; preds = %2
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
br label %36
9: ; preds = %2
%10 = zext i32 %1 to i64
br label %11
11: ; preds = %9, %11
%12 = phi i64 [ 0, %9 ], [ %17, %11 ]
%13 = tail call i32 (...) @rand()
%14 = srem i32 %13, 2001
%15 = add nsw i32 %14, -1000
%16 = getelementptr inbounds i32, i32* %0, i64 %12
store i32 %15, i32* %16
%17 = add nuw nsw i64 %12, 1
%18 = icmp eq i64 %17, %10
br i1 %18, label %19, label %11
19: ; preds = %11
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
br i1 %6, label %21, label %36
21: ; preds = %19
%22 = zext i32 %1 to i64
br label %23
23: ; preds = %21, %30
%24 = phi i64 [ 0, %21 ], [ %34, %30 ]
%25 = trunc i64 %24 to i32
%26 = urem i32 %25, 10
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %23
%29 = tail call i32 @putchar(i8 signext 10)
br label %30
30: ; preds = %28, %23
%31 = getelementptr inbounds i32, i32* %0, i64 %24
%32 = load i32, i32* %31
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %32)
%34 = add nuw nsw i64 %24, 1
%35 = icmp eq i64 %34, %22
br i1 %35, label %36, label %23
36: ; preds = %30, %7, %19
%37 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.3, i64 0, i64 0))
ret void
}