#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 ddot(int, double *, int, double *, int);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, double);
int main(int argc, char **argv) {
  double *a = (double *)malloc(3 * sizeof(double));
  a[0] = 1.0;
  a[1] = 2.0;
  a[2] = 3.0;
  double b[3] = {4.0, 5.0, 6.0};
  double dot_product = ddot(3, a, 1, b, 1);
  printf(" The dot product is: %f \n", dot_product);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x18,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsd  0xeb0(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
movsd  0xe98(%rip),%xmm0
movsd  %xmm0,0x8(%rax)
mov    -0x18(%rbp),%rax
movsd  0xe7f(%rip),%xmm0
movsd  %xmm0,0x10(%rax)
mov    0xe93(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xe90(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xe8d(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rsi
lea    -0x30(%rbp),%rcx
mov    $0x3,%edi
mov    $0x1,%r8d
mov    %r8d,%edx
call   1030 <ddot@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
lea    0xe65(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
mov    $0x18,%edi
call   1050 <malloc@plt>
movaps 0xebb(%rip),%xmm0
movups %xmm0,(%rax)
movabs $0x4008000000000000,%rcx
mov    %rcx,0x10(%rax)
mov    0xec3(%rip),%rcx
mov    %rcx,0x10(%rsp)
movaps 0xea7(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rcx
mov    $0x3,%edi
mov    %rax,%rsi
mov    $0x1,%edx
mov    $0x1,%r8d
call   1030 <ddot@plt>
lea    0xe99(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@__const.main.b = [3 x double] [double 4.000000e+00, double 5.000000e+00, double 6.000000e+00]
@.str = [26 x i8] c" The dot product is: %f \0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double*
%7 = alloca [3 x double]
%8 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i64 @malloc(i32 24)
%10 = inttoptr i64 %9 to double*
store double* %10, double** %6
%11 = load double*, double** %6
%12 = getelementptr inbounds double, double* %11, i64 0
store double 1.000000e+00, double* %12
%13 = load double*, double** %6
%14 = getelementptr inbounds double, double* %13, i64 1
store double 2.000000e+00, double* %14
%15 = load double*, double** %6
%16 = getelementptr inbounds double, double* %15, i64 2
store double 3.000000e+00, double* %16
%17 = bitcast [3 x double]* %7 to i8*
%18 = load double*, double** %6
%19 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 0
%20 = call double @ddot(i32 3, double* %18, i32 1, double* %19, i32 1)
store double %20, double* %8
%21 = load double, double* %8
%22 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), double %21)
ret i32 0
}

LLVM IR (-O2):
@__const.main.b = [3 x double] [double 4.000000e+00, double 5.000000e+00, double 6.000000e+00]
@.str = [26 x i8] c" The dot product is: %f \0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [3 x double]
%4 = tail call i64 @malloc(i32 24)
%5 = inttoptr i64 %4 to double*
%6 = inttoptr i64 %4 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 2.000000e+00>, <2 x double>* %6
%7 = getelementptr inbounds double, double* %5, i64 2
store double 3.000000e+00, double* %7
%8 = bitcast [3 x double]* %3 to i8*
%9 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 0
%10 = call double @ddot(i32 3, double* %5, i32 1, double* %9, i32 1)
%11 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), double %10)
ret i32 0
}