#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 atoi(char const *);
scalar_t__ malloc(int);
int /*<<< orphan*/ map(double *, double *, double, int);
int /*<<< orphan*/ printf(char *, double, double);
double *rand_double_arr(int);
int main(int argc, const char **argv) {
  int size = 512;
  if (argc > 1) {
    size = atoi(argv[1]);
  }
  double *arr = rand_double_arr(size);
  double *res = (double *)malloc(size * sizeof(double));
  map(res, arr, 5.0, size);
  for (int i = 0; i < size; ++i) {
    printf("%lf=>%lf ", arr[i], res[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x200,-0x14(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1187 <main+0x37>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1050 <rand_double_arr@plt>
mov    %rax,-0x20(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x14(%rbp),%edx
movsd  0xe47(%rip),%xmm0
call   1040 <map@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1205 <main+0xb5>
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
lea    0xe16(%rip),%rdi
call   1030 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11c5 <main+0x75>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    $0x200,%r15d
cmp    $0x2,%edi
jl     1170 <main+0x20>
mov    0x8(%rsi),%rdi
call   1070 <atoi@plt>
mov    %eax,%r15d
mov    %r15d,%edi
call   1050 <rand_double_arr@plt>
mov    %rax,%r14
lea    0x0(,%r15,8),%edi
call   1060 <malloc@plt>
mov    %rax,%r12
movsd  0xe6d(%rip),%xmm0
mov    %rax,%rdi
mov    %r14,%rsi
mov    %r15d,%edx
call   1040 <map@plt>
test   %r15d,%r15d
jle    11dd <main+0x8d>
mov    %r15d,%r13d
xor    %ebx,%ebx
lea    0xe56(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  (%r14,%rbx,8),%xmm0
movsd  (%r12,%rbx,8),%xmm1
mov    %r15,%rdi
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    11c0 <main+0x70>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [10 x i8] c"%lf=>%lf \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca double*
%8 = alloca double*
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 512, i32* %6
%10 = load i32, i32* %4
%11 = icmp sgt i32 %10, 1
br i1 %11, label %12, label %17
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @atoi(i8* %15)
store i32 %16, i32* %6
br label %17
17: ; preds = %12, %2
%18 = load i32, i32* %6
%19 = call double* @rand_double_arr(i32 %18)
store double* %19, double** %7
%20 = load i32, i32* %6
%21 = sext i32 %20 to i64
%22 = mul i64 %21, 8
%23 = trunc i64 %22 to i32
%24 = call i64 @malloc(i32 %23)
%25 = inttoptr i64 %24 to double*
store double* %25, double** %8
%26 = load double*, double** %8
%27 = load double*, double** %7
%28 = load i32, i32* %6
%29 = call i32 @map(double* %26, double* %27, double 5.000000e+00, i32 %28)
store i32 0, i32* %9
br label %30
30: ; preds = %46, %17
%31 = load i32, i32* %9
%32 = load i32, i32* %6
%33 = icmp slt i32 %31, %32
br i1 %33, label %34, label %49
34: ; preds = %30
%35 = load double*, double** %7
%36 = load i32, i32* %9
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds double, double* %35, i64 %37
%39 = load double, double* %38
%40 = load double*, double** %8
%41 = load i32, i32* %9
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds double, double* %40, i64 %42
%44 = load double, double* %43
%45 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), double %39, double %44)
br label %46
46: ; preds = %34
%47 = load i32, i32* %9
%48 = add nsw i32 %47, 1
store i32 %48, i32* %9
br label %30
49: ; preds = %30
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"%lf=>%lf \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @atoi(i8* %6)
br label %8
8: ; preds = %4, %2
%9 = phi i32 [ %7, %4 ], [ 512, %2 ]
%10 = tail call double* @rand_double_arr(i32 %9)
%11 = shl i32 %9, 3
%12 = tail call i64 @malloc(i32 %11)
%13 = inttoptr i64 %12 to double*
%14 = tail call i32 @map(double* %13, double* %10, double 5.000000e+00, i32 %9)
%15 = icmp sgt i32 %9, 0
br i1 %15, label %16, label %18
16: ; preds = %8
%17 = zext i32 %9 to i64
br label %19
18: ; preds = %19, %8
ret i32 0
19: ; preds = %16, %19
%20 = phi i64 [ 0, %16 ], [ %26, %19 ]
%21 = getelementptr inbounds double, double* %10, i64 %20
%22 = load double, double* %21
%23 = getelementptr inbounds double, double* %13, i64 %20
%24 = load double, double* %23
%25 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), double %22, double %24)
%26 = add nuw nsw i64 %20, 1
%27 = icmp eq i64 %26, %17
br i1 %27, label %18, label %19
}