#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 Utoprim_new_body(double *, double **, double **, double, double *);
double sqrt(double);
int Utoprim_2d(double U[(9)], double gcov[(4)][(4)], double gcon[(4)][(4)],
               double gdet, double prim[(9)]) {
  double U_tmp[(9)], U_tmp2[(9)], prim_tmp[(9)];
  int i, j, ret;
  double alpha;
  double dummy;
  for (i = 5; i <= 7; i++)
    prim[i] = U[i] / gdet;
  if (U[0] <= 0.) {
    return (-100);
  }
  alpha = 1.0 / sqrt(-gcon[0][0]);
  U_tmp[(0)] = alpha * U[(0)] / gdet;
  U_tmp[(1)] = alpha * (U[(1)] - U[(0)]) / gdet;
  for (i = 2; i <= 4; i++) {
    U_tmp[i] = alpha * U[i] / gdet;
  }
  for (i = 5; i <= 7; i++) {
    U_tmp[i] = alpha * U[i] / gdet;
  }
  for (i = 0; i < 5; i++) {
    prim_tmp[i] = prim[i];
  }
  for (i = 5; i <= 7; i++) {
    prim_tmp[i] = alpha * prim[i];
  }
  ret = Utoprim_new_body(U_tmp, gcov, gcon, gdet, prim_tmp);
  if (ret == 0) {
    for (i = 0; i < 5; i++) {
      prim[i] = prim_tmp[i];
    }
  }
  return (ret);
}


