#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 rand();
void arreglo(int *a, int *b) {
  int arr[10];
  int max, index, valor;
  for (int i = 0; i < 10; i++) {
    valor = (rand() % 100) + 1;
    arr[i] = valor;
    if (i == 0) {
      max = valor;
      index = i;
    } else if (valor > max) {
      max = valor;
      index = i;
    }
  }
  *a = max;
  *b = index;
}


x86 assembly (clang, -O0):
<arreglo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x50(%rbp)
cmpl   $0xa,-0x50(%rbp)
jge    119c <arreglo+0x8c>
mov    $0x0,%al
call   1030 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x4c(%rbp)
mov    -0x4c(%rbp),%ecx
movslq -0x50(%rbp),%rax
mov    %ecx,-0x40(%rbp,%rax,4)
cmpl   $0x0,-0x50(%rbp)
jne    116c <arreglo+0x5c>
mov    -0x4c(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x50(%rbp),%eax
mov    %eax,-0x48(%rbp)
jmp    1189 <arreglo+0x79>
mov    -0x4c(%rbp),%eax
cmp    -0x44(%rbp),%eax
jle    1184 <arreglo+0x74>
mov    -0x4c(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x50(%rbp),%eax
mov    %eax,-0x48(%rbp)
jmp    1189 <arreglo+0x79>
jmp    118e <arreglo+0x7e>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    1127 <arreglo+0x17>
mov    -0x44(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x48(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<arreglo>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
xor    %eax,%eax
call   1030 <rand@plt>
movslq %eax,%rbx
imul   $0x51eb851f,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%ebx
xor    %eax,%eax
call   1030 <rand@plt>
movslq %eax,%r12
imul   $0x51eb851f,%r12,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%r12d
xor    %r13d,%r13d
cmp    %ebx,%r12d
setg   %r13b
cmovle %ebx,%r12d
xor    %eax,%eax
call   1030 <rand@plt>
movslq %eax,%rbx
imul   $0x51eb851f,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%ebx
cmp    %r12d,%ebx
mov    $0x2,%ebp
cmovle %r13d,%ebp
cmovle %r12d,%ebx
xor    %eax,%eax
call   1030 <rand@plt>
movslq %eax,%r12
imul   $0x51eb851f,%r12,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%r12d
cmp    %ebx,%r12d
mov    $0x3,%r13d
cmovle %ebp,%r13d
cmovle %ebx,%r12d
xor    %eax,%eax
call   1030 <rand@plt>
movslq %eax,%rbx
imul   $0x51eb851f,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%ebx
cmp    %r12d,%ebx
mov    $0x4,%ebp
cmovle %r13d,%ebp
cmovle %r12d,%ebx
xor    %eax,%eax
call   1030 <rand@plt>
movslq %eax,%r12
imul   $0x51eb851f,%r12,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%r12d
cmp    %ebx,%r12d
mov    $0x5,%r13d
cmovle %ebp,%r13d
cmovle %ebx,%r12d
xor    %eax,%eax
call   1030 <rand@plt>
movslq %eax,%rbx
imul   $0x51eb851f,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%ebx
cmp    %r12d,%ebx
mov    $0x6,%ebp
cmovle %r13d,%ebp
cmovle %r12d,%ebx
xor    %eax,%eax
call   1030 <rand@plt>
movslq %eax,%r12
imul   $0x51eb851f,%r12,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%r12d
cmp    %ebx,%r12d
mov    $0x7,%r13d
cmovle %ebp,%r13d
cmovle %ebx,%r12d
xor    %eax,%eax
call   1030 <rand@plt>
movslq %eax,%rbx
imul   $0x51eb851f,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%ebx
cmp    %r12d,%ebx
mov    $0x8,%ebp
cmovle %r13d,%ebp
cmovle %r12d,%ebx
xor    %eax,%eax
call   1030 <rand@plt>
cltq
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rcx
add    %edx,%ecx
imul   $0x64,%ecx,%ecx
sub    %ecx,%eax
cmp    %ebx,%eax
mov    $0x9,%ecx
cmovle %ebp,%ecx
cmovle %ebx,%eax
add    $0x1,%eax
mov    %eax,(%r15)
mov    %ecx,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @arreglo(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca [10 x i32]
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
store i32 0, i32* %9
br label %10
10: ; preds = %35, %2
%11 = load i32, i32* %9
%12 = icmp slt i32 %11, 10
br i1 %12, label %13, label %38
13: ; preds = %10
%14 = call i32 (...) @rand()
%15 = srem i32 %14, 100
%16 = add nsw i32 %15, 1
store i32 %16, i32* %8
%17 = load i32, i32* %8
%18 = load i32, i32* %9
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 %19
store i32 %17, i32* %20
%21 = load i32, i32* %9
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %13
%24 = load i32, i32* %8
store i32 %24, i32* %6
%25 = load i32, i32* %9
store i32 %25, i32* %7
br label %34
26: ; preds = %13
%27 = load i32, i32* %8
%28 = load i32, i32* %6
%29 = icmp sgt i32 %27, %28
br i1 %29, label %30, label %33
30: ; preds = %26
%31 = load i32, i32* %8
store i32 %31, i32* %6
%32 = load i32, i32* %9
store i32 %32, i32* %7
br label %33
33: ; preds = %30, %26
br label %34
34: ; preds = %33, %23
br label %35
35: ; preds = %34
%36 = load i32, i32* %9
%37 = add nsw i32 %36, 1
store i32 %37, i32* %9
br label %10
38: ; preds = %10
%39 = load i32, i32* %6
%40 = load i32*, i32** %3
store i32 %39, i32* %40
%41 = load i32, i32* %7
%42 = load i32*, i32** %4
store i32 %41, i32* %42
ret void
}

LLVM IR (-O2):
define void @arreglo(i32* nocapture writeonly %0, i32* nocapture writeonly %1) {
%3 = tail call i32 (...) @rand()
%4 = srem i32 %3, 100
%5 = tail call i32 (...) @rand()
%6 = srem i32 %5, 100
%7 = icmp sgt i32 %6, %4
%8 = zext i1 %7 to i32
%9 = select i1 %7, i32 %6, i32 %4
%10 = tail call i32 (...) @rand()
%11 = srem i32 %10, 100
%12 = icmp sgt i32 %11, %9
%13 = select i1 %12, i32 2, i32 %8
%14 = select i1 %12, i32 %11, i32 %9
%15 = tail call i32 (...) @rand()
%16 = srem i32 %15, 100
%17 = icmp sgt i32 %16, %14
%18 = select i1 %17, i32 3, i32 %13
%19 = select i1 %17, i32 %16, i32 %14
%20 = tail call i32 (...) @rand()
%21 = srem i32 %20, 100
%22 = icmp sgt i32 %21, %19
%23 = select i1 %22, i32 4, i32 %18
%24 = select i1 %22, i32 %21, i32 %19
%25 = tail call i32 (...) @rand()
%26 = srem i32 %25, 100
%27 = icmp sgt i32 %26, %24
%28 = select i1 %27, i32 5, i32 %23
%29 = select i1 %27, i32 %26, i32 %24
%30 = tail call i32 (...) @rand()
%31 = srem i32 %30, 100
%32 = icmp sgt i32 %31, %29
%33 = select i1 %32, i32 6, i32 %28
%34 = select i1 %32, i32 %31, i32 %29
%35 = tail call i32 (...) @rand()
%36 = srem i32 %35, 100
%37 = icmp sgt i32 %36, %34
%38 = select i1 %37, i32 7, i32 %33
%39 = select i1 %37, i32 %36, i32 %34
%40 = tail call i32 (...) @rand()
%41 = srem i32 %40, 100
%42 = icmp sgt i32 %41, %39
%43 = select i1 %42, i32 8, i32 %38
%44 = select i1 %42, i32 %41, i32 %39
%45 = tail call i32 (...) @rand()
%46 = srem i32 %45, 100
%47 = icmp sgt i32 %46, %44
%48 = select i1 %47, i32 9, i32 %43
%49 = select i1 %47, i32 %46, i32 %44
%50 = add nsw i32 %49, 1
store i32 %50, i32* %0
store i32 %48, i32* %1
ret void
}