#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 RAND_MAX;
int /*<<< orphan*/ lazy_quick_asm(int *, int);
int /*<<< orphan*/ print(int *, int);
int rand();
int main(void) {
  int nums[100];
  int length = 100;
  int *n = nums;
  for (int i = 0; i < length; i++) {
    nums[i] = (int)(rand() * (1000 + 1.0) / (1.0 + RAND_MAX));
  }
  lazy_quick_asm(nums, length);
  print(n, length);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1c0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x64,-0x1a4(%rbp)
lea    -0x1a0(%rbp),%rax
mov    %rax,-0x1b0(%rbp)
movl   $0x0,-0x1b4(%rbp)
mov    -0x1b4(%rbp),%eax
cmp    -0x1a4(%rbp),%eax
jge    11ca <main+0x9a>
mov    $0x0,%al
call   1050 <rand@plt>
cvtsi2sd %eax,%xmm0
movsd  0xe7f(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe6b(%rip),%xmm1
mov    0x2e4c(%rip),%rax
addsd  (%rax),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ecx
movslq -0x1b4(%rbp),%rax
mov    %ecx,-0x1a0(%rbp,%rax,4)
mov    -0x1b4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1b4(%rbp)
jmp    1164 <main+0x34>
lea    -0x1a0(%rbp),%rdi
mov    -0x1a4(%rbp),%esi
call   1040 <lazy_quick_asm@plt>
mov    -0x1b0(%rbp),%rdi
mov    -0x1a4(%rbp),%esi
call   1030 <print@plt>
xor    %eax,%eax
add    $0x1c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x198,%rsp
mov    0x2ea7(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1050 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xe9a(%rip),%xmm0
movsd  (%r14),%xmm1
addsd  0xe95(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,(%rsp,%rbx,4)
add    $0x1,%rbx
cmp    $0x64,%rbx
jne    1150 <main+0x20>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x64,%esi
call   1040 <lazy_quick_asm@plt>
mov    %rbx,%rdi
mov    $0x64,%esi
call   1030 <print@plt>
xor    %eax,%eax
add    $0x198,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@RAND_MAX = global double 0.000000e+00
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i32]
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
store i32 0, i32* %1
store i32 100, i32* %3
%6 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
store i32* %6, i32** %4
store i32 0, i32* %5
br label %7
7: ; preds = %22, %0
%8 = load i32, i32* %5
%9 = load i32, i32* %3
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %25
11: ; preds = %7
%12 = call i32 (...) @rand()
%13 = sitofp i32 %12 to double
%14 = fmul double %13, 1.001000e+03
%15 = load double, double* @RAND_MAX
%16 = fadd double 1.000000e+00, %15
%17 = fdiv double %14, %16
%18 = fptosi double %17 to i32
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %20
store i32 %18, i32* %21
br label %22
22: ; preds = %11
%23 = load i32, i32* %5
%24 = add nsw i32 %23, 1
store i32 %24, i32* %5
br label %7
25: ; preds = %7
%26 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
%27 = load i32, i32* %3
%28 = call i32 @lazy_quick_asm(i32* %26, i32 %27)
%29 = load i32*, i32** %4
%30 = load i32, i32* %3
%31 = call i32 @print(i32* %29, i32 %30)
ret i32 0
}

LLVM IR (-O2):
@RAND_MAX = global double 0.000000e+00
define i32 @main() {
%1 = alloca [100 x i32]
%2 = bitcast [100 x i32]* %1 to i8*
br label %7
3: ; preds = %7
%4 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 0
%5 = call i32 @lazy_quick_asm(i32* %4, i32 100)
%6 = call i32 @print(i32* %4, i32 100)
ret i32 0
7: ; preds = %0, %7
%8 = phi i64 [ 0, %0 ], [ %17, %7 ]
%9 = tail call i32 (...) @rand()
%10 = sitofp i32 %9 to double
%11 = fmul double %10, 1.001000e+03
%12 = load double, double* @RAND_MAX
%13 = fadd double %12, 1.000000e+00
%14 = fdiv double %11, %13
%15 = fptosi double %14 to i32
%16 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %8
store i32 %15, i32* %16
%17 = add nuw nsw i64 %8, 1
%18 = icmp eq i64 %17, 100
br i1 %18, label %3, label %7
}