#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*/ printf(char *, double, double);
scalar_t__ rand();
double sin(double);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  srand(time(NULL));
  double interval = 2;
  double div = RAND_MAX / (interval * 2);
  for (int i = 0; i < 10000; i++) {
    double rnum = -interval + ((double)rand() / div);
    double sin_val = sin(rnum);
    double transformed = 0.5 * (sin_val + 1);
    printf("%lf;%lf\n", rnum, transformed);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
movsd  0xe89(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    0x2e65(%rip),%rax
movsd  (%rax),%xmm0
movsd  0xe71(%rip),%xmm1
mulsd  -0x10(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x2710,-0x1c(%rbp)
jge    1242 <main+0xf2>
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    $0x0,%al
call   1070 <rand@plt>
movsd  -0x40(%rbp),%xmm0
cvtsi2sd %rax,%xmm1
divsd  -0x18(%rbp),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1050 <sin@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  0xe08(%rip),%xmm1
addsd  -0x30(%rbp),%xmm1
movsd  0xdf3(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
lea    0xde9(%rip),%rdi
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11a4 <main+0x54>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
mov    0x2e7d(%rip),%rax
movsd  (%rax),%xmm0
mulsd  0xe89(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    $0x2710,%ebp
lea    0xe97(%rip),%rbx
nopl   0x0(%rax)
xor    %eax,%eax
call   1070 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
divsd  0x8(%rsp),%xmm0
addsd  0xe5b(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
call   1050 <sin@plt>
movapd %xmm0,%xmm1
addsd  0xe4c(%rip),%xmm1
mulsd  0xe4c(%rip),%xmm1
mov    %rbx,%rdi
movsd  0x10(%rsp),%xmm0
call   1030 <printf@plt>
add    $0xffffffff,%ebp
jne    1190 <main+0x40>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
@RAND_MAX = global double 0.000000e+00
@.str = [9 x i8] c"%lf;%lf\0A\00"
define i32 @main() {
%1 = tail call i32 @time(i32* null)
%2 = tail call i32 @srand(i32 %1)
%3 = load double, double* @RAND_MAX
%4 = fmul double %3, 2.500000e-01
br label %6
5: ; preds = %6
ret i32 0
6: ; preds = %0, %6
%7 = phi i32 [ 0, %0 ], [ %16, %6 ]
%8 = tail call i64 (...) @rand()
%9 = sitofp i64 %8 to double
%10 = fdiv double %9, %4
%11 = fadd double %10, -2.000000e+00
%12 = tail call double @sin(double %11)
%13 = fadd double %12, 1.000000e+00
%14 = fmul double %13, 5.000000e-01
%15 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), double %11, double %14)
%16 = add nuw nsw i32 %7, 1
%17 = icmp eq i32 %16, 10000
br i1 %17, label %5, label %6
}