#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 fabs(double);
double pow(double, double);
int function(double x[], double *f, double g[], void *state) {
  *f = pow(x[0], 2.0) + pow(fabs(x[1]), 3.0);
  g[0] = 2.0 * x[0];
  g[1] = 3.0 * pow(fabs(x[1]), 2.0);
  if (x[1] < 0)
    g[1] = -g[1];
  return 0;
}


x86 assembly (clang, -O0):
<function>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xed0(%rip),%xmm1
call   1030 <pow@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
movaps 0xebe(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xea2(%rip),%xmm1
call   1030 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  0xe85(%rip),%xmm0
mulsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
movaps 0xe71(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xe5d(%rip),%xmm1
call   1030 <pow@plt>
movaps %xmm0,%xmm1
movsd  0xe45(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
ucomisd 0x8(%rax),%xmm0
jbe    1203 <function+0xf3>
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<function>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
movsd  (%rdi),%xmm0
mulsd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%rdi),%xmm0
andpd  0xec3(%rip),%xmm0
movsd  0xedb(%rip),%xmm1
call   1030 <pow@plt>
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%r14)
movsd  (%rbx),%xmm0
addsd  %xmm0,%xmm0
movsd  %xmm0,(%r15)
movsd  0x8(%rbx),%xmm0
mulsd  %xmm0,%xmm0
mulsd  0xead(%rip),%xmm0
movsd  %xmm0,0x8(%r15)
xorpd  %xmm1,%xmm1
ucomisd 0x8(%rbx),%xmm1
jbe    1192 <function+0x82>
xorpd  0xe84(%rip),%xmm0
movlpd %xmm0,0x8(%r15)
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @function(double* %0, double* %1, double* %2, i8* %3) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca double*
%8 = alloca i8*
store double* %0, double** %5
store double* %1, double** %6
store double* %2, double** %7
store i8* %3, i8** %8
%9 = load double*, double** %5
%10 = getelementptr inbounds double, double* %9, i64 0
%11 = load double, double* %10
%12 = call double @pow(double %11, double 2.000000e+00)
%13 = load double*, double** %5
%14 = getelementptr inbounds double, double* %13, i64 1
%15 = load double, double* %14
%16 = call double @llvm.fabs.f64(double %15)
%17 = call double @pow(double %16, double 3.000000e+00)
%18 = fadd double %12, %17
%19 = load double*, double** %6
store double %18, double* %19
%20 = load double*, double** %5
%21 = getelementptr inbounds double, double* %20, i64 0
%22 = load double, double* %21
%23 = fmul double 2.000000e+00, %22
%24 = load double*, double** %7
%25 = getelementptr inbounds double, double* %24, i64 0
store double %23, double* %25
%26 = load double*, double** %5
%27 = getelementptr inbounds double, double* %26, i64 1
%28 = load double, double* %27
%29 = call double @llvm.fabs.f64(double %28)
%30 = call double @pow(double %29, double 2.000000e+00)
%31 = fmul double 3.000000e+00, %30
%32 = load double*, double** %7
%33 = getelementptr inbounds double, double* %32, i64 1
store double %31, double* %33
%34 = load double*, double** %5
%35 = getelementptr inbounds double, double* %34, i64 1
%36 = load double, double* %35
%37 = fcmp olt double %36, 0.000000e+00
br i1 %37, label %38, label %45
38: ; preds = %4
%39 = load double*, double** %7
%40 = getelementptr inbounds double, double* %39, i64 1
%41 = load double, double* %40
%42 = fneg double %41
%43 = load double*, double** %7
%44 = getelementptr inbounds double, double* %43, i64 1
store double %42, double* %44
br label %45
45: ; preds = %38, %4
ret i32 0
}

LLVM IR (-O2):
define i32 @function(double* nocapture %0, double* nocapture writeonly %1, double* nocapture writeonly %2, i8* nocapture readnone %3) {
%5 = load double, double* %0
%6 = fmul double %5, %5
%7 = getelementptr inbounds double, double* %0, i64 1
%8 = load double, double* %7
%9 = tail call double @llvm.fabs.f64(double %8)
%10 = tail call double @pow(double %9, double 3.000000e+00)
%11 = fadd double %6, %10
store double %11, double* %1
%12 = load double, double* %0
%13 = fmul double %12, 2.000000e+00
store double %13, double* %2
%14 = load double, double* %7
%15 = fmul double %14, %14
%16 = fmul double %15, 3.000000e+00
%17 = getelementptr inbounds double, double* %2, i64 1
store double %16, double* %17
%18 = load double, double* %7
%19 = fcmp olt double %18, 0.000000e+00
br i1 %19, label %20, label %22
20: ; preds = %4
%21 = fneg double %16
store double %21, double* %17
br label %22
22: ; preds = %20, %4
ret i32 0
}