user: Demonstrate the C code that generates the assembly output below:

```asm
<Riemann_solver_exact>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  mov    %rsi,%r13
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  mov    %ecx,%ebp
  push   %rbx
  mov    %rdx,%rbx
  sub    $0x98,%rsp
  comisd %xmm3,%xmm4
  movsd  %xmm1,0x48(%rsp)
  movsd  D82(%rip),%xmm1
  movsd  %xmm5,0x38(%rsp)
  movapd %xmm0,%xmm5
  addsd  %xmm5,%xmm1
  movsd  %xmm0,0x30(%rsp)
  movsd  %xmm6,0x40(%rsp)
  movapd %xmm0,%xmm6
  addsd  %xmm0,%xmm0
  subsd  D82(%rip),%xmm6
  movsd  %xmm2,0x50(%rsp)
  movapd %xmm1,%xmm2
  movsd  %xmm7,0x60(%rsp)
  divsd  %xmm0,%xmm2
  movsd  %xmm6,0x58(%rsp)
  divsd  %xmm0,%xmm6
  movsd  %xmm2,0x10(%rsp)
  movq   %xmm6,%r15
  jbe    L341
  movapd %xmm4,%xmm1
  subsd  %xmm3,%xmm1
  mulsd  %xmm1,%xmm2
  movapd %xmm2,%xmm0
  pxor   %xmm2,%xmm2
  divsd  %xmm3,%xmm0
  movq   %xmm2,%r14
  addsd  D82(%rip),%xmm0
  ucomisd %xmm0,%xmm2
  ja     L20
  sqrtsd %xmm0,%xmm0
L218:
  mulsd  0x38(%rsp),%xmm1
  comisd %xmm4,%xmm3
  movsd  0x48(%rsp),%xmm2
  divsd  0x30(%rsp),%xmm1
  divsd  %xmm3,%xmm1
  divsd  %xmm0,%xmm1
  subsd  %xmm1,%xmm2
  ja     L116
L322:
  movapd %xmm3,%xmm0
  movq   %r15,%xmm1
  movsd  %xmm4,(%rsp)
  divsd  %xmm4,%xmm0
  movsd  %xmm2,0x18(%rsp)
  movsd  %xmm3,0x8(%rsp)
  call   <pow@plt>
  movsd  0x40(%rsp),%xmm3
  movsd  0x18(%rsp),%xmm2
  subsd  D82(%rip),%xmm0
  movsd  (%rsp),%xmm4
  movapd %xmm3,%xmm1
  addsd  %xmm3,%xmm1
  movsd  0x8(%rsp),%xmm3
  mulsd  %xmm1,%xmm0
  divsd  0x58(%rsp),%xmm0
  addsd  0x50(%rsp),%xmm0
L189:
  movsd  0x50(%rsp),%xmm7
  movsd  0x60(%rsp),%xmm5
  xor    %eax,%eax
  movsd  0x48(%rsp),%xmm8
  movapd %xmm7,%xmm1
  addsd  %xmm5,%xmm1
  comisd %xmm1,%xmm2
  movapd %xmm8,%xmm1
  movsd  0x30(%rsp),%xmm2
  subsd  %xmm5,%xmm1
  setbe  %al
  mov    %eax,0x4(%rbx)
  xor    %eax,%eax
  comisd %xmm1,%xmm0
  movsd  0x38(%rsp),%xmm0
  xorpd  D191(%rip),%xmm0
  divsd  %xmm3,%xmm0
  seta   %al
  mov    %eax,(%rbx)
  movapd %xmm0,%xmm6
  movsd  0x40(%rsp),%xmm0
  divsd  %xmm2,%xmm6
  divsd  %xmm4,%xmm0
  movapd %xmm6,%xmm5
  movsd  %xmm6,0x28(%rsp)
  mulsd  %xmm3,%xmm5
  divsd  %xmm2,%xmm0
  movapd %xmm5,%xmm2
  subsd  %xmm0,%xmm6
  mulsd  %xmm4,%xmm0
  movsd  %xmm6,0x68(%rsp)
  subsd  %xmm0,%xmm2
  subsd  %xmm8,%xmm2
  addsd  %xmm7,%xmm2
  movq   %r14,%xmm7
  divsd  %xmm6,%xmm2
  comisd %xmm2,%xmm7
  jbe    L285
  movapd %xmm3,%xmm2
  minsd  %xmm4,%xmm2
L285:
  mulsd  D169(%rip),%xmm2
  comisd %xmm3,%xmm2
  jbe    L67
  movapd %xmm2,%xmm1
  movsd  0x10(%rsp),%xmm0
  movq   %r14,%xmm7
  subsd  %xmm3,%xmm1
  mulsd  %xmm1,%xmm0
  divsd  %xmm3,%xmm0
  addsd  D82(%rip),%xmm0
  ucomisd %xmm0,%xmm7
  ja     L353
  sqrtsd %xmm0,%xmm0
L196:
  mulsd  0x38(%rsp),%xmm1
  movsd  0x48(%rsp),%xmm7
  comisd %xmm4,%xmm2
  divsd  0x30(%rsp),%xmm1
  divsd  %xmm3,%xmm1
  divsd  %xmm0,%xmm1
  subsd  %xmm1,%xmm7
  movsd  %xmm7,0x18(%rsp)
  ja     L220
L16:
  movapd %xmm2,%xmm5
  movq   %r15,%xmm1
  movsd  %xmm3,0x78(%rsp)
  divsd  %xmm4,%xmm5
  movsd  %xmm2,0x70(%rsp)
  movsd  %xmm4,0x8(%rsp)
  movapd %xmm5,%xmm0
  movsd  %xmm5,(%rsp)
  call   <pow@plt>
  movsd  (%rsp),%xmm5
  movq   %r15,%xmm1
  movapd %xmm5,%xmm0
  call   <pow@plt>
  movsd  0x40(%rsp),%xmm3
  subsd  D82(%rip),%xmm0
  movsd  0x70(%rsp),%xmm2
  movsd  0x8(%rsp),%xmm4
  movapd %xmm3,%xmm1
  addsd  %xmm3,%xmm1
  movsd  0x78(%rsp),%xmm3
  mulsd  %xmm0,%xmm1
  divsd  0x58(%rsp),%xmm1
  addsd  0x50(%rsp),%xmm1
  movsd  %xmm1,0x20(%rsp)
L354:
  movsd  0x18(%rsp),%xmm0
  subsd  0x20(%rsp),%xmm0
  andpd  D244(%rip),%xmm0
  test   %ebp,%ebp
  je     L120
  comisd 0x60(%rsp),%xmm0
  jbe    L120
  movsd  0x30(%rsp),%xmm5
  movsd  0x38(%rsp),%xmm7
  xor    %ebx,%ebx
  movsd  %xmm3,(%rsp)
  movsd  0x40(%rsp),%xmm6
  movsd  %xmm4,0x8(%rsp)
  divsd  %xmm5,%xmm7
  divsd  %xmm5,%xmm6
  movsd  %xmm7,0x70(%rsp)
  movsd  %xmm6,0x78(%rsp)
  jmp    L336
  nopl   0x0(%rax)
L360:
  movapd %xmm2,%xmm4
  movsd  0x10(%rsp),%xmm0
  movq   %r14,%xmm6
  subsd  %xmm7,%xmm4
  mulsd  %xmm4,%xmm0
  divsd  %xmm7,%xmm0
  addsd  D82(%rip),%xmm0
  ucomisd %xmm0,%xmm6
  ja     L152
  sqrtsd %xmm0,%xmm0
L55:
  movsd  D82(%rip),%xmm3
  mov    D211(%rip),%rax
  movsd  %xmm2,0x80(%rsp)
  movsd  %xmm4,0x68(%rsp)
  divsd  %xmm0,%xmm3
  movq   %rax,%xmm1
  movapd %xmm3,%xmm0
  movsd  %xmm3,0x28(%rsp)
  call   <pow@plt>
  movsd  (%rsp),%xmm6
  movsd  0x70(%rsp),%xmm1
  movapd %xmm0,%xmm5
  movsd  0x68(%rsp),%xmm4
  movsd  D169(%rip),%xmm0
  divsd  %xmm6,%xmm1
  movsd  0x28(%rsp),%xmm3
  movsd  0x80(%rsp),%xmm2
  mulsd  %xmm1,%xmm0
  mulsd  0x10(%rsp),%xmm0
  mulsd  %xmm1,%xmm3
  divsd  %xmm6,%xmm0
  mulsd  %xmm4,%xmm0
  mulsd  %xmm5,%xmm0
  movsd  0x8(%rsp),%xmm5
  comisd %xmm5,%xmm2
  subsd  %xmm3,%xmm0
  movsd  %xmm0,0x28(%rsp)
  jbe    L369
L246:
  movapd %xmm2,%xmm3
  movsd  0x10(%rsp),%xmm0
  subsd  %xmm5,%xmm3
  mulsd  %xmm3,%xmm0
  divsd  %xmm5,%xmm0
  movq   %r14,%xmm5
  addsd  D82(%rip),%xmm0
  ucomisd %xmm0,%xmm5
  ja     L329
  sqrtsd %xmm0,%xmm0
L314:
  movsd  D82(%rip),%xmm5
  mov    D211(%rip),%rax
  movsd  %xmm2,0x88(%rsp)
  movsd  %xmm3,0x80(%rsp)
  divsd  %xmm0,%xmm5
  movq   %rax,%xmm1
  movapd %xmm5,%xmm0
  movsd  %xmm5,0x68(%rsp)
  call   <pow@plt>
  movsd  0x8(%rsp),%xmm7
  movsd  0x68(%rsp),%xmm5
  movsd  0x80(%rsp),%xmm3
  movapd %xmm0,%xmm4
  movsd  0x78(%rsp),%xmm0
  movsd  0x88(%rsp),%xmm2
  divsd  %xmm7,%xmm0
  mulsd  %xmm0,%xmm5
  mulsd  D169(%rip),%xmm0
  mulsd  0x10(%rsp),%xmm0
  movapd %xmm5,%xmm1
  divsd  %xmm7,%xmm0
  mulsd  %xmm3,%xmm0
  mulsd  %xmm4,%xmm0
  subsd  %xmm0,%xmm1
L99:
  movsd  0x28(%rsp),%xmm6
  movsd  0x20(%rsp),%xmm0
  subsd  0x18(%rsp),%xmm0
  subsd  %xmm1,%xmm6
  divsd  %xmm6,%xmm0
  movsd  %xmm6,0x68(%rsp)
  movq   %r14,%xmm6
  addsd  %xmm2,%xmm0
  comisd %xmm0,%xmm6
  ja     L320
  movapd %xmm0,%xmm2
L274:
  movsd  (%rsp),%xmm4
  add    $0x1,%ebx
  comisd %xmm4,%xmm2
  jbe    L53
  movapd %xmm2,%xmm1
  movsd  0x10(%rsp),%xmm0
  movq   %r14,%xmm7
  subsd  %xmm4,%xmm1
  mulsd  %xmm1,%xmm0
  divsd  %xmm4,%xmm0
  addsd  D82(%rip),%xmm0
  ucomisd %xmm0,%xmm7
  ja     L121
  sqrtsd %xmm0,%xmm0
L350:
  mulsd  0x38(%rsp),%xmm1
  movsd  0x48(%rsp),%xmm6
  divsd  0x30(%rsp),%xmm1
  divsd  (%rsp),%xmm1
  divsd  %xmm0,%xmm1
  subsd  %xmm1,%xmm6
  movsd  %xmm6,0x18(%rsp)
L264:
  movsd  0x8(%rsp),%xmm3
  comisd %xmm3,%xmm2
  jbe    L374
  movapd %xmm2,%xmm1
  movsd  0x10(%rsp),%xmm0
  movq   %r14,%xmm7
  subsd  %xmm3,%xmm1
  mulsd  %xmm1,%xmm0
  divsd  %xmm3,%xmm0
  addsd  D82(%rip),%xmm0
  ucomisd %xmm0,%xmm7
  ja     L344
  sqrtsd %xmm0,%xmm0
L41:
  mulsd  0x40(%rsp),%xmm1
  divsd  0x30(%rsp),%xmm1
  divsd  0x8(%rsp),%xmm1
  divsd  %xmm0,%xmm1
  addsd  0x50(%rsp),%xmm1
  movsd  %xmm1,0x20(%rsp)
L112:
  movsd  0x18(%rsp),%xmm0
  subsd  0x20(%rsp),%xmm0
  andpd  D244(%rip),%xmm0
  cmp    %ebx,%ebp
  je     L120
  comisd 0x60(%rsp),%xmm0
  jbe    L120
L336:
  movsd  (%rsp),%xmm7
  comisd %xmm7,%xmm2
  ja     L360
  movsd  0x10(%rsp),%xmm1
  movapd %xmm2,%xmm0
  movsd  %xmm2,0x68(%rsp)
  divsd  (%rsp),%xmm0
  call   <pow@plt>
  movsd  0x68(%rsp),%xmm2
  movsd  0x8(%rsp),%xmm5
  movapd %xmm0,%xmm1
  movsd  D82(%rip),%xmm0
  comisd %xmm5,%xmm2
  divsd  %xmm1,%xmm0
  movsd  0x70(%rsp),%xmm1
  divsd  (%rsp),%xmm1
  xorpd  D191(%rip),%xmm0
  mulsd  %xmm1,%xmm0
  movsd  %xmm0,0x28(%rsp)
  ja     L246
L369:
  movsd  0x10(%rsp),%xmm1
  movapd %xmm2,%xmm0
  movsd  %xmm2,0x68(%rsp)
  divsd  0x8(%rsp),%xmm0
  call   <pow@plt>
  movsd  0x68(%rsp),%xmm2
  movapd %xmm0,%xmm1
  movsd  D82(%rip),%xmm0
  divsd  %xmm1,%xmm0
  movsd  0x78(%rsp),%xmm1
  divsd  0x8(%rsp),%xmm1
  mulsd  %xmm0,%xmm1
  jmp    L99
  nopl   0x0(%rax,%rax,1)
L341:
  movapd %xmm4,%xmm0
  movapd %xmm6,%xmm1
  movsd  %xmm4,0x8(%rsp)
  divsd  %xmm3,%xmm0
  movsd  %xmm3,(%rsp)
  call   <pow@plt>
  movsd  0x38(%rsp),%xmm4
  movsd  (%rsp),%xmm3
  movapd %xmm0,%xmm1
  subsd  D82(%rip),%xmm1
  movsd  0x48(%rsp),%xmm2
  movapd %xmm4,%xmm0
  addsd  %xmm4,%xmm0
  pxor   %xmm4,%xmm4
  movq   %xmm4,%r14
  movsd  0x8(%rsp),%xmm4
  mulsd  %xmm1,%xmm0
  comisd %xmm4,%xmm3
  divsd  0x58(%rsp),%xmm0
  subsd  %xmm0,%xmm2
  jbe    L322
L116:
  movapd %xmm3,%xmm1
  movsd  0x10(%rsp),%xmm0
  movq   %r14,%xmm7
  subsd  %xmm4,%xmm1
  mulsd  %xmm1,%xmm0
  divsd  %xmm4,%xmm0
  addsd  D82(%rip),%xmm0
  ucomisd %xmm0,%xmm7
  ja     L45
  movapd %xmm0,%xmm5
  sqrtsd %xmm5,%xmm5
L279:
  mulsd  0x40(%rsp),%xmm1
  movapd %xmm1,%xmm0
  divsd  0x30(%rsp),%xmm0
  divsd  %xmm4,%xmm0
  divsd  %xmm5,%xmm0
  addsd  0x50(%rsp),%xmm0
  jmp    L189
  nopl   0x0(%rax,%rax,1)
L67:
  movapd %xmm2,%xmm0
  movq   %r15,%xmm1
  movsd  %xmm3,(%rsp)
  divsd  %xmm3,%xmm0
  movsd  %xmm4,0x20(%rsp)
  movsd  %xmm2,0x8(%rsp)
  call   <pow@plt>
  movsd  0x38(%rsp),%xmm4
  movsd  0x8(%rsp),%xmm2
  movapd %xmm0,%xmm1
  subsd  D82(%rip),%xmm1
  movsd  (%rsp),%xmm3
  movapd %xmm4,%xmm0
  addsd  %xmm4,%xmm0
  movsd  0x48(%rsp),%xmm4
  mulsd  %xmm1,%xmm0
  divsd  0x58(%rsp),%xmm0
  subsd  %xmm0,%xmm4
  movsd  %xmm4,0x18(%rsp)
  movsd  0x20(%rsp),%xmm4
  comisd %xmm4,%xmm2
  jbe    L16
L220:
  movapd %xmm2,%xmm1
  movsd  0x10(%rsp),%xmm0
  movq   %r14,%xmm7
  subsd  %xmm4,%xmm1
  mulsd  %xmm1,%xmm0
  divsd  %xmm4,%xmm0
  addsd  D82(%rip),%xmm0
  ucomisd %xmm0,%xmm7
  ja     L92
  sqrtsd %xmm0,%xmm0
L39:
  mulsd  0x40(%rsp),%xmm1
  divsd  0x30(%rsp),%xmm1
  divsd  %xmm4,%xmm1
  divsd  %xmm0,%xmm1
  addsd  0x50(%rsp),%xmm1
  movsd  %xmm1,0x20(%rsp)
  jmp    L354
  nopl   0x0(%rax,%rax,1)
L374:
  movq   %r15,%xmm1
  movapd %xmm2,%xmm0
  movsd  %xmm2,0x80(%rsp)
  divsd  0x8(%rsp),%xmm0
  call   <pow@plt>
  movsd  0x40(%rsp),%xmm5
  subsd  D82(%rip),%xmm0
  movsd  0x80(%rsp),%xmm2
  movapd %xmm5,%xmm1
  addsd  %xmm5,%xmm1
  mulsd  %xmm1,%xmm0
  divsd  0x58(%rsp),%xmm0
  addsd  0x50(%rsp),%xmm0
  movsd  %xmm0,0x20(%rsp)
  jmp    L112
  nopw   0x0(%rax,%rax,1)
L53:
  movq   %r15,%xmm1
  movapd %xmm2,%xmm0
  movsd  %xmm2,0x20(%rsp)
  divsd  (%rsp),%xmm0
  call   <pow@plt>
  movsd  0x38(%rsp),%xmm6
  subsd  D82(%rip),%xmm0
  movsd  0x48(%rsp),%xmm4
  movsd  0x20(%rsp),%xmm2
  movapd %xmm6,%xmm1
  addsd  %xmm6,%xmm1
  mulsd  %xmm1,%xmm0
  divsd  0x58(%rsp),%xmm0
  subsd  %xmm0,%xmm4
  movsd  %xmm4,0x18(%rsp)
  jmp    L264
  nopl   0x0(%rax)
L320:
  mulsd  D169(%rip),%xmm2
  jmp    L274
  nopl   (%rax)
L120:
  movsd  0x18(%rsp),%xmm4
  movsd  0x20(%rsp),%xmm1
  movsd  %xmm2,0x0(%r13)
  subsd  %xmm4,%xmm1
  mulsd  0x28(%rsp),%xmm1
  divsd  0x68(%rsp),%xmm1
  addsd  %xmm4,%xmm1
  movsd  %xmm1,(%r12)
  add    $0x98,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L344:
  movsd  %xmm2,0x80(%rsp)
  movsd  %xmm1,0x20(%rsp)
  call   <sqrt@plt>
  movsd  0x20(%rsp),%xmm1
  movsd  0x80(%rsp),%xmm2
  jmp    L41
L121:
  movsd  %xmm2,0x20(%rsp)
  movsd  %xmm1,0x18(%rsp)
  call   <sqrt@plt>
  movsd  0x20(%rsp),%xmm2
  movsd  0x18(%rsp),%xmm1
  jmp    L350
L329:
  movsd  %xmm2,0x80(%rsp)
  movsd  %xmm3,0x68(%rsp)
  call   <sqrt@plt>
  movsd  0x68(%rsp),%xmm3
  movsd  0x80(%rsp),%xmm2
  jmp    L314
L152:
  movsd  %xmm2,0x68(%rsp)
  movsd  %xmm4,0x28(%rsp)
  call   <sqrt@plt>
  movsd  0x68(%rsp),%xmm2
  movsd  0x28(%rsp),%xmm4
  jmp    L55
L20:
  movsd  %xmm4,0x18(%rsp)
  movsd  %xmm3,0x8(%rsp)
  movsd  %xmm1,(%rsp)
  call   <sqrt@plt>
  movsd  0x18(%rsp),%xmm4
  movsd  0x8(%rsp),%xmm3
  movsd  (%rsp),%xmm1
  jmp    L218
L92:
  movsd  %xmm4,0x70(%rsp)
  movsd  %xmm3,0x20(%rsp)
  movsd  %xmm1,0x8(%rsp)
  movsd  %xmm2,(%rsp)
  call   <sqrt@plt>
  movsd  0x70(%rsp),%xmm4
  movsd  0x20(%rsp),%xmm3
  movsd  0x8(%rsp),%xmm1
  movsd  (%rsp),%xmm2
  jmp    L39
L353:
  movsd  %xmm4,0x20(%rsp)
  movsd  %xmm3,0x18(%rsp)
  movsd  %xmm1,0x8(%rsp)
  movsd  %xmm2,(%rsp)
  call   <sqrt@plt>
  movsd  0x20(%rsp),%xmm4
  movsd  0x18(%rsp),%xmm3
  movsd  0x8(%rsp),%xmm1
  movsd  (%rsp),%xmm2
  jmp    L196
L45:
  movsd  %xmm4,0x20(%rsp)
  movsd  %xmm3,0x18(%rsp)
  movsd  %xmm1,0x8(%rsp)
  movsd  %xmm2,(%rsp)
  call   <sqrt@plt>
  movsd  0x20(%rsp),%xmm4
  movsd  0x18(%rsp),%xmm3
  movsd  0x8(%rsp),%xmm1
  movsd  (%rsp),%xmm2
  movapd %xmm0,%xmm5
  jmp    L279
```

