#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*/ free(double *);
scalar_t__ malloc(int);
int /*<<< orphan*/ mdisplay(double *, int, int);
int /*<<< orphan*/ printf(char *);
void printGradient(void (*funcgrad)(double *, int, double *), double *xi,
                   int N) {
  double *jac;
  jac = (double *)malloc(sizeof(double) * N);
  if (funcgrad == NULL) {
    printf("\n No gradient information \n");
  } else {
    funcgrad(xi, N, jac);
    mdisplay(jac, 1, N);
  }
  free(jac);
}


x86 assembly (clang, -O0):
<printGradient>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1182 <printGradient+0x42>
lea    0xe88(%rip),%rdi
call   1040 <printf@plt>
jmp    11a4 <printGradient+0x64>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
call   *%rax
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    $0x1,%esi
call   1050 <mdisplay@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printGradient>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %edx,%ebx
mov    %rsi,%r12
mov    %rdi,%r15
lea    0x0(,%rbx,8),%edi
call   1060 <malloc@plt>
mov    %rax,%r14
test   %r15,%r15
je     1180 <printGradient+0x40>
mov    %r12,%rdi
mov    %ebx,%esi
mov    %r14,%rdx
call   *%r15
mov    %r14,%rdi
mov    $0x1,%esi
mov    %ebx,%edx
call   1050 <mdisplay@plt>
jmp    118c <printGradient+0x4c>
lea    0xe79(%rip),%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [28 x i8] c"\0A No gradient information \0A\00"
define void @printGradient(void (double*, i32, double*)* %0, double* %1, i32 %2) {
%4 = alloca void (double*, i32, double*)*
%5 = alloca double*
%6 = alloca i32
%7 = alloca double*
store void (double*, i32, double*)* %0, void (double*, i32, double*)** %4
store double* %1, double** %5
store i32 %2, i32* %6
%8 = load i32, i32* %6
%9 = sext i32 %8 to i64
%10 = mul i64 8, %9
%11 = trunc i64 %10 to i32
%12 = call i64 @malloc(i32 %11)
%13 = inttoptr i64 %12 to double*
store double* %13, double** %7
%14 = load void (double*, i32, double*)*, void (double*, i32, double*)** %4
%15 = icmp eq void (double*, i32, double*)* %14, null
br i1 %15, label %16, label %18
16: ; preds = %3
%17 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
br label %26
18: ; preds = %3
%19 = load void (double*, i32, double*)*, void (double*, i32, double*)** %4
%20 = load double*, double** %5
%21 = load i32, i32* %6
%22 = load double*, double** %7
%23 = load double*, double** %7
%24 = load i32, i32* %6
%25 = call i32 @mdisplay(double* %23, i32 1, i32 %24)
br label %26
26: ; preds = %18, %16
%27 = load double*, double** %7
%28 = call i32 @free(double* %27)
ret void
}

LLVM IR (-O2):
@str = [27 x i8] c"\0A No gradient information \00"
define void @printGradient(void (double*, i32, double*)* %0, double* %1, i32 %2) {
%4 = shl i32 %2, 3
%5 = tail call i64 @malloc(i32 %4)
%6 = inttoptr i64 %5 to double*
%7 = icmp eq void (double*, i32, double*)* %0, null
br i1 %7, label %8, label %10
8: ; preds = %3
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
br label %12
10: ; preds = %3
tail call void %0(double* %1, i32 %2, double* %6)
%11 = tail call i32 @mdisplay(double* %6, i32 1, i32 %2)
br label %12
12: ; preds = %10, %8
%13 = tail call i32 @free(double* %6)
ret void
}