#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 */
double det(double *, int);
int /*<<< orphan*/ printf(char *, double);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int main(void) {
  double x[18 * 18];
  srand(0);
  int i;
  for (i = 0; i < 18 * 18; i++)
    x[i] = rand() % 18;
  printf("det: %19f\n", det(x, 18));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa40,%rsp
movl   $0x0,-0x4(%rbp)
xor    %edi,%edi
call   1040 <srand@plt>
movl   $0x0,-0xa34(%rbp)
cmpl   $0x144,-0xa34(%rbp)
jge    11aa <main+0x6a>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x12,%ecx
cltd
idiv   %ecx
cvtsi2sd %edx,%xmm0
movslq -0xa34(%rbp),%rax
movsd  %xmm0,-0xa30(%rbp,%rax,8)
ff ff
mov    -0xa34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa34(%rbp)
jmp    1163 <main+0x23>
lea    -0xa30(%rbp),%rdi
mov    $0x12,%esi
call   1050 <det@plt>
lea    0xe3e(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xa40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0xa20,%rsp
xor    %edi,%edi
call   1040 <srand@plt>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <rand@plt>
cltq
imul   $0x38e38e39,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,8),%ecx
sub    %ecx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,(%rsp,%rbx,8)
add    $0x1,%rbx
cmp    $0x144,%rbx
jne    1160 <main+0x20>
mov    %rsp,%rdi
mov    $0x12,%esi
call   1050 <det@plt>
lea    0xe4f(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xa20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [11 x i8] c"det: %19f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [324 x double]
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @srand(i32 0)
store i32 0, i32* %3
br label %5
5: ; preds = %15, %0
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 324
br i1 %7, label %8, label %18
8: ; preds = %5
%9 = call i32 (...) @rand()
%10 = srem i32 %9, 18
%11 = sitofp i32 %10 to double
%12 = load i32, i32* %3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [324 x double], [324 x double]* %2, i64 0, i64 %13
store double %11, double* %14
br label %15
15: ; preds = %8
%16 = load i32, i32* %3
%17 = add nsw i32 %16, 1
store i32 %17, i32* %3
br label %5
18: ; preds = %5
%19 = getelementptr inbounds [324 x double], [324 x double]* %2, i64 0, i64 0
%20 = call double @det(double* %19, i32 18)
%21 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), double %20)
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"det: %19f\0A\00"
define i32 @main() {
%1 = alloca [324 x double]
%2 = bitcast [324 x double]* %1 to i8*
%3 = tail call i32 @srand(i32 0)
br label %4
4: ; preds = %0, %4
%5 = phi i64 [ 0, %0 ], [ %10, %4 ]
%6 = tail call i32 (...) @rand()
%7 = srem i32 %6, 18
%8 = sitofp i32 %7 to double
%9 = getelementptr inbounds [324 x double], [324 x double]* %1, i64 0, i64 %5
store double %8, double* %9
%10 = add nuw nsw i64 %5, 1
%11 = icmp eq i64 %10, 324
br i1 %11, label %12, label %4
12: ; preds = %4
%13 = getelementptr inbounds [324 x double], [324 x double]* %1, i64 0, i64 0
%14 = call double @det(double* %13, i32 18)
%15 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), double %14)
ret i32 0
}