#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*/ MinMax3(int *, int, int *, int *);
double RAND_MAX;
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, int, int);
scalar_t__ rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  srand(time(NULL));
  int n = 10;
  int *vec = (int *)malloc(n * sizeof(int));
  for (int i = 0; i < n; i++) {
    vec[i] = 20 * ((double)rand() / RAND_MAX);
  }
  int min = 0;
  int max = 0;
  MinMax3(vec, n, &min, &max);
  printf("Min %d; Max %d\n", min, max);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
movl   $0xa,-0x8(%rbp)
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11ec <main+0x8c>
mov    $0x0,%al
call   1080 <rand@plt>
cvtsi2sd %rax,%xmm1
mov    0x2e29(%rip),%rax
divsd  (%rax),%xmm1
movsd  0xe35(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a0 <main+0x40>
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%esi
lea    -0x18(%rbp),%rdx
lea    -0x1c(%rbp),%rcx
call   1050 <MinMax3@plt>
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
lea    0xded(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
mov    $0x28,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1080 <rand@plt>
cvtsi2sd %rax,%xmm0
mov    0x2e56(%rip),%r14
divsd  (%r14),%xmm0
mulsd  0xe61(%rip),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,(%rbx)
xor    %eax,%eax
call   1080 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
divsd  (%r14),%xmm0
mulsd  0xe3f(%rip),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,0x4(%rbx)
xor    %eax,%eax
call   1080 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
divsd  (%r14),%xmm0
mulsd  0xe1c(%rip),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,0x8(%rbx)
xor    %eax,%eax
call   1080 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
divsd  (%r14),%xmm0
mulsd  0xdf9(%rip),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,0xc(%rbx)
xor    %eax,%eax
call   1080 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
divsd  (%r14),%xmm0
mulsd  0xdd6(%rip),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,0x10(%rbx)
xor    %eax,%eax
call   1080 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
divsd  (%r14),%xmm0
mulsd  0xdb3(%rip),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,0x14(%rbx)
xor    %eax,%eax
call   1080 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
divsd  (%r14),%xmm0
mulsd  0xd90(%rip),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,0x18(%rbx)
xor    %eax,%eax
call   1080 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
divsd  (%r14),%xmm0
mulsd  0xd6d(%rip),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,0x1c(%rbx)
xor    %eax,%eax
call   1080 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
divsd  (%r14),%xmm0
mulsd  0xd4a(%rip),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,0x20(%rbx)
xor    %eax,%eax
call   1080 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
divsd  (%r14),%xmm0
mulsd  0xd27(%rip),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,0x24(%rbx)
movl   $0x0,0x4(%rsp)
movl   $0x0,(%rsp)
lea    0x4(%rsp),%rdx
mov    %rsp,%rcx
mov    %rbx,%rdi
mov    $0xa,%esi
call   1050 <MinMax3@plt>
mov    0x4(%rsp),%esi
mov    (%rsp),%edx
lea    0xcf6(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@RAND_MAX = global double 0.000000e+00
@.str = [16 x i8] c"Min %d; Max %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 @time(i32* null)
%8 = call i32 @srand(i32 %7)
store i32 10, i32* %2
%9 = load i32, i32* %2
%10 = sext i32 %9 to i64
%11 = mul i64 %10, 4
%12 = trunc i64 %11 to i32
%13 = call i64 @malloc(i32 %12)
%14 = inttoptr i64 %13 to i32*
store i32* %14, i32** %3
store i32 0, i32* %4
br label %15
15: ; preds = %30, %0
%16 = load i32, i32* %4
%17 = load i32, i32* %2
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %33
19: ; preds = %15
%20 = call i64 (...) @rand()
%21 = sitofp i64 %20 to double
%22 = load double, double* @RAND_MAX
%23 = fdiv double %21, %22
%24 = fmul double 2.000000e+01, %23
%25 = fptosi double %24 to i32
%26 = load i32*, i32** %3
%27 = load i32, i32* %4
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i32, i32* %26, i64 %28
store i32 %25, i32* %29
br label %30
30: ; preds = %19
%31 = load i32, i32* %4
%32 = add nsw i32 %31, 1
store i32 %32, i32* %4
br label %15
33: ; preds = %15
store i32 0, i32* %5
store i32 0, i32* %6
%34 = load i32*, i32** %3
%35 = load i32, i32* %2
%36 = call i32 @MinMax3(i32* %34, i32 %35, i32* %5, i32* %6)
%37 = load i32, i32* %5
%38 = load i32, i32* %6
%39 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %37, i32 %38)
ret i32 0
}

LLVM IR (-O2):
@RAND_MAX = global double 0.000000e+00
@.str = [16 x i8] c"Min %d; Max %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = tail call i32 @time(i32* null)
%4 = tail call i32 @srand(i32 %3)
%5 = tail call i64 @malloc(i32 40)
%6 = inttoptr i64 %5 to i32*
%7 = tail call i64 (...) @rand()
%8 = sitofp i64 %7 to double
%9 = load double, double* @RAND_MAX
%10 = fdiv double %8, %9
%11 = fmul double %10, 2.000000e+01
%12 = fptosi double %11 to i32
store i32 %12, i32* %6
%13 = tail call i64 (...) @rand()
%14 = sitofp i64 %13 to double
%15 = load double, double* @RAND_MAX
%16 = fdiv double %14, %15
%17 = fmul double %16, 2.000000e+01
%18 = fptosi double %17 to i32
%19 = getelementptr inbounds i32, i32* %6, i64 1
store i32 %18, i32* %19
%20 = tail call i64 (...) @rand()
%21 = sitofp i64 %20 to double
%22 = load double, double* @RAND_MAX
%23 = fdiv double %21, %22
%24 = fmul double %23, 2.000000e+01
%25 = fptosi double %24 to i32
%26 = getelementptr inbounds i32, i32* %6, i64 2
store i32 %25, i32* %26
%27 = tail call i64 (...) @rand()
%28 = sitofp i64 %27 to double
%29 = load double, double* @RAND_MAX
%30 = fdiv double %28, %29
%31 = fmul double %30, 2.000000e+01
%32 = fptosi double %31 to i32
%33 = getelementptr inbounds i32, i32* %6, i64 3
store i32 %32, i32* %33
%34 = tail call i64 (...) @rand()
%35 = sitofp i64 %34 to double
%36 = load double, double* @RAND_MAX
%37 = fdiv double %35, %36
%38 = fmul double %37, 2.000000e+01
%39 = fptosi double %38 to i32
%40 = getelementptr inbounds i32, i32* %6, i64 4
store i32 %39, i32* %40
%41 = tail call i64 (...) @rand()
%42 = sitofp i64 %41 to double
%43 = load double, double* @RAND_MAX
%44 = fdiv double %42, %43
%45 = fmul double %44, 2.000000e+01
%46 = fptosi double %45 to i32
%47 = getelementptr inbounds i32, i32* %6, i64 5
store i32 %46, i32* %47
%48 = tail call i64 (...) @rand()
%49 = sitofp i64 %48 to double
%50 = load double, double* @RAND_MAX
%51 = fdiv double %49, %50
%52 = fmul double %51, 2.000000e+01
%53 = fptosi double %52 to i32
%54 = getelementptr inbounds i32, i32* %6, i64 6
store i32 %53, i32* %54
%55 = tail call i64 (...) @rand()
%56 = sitofp i64 %55 to double
%57 = load double, double* @RAND_MAX
%58 = fdiv double %56, %57
%59 = fmul double %58, 2.000000e+01
%60 = fptosi double %59 to i32
%61 = getelementptr inbounds i32, i32* %6, i64 7
store i32 %60, i32* %61
%62 = tail call i64 (...) @rand()
%63 = sitofp i64 %62 to double
%64 = load double, double* @RAND_MAX
%65 = fdiv double %63, %64
%66 = fmul double %65, 2.000000e+01
%67 = fptosi double %66 to i32
%68 = getelementptr inbounds i32, i32* %6, i64 8
store i32 %67, i32* %68
%69 = tail call i64 (...) @rand()
%70 = sitofp i64 %69 to double
%71 = load double, double* @RAND_MAX
%72 = fdiv double %70, %71
%73 = fmul double %72, 2.000000e+01
%74 = fptosi double %73 to i32
%75 = getelementptr inbounds i32, i32* %6, i64 9
store i32 %74, i32* %75
%76 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%77 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%78 = call i32 @MinMax3(i32* %6, i32 10, i32* %1, i32* %2)
%79 = load i32, i32* %1
%80 = load i32, i32* %2
%81 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %79, i32 %80)
ret i32 0
}