#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*/ fisher_yates_shuffle(int, char **, char **);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, double, double);
int /*<<< orphan*/ free(char **);
scalar_t__ malloc(int);
int /*<<< orphan*/ stdout;
int time_test(int, int, char **, char *, char *, double *, double *);
void time_compare(int n, char *ps[], char *s, char *end) {
  int r;
  int i;
  int repeat;
  double t_set, t_reg;
  double total_set, total_reg;
  char **cps;
  cps = (char **)malloc(sizeof(char *) * n);
  if (cps == 0)
    return;
  repeat = 100 / n;
  total_set = total_reg = 0.0;
  for (i = 0; i < n; i++) {
    fisher_yates_shuffle(n, ps, cps);
    r = time_test(repeat, n, cps, s, end, &t_set, &t_reg);
    if (r != 0)
      return;
    total_set += t_set;
    total_reg += t_reg;
  }
  free(cps);
  fprintf(stdout, "POS lead: %6.2lfmsec.  REG lead: %6.2lfmsec.\n",
          total_set * 1000.0, total_reg * 1000.0);
}


x86 assembly (clang, -O0):
<time_compare>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
jne    118a <time_compare+0x3a>
jmp    1262 <time_compare+0x112>
mov    $0x64,%eax
cltd
idivl  -0x4(%rbp)
mov    %eax,-0x2c(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    122a <time_compare+0xda>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x58(%rbp),%rdx
call   1060 <fisher_yates_shuffle@plt>
mov    -0x2c(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    -0x58(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
lea    -0x38(%rbp),%r9
lea    -0x40(%rbp),%rax
mov    %rax,(%rsp)
call   1040 <time_test@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     11fe <time_compare+0xae>
jmp    1262 <time_compare+0x112>
movsd  -0x38(%rbp),%xmm0
addsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x40(%rbp),%xmm0
addsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11ad <time_compare+0x5d>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
mov    0x2da6(%rip),%rax
mov    (%rax),%edi
movsd  0xdbc(%rip),%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  0xdaf(%rip),%xmm1
mulsd  -0x50(%rbp),%xmm1
lea    0xdab(%rip),%rsi
call   1050 <fprintf@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<time_compare>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rcx,0x20(%rsp)
mov    %rdx,%r15
mov    %rsi,%r12
mov    %edi,%ebx
lea    0x0(,%rbx,8),%edi
call   1070 <malloc@plt>
test   %rax,%rax
je     123a <time_compare+0xea>
mov    %rax,%r13
mov    $0x64,%eax
xor    %edx,%edx
idiv   %ebx
test   %ebx,%ebx
jle    1205 <time_compare+0xb5>
mov    %eax,%ebp
xorpd  %xmm1,%xmm1
mov    %ebx,%r14d
nopl   0x0(%rax)
movapd %xmm1,0x10(%rsp)
mov    %ebx,%edi
mov    %r12,%rsi
mov    %r13,%rdx
call   1060 <fisher_yates_shuffle@plt>
lea    0x28(%rsp),%rax
mov    %rax,(%rsp)
mov    %ebp,%edi
mov    %ebx,%esi
mov    %r13,%rdx
mov    %r15,%rcx
mov    0x20(%rsp),%r8
lea    0x30(%rsp),%r9
call   1040 <time_test@plt>
test   %eax,%eax
jne    123a <time_compare+0xea>
movsd  0x30(%rsp),%xmm0
movhpd 0x28(%rsp),%xmm0
movapd 0x10(%rsp),%xmm1
addpd  %xmm0,%xmm1
add    $0xffffffff,%r14d
jne    11a0 <time_compare+0x50>
mulpd  0xe03(%rip),%xmm1
movapd %xmm1,0x10(%rsp)
jmp    120f <time_compare+0xbf>
xorpd  %xmm0,%xmm0
movapd %xmm0,0x10(%rsp)
mov    %r13,%rdi
call   1030 <free@plt>
mov    0x2dc2(%rip),%rax
mov    (%rax),%edi
movapd 0x10(%rsp),%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
lea    0xddb(%rip),%rsi
call   1050 <fprintf@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [46 x i8] c"POS lead: %6.2lfmsec. REG lead: %6.2lfmsec.\0A\00"
define void @time_compare(i32 %0, i8** %1, i8* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca i8**
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = mul i64 8, %18
%20 = trunc i64 %19 to i32
%21 = call i64 @malloc(i32 %20)
%22 = inttoptr i64 %21 to i8**
store i8** %22, i8*** %16
%23 = load i8**, i8*** %16
%24 = icmp eq i8** %23, null
br i1 %24, label %25, label %26
25: ; preds = %4
br label %66
26: ; preds = %4
%27 = load i32, i32* %5
%28 = sdiv i32 100, %27
store i32 %28, i32* %11
store double 0.000000e+00, double* %15
store double 0.000000e+00, double* %14
store i32 0, i32* %10
br label %29
29: ; preds = %54, %26
%30 = load i32, i32* %10
%31 = load i32, i32* %5
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %57
33: ; preds = %29
%34 = load i32, i32* %5
%35 = load i8**, i8*** %6
%36 = load i8**, i8*** %16
%37 = call i32 @fisher_yates_shuffle(i32 %34, i8** %35, i8** %36)
%38 = load i32, i32* %11
%39 = load i32, i32* %5
%40 = load i8**, i8*** %16
%41 = load i8*, i8** %7
%42 = load i8*, i8** %8
%43 = call i32 @time_test(i32 %38, i32 %39, i8** %40, i8* %41, i8* %42, double* %12, double* %13)
store i32 %43, i32* %9
%44 = load i32, i32* %9
%45 = icmp ne i32 %44, 0
br i1 %45, label %46, label %47
46: ; preds = %33
br label %66
47: ; preds = %33
%48 = load double, double* %12
%49 = load double, double* %14
%50 = fadd double %49, %48
store double %50, double* %14
%51 = load double, double* %13
%52 = load double, double* %15
%53 = fadd double %52, %51
store double %53, double* %15
br label %54
54: ; preds = %47
%55 = load i32, i32* %10
%56 = add nsw i32 %55, 1
store i32 %56, i32* %10
br label %29
57: ; preds = %29
%58 = load i8**, i8*** %16
%59 = call i32 @free(i8** %58)
%60 = load i32, i32* @stdout
%61 = load double, double* %14
%62 = fmul double %61, 1.000000e+03
%63 = load double, double* %15
%64 = fmul double %63, 1.000000e+03
%65 = call i32 @fprintf(i32 %60, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), double %62, double %64)
br label %66
66: ; preds = %57, %46, %25
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [46 x i8] c"POS lead: %6.2lfmsec. REG lead: %6.2lfmsec.\0A\00"
define void @time_compare(i32 %0, i8** %1, i8* %2, i8* %3) {
%5 = alloca double
%6 = alloca double
%7 = bitcast double* %5 to i8*
%8 = bitcast double* %6 to i8*
%9 = shl i32 %0, 3
%10 = tail call i64 @malloc(i32 %9)
%11 = inttoptr i64 %10 to i8**
%12 = icmp eq i64 %10, 0
br i1 %12, label %39, label %13
13: ; preds = %4
%14 = sdiv i32 100, %0
%15 = icmp sgt i32 %0, 0
br i1 %15, label %16, label %32
16: ; preds = %13, %22
%17 = phi i32 [ %28, %22 ], [ 0, %13 ]
%18 = phi <2 x double> [ %27, %22 ], [ zeroinitializer, %13 ]
%19 = call i32 @fisher_yates_shuffle(i32 %0, i8** %1, i8** %11)
%20 = call i32 @time_test(i32 %14, i32 %0, i8** %11, i8* %2, i8* %3, double* %5, double* %6)
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %39
22: ; preds = %16
%23 = load double, double* %5
%24 = load double, double* %6
%25 = insertelement <2 x double> poison, double %23, i64 0
%26 = insertelement <2 x double> %25, double %24, i64 1
%27 = fadd <2 x double> %18, %26
%28 = add nuw nsw i32 %17, 1
%29 = icmp eq i32 %28, %0
br i1 %29, label %30, label %16
30: ; preds = %22
%31 = fmul <2 x double> %27, <double 1.000000e+03, double 1.000000e+03>
br label %32
32: ; preds = %30, %13
%33 = phi <2 x double> [ zeroinitializer, %13 ], [ %31, %30 ]
%34 = call i32 @free(i8** %11)
%35 = load i32, i32* @stdout
%36 = extractelement <2 x double> %33, i64 0
%37 = extractelement <2 x double> %33, i64 1
%38 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), double %36, double %37)
br label %39
39: ; preds = %16, %4, %32
ret void
}