#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 cos(double);
double fabs(double);
double pow(double, int);
double sqrt(double);
void g02(double *x, double *f, double *g, double *h, int nx, int nf, int ng,
         int nh) {
  int j;
  double f1, f2, f3, g1, g2;
  f1 = 0.;
  f2 = 1.;
  f3 = 0.;
  g1 = 1.;
  g2 = 0.;
  for (j = 0; j < nx; j++) {
    f1 = f1 + pow(cos(x[j]), 4);
    f2 = f2 * cos(x[j]) * cos(x[j]);
    f3 = f3 + ((double)(j + 1)) * x[j] * x[j];
    g1 = g1 * x[j];
    g2 = g2 + x[j];
  }
  f[0] = fabs((f1 - 2 * f2) / sqrt(f3));
  f[0] = -f[0];
  g[0] = 0.75 - g1;
  g[1] = g2 - 7.5 * ((double)nx);
}


x86 assembly (clang, -O0):
<g02>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9d,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe97(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xe82(%rip),%xmm0
movsd  %xmm0,-0x50(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1297 <g02+0x167>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1030 <cos@plt>
mov    $0x4,%edi
call   1040 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1030 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1030 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x48(%rbp),%xmm1
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x50(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x58(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1192 <g02+0x62>
movsd  -0x38(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
addsd  %xmm1,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x48(%rbp),%xmm0
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x78(%rbp),%xmm0
divsd  %xmm1,%xmm0
movaps 0xd55(%rip),%xmm1
pand   %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  0xd0a(%rip),%xmm0
subsd  -0x50(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x58(%rbp),%xmm1
cvtsi2sdl -0x24(%rbp),%xmm0
movsd  0xce3(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<g02>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r8d,%r12d
mov    %rdx,%r15
mov    %rsi,%r14
test   %r8d,%r8d
jle    122a <g02+0xfa>
mov    %rdi,%rbx
mov    %r12d,%r13d
movsd  0xea2(%rip),%xmm2
xorpd  %xmm1,%xmm1
xor    %ebp,%ebp
xorpd  %xmm4,%xmm4
movapd %xmm2,%xmm5
xorpd  %xmm0,%xmm0
movapd %xmm0,0x20(%rsp)
cs nopw 0x0(%rax,%rax,1)
movsd  %xmm5,0x8(%rsp)
movsd  %xmm4,0x30(%rsp)
movsd  %xmm2,0x10(%rsp)
movsd  %xmm1,0x18(%rsp)
movsd  (%rbx,%rbp,8),%xmm0
call   1030 <cos@plt>
mov    $0x4,%edi
call   1040 <pow@plt>
movapd 0x20(%rsp),%xmm1
addsd  %xmm0,%xmm1
movapd %xmm1,0x20(%rsp)
movsd  (%rbx,%rbp,8),%xmm0
call   1030 <cos@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  (%rbx,%rbp,8),%xmm0
call   1030 <cos@plt>
movsd  0x30(%rsp),%xmm4
movsd  0x10(%rsp),%xmm2
movapd %xmm0,%xmm5
mulsd  0x8(%rsp),%xmm5
movsd  (%rbx,%rbp,8),%xmm0
lea    0x1(%rbp),%rax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
mulsd  %xmm0,%xmm1
mulsd  %xmm0,%xmm1
addsd  %xmm1,%xmm4
movsd  0x18(%rsp),%xmm1
mulsd  %xmm0,%xmm2
addsd  %xmm0,%xmm1
mov    %rax,%rbp
cmp    %rax,%r13
jne    1180 <g02+0x50>
jmp    1248 <g02+0x118>
movsd  0xdce(%rip),%xmm5
xorpd  %xmm0,%xmm0
movapd %xmm0,0x20(%rsp)
xorpd  %xmm4,%xmm4
movapd %xmm5,%xmm2
xorpd  %xmm1,%xmm1
addsd  %xmm5,%xmm5
movapd 0x20(%rsp),%xmm3
subsd  %xmm5,%xmm3
ucomisd 0xdba(%rip),%xmm4
jb     1269 <g02+0x139>
xorps  %xmm0,%xmm0
sqrtsd %xmm4,%xmm0
jmp    1296 <g02+0x166>
movapd %xmm4,%xmm0
movsd  %xmm1,0x18(%rsp)
movsd  %xmm2,0x10(%rsp)
movapd %xmm3,0x20(%rsp)
call   1050 <sqrt@plt>
movapd 0x20(%rsp),%xmm3
movsd  0x10(%rsp),%xmm2
movsd  0x18(%rsp),%xmm1
divsd  %xmm0,%xmm3
orpd   0xd7e(%rip),%xmm3
movlpd %xmm3,(%r14)
movsd  0xd59(%rip),%xmm0
subsd  %xmm2,%xmm0
movsd  %xmm0,(%r15)
xorps  %xmm0,%xmm0
cvtsi2sd %r12d,%xmm0
mulsd  0xd48(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%r15)
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @g02(double* %0, double* %1, double* %2, double* %3, i32 %4, i32 %5, i32 %6, i32 %7) {
%9 = alloca double*
%10 = alloca double*
%11 = alloca double*
%12 = alloca double*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
%22 = alloca double
store double* %0, double** %9
store double* %1, double** %10
store double* %2, double** %11
store double* %3, double** %12
store i32 %4, i32* %13
store i32 %5, i32* %14
store i32 %6, i32* %15
store i32 %7, i32* %16
store double 0.000000e+00, double* %18
store double 1.000000e+00, double* %19
store double 0.000000e+00, double* %20
store double 1.000000e+00, double* %21
store double 0.000000e+00, double* %22
store i32 0, i32* %17
br label %23
23: ; preds = %82, %8
%24 = load i32, i32* %17
%25 = load i32, i32* %13
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %85
27: ; preds = %23
%28 = load double, double* %18
%29 = load double*, double** %9
%30 = load i32, i32* %17
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds double, double* %29, i64 %31
%33 = load double, double* %32
%34 = call double @cos(double %33)
%35 = call double @pow(double %34, i32 4)
%36 = fadd double %28, %35
store double %36, double* %18
%37 = load double, double* %19
%38 = load double*, double** %9
%39 = load i32, i32* %17
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds double, double* %38, i64 %40
%42 = load double, double* %41
%43 = call double @cos(double %42)
%44 = fmul double %37, %43
%45 = load double*, double** %9
%46 = load i32, i32* %17
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds double, double* %45, i64 %47
%49 = load double, double* %48
%50 = call double @cos(double %49)
%51 = fmul double %44, %50
store double %51, double* %19
%52 = load double, double* %20
%53 = load i32, i32* %17
%54 = add nsw i32 %53, 1
%55 = sitofp i32 %54 to double
%56 = load double*, double** %9
%57 = load i32, i32* %17
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds double, double* %56, i64 %58
%60 = load double, double* %59
%61 = fmul double %55, %60
%62 = load double*, double** %9
%63 = load i32, i32* %17
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds double, double* %62, i64 %64
%66 = load double, double* %65
%67 = call double @llvm.fmuladd.f64(double %61, double %66, double %52)
store double %67, double* %20
%68 = load double, double* %21
%69 = load double*, double** %9
%70 = load i32, i32* %17
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds double, double* %69, i64 %71
%73 = load double, double* %72
%74 = fmul double %68, %73
store double %74, double* %21
%75 = load double, double* %22
%76 = load double*, double** %9
%77 = load i32, i32* %17
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds double, double* %76, i64 %78
%80 = load double, double* %79
%81 = fadd double %75, %80
store double %81, double* %22
br label %82
82: ; preds = %27
%83 = load i32, i32* %17
%84 = add nsw i32 %83, 1
store i32 %84, i32* %17
br label %23
85: ; preds = %23
%86 = load double, double* %18
%87 = load double, double* %19
%88 = call double @llvm.fmuladd.f64(double -2.000000e+00, double %87, double %86)
%89 = load double, double* %20
%90 = call double @sqrt(double %89)
%91 = fdiv double %88, %90
%92 = call double @llvm.fabs.f64(double %91)
%93 = load double*, double** %10
%94 = getelementptr inbounds double, double* %93, i64 0
store double %92, double* %94
%95 = load double*, double** %10
%96 = getelementptr inbounds double, double* %95, i64 0
%97 = load double, double* %96
%98 = fneg double %97
%99 = load double*, double** %10
%100 = getelementptr inbounds double, double* %99, i64 0
store double %98, double* %100
%101 = load double, double* %21
%102 = fsub double 7.500000e-01, %101
%103 = load double*, double** %11
%104 = getelementptr inbounds double, double* %103, i64 0
store double %102, double* %104
%105 = load double, double* %22
%106 = load i32, i32* %13
%107 = sitofp i32 %106 to double
%108 = call double @llvm.fmuladd.f64(double -7.500000e+00, double %107, double %105)
%109 = load double*, double** %11
%110 = getelementptr inbounds double, double* %109, i64 1
store double %108, double* %110
ret void
}

LLVM IR (-O2):
define void @g02(double* nocapture %0, double* nocapture writeonly %1, double* nocapture writeonly %2, double* nocapture readnone %3, i32 %4, i32 %5, i32 %6, i32 %7) {
%9 = icmp sgt i32 %4, 0
br i1 %9, label %10, label %39
10: ; preds = %8
%11 = zext i32 %4 to i64
br label %12
12: ; preds = %10, %12
%13 = phi i64 [ 0, %10 ], [ %30, %12 ]
%14 = phi double [ 0.000000e+00, %10 ], [ %37, %12 ]
%15 = phi double [ 1.000000e+00, %10 ], [ %36, %12 ]
%16 = phi double [ 0.000000e+00, %10 ], [ %35, %12 ]
%17 = phi double [ 1.000000e+00, %10 ], [ %29, %12 ]
%18 = phi double [ 0.000000e+00, %10 ], [ %23, %12 ]
%19 = getelementptr inbounds double, double* %0, i64 %13
%20 = load double, double* %19
%21 = tail call double @cos(double %20)
%22 = tail call double @pow(double %21, i32 4)
%23 = fadd double %18, %22
%24 = load double, double* %19
%25 = tail call double @cos(double %24)
%26 = fmul double %17, %25
%27 = load double, double* %19
%28 = tail call double @cos(double %27)
%29 = fmul double %26, %28
%30 = add nuw nsw i64 %13, 1
%31 = trunc i64 %30 to i32
%32 = sitofp i32 %31 to double
%33 = load double, double* %19
%34 = fmul double %33, %32
%35 = tail call double @llvm.fmuladd.f64(double %34, double %33, double %16)
%36 = fmul double %15, %33
%37 = fadd double %14, %33
%38 = icmp eq i64 %30, %11
br i1 %38, label %39, label %12
39: ; preds = %12, %8
%40 = phi double [ 0.000000e+00, %8 ], [ %23, %12 ]
%41 = phi double [ 1.000000e+00, %8 ], [ %29, %12 ]
%42 = phi double [ 0.000000e+00, %8 ], [ %35, %12 ]
%43 = phi double [ 1.000000e+00, %8 ], [ %36, %12 ]
%44 = phi double [ 0.000000e+00, %8 ], [ %37, %12 ]
%45 = tail call double @llvm.fmuladd.f64(double %41, double -2.000000e+00, double %40)
%46 = tail call double @sqrt(double %42)
%47 = fdiv double %45, %46
%48 = tail call double @llvm.fabs.f64(double %47)
%49 = fneg double %48
store double %49, double* %1
%50 = fsub double 7.500000e-01, %43
store double %50, double* %2
%51 = sitofp i32 %4 to double
%52 = tail call double @llvm.fmuladd.f64(double %51, double -7.500000e+00, double %44)
%53 = getelementptr inbounds double, double* %2, i64 1
store double %52, double* %53
ret void
}