#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 */
typedef scalar_t__ int8_t;

/* Variables and functions */
int drand48();
void cp_array(int8_t *marr, int8_t *barr, int pos) {
  int i;
  for (i = 0; i < 1024; i++)
    *(barr + pos * 1024 + i) = marr[i] + (int)(drand48() * 0);
}


x86 assembly (clang, -O0):
<cp_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x400,-0x18(%rbp)
jge    1184 <cp_array+0x74>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   1030 <drand48@plt>
mov    -0x20(%rbp),%rdx
imul   $0x0,%eax,%eax
cltq
add    %rax,%rdx
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
shl    $0xa,%ecx
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    112a <cp_array+0x1a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cp_array>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
shl    $0xa,%edx
movslq %edx,%rax
lea    (%rsi,%rax,8),%r15
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    (%r14,%rbx,8),%r12
xor    %eax,%eax
call   1030 <drand48@plt>
mov    %r12,(%r15,%rbx,8)
add    $0x1,%rbx
cmp    $0x400,%rbx
jne    1130 <cp_array+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @cp_array(i64* %0, i64* %1, i32 %2) {
%4 = alloca i64*
%5 = alloca i64*
%6 = alloca i32
%7 = alloca i32
store i64* %0, i64** %4
store i64* %1, i64** %5
store i32 %2, i32* %6
store i32 0, i32* %7
br label %8
8: ; preds = %29, %3
%9 = load i32, i32* %7
%10 = icmp slt i32 %9, 1024
br i1 %10, label %11, label %32
11: ; preds = %8
%12 = load i64*, i64** %4
%13 = load i32, i32* %7
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i64, i64* %12, i64 %14
%16 = load i64, i64* %15
%17 = call i32 (...) @drand48()
%18 = mul nsw i32 %17, 0
%19 = sext i32 %18 to i64
%20 = add nsw i64 %16, %19
%21 = load i64*, i64** %5
%22 = load i32, i32* %6
%23 = mul nsw i32 %22, 1024
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i64, i64* %21, i64 %24
%26 = load i32, i32* %7
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i64, i64* %25, i64 %27
store i64 %20, i64* %28
br label %29
29: ; preds = %11
%30 = load i32, i32* %7
%31 = add nsw i32 %30, 1
store i32 %31, i32* %7
br label %8
32: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @cp_array(i64* nocapture %0, i64* nocapture writeonly %1, i32 %2) {
%4 = shl nsw i32 %2, 10
%5 = sext i32 %4 to i64
%6 = getelementptr inbounds i64, i64* %1, i64 %5
br label %7
7: ; preds = %3, %7
%8 = phi i64 [ 0, %3 ], [ %13, %7 ]
%9 = getelementptr inbounds i64, i64* %0, i64 %8
%10 = load i64, i64* %9
%11 = tail call i32 (...) @drand48()
%12 = getelementptr inbounds i64, i64* %6, i64 %8
store i64 %10, i64* %12
%13 = add nuw nsw i64 %8, 1
%14 = icmp eq i64 %13, 1024
br i1 %14, label %15, label %7
15: ; preds = %7
ret void
}