#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 /*<<< orphan*/ memcpy(double *, double *, int);
int Add(const double *args, int argc, double *OutResult) {
  if (!args) {
    return 7;
  }
  if (argc != 2) {
    return 7;
  }
  if (!OutResult) {
    return 7;
  }
  double result = 0.0;
  double a = 0.0;
  double b = 0.0;
  a = args[0];
  b = args[1];
  result = a + b;
  memcpy(OutResult, &result, sizeof(double));
  return 0;
}


x86 assembly (clang, -O0):
<Add>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    113a <Add+0x2a>
movl   $0x7,-0x4(%rbp)
jmp    11c2 <Add+0xb2>
cmpl   $0x2,-0x14(%rbp)
je     1150 <Add+0x40>
movl   $0x7,-0x4(%rbp)
jmp    11c2 <Add+0xb2>
cmpq   $0x0,-0x20(%rbp)
jne    1167 <Add+0x57>
movl   $0x7,-0x4(%rbp)
jmp    11c2 <Add+0xb2>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
mov    $0x8,%edx
call   1030 <memcpy@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Add>:
mov    $0x7,%eax
test   %rdi,%rdi
je     1149 <Add+0x39>
cmp    $0x2,%esi
jne    1149 <Add+0x39>
test   %rdx,%rdx
je     1149 <Add+0x39>
push   %rax
movsd  (%rdi),%xmm0
addsd  0x8(%rdi),%xmm0
movsd  %xmm0,(%rsp)
mov    %rsp,%rsi
mov    %rdx,%rdi
mov    $0x8,%edx
call   1030 <memcpy@plt>
xor    %eax,%eax
add    $0x8,%rsp
ret

LLVM IR (-O0):
define i32 @Add(double* %0, i32 %1, double* %2) {
%4 = alloca i32
%5 = alloca double*
%6 = alloca i32
%7 = alloca double*
%8 = alloca double
%9 = alloca double
%10 = alloca double
store double* %0, double** %5
store i32 %1, i32* %6
store double* %2, double** %7
%11 = load double*, double** %5
%12 = icmp ne double* %11, null
br i1 %12, label %14, label %13
13: ; preds = %3
store i32 7, i32* %4
br label %34
14: ; preds = %3
%15 = load i32, i32* %6
%16 = icmp ne i32 %15, 2
br i1 %16, label %17, label %18
17: ; preds = %14
store i32 7, i32* %4
br label %34
18: ; preds = %14
%19 = load double*, double** %7
%20 = icmp ne double* %19, null
br i1 %20, label %22, label %21
21: ; preds = %18
store i32 7, i32* %4
br label %34
22: ; preds = %18
store double 0.000000e+00, double* %8
store double 0.000000e+00, double* %9
store double 0.000000e+00, double* %10
%23 = load double*, double** %5
%24 = getelementptr inbounds double, double* %23, i64 0
%25 = load double, double* %24
store double %25, double* %9
%26 = load double*, double** %5
%27 = getelementptr inbounds double, double* %26, i64 1
%28 = load double, double* %27
store double %28, double* %10
%29 = load double, double* %9
%30 = load double, double* %10
%31 = fadd double %29, %30
store double %31, double* %8
%32 = load double*, double** %7
%33 = call i32 @memcpy(double* %32, double* %8, i32 8)
store i32 0, i32* %4
br label %34
34: ; preds = %22, %21, %17, %13
%35 = load i32, i32* %4
ret i32 %35
}

LLVM IR (-O2):
define i32 @Add(double* %0, i32 %1, double* %2) {
%4 = alloca double
%5 = icmp eq double* %0, null
%6 = icmp ne i32 %1, 2
%7 = or i1 %5, %6
%8 = icmp eq double* %2, null
%9 = or i1 %7, %8
br i1 %9, label %17, label %10
10: ; preds = %3
%11 = bitcast double* %4 to i8*
%12 = load double, double* %0
%13 = getelementptr inbounds double, double* %0, i64 1
%14 = load double, double* %13
%15 = fadd double %12, %14
store double %15, double* %4
%16 = call i32 @memcpy(double* %2, double* %4, i32 8)
br label %17
17: ; preds = %3, %10
%18 = phi i32 [ 0, %10 ], [ 7, %3 ]
ret i32 %18
}