tool_calls: name: read_data
arguments: tag: D82
type_infered: f64
name: read_data
arguments: tag: D191
type_infered: f32[4]
name: read_data
arguments: tag: D169
type_infered: f64
name: read_data
arguments: tag: D244
type_infered: qword[2]
name: read_data
arguments: tag: D211
type_infered: f64

tool: D82: 1

tool: {"D191": [0.0,-0.0,0.0,0.0]}

tool: D169: 0.5

tool: {"D244": [0x7fffffffffffffff,0x0000000000000000]}

tool: D211: 3

assistant: ```c
double Riemann_solver_exact(double *U_star, double *P_star, double gamma, double u_L, double u_R, double p_L, double p_R, double c_L, double c_R, int *CRW, double tol, int N) {
  double mu, nu, sigma;
  double delta_p, u_LR, u_RL;
  double k1, k3, p_INT, p_INT0, u_INT;
  double rho_star_l, rho_star_r;
  double v_L, v_R, gap;
  double temp1, temp2, temp3;
  double dbg = 2;
  int n = 0;
  mu = (gamma - 1.0) / (2.0 * gamma);
  nu = (gamma + 1.0) / (2.0 * gamma);
  sigma = (gamma - 1.0) / (gamma + 1.0);
  if (p_R > p_L) {
    delta_p = p_R - p_L;
    u_LR = sqrt(1.0 + nu * delta_p / p_L);
    u_LR = delta_p * c_L / gamma / p_L / u_LR;
    u_LR = u_L - u_LR;
  } else {
    u_LR = pow(p_R / p_L, mu) - 1.0;
    u_LR = 2.0 * c_L * u_LR / (gamma - 1.0);
    u_LR = u_L - u_LR;
  }
  if (p_L > p_R) {
    delta_p = p_L - p_R;
    u_RL = sqrt(1.0 + nu * delta_p / p_R);
    u_RL = delta_p * c_R / gamma / p_R / u_RL;
    u_RL = u_R + u_RL;
  } else {
    u_RL = pow(p_L / p_R, mu) - 1.0;
    u_RL = 2.0 * c_R * u_RL / (gamma - 1.0);
    u_RL = u_R + u_RL;
  }
  if (u_LR > u_R + tol)
    CRW[1] = 0;
  else
    CRW[1] = 1;
  if (u_RL > u_L - tol)
    CRW[0] = 1;
  else
    CRW[0] = 0;
  k1 = -c_L / p_L / gamma;
  k3 = c_R / p_R / gamma;
  p_INT = (k1 * p_L - k3 * p_R - u_L + u_R) / (k1 - k3);
  if (p_INT < 0)
    p_INT = (p_L < p_R) ? p_L : p_R;
  p_INT = 0.5 * p_INT;
  if (p_INT > p_L) {
    delta_p = p_INT - p_L;
    v_L = sqrt(1.0 + nu * delta_p / p_L);
    v_L = delta_p * c_L / gamma / p_L / v_L;
    v_L = u_L - v_L;
  } else {
    v_L = pow(p_INT / p_L, mu) - 1.0;
    v_L = 2.0 * c_L * v_L / (gamma - 1.0);
    v_L = u_L - v_L;
  }
  if (p_INT > p_R) {
    delta_p = p_INT - p_R;
    v_R = sqrt(1.0 + nu * delta_p / p_R);
    v_R = delta_p * c_R / gamma / p_R / v_R;
    v_R = u_R + v_R;
  } else {
    dbg = pow(p_INT / p_R, mu);
    v_R = pow(p_INT / p_R, mu) - 1.0;
    v_R = 2.0 * c_R * v_R / (gamma - 1.0);
    v_R = u_R + v_R;
  }
  gap = fabs(v_L - v_R);
  while ((gap > tol) && (n != N)) {
    if (p_INT > p_L) {
      delta_p = p_INT - p_L;
      temp1 = 1.0 / sqrt(1.0 + nu * delta_p / p_L);
      temp2 = c_L / gamma / p_L;
      temp3 = 0.5 * temp2 * nu / p_L;
      k1 = temp3 * delta_p * pow(temp1, 3.0) - temp2 * temp1;
    } else {
      temp2 = c_L / gamma / p_L;
      temp1 = 1.0 / pow(p_INT / p_L, nu);
      k1 = -temp1 * temp2;
    }
    if (p_INT > p_R) {
      delta_p = p_INT - p_R;
      temp1 = 1.0 / sqrt(1.0 + nu * delta_p / p_R);
      temp2 = c_R / gamma / p_R;
      temp3 = 0.5 * temp2 * nu / p_R;
      k3 = temp2 * temp1 - temp3 * delta_p * pow(temp1, 3.0);
    } else {
      temp2 = c_R / gamma / p_R;
      temp1 = 1.0 / pow(p_INT / p_R, nu);
      k3 = temp1 * temp2;
    }
    p_INT0 = p_INT + (v_R - v_L) / (k1 - k3);
    if (p_INT0 < 0.0)
      p_INT = 0.5 * p_INT;
    else
      p_INT = p_INT0;
    ++n;
    if (p_INT > p_L) {
      delta_p = p_INT - p_L;
      v_L = sqrt(1.0 + nu * delta_p / p_L);
      v_L = delta_p * c_L / gamma / p_L / v_L;
      v_L = u_L - v_L;
    } else {
      v_L = pow(p_INT / p_L, mu) - 1.0;
      v_L = 2.0 * c_L * v_L / (gamma - 1.0);
      v_L = u_L - v_L;
    }
    if (p_INT > p_R) {
      delta_p = p_INT - p_R;
      v_R = sqrt(1.0 + nu * delta_p / p_R);
      v_R = delta_p * c_R / gamma / p_R / v_R;
      v_R = u_R + v_R;
    } else {
      v_R = pow(p_INT / p_R, mu) - 1.0;
      v_R = 2.0 * c_R * v_R / (gamma - 1.0);
      v_R = u_R + v_R;
    }
    gap = fabs(v_L - v_R);
  }
  u_INT = k1 * (v_R - v_L) / (k1 - k3) + v_L;
  *P_star = p_INT;
  *U_star = u_INT;
  return gap;
}
```