#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 Div(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];
  if (b == 0.0) {
    return 6;
  }
  result = a / b;
  memcpy(OutResult, &result, sizeof(double));
  return 0;
}


x86 assembly (clang, -O0):
<Div>:
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 <Div+0x2a>
movl   $0x7,-0x4(%rbp)
jmp    11e6 <Div+0xd6>
cmpl   $0x2,-0x14(%rbp)
je     1150 <Div+0x40>
movl   $0x7,-0x4(%rbp)
jmp    11e6 <Div+0xd6>
cmpq   $0x0,-0x20(%rbp)
jne    1167 <Div+0x57>
movl   $0x7,-0x4(%rbp)
jmp    11e6 <Div+0xd6>
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  -0x38(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11be <Div+0xae>
jp     11be <Div+0xae>
movl   $0x6,-0x4(%rbp)
jmp    11e6 <Div+0xd6>
movsd  -0x30(%rbp),%xmm0
divsd  -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):
<Div>:
mov    $0x7,%eax
test   %rdi,%rdi
je     115e <Div+0x4e>
cmp    $0x2,%esi
jne    115e <Div+0x4e>
test   %rdx,%rdx
je     115e <Div+0x4e>
push   %rax
movsd  0x8(%rdi),%xmm0
mov    $0x6,%eax
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    113b <Div+0x2b>
jnp    115a <Div+0x4a>
movsd  (%rdi),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%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 @Div(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 %38
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 %38
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 %38
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* %10
%30 = fcmp oeq double %29, 0.000000e+00
br i1 %30, label %31, label %32
31: ; preds = %22
store i32 6, i32* %4
br label %38
32: ; preds = %22
%33 = load double, double* %9
%34 = load double, double* %10
%35 = fdiv double %33, %34
store double %35, double* %8
%36 = load double*, double** %7
%37 = call i32 @memcpy(double* %36, double* %8, i32 8)
store i32 0, i32* %4
br label %38
38: ; preds = %32, %31, %21, %17, %13
%39 = load i32, i32* %4
ret i32 %39
}

LLVM IR (-O2):
define i32 @Div(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 %21, label %10
10: ; preds = %3
%11 = bitcast double* %4 to i8*
%12 = getelementptr inbounds double, double* %0, i64 1
%13 = load double, double* %12
%14 = fcmp oeq double %13, 0.000000e+00
br i1 %14, label %19, label %15
15: ; preds = %10
%16 = load double, double* %0
%17 = fdiv double %16, %13
store double %17, double* %4
%18 = call i32 @memcpy(double* %2, double* %4, i32 8)
br label %19
19: ; preds = %10, %15
%20 = phi i32 [ 0, %15 ], [ 6, %10 ]
br label %21
21: ; preds = %3, %19
%22 = phi i32 [ %20, %19 ], [ 7, %3 ]
ret i32 %22
}