#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 exp(double);
void powellgrad(double *x, int N, double *g) {
  double t1, t2;
  t1 = (10000 * x[0] * x[1] - 1);
  t2 = (exp(-x[0]) + exp(-x[1]) - 1.0001);
  g[0] = 2 * t1 * 10000 * x[1] - 2 * exp(-x[0]) * t2;
  g[1] = 2 * t1 * 10000 * x[0] - 2 * exp(-x[1]) * t2;
}


x86 assembly (clang, -O0):
<powellgrad>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsd  0xed1(%rip),%xmm0
mulsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xed0(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
call   1030 <exp@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
call   1030 <exp@plt>
mov    %eax,%ecx
mov    -0x4c(%rbp),%eax
add    %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  0xe60(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe47(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  0xe32(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
call   1030 <exp@plt>
movsd  -0x48(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm2
shl    $0x1,%eax
cvtsi2sd %eax,%xmm1
mulsd  -0x28(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  0xdba(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  0xda5(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
call   1030 <exp@plt>
movsd  -0x38(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
shl    $0x1,%eax
cvtsi2sd %eax,%xmm1
mulsd  -0x28(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<powellgrad>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rdx,%r14
mov    %rdi,%rbx
movsd  (%rdi),%xmm0
movapd %xmm0,%xmm1
mulsd  0xed2(%rip),%xmm1
mulsd  0x8(%rdi),%xmm1
addsd  0xecd(%rip),%xmm1
movapd %xmm1,(%rsp)
xorpd  0xed8(%rip),%xmm0
call   1030 <exp@plt>
mov    %eax,%ebp
movsd  0x8(%rbx),%xmm0
xorps  0xec5(%rip),%xmm0
call   1030 <exp@plt>
add    %ebp,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  0xe9f(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
movapd (%rsp),%xmm1
addsd  %xmm1,%xmm1
mulsd  0xe78(%rip),%xmm1
movapd %xmm1,(%rsp)
movsd  (%rbx),%xmm0
xorps  0xe88(%rip),%xmm0
movsd  0x8(%rbx),%xmm2
mulsd  %xmm1,%xmm2
movsd  %xmm2,0x18(%rsp)
call   1030 <exp@plt>
add    %eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x10(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%r14)
movsd  0x8(%rbx),%xmm0
xorps  0xe4a(%rip),%xmm0
movapd (%rsp),%xmm1
mulsd  (%rbx),%xmm1
movapd %xmm1,(%rsp)
call   1030 <exp@plt>
add    %eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x10(%rsp),%xmm0
movapd (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%r14)
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @powellgrad(double* %0, i32 %1, double* %2) {
%4 = alloca double*
%5 = alloca i32
%6 = alloca double*
%7 = alloca double
%8 = alloca double
store double* %0, double** %4
store i32 %1, i32* %5
store double* %2, double** %6
%9 = load double*, double** %4
%10 = getelementptr inbounds double, double* %9, i64 0
%11 = load double, double* %10
%12 = fmul double 1.000000e+04, %11
%13 = load double*, double** %4
%14 = getelementptr inbounds double, double* %13, i64 1
%15 = load double, double* %14
%16 = call double @llvm.fmuladd.f64(double %12, double %15, double -1.000000e+00)
store double %16, double* %7
%17 = load double*, double** %4
%18 = getelementptr inbounds double, double* %17, i64 0
%19 = load double, double* %18
%20 = fneg double %19
%21 = call i32 @exp(double %20)
%22 = load double*, double** %4
%23 = getelementptr inbounds double, double* %22, i64 1
%24 = load double, double* %23
%25 = fneg double %24
%26 = call i32 @exp(double %25)
%27 = add nsw i32 %21, %26
%28 = sitofp i32 %27 to double
%29 = fsub double %28, 1.000100e+00
store double %29, double* %8
%30 = load double, double* %7
%31 = fmul double 2.000000e+00, %30
%32 = fmul double %31, 1.000000e+04
%33 = load double*, double** %4
%34 = getelementptr inbounds double, double* %33, i64 1
%35 = load double, double* %34
%36 = load double*, double** %4
%37 = getelementptr inbounds double, double* %36, i64 0
%38 = load double, double* %37
%39 = fneg double %38
%40 = call i32 @exp(double %39)
%41 = mul nsw i32 2, %40
%42 = sitofp i32 %41 to double
%43 = load double, double* %8
%44 = fmul double %42, %43
%45 = fneg double %44
%46 = call double @llvm.fmuladd.f64(double %32, double %35, double %45)
%47 = load double*, double** %6
%48 = getelementptr inbounds double, double* %47, i64 0
store double %46, double* %48
%49 = load double, double* %7
%50 = fmul double 2.000000e+00, %49
%51 = fmul double %50, 1.000000e+04
%52 = load double*, double** %4
%53 = getelementptr inbounds double, double* %52, i64 0
%54 = load double, double* %53
%55 = load double*, double** %4
%56 = getelementptr inbounds double, double* %55, i64 1
%57 = load double, double* %56
%58 = fneg double %57
%59 = call i32 @exp(double %58)
%60 = mul nsw i32 2, %59
%61 = sitofp i32 %60 to double
%62 = load double, double* %8
%63 = fmul double %61, %62
%64 = fneg double %63
%65 = call double @llvm.fmuladd.f64(double %51, double %54, double %64)
%66 = load double*, double** %6
%67 = getelementptr inbounds double, double* %66, i64 1
store double %65, double* %67
ret void
}

LLVM IR (-O2):
define void @powellgrad(double* nocapture %0, i32 %1, double* nocapture writeonly %2) {
%4 = load double, double* %0
%5 = fmul double %4, 1.000000e+04
%6 = getelementptr inbounds double, double* %0, i64 1
%7 = load double, double* %6
%8 = tail call double @llvm.fmuladd.f64(double %5, double %7, double -1.000000e+00)
%9 = fneg double %4
%10 = tail call i32 @exp(double %9)
%11 = load double, double* %6
%12 = fneg double %11
%13 = tail call i32 @exp(double %12)
%14 = add nsw i32 %13, %10
%15 = sitofp i32 %14 to double
%16 = fadd double %15, -1.000100e+00
%17 = fmul double %8, 2.000000e+00
%18 = fmul double %17, 1.000000e+04
%19 = load double, double* %6
%20 = load double, double* %0
%21 = fneg double %20
%22 = tail call i32 @exp(double %21)
%23 = shl nsw i32 %22, 1
%24 = sitofp i32 %23 to double
%25 = fneg double %16
%26 = fmul double %25, %24
%27 = tail call double @llvm.fmuladd.f64(double %18, double %19, double %26)
store double %27, double* %2
%28 = load double, double* %0
%29 = load double, double* %6
%30 = fneg double %29
%31 = tail call i32 @exp(double %30)
%32 = shl nsw i32 %31, 1
%33 = sitofp i32 %32 to double
%34 = fmul double %25, %33
%35 = tail call double @llvm.fmuladd.f64(double %18, double %28, double %34)
%36 = getelementptr inbounds double, double* %2, i64 1
store double %35, double* %36
ret void
}