#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 */
struct tms {
  int dummy;
};
typedef double clock_t;

/* Variables and functions */
int /*<<< orphan*/ free(long *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, int, ...);
int rand();
double times(struct tms *);
int main(int argc, char **argv) {
  int N = 100000;
  long *array_dinamico = (long *)malloc(N * sizeof(long));
  long mayor = 0;
  int i, x;
  for (i = 0; i < N; i++) {
    array_dinamico[i] = rand() % 10000;
  }
  struct tms buf;
  clock_t t1 = times(&buf);
  for (i = 0; i < N; i++) {
    if (array_dinamico[i] > mayor) {
      mayor = array_dinamico[i];
    }
    for (x = 0; x < 100000; x++) {
    }
  }
  clock_t t2 = times(&buf);
  printf("El mayor es %lu\n", mayor);
  free(array_dinamico);
  printf("El tiempo de ejecucion con %d veces es %f\n", N, (float)t2 - t1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x186a0,-0x14(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11c7 <main+0x77>
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x2710,%ecx
cltd
idiv   %ecx
movslq %edx,%rdx
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    118f <main+0x3f>
lea    -0x38(%rbp),%rdi
call   1060 <times@plt>
movsd  %xmm0,-0x40(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1248 <main+0xf8>
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
cmp    -0x28(%rbp),%rax
jle    120e <main+0xbe>
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x30(%rbp)
cmpl   $0x186a0,-0x30(%rbp)
jge    1235 <main+0xe5>
jmp    1227 <main+0xd7>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1215 <main+0xc5>
jmp    123a <main+0xea>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11dc <main+0x8c>
lea    -0x38(%rbp),%rdi
call   1060 <times@plt>
movsd  %xmm0,-0x48(%rbp)
mov    -0x28(%rbp),%rax
mov    %eax,%esi
lea    0xd9d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x14(%rbp),%esi
movsd  -0x48(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
cvtss2sd %xmm0,%xmm0
subsd  -0x40(%rbp),%xmm0
lea    0xd82(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    $0xc3500,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1070 <rand@plt>
cltq
imul   $0x68db8bad,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x2c,%rcx
add    %edx,%ecx
imul   $0x2710,%ecx,%ecx
sub    %ecx,%eax
cltq
mov    %rax,(%r14,%rbx,8)
add    $0x1,%rbx
cmp    $0x186a0,%rbx
jne    1170 <main+0x20>
mov    %rsp,%rdi
call   1060 <times@plt>
movsd  %xmm0,0x10(%rsp)
mov    $0x4,%eax
xor    %ebx,%ebx
jmp    11cc <main+0x7c>
nop
add    $0x5,%rax
cmp    $0x186a4,%rax
je     120e <main+0xbe>
mov    -0x20(%r14,%rax,8),%rcx
cmp    %rbx,%rcx
jg     11d9 <main+0x89>
mov    %rbx,%rcx
mov    -0x18(%r14,%rax,8),%rdx
cmp    %rcx,%rdx
jg     11e6 <main+0x96>
mov    %rcx,%rdx
mov    -0x10(%r14,%rax,8),%rcx
cmp    %rdx,%rcx
jg     11f3 <main+0xa3>
mov    %rdx,%rcx
mov    -0x8(%r14,%rax,8),%rdx
cmp    %rcx,%rdx
jg     1200 <main+0xb0>
mov    %rcx,%rdx
mov    (%r14,%rax,8),%rbx
cmp    %rdx,%rbx
jg     11c0 <main+0x70>
mov    %rdx,%rbx
jmp    11c0 <main+0x70>
mov    %rsp,%rdi
call   1060 <times@plt>
movsd  %xmm0,0x8(%rsp)
lea    0xddd(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
call   1030 <free@plt>
movsd  0x8(%rsp),%xmm0
cvtsd2ss %xmm0,%xmm0
cvtss2sd %xmm0,%xmm0
subsd  0x10(%rsp),%xmm0
lea    0xdc2(%rip),%rdi
mov    $0x186a0,%esi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tms = type { i32 }
@.str = [17 x i8] c"El mayor es %lu\0A\00"
@.str.1 = [43 x i8] c"El tiempo de ejecucion con %d veces es %f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i64*
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32
%11 = alloca %struct.tms
%12 = alloca double
%13 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 100000, i32* %6
%14 = load i32, i32* %6
%15 = sext i32 %14 to i64
%16 = mul i64 %15, 8
%17 = trunc i64 %16 to i32
%18 = call i64 @malloc(i32 %17)
%19 = inttoptr i64 %18 to i64*
store i64* %19, i64** %7
store i64 0, i64* %8
store i32 0, i32* %9
br label %20
20: ; preds = %32, %2
%21 = load i32, i32* %9
%22 = load i32, i32* %6
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %35
24: ; preds = %20
%25 = call i32 (...) @rand()
%26 = srem i32 %25, 10000
%27 = sext i32 %26 to i64
%28 = load i64*, i64** %7
%29 = load i32, i32* %9
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i64, i64* %28, i64 %30
store i64 %27, i64* %31
br label %32
32: ; preds = %24
%33 = load i32, i32* %9
%34 = add nsw i32 %33, 1
store i32 %34, i32* %9
br label %20
35: ; preds = %20
%36 = call double @times(%struct.tms* %11)
store double %36, double* %12
store i32 0, i32* %9
br label %37
37: ; preds = %64, %35
%38 = load i32, i32* %9
%39 = load i32, i32* %6
%40 = icmp slt i32 %38, %39
br i1 %40, label %41, label %67
41: ; preds = %37
%42 = load i64*, i64** %7
%43 = load i32, i32* %9
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i64, i64* %42, i64 %44
%46 = load i64, i64* %45
%47 = load i64, i64* %8
%48 = icmp sgt i64 %46, %47
br i1 %48, label %49, label %55
49: ; preds = %41
%50 = load i64*, i64** %7
%51 = load i32, i32* %9
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i64, i64* %50, i64 %52
%54 = load i64, i64* %53
store i64 %54, i64* %8
br label %55
55: ; preds = %49, %41
store i32 0, i32* %10
br label %56
56: ; preds = %60, %55
%57 = load i32, i32* %10
%58 = icmp slt i32 %57, 100000
br i1 %58, label %59, label %63
59: ; preds = %56
br label %60
60: ; preds = %59
%61 = load i32, i32* %10
%62 = add nsw i32 %61, 1
store i32 %62, i32* %10
br label %56
63: ; preds = %56
br label %64
64: ; preds = %63
%65 = load i32, i32* %9
%66 = add nsw i32 %65, 1
store i32 %66, i32* %9
br label %37
67: ; preds = %37
%68 = call double @times(%struct.tms* %11)
store double %68, double* %13
%69 = load i64, i64* %8
%70 = trunc i64 %69 to i32
%71 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %70)
%72 = load i64*, i64** %7
%73 = call i32 @free(i64* %72)
%74 = load i32, i32* %6
%75 = load double, double* %13
%76 = fptrunc double %75 to float
%77 = fpext float %76 to double
%78 = load double, double* %12
%79 = fsub double %77, %78
%80 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i32 %74, double %79)
ret i32 0
}

LLVM IR (-O2):
%struct.tms = type { i32 }
@.str = [17 x i8] c"El mayor es %lu\0A\00"
@.str.1 = [43 x i8] c"El tiempo de ejecucion con %d veces es %f\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.tms
%4 = tail call i64 @malloc(i32 800000)
%5 = inttoptr i64 %4 to i64*
br label %6
6: ; preds = %2, %6
%7 = phi i64 [ 0, %2 ], [ %12, %6 ]
%8 = tail call i32 (...) @rand()
%9 = srem i32 %8, 10000
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i64, i64* %5, i64 %7
store i64 %10, i64* %11
%12 = add nuw nsw i64 %7, 1
%13 = icmp eq i64 %12, 100000
br i1 %13, label %14, label %6
14: ; preds = %6
%15 = bitcast %struct.tms* %3 to i8*
%16 = call double @times(%struct.tms* %3)
br label %17
17: ; preds = %17, %14
%18 = phi i64 [ 0, %14 ], [ %44, %17 ]
%19 = phi i64 [ 0, %14 ], [ %43, %17 ]
%20 = getelementptr inbounds i64, i64* %5, i64 %18
%21 = load i64, i64* %20
%22 = icmp sgt i64 %21, %19
%23 = select i1 %22, i64 %21, i64 %19
%24 = add nuw nsw i64 %18, 1
%25 = getelementptr inbounds i64, i64* %5, i64 %24
%26 = load i64, i64* %25
%27 = icmp sgt i64 %26, %23
%28 = select i1 %27, i64 %26, i64 %23
%29 = add nuw nsw i64 %18, 2
%30 = getelementptr inbounds i64, i64* %5, i64 %29
%31 = load i64, i64* %30
%32 = icmp sgt i64 %31, %28
%33 = select i1 %32, i64 %31, i64 %28
%34 = add nuw nsw i64 %18, 3
%35 = getelementptr inbounds i64, i64* %5, i64 %34
%36 = load i64, i64* %35
%37 = icmp sgt i64 %36, %33
%38 = select i1 %37, i64 %36, i64 %33
%39 = add nuw nsw i64 %18, 4
%40 = getelementptr inbounds i64, i64* %5, i64 %39
%41 = load i64, i64* %40
%42 = icmp sgt i64 %41, %38
%43 = select i1 %42, i64 %41, i64 %38
%44 = add nuw nsw i64 %18, 5
%45 = icmp eq i64 %44, 100000
br i1 %45, label %46, label %17
46: ; preds = %17
%47 = call double @times(%struct.tms* %3)
%48 = trunc i64 %43 to i32
%49 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %48)
%50 = tail call i32 @free(i64* %5)
%51 = fptrunc double %47 to float
%52 = fpext float %51 to double
%53 = fsub double %52, %16
%54 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i32 100000, double %53)
ret i32 0
}