#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 exp(double const);
scalar_t__ malloc(int const);
scalar_t__ pow(int, int);
int round(int const);
double *create_exponential_centered_grid(const double xmin, const double xmax,
                                         const double xcenter,
                                         const int npoints, const double decay,
                                         int round_digits) {
  int n;
  double *grid;
  int M;
  double A_left;
  double A_right;
  double B_left;
  double B_right;
  grid = (double *)malloc(npoints * sizeof(double));
  M = round(npoints / 2.0);
  B_left = decay / M;
  A_left = (xcenter - xmin) / (exp(-decay) - 1.0);
  B_right = decay / (npoints - M - 1);
  A_right = (xmax - xcenter) / (exp(decay) - 1.0);
  for (n = 0; n < npoints; n++) {
    if (n < M) {
      grid[n] = A_left * (exp(-B_left * n) - 1.0) + xmin;
    } else {
      grid[n] = A_right * (exp(B_right * (n - M)) - 1.0) + xcenter;
    }
  }
  if (round_digits) {
    for (n = 0; n < npoints; n++) {
      grid[n] = ((int)(grid[n] * ((int)pow(10, round_digits)))) /
                ((double)pow(10, round_digits));
    }
  }
  return grid;
}


x86 assembly (clang, -O0):
<create_exponential_centered_grid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
mov    %edi,-0x1c(%rbp)
movsd  %xmm3,-0x28(%rbp)
mov    %esi,-0x2c(%rbp)
movslq -0x1c(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x38(%rbp)
cvtsi2sdl -0x1c(%rbp),%xmm0
movsd  0xe83(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1060 <round@plt>
mov    %eax,-0x3c(%rbp)
movsd  -0x28(%rbp),%xmm0
cvtsi2sdl -0x3c(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x28(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
call   1040 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm0
movsd  0xe18(%rip),%xmm2
subsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x28(%rbp),%xmm0
mov    -0x1c(%rbp),%eax
sub    -0x3c(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1040 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
movsd  0xdc7(%rip),%xmm2
subsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    132f <create_exponential_centered_grid+0x1ef>
mov    -0x30(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jge    12cc <create_exponential_centered_grid+0x18c>
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x58(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
cvtsi2sdl -0x30(%rbp),%xmm1
mulsd  %xmm1,%xmm0
call   1040 <exp@plt>
movaps %xmm0,%xmm2
movsd  -0x78(%rbp),%xmm0
movsd  0xd57(%rip),%xmm1
subsd  %xmm1,%xmm2
movsd  -0x8(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x38(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    131c <create_exponential_centered_grid+0x1dc>
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x60(%rbp),%xmm0
mov    -0x30(%rbp),%eax
sub    -0x3c(%rbp),%eax
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
call   1040 <exp@plt>
movaps %xmm0,%xmm2
movsd  -0x80(%rbp),%xmm0
movsd  0xd02(%rip),%xmm1
subsd  %xmm1,%xmm2
movsd  -0x18(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x38(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    1321 <create_exponential_centered_grid+0x1e1>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    124d <create_exponential_centered_grid+0x10d>
cmpl   $0x0,-0x2c(%rbp)
je     13cc <create_exponential_centered_grid+0x28c>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    13c7 <create_exponential_centered_grid+0x287>
mov    -0x38(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
mov    -0x2c(%rbp),%esi
mov    $0xa,%edi
call   1050 <pow@plt>
movsd  -0x90(%rbp),%xmm0
ff
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
mov    -0x2c(%rbp),%esi
mov    $0xa,%edi
call   1050 <pow@plt>
movsd  -0x88(%rbp),%xmm0
ff
cvtsi2sd %rax,%xmm1
divsd  %xmm1,%xmm0
mov    -0x38(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1340 <create_exponential_centered_grid+0x200>
jmp    13cc <create_exponential_centered_grid+0x28c>
mov    -0x38(%rbp),%rax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_exponential_centered_grid>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %esi,%r12d
movapd %xmm3,(%rsp)
mov    %edi,%ebp
movsd  %xmm2,0x28(%rsp)
movsd  %xmm1,0x18(%rsp)
movsd  %xmm0,0x20(%rsp)
lea    0x0(,%rbp,8),%edi
call   1030 <malloc@plt>
mov    %rax,%r13
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
mulsd  0xe78(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1060 <round@plt>
mov    %eax,%r15d
movaps 0xe75(%rip),%xmm0
xorps  (%rsp),%xmm0
movaps %xmm0,0x30(%rsp)
call   1040 <exp@plt>
movsd  %xmm0,0x10(%rsp)
movapd (%rsp),%xmm0
call   1040 <exp@plt>
test   %ebp,%ebp
jle    134f <create_exponential_centered_grid+0x20f>
movsd  0x28(%rsp),%xmm4
movapd %xmm4,%xmm2
movsd  0x20(%rsp),%xmm6
subsd  %xmm6,%xmm2
movsd  0xe2b(%rip),%xmm3
movsd  0x10(%rsp),%xmm5
addsd  %xmm3,%xmm5
mov    %r15d,%eax
not    %eax
add    %ebp,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
divsd  %xmm5,%xmm2
movsd  %xmm2,0x10(%rsp)
movapd (%rsp),%xmm2
divsd  %xmm1,%xmm2
movsd  0x18(%rsp),%xmm5
subsd  %xmm4,%xmm5
addsd  %xmm3,%xmm0
divsd  %xmm0,%xmm5
xorps  %xmm0,%xmm0
cvtsi2sd %r15d,%xmm0
movapd 0x30(%rsp),%xmm7
divsd  %xmm0,%xmm7
movslq %r15d,%rbx
mov    %rbp,0x40(%rsp)
mov    %ebp,%ebp
mov    %ebx,%r15d
neg    %r15d
xor    %r14d,%r14d
movapd %xmm2,%xmm1
movapd %xmm2,(%rsp)
movapd %xmm5,%xmm3
movapd %xmm7,%xmm5
movapd %xmm7,0x30(%rsp)
movsd  %xmm3,0x18(%rsp)
jmp    12ab <create_exponential_centered_grid+0x16b>
xchg   %ax,%ax
lea    (%r15,%r14,1),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  %xmm1,%xmm0
call   1040 <exp@plt>
addsd  0xd8c(%rip),%xmm0
movsd  0x18(%rsp),%xmm3
mulsd  %xmm3,%xmm0
movsd  0x28(%rsp),%xmm2
addsd  %xmm2,%xmm0
movsd  %xmm0,0x0(%r13,%r14,8)
add    $0x1,%r14
cmp    %r14,%rbp
movapd (%rsp),%xmm1
movapd 0x30(%rsp),%xmm5
je     12db <create_exponential_centered_grid+0x19b>
cmp    %rbx,%r14
jge    1260 <create_exponential_centered_grid+0x120>
xorps  %xmm0,%xmm0
cvtsi2sd %r14d,%xmm0
mulsd  %xmm5,%xmm0
call   1040 <exp@plt>
addsd  0xd3f(%rip),%xmm0
mulsd  0x10(%rsp),%xmm0
movsd  0x20(%rsp),%xmm4
addsd  %xmm4,%xmm0
jmp    1290 <create_exponential_centered_grid+0x150>
test   %r12d,%r12d
mov    0x40(%rsp),%rax
je     134f <create_exponential_centered_grid+0x20f>
test   %eax,%eax
jle    134f <create_exponential_centered_grid+0x20f>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movsd  0x0(%r13,%rbx,8),%xmm0
movsd  %xmm0,(%rsp)
mov    $0xa,%edi
mov    %r12d,%esi
call   1050 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  (%rsp),%xmm0
cvttpd2dq %xmm0,%xmm0
cvtdq2pd %xmm0,%xmm0
movaps %xmm0,(%rsp)
mov    $0xa,%edi
mov    %r12d,%esi
call   1050 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movapd (%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x0(%r13,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    12f0 <create_exponential_centered_grid+0x1b0>
mov    %r13,%rax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double* @create_exponential_centered_grid(double %0, double %1, double %2, i32 %3, double %4, i32 %5) {
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca i32
%11 = alloca double
%12 = alloca i32
%13 = alloca i32
%14 = alloca double*
%15 = alloca i32
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
store double %0, double* %7
store double %1, double* %8
store double %2, double* %9
store i32 %3, i32* %10
store double %4, double* %11
store i32 %5, i32* %12
%20 = load i32, i32* %10
%21 = sext i32 %20 to i64
%22 = mul i64 %21, 8
%23 = trunc i64 %22 to i32
%24 = call i64 @malloc(i32 %23)
%25 = inttoptr i64 %24 to double*
store double* %25, double** %14
%26 = load i32, i32* %10
%27 = sitofp i32 %26 to double
%28 = fdiv double %27, 2.000000e+00
%29 = fptosi double %28 to i32
%30 = call i32 @round(i32 %29)
store i32 %30, i32* %15
%31 = load double, double* %11
%32 = load i32, i32* %15
%33 = sitofp i32 %32 to double
%34 = fdiv double %31, %33
store double %34, double* %18
%35 = load double, double* %9
%36 = load double, double* %7
%37 = fsub double %35, %36
%38 = load double, double* %11
%39 = fneg double %38
%40 = call double @exp(double %39)
%41 = fsub double %40, 1.000000e+00
%42 = fdiv double %37, %41
store double %42, double* %16
%43 = load double, double* %11
%44 = load i32, i32* %10
%45 = load i32, i32* %15
%46 = sub nsw i32 %44, %45
%47 = sub nsw i32 %46, 1
%48 = sitofp i32 %47 to double
%49 = fdiv double %43, %48
store double %49, double* %19
%50 = load double, double* %8
%51 = load double, double* %9
%52 = fsub double %50, %51
%53 = load double, double* %11
%54 = call double @exp(double %53)
%55 = fsub double %54, 1.000000e+00
%56 = fdiv double %52, %55
store double %56, double* %17
store i32 0, i32* %13
br label %57
57: ; preds = %97, %6
%58 = load i32, i32* %13
%59 = load i32, i32* %10
%60 = icmp slt i32 %58, %59
br i1 %60, label %61, label %100
61: ; preds = %57
%62 = load i32, i32* %13
%63 = load i32, i32* %15
%64 = icmp slt i32 %62, %63
br i1 %64, label %65, label %80
65: ; preds = %61
%66 = load double, double* %16
%67 = load double, double* %18
%68 = fneg double %67
%69 = load i32, i32* %13
%70 = sitofp i32 %69 to double
%71 = fmul double %68, %70
%72 = call double @exp(double %71)
%73 = fsub double %72, 1.000000e+00
%74 = load double, double* %7
%75 = call double @llvm.fmuladd.f64(double %66, double %73, double %74)
%76 = load double*, double** %14
%77 = load i32, i32* %13
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds double, double* %76, i64 %78
store double %75, double* %79
br label %96
80: ; preds = %61
%81 = load double, double* %17
%82 = load double, double* %19
%83 = load i32, i32* %13
%84 = load i32, i32* %15
%85 = sub nsw i32 %83, %84
%86 = sitofp i32 %85 to double
%87 = fmul double %82, %86
%88 = call double @exp(double %87)
%89 = fsub double %88, 1.000000e+00
%90 = load double, double* %9
%91 = call double @llvm.fmuladd.f64(double %81, double %89, double %90)
%92 = load double*, double** %14
%93 = load i32, i32* %13
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds double, double* %92, i64 %94
store double %91, double* %95
br label %96
96: ; preds = %80, %65
br label %97
97: ; preds = %96
%98 = load i32, i32* %13
%99 = add nsw i32 %98, 1
store i32 %99, i32* %13
br label %57
100: ; preds = %57
%101 = load i32, i32* %12
%102 = icmp ne i32 %101, 0
br i1 %102, label %103, label %133
103: ; preds = %100
store i32 0, i32* %13
br label %104
104: ; preds = %129, %103
%105 = load i32, i32* %13
%106 = load i32, i32* %10
%107 = icmp slt i32 %105, %106
br i1 %107, label %108, label %132
108: ; preds = %104
%109 = load double*, double** %14
%110 = load i32, i32* %13
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds double, double* %109, i64 %111
%113 = load double, double* %112
%114 = load i32, i32* %12
%115 = call i64 @pow(i32 10, i32 %114)
%116 = trunc i64 %115 to i32
%117 = sitofp i32 %116 to double
%118 = fmul double %113, %117
%119 = fptosi double %118 to i32
%120 = sitofp i32 %119 to double
%121 = load i32, i32* %12
%122 = call i64 @pow(i32 10, i32 %121)
%123 = sitofp i64 %122 to double
%124 = fdiv double %120, %123
%125 = load double*, double** %14
%126 = load i32, i32* %13
%127 = sext i32 %126 to i64
%128 = getelementptr inbounds double, double* %125, i64 %127
store double %124, double* %128
br label %129
129: ; preds = %108
%130 = load i32, i32* %13
%131 = add nsw i32 %130, 1
store i32 %131, i32* %13
br label %104
132: ; preds = %104
br label %133
133: ; preds = %132, %100
%134 = load double*, double** %14
ret double* %134
}

LLVM IR (-O2):
define double* @create_exponential_centered_grid(double %0, double %1, double %2, i32 %3, double %4, i32 %5) {
%7 = shl i32 %3, 3
%8 = tail call i64 @malloc(i32 %7)
%9 = inttoptr i64 %8 to double*
%10 = sitofp i32 %3 to double
%11 = fmul double %10, 5.000000e-01
%12 = fptosi double %11 to i32
%13 = tail call i32 @round(i32 %12)
%14 = fsub double %2, %0
%15 = fneg double %4
%16 = tail call double @exp(double %15)
%17 = fadd double %16, -1.000000e+00
%18 = fdiv double %14, %17
%19 = xor i32 %13, -1
%20 = add i32 %19, %3
%21 = sitofp i32 %20 to double
%22 = fdiv double %4, %21
%23 = fsub double %1, %2
%24 = tail call double @exp(double %4)
%25 = fadd double %24, -1.000000e+00
%26 = fdiv double %23, %25
%27 = icmp sgt i32 %3, 0
br i1 %27, label %28, label %75
28: ; preds = %6
%29 = sitofp i32 %13 to double
%30 = fdiv double %15, %29
%31 = sext i32 %13 to i64
%32 = zext i32 %3 to i64
br label %33
33: ; preds = %28, %50
%34 = phi i64 [ 0, %28 ], [ %53, %50 ]
%35 = icmp slt i64 %34, %31
%36 = trunc i64 %34 to i32
br i1 %35, label %37, label %43
37: ; preds = %33
%38 = sitofp i32 %36 to double
%39 = fmul double %30, %38
%40 = tail call double @exp(double %39)
%41 = fadd double %40, -1.000000e+00
%42 = tail call double @llvm.fmuladd.f64(double %18, double %41, double %0)
br label %50
43: ; preds = %33
%44 = sub nsw i32 %36, %13
%45 = sitofp i32 %44 to double
%46 = fmul double %22, %45
%47 = tail call double @exp(double %46)
%48 = fadd double %47, -1.000000e+00
%49 = tail call double @llvm.fmuladd.f64(double %26, double %48, double %2)
br label %50
50: ; preds = %37, %43
%51 = phi double [ %42, %37 ], [ %49, %43 ]
%52 = getelementptr inbounds double, double* %9, i64 %34
store double %51, double* %52
%53 = add nuw nsw i64 %34, 1
%54 = icmp eq i64 %53, %32
br i1 %54, label %55, label %33
55: ; preds = %50
%56 = icmp ne i32 %5, 0
%57 = and i1 %56, %27
br i1 %57, label %58, label %75
58: ; preds = %55
%59 = zext i32 %3 to i64
br label %60
60: ; preds = %58, %60
%61 = phi i64 [ 0, %58 ], [ %73, %60 ]
%62 = getelementptr inbounds double, double* %9, i64 %61
%63 = load double, double* %62
%64 = tail call i64 @pow(i32 10, i32 %5)
%65 = trunc i64 %64 to i32
%66 = sitofp i32 %65 to double
%67 = fmul double %63, %66
%68 = fptosi double %67 to i32
%69 = sitofp i32 %68 to double
%70 = tail call i64 @pow(i32 10, i32 %5)
%71 = sitofp i64 %70 to double
%72 = fdiv double %69, %71
store double %72, double* %62
%73 = add nuw nsw i64 %61, 1
%74 = icmp eq i64 %73, %59
br i1 %74, label %75, label %60
75: ; preds = %60, %6, %55
ret double* %9
}