#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 drand48();
int /*<<< orphan*/ srand48(long);
void set_value(const int seed, const int N, const int LD, double (*A)[LD],
               double *b) {
  srand48((long int)seed);
  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++)
      A[i][j] = -1 * drand48() + 0.5;
  for (int i = 0; i < N; i++)
    b[i] = -1 * drand48() + 0.5;
}


x86 assembly (clang, -O0):
<set_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    -0xc(%rbp),%eax
mov    %rax,-0x38(%rbp)
movslq -0x4(%rbp),%rdi
call   1030 <srand48@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11cd <set_value+0xad>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11ba <set_value+0x9a>
mov    $0x0,%al
call   1040 <drand48@plt>
mov    -0x38(%rbp),%rdx
imul   $0xffffffff,%eax,%eax
cvtsi2sd %eax,%xmm0
movsd  0xe74(%rip),%xmm1
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
imul   %rdx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
movslq -0x28(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1163 <set_value+0x43>
jmp    11bf <set_value+0x9f>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1150 <set_value+0x30>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1218 <set_value+0xf8>
mov    $0x0,%al
call   1040 <drand48@plt>
imul   $0xffffffff,%eax,%eax
cvtsi2sd %eax,%xmm0
movsd  0xe07(%rip),%xmm1
addsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11d4 <set_value+0xb4>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_value>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%r14
mov    %rcx,%rbx
mov    %edx,%r15d
mov    %esi,%ebp
movslq %edi,%rdi
call   1030 <srand48@plt>
test   %ebp,%ebp
jle    11d7 <set_value+0xb7>
mov    %r15d,%r12d
mov    %ebp,0x4(%rsp)
mov    %ebp,%ebp
shl    $0x3,%r12
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1040 <drand48@plt>
movsd  0xe81(%rip),%xmm1
neg    %eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rbx,%r15,8)
add    $0x1,%r15
cmp    %r15,%rbp
jne    1170 <set_value+0x50>
add    $0x1,%r13
add    %r12,%rbx
cmp    %rbp,%r13
jne    1160 <set_value+0x40>
cmpl   $0x0,0x4(%rsp)
jle    11d7 <set_value+0xb7>
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <drand48@plt>
neg    %eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  0xe38(%rip),%xmm0
movsd  %xmm0,(%r14,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    11b0 <set_value+0x90>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @set_value(i32 %0, i32 %1, i32 %2, double* %3, double* %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca double*
%10 = alloca double*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store double* %3, double** %9
store double* %4, double** %10
%14 = load i32, i32* %8
%15 = zext i32 %14 to i64
%16 = load i32, i32* %6
%17 = sext i32 %16 to i64
%18 = call i32 @srand48(i64 %17)
store i32 0, i32* %11
br label %19
19: ; preds = %45, %5
%20 = load i32, i32* %11
%21 = load i32, i32* %7
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %48
23: ; preds = %19
store i32 0, i32* %12
br label %24
24: ; preds = %41, %23
%25 = load i32, i32* %12
%26 = load i32, i32* %7
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %44
28: ; preds = %24
%29 = call i32 (...) @drand48()
%30 = mul nsw i32 -1, %29
%31 = sitofp i32 %30 to double
%32 = fadd double %31, 5.000000e-01
%33 = load double*, double** %9
%34 = load i32, i32* %11
%35 = sext i32 %34 to i64
%36 = mul nsw i64 %35, %15
%37 = getelementptr inbounds double, double* %33, i64 %36
%38 = load i32, i32* %12
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds double, double* %37, i64 %39
store double %32, double* %40
br label %41
41: ; preds = %28
%42 = load i32, i32* %12
%43 = add nsw i32 %42, 1
store i32 %43, i32* %12
br label %24
44: ; preds = %24
br label %45
45: ; preds = %44
%46 = load i32, i32* %11
%47 = add nsw i32 %46, 1
store i32 %47, i32* %11
br label %19
48: ; preds = %19
store i32 0, i32* %13
br label %49
49: ; preds = %62, %48
%50 = load i32, i32* %13
%51 = load i32, i32* %7
%52 = icmp slt i32 %50, %51
br i1 %52, label %53, label %65
53: ; preds = %49
%54 = call i32 (...) @drand48()
%55 = mul nsw i32 -1, %54
%56 = sitofp i32 %55 to double
%57 = fadd double %56, 5.000000e-01
%58 = load double*, double** %10
%59 = load i32, i32* %13
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds double, double* %58, i64 %60
store double %57, double* %61
br label %62
62: ; preds = %53
%63 = load i32, i32* %13
%64 = add nsw i32 %63, 1
store i32 %64, i32* %13
br label %49
65: ; preds = %49
ret void
}

LLVM IR (-O2):
define void @set_value(i32 %0, i32 %1, i32 %2, double* nocapture writeonly %3, double* nocapture writeonly %4) {
%6 = zext i32 %2 to i64
%7 = sext i32 %0 to i64
%8 = tail call i32 @srand48(i64 %7)
%9 = icmp sgt i32 %1, 0
br i1 %9, label %10, label %31
10: ; preds = %5
%11 = zext i32 %1 to i64
br label %12
12: ; preds = %19, %10
%13 = phi i64 [ 0, %10 ], [ %20, %19 ]
%14 = mul nuw nsw i64 %13, %6
%15 = getelementptr inbounds double, double* %3, i64 %14
br label %22
16: ; preds = %19
br i1 %9, label %17, label %31
17: ; preds = %16
%18 = zext i32 %1 to i64
br label %32
19: ; preds = %22
%20 = add nuw nsw i64 %13, 1
%21 = icmp eq i64 %20, %11
br i1 %21, label %16, label %12
22: ; preds = %12, %22
%23 = phi i64 [ 0, %12 ], [ %29, %22 ]
%24 = tail call i32 (...) @drand48()
%25 = sub nsw i32 0, %24
%26 = sitofp i32 %25 to double
%27 = fadd double %26, 5.000000e-01
%28 = getelementptr inbounds double, double* %15, i64 %23
store double %27, double* %28
%29 = add nuw nsw i64 %23, 1
%30 = icmp eq i64 %29, %11
br i1 %30, label %19, label %22
31: ; preds = %32, %5, %16
ret void
32: ; preds = %17, %32
%33 = phi i64 [ 0, %17 ], [ %39, %32 ]
%34 = tail call i32 (...) @drand48()
%35 = sub nsw i32 0, %34
%36 = sitofp i32 %35 to double
%37 = fadd double %36, 5.000000e-01
%38 = getelementptr inbounds double, double* %4, i64 %33
store double %37, double* %38
%39 = add nuw nsw i64 %33, 1
%40 = icmp eq i64 %39, %18
br i1 %40, label %31, label %32
}