x86 assembly (clang, -O0):
<Utoprim_2d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movsd  %xmm0,-0x28(%rbp)
mov    %rcx,-0x30(%rbp)
movl   $0x5,-0x124(%rbp)
cmpl   $0x7,-0x124(%rbp)
jg     1190 <Utoprim_2d+0x70>
mov    -0x10(%rbp),%rax
movslq -0x124(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
divsd  -0x28(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movslq -0x124(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x124(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x124(%rbp)
jmp    114a <Utoprim_2d+0x2a>
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
ucomisd (%rax),%xmm0
jb     11ad <Utoprim_2d+0x8d>
movl   $0xffffff9c,-0x4(%rbp)
jmp    13fa <Utoprim_2d+0x2da>
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  0xe24(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x138(%rbp)
ff
movsd  -0x138(%rbp),%xmm0
ff
mov    -0x10(%rbp),%rax
mulsd  (%rax),%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x138(%rbp),%xmm0
ff
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x10(%rbp),%rax
subsd  (%rax),%xmm1
mulsd  %xmm1,%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movl   $0x2,-0x124(%rbp)
cmpl   $0x4,-0x124(%rbp)
jg     127e <Utoprim_2d+0x15e>
movsd  -0x138(%rbp),%xmm0
ff
mov    -0x10(%rbp),%rax
movslq -0x124(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
divsd  -0x28(%rbp),%xmm0
movslq -0x124(%rbp),%rax
movsd  %xmm0,-0x80(%rbp,%rax,8)
mov    -0x124(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x124(%rbp)
jmp    1233 <Utoprim_2d+0x113>
movl   $0x5,-0x124(%rbp)
cmpl   $0x7,-0x124(%rbp)
jg     12d3 <Utoprim_2d+0x1b3>
movsd  -0x138(%rbp),%xmm0
ff
mov    -0x10(%rbp),%rax
movslq -0x124(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
divsd  -0x28(%rbp),%xmm0
movslq -0x124(%rbp),%rax
movsd  %xmm0,-0x80(%rbp,%rax,8)
mov    -0x124(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x124(%rbp)
jmp    1288 <Utoprim_2d+0x168>
movl   $0x0,-0x124(%rbp)
cmpl   $0x5,-0x124(%rbp)
jge    131e <Utoprim_2d+0x1fe>
mov    -0x30(%rbp),%rax
movslq -0x124(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0x124(%rbp),%rax
movsd  %xmm0,-0x120(%rbp,%rax,8)
ff ff
mov    -0x124(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x124(%rbp)
jmp    12dd <Utoprim_2d+0x1bd>
movl   $0x5,-0x124(%rbp)
cmpl   $0x7,-0x124(%rbp)
jg     1371 <Utoprim_2d+0x251>
movsd  -0x138(%rbp),%xmm0
ff
mov    -0x30(%rbp),%rax
movslq -0x124(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
movslq -0x124(%rbp),%rax
movsd  %xmm0,-0x120(%rbp,%rax,8)
ff ff
mov    -0x124(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x124(%rbp)
jmp    1328 <Utoprim_2d+0x208>
lea    -0x80(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
movsd  -0x28(%rbp),%xmm0
lea    -0x120(%rbp),%rcx
call   1030 <Utoprim_new_body@plt>
mov    %eax,-0x12c(%rbp)
cmpl   $0x0,-0x12c(%rbp)
jne    13f1 <Utoprim_2d+0x2d1>
movl   $0x0,-0x124(%rbp)
cmpl   $0x5,-0x124(%rbp)
jge    13ec <Utoprim_2d+0x2cc>
movslq -0x124(%rbp),%rax
movsd  -0x120(%rbp,%rax,8),%xmm0
ff ff
mov    -0x30(%rbp),%rax
movslq -0x124(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x124(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x124(%rbp)
jmp    13ab <Utoprim_2d+0x28b>
jmp    13f1 <Utoprim_2d+0x2d1>
mov    -0x12c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Utoprim_2d>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xa8,%rsp
movapd %xmm0,%xmm4
movsd  0x28(%rdi),%xmm0
divsd  %xmm4,%xmm0
movsd  %xmm0,0x28(%rcx)
movsd  0x30(%rdi),%xmm0
divsd  %xmm4,%xmm0
movsd  %xmm0,0x30(%rcx)
movsd  0x38(%rdi),%xmm0
divsd  %xmm4,%xmm0
movsd  %xmm0,0x38(%rcx)
mov    $0xffffff9c,%eax
xorpd  %xmm0,%xmm0
ucomisd (%rdi),%xmm0
jae    12a7 <Utoprim_2d+0x187>
mov    %rcx,%r12
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
movsd  (%rdx),%xmm1
movapd 0xe79(%rip),%xmm0
xorpd  %xmm1,%xmm0
movsd  0xe7d(%rip),%xmm2
ucomisd %xmm1,%xmm2
jb     119f <Utoprim_2d+0x7f>
sqrtsd %xmm0,%xmm0
jmp    11ae <Utoprim_2d+0x8e>
movapd %xmm4,(%rsp)
call   1040 <sqrt@plt>
movapd (%rsp),%xmm4
movsd  0xe62(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  (%rbx),%xmm2
movsd  0x8(%rbx),%xmm3
subsd  %xmm2,%xmm3
movapd %xmm1,%xmm0
unpcklpd %xmm1,%xmm0
unpcklpd %xmm3,%xmm2
mulpd  %xmm0,%xmm2
movapd %xmm4,%xmm3
unpcklpd %xmm4,%xmm3
divpd  %xmm3,%xmm2
movapd %xmm2,0x60(%rsp)
movupd 0x10(%rbx),%xmm2
mulpd  %xmm0,%xmm2
divpd  %xmm3,%xmm2
movapd %xmm2,0x70(%rsp)
movupd 0x20(%rbx),%xmm2
mulpd  %xmm0,%xmm2
divpd  %xmm3,%xmm2
movapd %xmm2,0x80(%rsp)
movupd 0x30(%rbx),%xmm2
mulpd  %xmm0,%xmm2
divpd  %xmm3,%xmm2
movapd %xmm2,0x90(%rsp)
movups (%r12),%xmm2
movups 0x10(%r12),%xmm3
movaps %xmm2,0x10(%rsp)
movaps %xmm3,0x20(%rsp)
mov    0x20(%r12),%rax
mov    %rax,0x30(%rsp)
movupd 0x28(%r12),%xmm2
mulpd  %xmm0,%xmm2
movupd %xmm2,0x38(%rsp)
mulsd  0x38(%r12),%xmm1
movsd  %xmm1,0x48(%rsp)
lea    0x60(%rsp),%rdi
lea    0x10(%rsp),%rcx
mov    %r15,%rsi
mov    %r14,%rdx
movapd %xmm4,%xmm0
call   1030 <Utoprim_new_body@plt>
test   %eax,%eax
jne    12a7 <Utoprim_2d+0x187>
mov    0x30(%rsp),%rax
mov    %rax,0x20(%r12)
movapd 0x10(%rsp),%xmm0
movapd 0x20(%rsp),%xmm1
movupd %xmm1,0x10(%r12)
movupd %xmm0,(%r12)
xor    %eax,%eax
add    $0xa8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @Utoprim_2d(double* %0, [4 x double]* %1, [4 x double]* %2, double %3, double* %4) {
%6 = alloca i32
%7 = alloca double*
%8 = alloca [4 x double]*
%9 = alloca [4 x double]*
%10 = alloca double
%11 = alloca double*
%12 = alloca [9 x double]
%13 = alloca [9 x double]
%14 = alloca [9 x double]
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca double
%19 = alloca double
store double* %0, double** %7
store [4 x double]* %1, [4 x double]** %8
store [4 x double]* %2, [4 x double]** %9
store double %3, double* %10
store double* %4, double** %11
store i32 5, i32* %15
br label %20
20: ; preds = %35, %5
%21 = load i32, i32* %15
%22 = icmp sle i32 %21, 7
br i1 %22, label %23, label %38
23: ; preds = %20
%24 = load double*, double** %7
%25 = load i32, i32* %15
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds double, double* %24, i64 %26
%28 = load double, double* %27
%29 = load double, double* %10
%30 = fdiv double %28, %29
%31 = load double*, double** %11
%32 = load i32, i32* %15
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double, double* %31, i64 %33
store double %30, double* %34
br label %35
35: ; preds = %23
%36 = load i32, i32* %15
%37 = add nsw i32 %36, 1
store i32 %37, i32* %15
br label %20
38: ; preds = %20
%39 = load double*, double** %7
%40 = getelementptr inbounds double, double* %39, i64 0
%41 = load double, double* %40
%42 = fcmp ole double %41, 0.000000e+00
br i1 %42, label %43, label %44
43: ; preds = %38
store i32 -100, i32* %6
br label %175
44: ; preds = %38
%45 = load [4 x double]*, [4 x double]** %9
%46 = getelementptr inbounds [4 x double], [4 x double]* %45, i64 0
%47 = getelementptr inbounds [4 x double], [4 x double]* %46, i64 0, i64 0
%48 = load double, double* %47
%49 = fneg double %48
%50 = call double @sqrt(double %49)
%51 = fdiv double 1.000000e+00, %50
store double %51, double* %18
%52 = load double, double* %18
%53 = load double*, double** %7
%54 = getelementptr inbounds double, double* %53, i64 0
%55 = load double, double* %54
%56 = fmul double %52, %55
%57 = load double, double* %10
%58 = fdiv double %56, %57
%59 = getelementptr inbounds [9 x double], [9 x double]* %12, i64 0, i64 0
store double %58, double* %59
%60 = load double, double* %18
%61 = load double*, double** %7
%62 = getelementptr inbounds double, double* %61, i64 1
%63 = load double, double* %62
%64 = load double*, double** %7
%65 = getelementptr inbounds double, double* %64, i64 0
%66 = load double, double* %65
%67 = fsub double %63, %66
%68 = fmul double %60, %67
%69 = load double, double* %10
%70 = fdiv double %68, %69
%71 = getelementptr inbounds [9 x double], [9 x double]* %12, i64 0, i64 1
store double %70, double* %71
store i32 2, i32* %15
br label %72
72: ; preds = %88, %44
%73 = load i32, i32* %15
%74 = icmp sle i32 %73, 4
br i1 %74, label %75, label %91
75: ; preds = %72
%76 = load double, double* %18
%77 = load double*, double** %7
%78 = load i32, i32* %15
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds double, double* %77, i64 %79
%81 = load double, double* %80
%82 = fmul double %76, %81
%83 = load double, double* %10
%84 = fdiv double %82, %83
%85 = load i32, i32* %15
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds [9 x double], [9 x double]* %12, i64 0, i64 %86
store double %84, double* %87
br label %88
88: ; preds = %75
%89 = load i32, i32* %15
%90 = add nsw i32 %89, 1
store i32 %90, i32* %15
br label %72
91: ; preds = %72
store i32 5, i32* %15
br label %92
92: ; preds = %108, %91
%93 = load i32, i32* %15
%94 = icmp sle i32 %93, 7
br i1 %94, label %95, label %111
95: ; preds = %92
%96 = load double, double* %18
%97 = load double*, double** %7
%98 = load i32, i32* %15
%99 = sext i32 %98 to i64
%100 = getelementptr inbounds double, double* %97, i64 %99
%101 = load double, double* %100
%102 = fmul double %96, %101
%103 = load double, double* %10
%104 = fdiv double %102, %103
%105 = load i32, i32* %15
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds [9 x double], [9 x double]* %12, i64 0, i64 %106
store double %104, double* %107
br label %108
108: ; preds = %95
%109 = load i32, i32* %15
%110 = add nsw i32 %109, 1
store i32 %110, i32* %15
br label %92
111: ; preds = %92
store i32 0, i32* %15
br label %112
112: ; preds = %124, %111
%113 = load i32, i32* %15
%114 = icmp slt i32 %113, 5
br i1 %114, label %115, label %127
115: ; preds = %112
%116 = load double*, double** %11
%117 = load i32, i32* %15
%118 = sext i32 %117 to i64
%119 = getelementptr inbounds double, double* %116, i64 %118
%120 = load double, double* %119
%121 = load i32, i32* %15
%122 = sext i32 %121 to i64
%123 = getelementptr inbounds [9 x double], [9 x double]* %14, i64 0, i64 %122
store double %120, double* %123
br label %124
124: ; preds = %115
%125 = load i32, i32* %15
%126 = add nsw i32 %125, 1
store i32 %126, i32* %15
br label %112
127: ; preds = %112
store i32 5, i32* %15
br label %128
128: ; preds = %142, %127
%129 = load i32, i32* %15
%130 = icmp sle i32 %129, 7
br i1 %130, label %131, label %145
131: ; preds = %128
%132 = load double, double* %18
%133 = load double*, double** %11
%134 = load i32, i32* %15
%135 = sext i32 %134 to i64
%136 = getelementptr inbounds double, double* %133, i64 %135
%137 = load double, double* %136
%138 = fmul double %132, %137
%139 = load i32, i32* %15
%140 = sext i32 %139 to i64
%141 = getelementptr inbounds [9 x double], [9 x double]* %14, i64 0, i64 %140
store double %138, double* %141
br label %142
142: ; preds = %131
%143 = load i32, i32* %15
%144 = add nsw i32 %143, 1
store i32 %144, i32* %15
br label %128
145: ; preds = %128
%146 = getelementptr inbounds [9 x double], [9 x double]* %12, i64 0, i64 0
%147 = load [4 x double]*, [4 x double]** %8
%148 = bitcast [4 x double]* %147 to double**
%149 = load [4 x double]*, [4 x double]** %9
%150 = bitcast [4 x double]* %149 to double**
%151 = load double, double* %10
%152 = getelementptr inbounds [9 x double], [9 x double]* %14, i64 0, i64 0
%153 = call i32 @Utoprim_new_body(double* %146, double** %148, double** %150, double %151, double* %152)
store i32 %153, i32* %17
%154 = load i32, i32* %17
%155 = icmp eq i32 %154, 0
br i1 %155, label %156, label %173
156: ; preds = %145
store i32 0, i32* %15
br label %157
157: ; preds = %169, %156
%158 = load i32, i32* %15
%159 = icmp slt i32 %158, 5
br i1 %159, label %160, label %172
160: ; preds = %157
%161 = load i32, i32* %15
%162 = sext i32 %161 to i64
%163 = getelementptr inbounds [9 x double], [9 x double]* %14, i64 0, i64 %162
%164 = load double, double* %163
%165 = load double*, double** %11
%166 = load i32, i32* %15
%167 = sext i32 %166 to i64
%168 = getelementptr inbounds double, double* %165, i64 %167
store double %164, double* %168
br label %169
169: ; preds = %160
%170 = load i32, i32* %15
%171 = add nsw i32 %170, 1
store i32 %171, i32* %15
br label %157
172: ; preds = %157
br label %173
173: ; preds = %172, %145
%174 = load i32, i32* %17
store i32 %174, i32* %6
br label %175
175: ; preds = %173, %43
%176 = load i32, i32* %6
ret i32 %176
}

LLVM IR (-O2):
define i32 @Utoprim_2d(double* nocapture %0, [4 x double]* %1, [4 x double]* %2, double %3, double* nocapture %4) {
%6 = bitcast double* %4 to i8*
%7 = alloca [9 x double]
%8 = alloca [9 x double]
%9 = bitcast [9 x double]* %8 to i8*
%10 = bitcast [9 x double]* %7 to i8*
%11 = getelementptr inbounds double, double* %0, i64 5
%12 = load double, double* %11
%13 = fdiv double %12, %3
%14 = getelementptr inbounds double, double* %4, i64 5
store double %13, double* %14
%15 = getelementptr inbounds double, double* %0, i64 6
%16 = load double, double* %15
%17 = fdiv double %16, %3
%18 = getelementptr inbounds double, double* %4, i64 6
store double %17, double* %18
%19 = getelementptr inbounds double, double* %0, i64 7
%20 = load double, double* %19
%21 = fdiv double %20, %3
%22 = getelementptr inbounds double, double* %4, i64 7
store double %21, double* %22
%23 = load double, double* %0
%24 = fcmp ugt double %23, 0.000000e+00
br i1 %24, label %25, label %79
25: ; preds = %5
%26 = getelementptr inbounds [4 x double], [4 x double]* %2, i64 0, i64 0
%27 = load double, double* %26
%28 = fneg double %27
%29 = tail call double @sqrt(double %28)
%30 = fdiv double 1.000000e+00, %29
%31 = load double, double* %0
%32 = getelementptr inbounds [9 x double], [9 x double]* %7, i64 0, i64 0
%33 = getelementptr inbounds double, double* %0, i64 1
%34 = load double, double* %33
%35 = fsub double %34, %31
%36 = insertelement <2 x double> poison, double %30, i64 0
%37 = shufflevector <2 x double> %36, <2 x double> poison, <2 x i32> zeroinitializer
%38 = insertelement <2 x double> poison, double %31, i64 0
%39 = insertelement <2 x double> %38, double %35, i64 1
%40 = fmul <2 x double> %37, %39
%41 = insertelement <2 x double> poison, double %3, i64 0
%42 = shufflevector <2 x double> %41, <2 x double> poison, <2 x i32> zeroinitializer
%43 = fdiv <2 x double> %40, %42
%44 = bitcast [9 x double]* %7 to <2 x double>*
store <2 x double> %43, <2 x double>* %44
%45 = getelementptr inbounds double, double* %0, i64 2
%46 = getelementptr inbounds [9 x double], [9 x double]* %7, i64 0, i64 2
%47 = bitcast double* %45 to <2 x double>*
%48 = load <2 x double>, <2 x double>* %47
%49 = fmul <2 x double> %37, %48
%50 = fdiv <2 x double> %49, %42
%51 = bitcast double* %46 to <2 x double>*
store <2 x double> %50, <2 x double>* %51
%52 = getelementptr inbounds double, double* %0, i64 4
%53 = getelementptr inbounds [9 x double], [9 x double]* %7, i64 0, i64 4
%54 = bitcast double* %52 to <2 x double>*
%55 = load <2 x double>, <2 x double>* %54
%56 = fmul <2 x double> %37, %55
%57 = fdiv <2 x double> %56, %42
%58 = bitcast double* %53 to <2 x double>*
store <2 x double> %57, <2 x double>* %58
%59 = getelementptr inbounds [9 x double], [9 x double]* %7, i64 0, i64 6
%60 = bitcast double* %15 to <2 x double>*
%61 = load <2 x double>, <2 x double>* %60
%62 = fmul <2 x double> %37, %61
%63 = fdiv <2 x double> %62, %42
%64 = bitcast double* %59 to <2 x double>*
store <2 x double> %63, <2 x double>* %64
%65 = getelementptr inbounds [9 x double], [9 x double]* %8, i64 0, i64 5
%66 = bitcast double* %14 to <2 x double>*
%67 = load <2 x double>, <2 x double>* %66
%68 = fmul <2 x double> %37, %67
%69 = bitcast double* %65 to <2 x double>*
store <2 x double> %68, <2 x double>* %69
%70 = load double, double* %22
%71 = fmul double %30, %70
%72 = getelementptr inbounds [9 x double], [9 x double]* %8, i64 0, i64 7
store double %71, double* %72
%73 = bitcast [4 x double]* %1 to double**
%74 = bitcast [4 x double]* %2 to double**
%75 = getelementptr inbounds [9 x double], [9 x double]* %8, i64 0, i64 0
%76 = call i32 @Utoprim_new_body(double* %32, double** %73, double** %74, double %3, double* %75)
%77 = icmp eq i32 %76, 0
br i1 %77, label %78, label %79
78: ; preds = %25
br label %79
79: ; preds = %78, %25, %5
%80 = phi i32 [ -100, %5 ], [ %76, %25 ], [ 0, %78 ]
ret i32 %80
}