#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 *compute_grid_bound(int, double *, int *, int *, char const *);
double *compute_grid_bound_legacy(int, double *, double *, double, int *,
                                  char const *);
int /*<<< orphan*/ free(double *);
void create_vgrid(int nbnds, double *bnds, int *nz, double *dbnds,
                  double stretch, int use_legacy, double *zeta, int *np,
                  const char *center) {
  int i;
  double *zb = NULL;
  if (use_legacy)
    zb = compute_grid_bound_legacy(nbnds, bnds, dbnds, stretch, np, center);
  else
    zb = compute_grid_bound(nbnds, bnds, nz, np, center);
  for (i = 0; i < (*np + 1); i++)
    zeta[i] = zb[i];
  free(zb);
}


x86 assembly (clang, -O0):
<create_vgrid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movsd  %xmm0,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
mov    %r9,-0x38(%rbp)
movq   $0x0,-0x48(%rbp)
cmpl   $0x0,-0x2c(%rbp)
je     1194 <create_vgrid+0x64>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
movsd  -0x28(%rbp),%xmm0
mov    0x10(%rbp),%rcx
mov    0x18(%rbp),%r8
call   1040 <compute_grid_bound_legacy@plt>
mov    %rax,-0x48(%rbp)
jmp    11b0 <create_vgrid+0x80>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    0x10(%rbp),%rcx
mov    0x18(%rbp),%r8
call   1050 <compute_grid_bound@plt>
mov    %rax,-0x48(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    0x10(%rbp),%rcx
mov    (%rcx),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    11f3 <create_vgrid+0xc3>
mov    -0x48(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x38(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11b7 <create_vgrid+0x87>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_vgrid>:
push   %r14
push   %rbx
push   %rax
mov    %r9,%rbx
mov    %r8d,%eax
mov    0x28(%rsp),%r8
mov    0x20(%rsp),%r14
test   %eax,%eax
je     1155 <create_vgrid+0x25>
mov    %rcx,%rdx
mov    %r14,%rcx
call   1040 <compute_grid_bound_legacy@plt>
jmp    115d <create_vgrid+0x2d>
mov    %r14,%rcx
call   1050 <compute_grid_bound@plt>
mov    %rax,%rdi
mov    (%r14),%r9d
test   %r9d,%r9d
js     12d4 <create_vgrid+0x1a4>
mov    %r9d,%eax
add    $0x1,%r9
cmp    $0x3,%eax
jb     118a <create_vgrid+0x5a>
lea    (%rdi,%r9,8),%rax
cmp    %rbx,%rax
jbe    11fc <create_vgrid+0xcc>
lea    (%rbx,%r9,8),%rax
cmp    %rax,%rdi
jae    11fc <create_vgrid+0xcc>
xor    %ecx,%ecx
mov    %rcx,%rdx
not    %rdx
add    %r9,%rdx
mov    %r9,%rsi
and    $0x3,%rsi
je     11b4 <create_vgrid+0x84>
xchg   %ax,%ax
movsd  (%rdi,%rcx,8),%xmm0
movsd  %xmm0,(%rbx,%rcx,8)
add    $0x1,%rcx
add    $0xffffffffffffffff,%rsi
jne    11a0 <create_vgrid+0x70>
cmp    $0x3,%rdx
jb     12d4 <create_vgrid+0x1a4>
xchg   %ax,%ax
movsd  (%rdi,%rcx,8),%xmm0
movsd  %xmm0,(%rbx,%rcx,8)
movsd  0x8(%rdi,%rcx,8),%xmm0
movsd  %xmm0,0x8(%rbx,%rcx,8)
movsd  0x10(%rdi,%rcx,8),%xmm0
movsd  %xmm0,0x10(%rbx,%rcx,8)
movsd  0x18(%rdi,%rcx,8),%xmm0
movsd  %xmm0,0x18(%rbx,%rcx,8)
add    $0x4,%rcx
cmp    %rcx,%r9
jne    11c0 <create_vgrid+0x90>
jmp    12d4 <create_vgrid+0x1a4>
mov    %r9d,%ecx
and    $0xfffffffc,%ecx
lea    -0x4(%rcx),%rax
mov    %rax,%rsi
shr    $0x2,%rsi
add    $0x1,%rsi
mov    %esi,%r8d
and    $0x3,%r8d
cmp    $0xc,%rax
jae    1222 <create_vgrid+0xf2>
xor    %edx,%edx
jmp    1288 <create_vgrid+0x158>
and    $0xfffffffffffffffc,%rsi
xor    %edx,%edx
nopl   0x0(%rax,%rax,1)
movups (%rdi,%rdx,8),%xmm0
movups 0x10(%rdi,%rdx,8),%xmm1
movups %xmm0,(%rbx,%rdx,8)
movups %xmm1,0x10(%rbx,%rdx,8)
movups 0x20(%rdi,%rdx,8),%xmm0
movups 0x30(%rdi,%rdx,8),%xmm1
movups %xmm0,0x20(%rbx,%rdx,8)
movups %xmm1,0x30(%rbx,%rdx,8)
movups 0x40(%rdi,%rdx,8),%xmm0
movups 0x50(%rdi,%rdx,8),%xmm1
movups %xmm0,0x40(%rbx,%rdx,8)
movups %xmm1,0x50(%rbx,%rdx,8)
movups 0x60(%rdi,%rdx,8),%xmm0
movups 0x70(%rdi,%rdx,8),%xmm1
movups %xmm0,0x60(%rbx,%rdx,8)
movups %xmm1,0x70(%rbx,%rdx,8)
add    $0x10,%rdx
add    $0xfffffffffffffffc,%rsi
jne    1230 <create_vgrid+0x100>
test   %r8,%r8
je     12cb <create_vgrid+0x19b>
lea    (%rbx,%rdx,8),%rsi
add    $0x10,%rsi
lea    (%rdi,%rdx,8),%rdx
add    $0x10,%rdx
shl    $0x5,%r8
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movups -0x10(%rdx,%rax,1),%xmm0
movups (%rdx,%rax,1),%xmm1
movups %xmm0,-0x10(%rsi,%rax,1)
movups %xmm1,(%rsi,%rax,1)
add    $0x20,%rax
cmp    %rax,%r8
jne    12b0 <create_vgrid+0x180>
cmp    %r9,%rcx
jne    118c <create_vgrid+0x5c>
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <free@plt>

LLVM IR (-O0):
define void @create_vgrid(i32 %0, double* %1, i32* %2, double* %3, double %4, i32 %5, double* %6, i32* %7, i8* %8) {
%10 = alloca i32
%11 = alloca double*
%12 = alloca i32*
%13 = alloca double*
%14 = alloca double
%15 = alloca i32
%16 = alloca double*
%17 = alloca i32*
%18 = alloca i8*
%19 = alloca i32
%20 = alloca double*
store i32 %0, i32* %10
store double* %1, double** %11
store i32* %2, i32** %12
store double* %3, double** %13
store double %4, double* %14
store i32 %5, i32* %15
store double* %6, double** %16
store i32* %7, i32** %17
store i8* %8, i8** %18
store double* null, double** %20
%21 = load i32, i32* %15
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %31
23: ; preds = %9
%24 = load i32, i32* %10
%25 = load double*, double** %11
%26 = load double*, double** %13
%27 = load double, double* %14
%28 = load i32*, i32** %17
%29 = load i8*, i8** %18
%30 = call double* @compute_grid_bound_legacy(i32 %24, double* %25, double* %26, double %27, i32* %28, i8* %29)
store double* %30, double** %20
br label %38
31: ; preds = %9
%32 = load i32, i32* %10
%33 = load double*, double** %11
%34 = load i32*, i32** %12
%35 = load i32*, i32** %17
%36 = load i8*, i8** %18
%37 = call double* @compute_grid_bound(i32 %32, double* %33, i32* %34, i32* %35, i8* %36)
store double* %37, double** %20
br label %38
38: ; preds = %31, %23
store i32 0, i32* %19
br label %39
39: ; preds = %55, %38
%40 = load i32, i32* %19
%41 = load i32*, i32** %17
%42 = load i32, i32* %41
%43 = add nsw i32 %42, 1
%44 = icmp slt i32 %40, %43
br i1 %44, label %45, label %58
45: ; preds = %39
%46 = load double*, double** %20
%47 = load i32, i32* %19
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds double, double* %46, i64 %48
%50 = load double, double* %49
%51 = load double*, double** %16
%52 = load i32, i32* %19
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds double, double* %51, i64 %53
store double %50, double* %54
br label %55
55: ; preds = %45
%56 = load i32, i32* %19
%57 = add nsw i32 %56, 1
store i32 %57, i32* %19
br label %39
58: ; preds = %39
%59 = load double*, double** %20
%60 = call i32 @free(double* %59)
ret void
}

LLVM IR (-O2):
define void @create_vgrid(i32 %0, double* %1, i32* %2, double* %3, double %4, i32 %5, double* nocapture writeonly %6, i32* %7, i8* %8) {
%10 = icmp eq i32 %5, 0
br i1 %10, label %13, label %11
11: ; preds = %9
%12 = tail call double* @compute_grid_bound_legacy(i32 %0, double* %1, double* %3, double %4, i32* %7, i8* %8)
br label %15
13: ; preds = %9
%14 = tail call double* @compute_grid_bound(i32 %0, double* %1, i32* %2, i32* %7, i8* %8)
br label %15
15: ; preds = %13, %11
%16 = phi double* [ %12, %11 ], [ %14, %13 ]
%17 = load i32, i32* %7
%18 = icmp slt i32 %17, 0
br i1 %18, label %145, label %19
19: ; preds = %15
%20 = add nuw i32 %17, 1
%21 = zext i32 %20 to i64
%22 = icmp ult i32 %17, 3
br i1 %22, label %108, label %23
23: ; preds = %19
%24 = getelementptr double, double* %6, i64 %21
%25 = getelementptr double, double* %16, i64 %21
%26 = icmp ugt double* %25, %6
%27 = icmp ult double* %16, %24
%28 = and i1 %26, %27
br i1 %28, label %108, label %29
29: ; preds = %23
%30 = and i64 %21, 4294967292
%31 = add nsw i64 %30, -4
%32 = lshr exact i64 %31, 2
%33 = add nuw nsw i64 %32, 1
%34 = and i64 %33, 3
%35 = icmp ult i64 %31, 12
br i1 %35, label %87, label %36
36: ; preds = %29
%37 = and i64 %33, 9223372036854775804
br label %38
38: ; preds = %38, %36
%39 = phi i64 [ 0, %36 ], [ %84, %38 ]
%40 = phi i64 [ 0, %36 ], [ %85, %38 ]
%41 = getelementptr inbounds double, double* %16, i64 %39
%42 = bitcast double* %41 to <2 x double>*
%43 = load <2 x double>, <2 x double>* %42
%44 = getelementptr inbounds double, double* %41, i64 2
%45 = bitcast double* %44 to <2 x double>*
%46 = load <2 x double>, <2 x double>* %45
%47 = getelementptr inbounds double, double* %6, i64 %39
%48 = bitcast double* %47 to <2 x double>*
store <2 x double> %43, <2 x double>* %48
%49 = getelementptr inbounds double, double* %47, i64 2
%50 = bitcast double* %49 to <2 x double>*
store <2 x double> %46, <2 x double>* %50
%51 = or i64 %39, 4
%52 = getelementptr inbounds double, double* %16, i64 %51
%53 = bitcast double* %52 to <2 x double>*
%54 = load <2 x double>, <2 x double>* %53
%55 = getelementptr inbounds double, double* %52, i64 2
%56 = bitcast double* %55 to <2 x double>*
%57 = load <2 x double>, <2 x double>* %56
%58 = getelementptr inbounds double, double* %6, i64 %51
%59 = bitcast double* %58 to <2 x double>*
store <2 x double> %54, <2 x double>* %59
%60 = getelementptr inbounds double, double* %58, i64 2
%61 = bitcast double* %60 to <2 x double>*
store <2 x double> %57, <2 x double>* %61
%62 = or i64 %39, 8
%63 = getelementptr inbounds double, double* %16, i64 %62
%64 = bitcast double* %63 to <2 x double>*
%65 = load <2 x double>, <2 x double>* %64
%66 = getelementptr inbounds double, double* %63, i64 2
%67 = bitcast double* %66 to <2 x double>*
%68 = load <2 x double>, <2 x double>* %67
%69 = getelementptr inbounds double, double* %6, i64 %62
%70 = bitcast double* %69 to <2 x double>*
store <2 x double> %65, <2 x double>* %70
%71 = getelementptr inbounds double, double* %69, i64 2
%72 = bitcast double* %71 to <2 x double>*
store <2 x double> %68, <2 x double>* %72
%73 = or i64 %39, 12
%74 = getelementptr inbounds double, double* %16, i64 %73
%75 = bitcast double* %74 to <2 x double>*
%76 = load <2 x double>, <2 x double>* %75
%77 = getelementptr inbounds double, double* %74, i64 2
%78 = bitcast double* %77 to <2 x double>*
%79 = load <2 x double>, <2 x double>* %78
%80 = getelementptr inbounds double, double* %6, i64 %73
%81 = bitcast double* %80 to <2 x double>*
store <2 x double> %76, <2 x double>* %81
%82 = getelementptr inbounds double, double* %80, i64 2
%83 = bitcast double* %82 to <2 x double>*
store <2 x double> %79, <2 x double>* %83
%84 = add nuw i64 %39, 16
%85 = add nuw i64 %40, 4
%86 = icmp eq i64 %85, %37
br i1 %86, label %87, label %38
87: ; preds = %38, %29
%88 = phi i64 [ 0, %29 ], [ %84, %38 ]
%89 = icmp eq i64 %34, 0
br i1 %89, label %106, label %90
90: ; preds = %87, %90
%91 = phi i64 [ %103, %90 ], [ %88, %87 ]
%92 = phi i64 [ %104, %90 ], [ 0, %87 ]
%93 = getelementptr inbounds double, double* %16, i64 %91
%94 = bitcast double* %93 to <2 x double>*
%95 = load <2 x double>, <2 x double>* %94
%96 = getelementptr inbounds double, double* %93, i64 2
%97 = bitcast double* %96 to <2 x double>*
%98 = load <2 x double>, <2 x double>* %97
%99 = getelementptr inbounds double, double* %6, i64 %91
%100 = bitcast double* %99 to <2 x double>*
store <2 x double> %95, <2 x double>* %100
%101 = getelementptr inbounds double, double* %99, i64 2
%102 = bitcast double* %101 to <2 x double>*
store <2 x double> %98, <2 x double>* %102
%103 = add nuw i64 %91, 4
%104 = add i64 %92, 1
%105 = icmp eq i64 %104, %34
br i1 %105, label %106, label %90
106: ; preds = %90, %87
%107 = icmp eq i64 %30, %21
br i1 %107, label %145, label %108
108: ; preds = %23, %19, %106
%109 = phi i64 [ 0, %23 ], [ 0, %19 ], [ %30, %106 ]
%110 = xor i64 %109, -1
%111 = add nsw i64 %110, %21
%112 = and i64 %21, 3
%113 = icmp eq i64 %112, 0
br i1 %113, label %123, label %114
114: ; preds = %108, %114
%115 = phi i64 [ %120, %114 ], [ %109, %108 ]
%116 = phi i64 [ %121, %114 ], [ 0, %108 ]
%117 = getelementptr inbounds double, double* %16, i64 %115
%118 = load double, double* %117
%119 = getelementptr inbounds double, double* %6, i64 %115
store double %118, double* %119
%120 = add nuw nsw i64 %115, 1
%121 = add i64 %116, 1
%122 = icmp eq i64 %121, %112
br i1 %122, label %123, label %114
123: ; preds = %114, %108
%124 = phi i64 [ %109, %108 ], [ %120, %114 ]
%125 = icmp ult i64 %111, 3
br i1 %125, label %145, label %126
126: ; preds = %123, %126
%127 = phi i64 [ %143, %126 ], [ %124, %123 ]
%128 = getelementptr inbounds double, double* %16, i64 %127
%129 = load double, double* %128
%130 = getelementptr inbounds double, double* %6, i64 %127
store double %129, double* %130
%131 = add nuw nsw i64 %127, 1
%132 = getelementptr inbounds double, double* %16, i64 %131
%133 = load double, double* %132
%134 = getelementptr inbounds double, double* %6, i64 %131
store double %133, double* %134
%135 = add nuw nsw i64 %127, 2
%136 = getelementptr inbounds double, double* %16, i64 %135
%137 = load double, double* %136
%138 = getelementptr inbounds double, double* %6, i64 %135
store double %137, double* %138
%139 = add nuw nsw i64 %127, 3
%140 = getelementptr inbounds double, double* %16, i64 %139
%141 = load double, double* %140
%142 = getelementptr inbounds double, double* %6, i64 %139
store double %141, double* %142
%143 = add nuw nsw i64 %127, 4
%144 = icmp eq i64 %143, %21
br i1 %144, label %145, label %126
145: ; preds = %123, %126, %106, %15
%146 = tail call i32 @free(double* %16)
ret void
}