user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<Riemann>:
  endbr64
  push   %r15
  push   %r14
  push   %rbx
  mov    %rdx,%rbx
  sub    $0xa0,%rsp
  movsd  0x8(%rsi),%xmm0
  movsd  (%rsi),%xmm3
  movsd  %xmm3,0x88(%rsp)
  movapd %xmm0,%xmm6
  movsd  D367(%rip),%xmm0
  divsd  %xmm3,%xmm6
  mulsd  %xmm3,%xmm0
  mulsd  %xmm6,%xmm0
  movsd  %xmm6,0x48(%rsp)
  mulsd  %xmm6,%xmm0
  movsd  %xmm0,0x80(%rsp)
  movapd %xmm0,%xmm4
  movsd  0x10(%rsi),%xmm0
  subsd  %xmm4,%xmm0
  mulsd  D22(%rip),%xmm0
  movapd %xmm0,%xmm4
  movsd  %xmm0,0x50(%rsp)
  movsd  D155(%rip),%xmm0
  mulsd  %xmm4,%xmm0
  pxor   %xmm4,%xmm4
  divsd  %xmm3,%xmm0
  ucomisd %xmm0,%xmm4
  ja     L45
  sqrtsd %xmm0,%xmm0
  movsd  %xmm0,0x58(%rsp)
L147:
  movsd  0x8(%rdi),%xmm0
  movsd  (%rdi),%xmm4
  movapd %xmm0,%xmm6
  movsd  D367(%rip),%xmm0
  movsd  %xmm4,0x70(%rsp)
  divsd  %xmm4,%xmm6
  mulsd  %xmm4,%xmm0
  mulsd  %xmm6,%xmm0
  movsd  %xmm6,0x30(%rsp)
  mulsd  %xmm6,%xmm0
  movapd %xmm0,%xmm3
  movsd  %xmm0,0x68(%rsp)
  movsd  0x10(%rdi),%xmm0
  subsd  %xmm3,%xmm0
  mulsd  D22(%rip),%xmm0
  movapd %xmm0,%xmm6
  movsd  %xmm0,0x40(%rsp)
  movsd  D155(%rip),%xmm0
  mulsd  %xmm6,%xmm0
  divsd  %xmm4,%xmm0
  pxor   %xmm4,%xmm4
  ucomisd %xmm0,%xmm4
  ja     L25
  sqrtsd %xmm0,%xmm0
  movapd %xmm6,%xmm3
  movsd  %xmm0,0x38(%rsp)
L197:
  movsd  D187(%rip),%xmm7
  movsd  0x50(%rsp),%xmm2
  mov    D434(%rip),%rax
  mulsd  %xmm3,%xmm7
  divsd  %xmm2,%xmm3
  movq   %rax,%xmm1
  divsd  %xmm2,%xmm7
  movapd %xmm3,%xmm0
  movsd  %xmm3,0x8(%rsp)
  movsd  %xmm7,(%rsp)
  call   <pow@plt>
  movsd  (%rsp),%xmm7
  mov    D434(%rip),%rax
  movq   %xmm0,%r14
  movq   %rax,%xmm1
  movapd %xmm7,%xmm0
  call   <pow@plt>
  movsd  0x38(%rsp),%xmm3
  movsd  (%rsp),%xmm7
  movsd  0x30(%rsp),%xmm4
  subsd  0x48(%rsp),%xmm4
  movapd %xmm0,%xmm1
  movapd %xmm3,%xmm2
  movapd %xmm7,%xmm9
  movsd  0x58(%rsp),%xmm6
  divsd  D155(%rip),%xmm6
  addsd  %xmm3,%xmm2
  movsd  %xmm6,0x20(%rsp)
  movsd  0x8(%rsp),%xmm5
  movsd  D22(%rip),%xmm3
  movq   %xmm4,%r15
  movsd  D294(%rip),%xmm4
  divsd  %xmm2,%xmm3
  subsd  %xmm4,%xmm9
  movsd  %xmm2,0x78(%rsp)
  movapd %xmm6,%xmm2
  movsd  D479(%rip),%xmm6
  mulsd  %xmm9,%xmm6
  mulsd  %xmm9,%xmm2
  addsd  %xmm4,%xmm6
  movsd  %xmm3,0x18(%rsp)
  pxor   %xmm3,%xmm3
  ucomisd %xmm6,%xmm3
  ja     L52
  movapd %xmm6,%xmm0
  sqrtsd %xmm0,%xmm0
L198:
  divsd  %xmm0,%xmm2
  movq   %r15,%xmm0
  movq   %r14,%xmm8
  mov    D434(%rip),%rax
  movsd  %xmm6,0x60(%rsp)
  movsd  %xmm9,0x28(%rsp)
  movsd  %xmm7,0x10(%rsp)
  movsd  %xmm5,(%rsp)
  subsd  %xmm2,%xmm0
  mulsd  0x18(%rsp),%xmm0
  addsd  %xmm4,%xmm0
  mulsd  %xmm1,%xmm0
  movq   %rax,%xmm1
  subsd  %xmm0,%xmm8
  movapd %xmm5,%xmm0
  movsd  %xmm8,0x8(%rsp)
  call   <pow@plt>
  mov    D434(%rip),%rax
  movsd  (%rsp),%xmm5
  movq   %xmm0,%r14
  movq   %rax,%xmm1
  movapd %xmm5,%xmm0
  call   <pow@plt>
  movsd  (%rsp),%xmm5
  mov    D294(%rip),%rax
  pxor   %xmm7,%xmm7
  movapd %xmm0,%xmm1
  movsd  0x20(%rsp),%xmm2
  movsd  0x8(%rsp),%xmm8
  movq   %rax,%xmm4
  movapd %xmm5,%xmm0
  movsd  0x28(%rsp),%xmm9
  movsd  0x60(%rsp),%xmm6
  subsd  %xmm4,%xmm0
  mulsd  %xmm0,%xmm2
  mulsd  D479(%rip),%xmm0
  addsd  %xmm4,%xmm0
  ucomisd %xmm0,%xmm7
  movsd  0x10(%rsp),%xmm7
  ja     L302
  sqrtsd %xmm0,%xmm0
L267:
  divsd  %xmm0,%xmm2
  movq   %r15,%xmm0
  movq   %r14,%xmm3
  subsd  %xmm2,%xmm0
  mulsd  0x18(%rsp),%xmm0
  movapd %xmm5,%xmm2
  addsd  %xmm4,%xmm0
  mulsd  %xmm1,%xmm0
  subsd  %xmm0,%xmm3
  movapd %xmm7,%xmm0
  subsd  %xmm5,%xmm0
  andpd  D360(%rip),%xmm0
  comisd D450(%rip),%xmm0
  jbe    L303
  movsd  %xmm5,0x28(%rsp)
  jmp    L247
  nopl   0x0(%rax,%rax,1)
L279:
  movapd %xmm3,%xmm8
  movapd %xmm2,%xmm7
  movapd %xmm1,%xmm3
  movapd %xmm5,%xmm2
L247:
  movapd %xmm2,%xmm0
  movapd %xmm3,%xmm1
  movapd %xmm2,%xmm5
  mov    D434(%rip),%rax
  subsd  %xmm7,%xmm0
  subsd  %xmm8,%xmm1
  movsd  %xmm3,0x10(%rsp)
  movsd  %xmm2,0x8(%rsp)
  mulsd  %xmm3,%xmm0
  divsd  %xmm1,%xmm0
  movq   %rax,%xmm1
  subsd  %xmm0,%xmm5
  movsd  0x28(%rsp),%xmm0
  movsd  %xmm5,(%rsp)
  call   <pow@plt>
  mov    D434(%rip),%rax
  movsd  (%rsp),%xmm5
  movq   %xmm0,%r14
  movq   %rax,%xmm1
  movapd %xmm5,%xmm0
  call   <pow@plt>
  movsd  (%rsp),%xmm5
  mov    D294(%rip),%rax
  pxor   %xmm6,%xmm6
  movapd %xmm0,%xmm1
  movsd  0x20(%rsp),%xmm7
  movsd  0x8(%rsp),%xmm2
  movq   %rax,%xmm4
  movapd %xmm5,%xmm0
  movsd  0x10(%rsp),%xmm3
  subsd  %xmm4,%xmm0
  mulsd  %xmm0,%xmm7
  mulsd  D479(%rip),%xmm0
  addsd  %xmm4,%xmm0
  ucomisd %xmm0,%xmm6
  ja     L111
  sqrtsd %xmm0,%xmm0
  divsd  %xmm0,%xmm7
  movq   %r15,%xmm0
  subsd  %xmm7,%xmm0
  mulsd  0x18(%rsp),%xmm0
  addsd  %xmm4,%xmm0
  mulsd  %xmm1,%xmm0
  movq   %r14,%xmm1
  subsd  %xmm0,%xmm1
  movapd %xmm2,%xmm0
  subsd  %xmm5,%xmm0
  andpd  D360(%rip),%xmm0
  comisd D450(%rip),%xmm0
  ja     L279
L226:
  movapd %xmm2,%xmm9
  movsd  D479(%rip),%xmm6
  subsd  %xmm4,%xmm9
  mulsd  %xmm9,%xmm6
  addsd  %xmm4,%xmm6
L305:
  pxor   %xmm3,%xmm3
  ucomisd %xmm6,%xmm3
  ja     L242
  movapd %xmm6,%xmm5
  sqrtsd %xmm5,%xmm5
L281:
  movsd  D37(%rip),%xmm1
  movapd %xmm2,%xmm0
  addsd  %xmm1,%xmm0
  mulsd  %xmm2,%xmm1
  mulsd  %xmm2,%xmm0
  addsd  %xmm4,%xmm1
  pxor   %xmm4,%xmm4
  divsd  %xmm1,%xmm0
  ucomisd %xmm0,%xmm4
  ja     L208
  movapd %xmm0,%xmm3
  sqrtsd %xmm3,%xmm3
L154:
  ucomisd %xmm6,%xmm4
  ja     L157
  sqrtsd %xmm6,%xmm6
  movapd %xmm4,%xmm1
L43:
  movsd  0x30(%rsp),%xmm4
  movsd  0x38(%rsp),%xmm7
  movapd %xmm4,%xmm0
  subsd  %xmm7,%xmm0
  comisd %xmm1,%xmm0
  jbe    L166
  movsd  0x70(%rsp),%xmm5
  movsd  0x68(%rsp),%xmm1
  movapd %xmm4,%xmm2
  mulsd  %xmm4,%xmm1
  movapd %xmm5,%xmm3
  mulsd  %xmm7,%xmm5
  mulsd  %xmm4,%xmm3
  movapd %xmm5,%xmm0
  mulsd  %xmm7,%xmm0
  mulsd  %xmm3,%xmm2
  addsd  0x40(%rsp),%xmm2
  mulsd  %xmm4,%xmm0
  divsd  D22(%rip),%xmm0
  addsd  %xmm1,%xmm0
L185:
  unpcklpd %xmm2,%xmm3
  movsd  %xmm0,0x10(%rbx)
  movups %xmm3,(%rbx)
  add    $0xa0,%rsp
  pop    %rbx
  pop    %r14
  pop    %r15
  ret
  nopw   0x0(%rax,%rax,1)
L166:
  divsd  %xmm5,%xmm9
  movsd  0x78(%rsp),%xmm7
  movsd  0x30(%rsp),%xmm5
  movapd %xmm7,%xmm4
  divsd  D22(%rip),%xmm4
  addsd  %xmm5,%xmm4
  mulsd  0x20(%rsp),%xmm9
  addsd  0x48(%rsp),%xmm9
  subsd  %xmm9,%xmm4
  mulsd  D22(%rip),%xmm4
  movapd %xmm9,%xmm0
  mulsd  D367(%rip),%xmm4
  subsd  %xmm4,%xmm0
  comisd %xmm1,%xmm0
  ja     L137
  mulsd  0x50(%rsp),%xmm2
  movapd %xmm1,%xmm7
  movsd  D155(%rip),%xmm1
  comisd %xmm7,%xmm9
  mulsd  %xmm2,%xmm1
  jbe    L233
  movapd %xmm4,%xmm0
  movapd %xmm9,%xmm3
  mulsd  %xmm4,%xmm0
  divsd  %xmm0,%xmm1
  movapd %xmm9,%xmm0
  mulsd  %xmm1,%xmm3
  mulsd  %xmm3,%xmm0
  addsd  %xmm0,%xmm2
  movsd  D367(%rip),%xmm0
  mulsd  %xmm1,%xmm0
  mulsd  %xmm4,%xmm1
  mulsd  %xmm9,%xmm0
  mulsd  %xmm4,%xmm1
  mulsd  %xmm9,%xmm0
  mulsd  %xmm9,%xmm1
  divsd  D22(%rip),%xmm1
  mulsd  %xmm9,%xmm0
  addsd  %xmm1,%xmm0
  jmp    L185
  nopw   0x0(%rax,%rax,1)
L233:
  movapd %xmm7,%xmm4
  movsd  0x58(%rsp),%xmm7
  mulsd  %xmm7,%xmm6
  addsd  0x48(%rsp),%xmm6
  comisd %xmm4,%xmm6
  jbe    L95
  mulsd  %xmm3,%xmm7
  movapd %xmm9,%xmm4
  movapd %xmm7,%xmm3
  mulsd  %xmm7,%xmm3
  divsd  %xmm3,%xmm1
  movapd %xmm9,%xmm3
  mulsd  %xmm1,%xmm3
  mulsd  %xmm3,%xmm4
  addsd  %xmm4,%xmm2
  movsd  D367(%rip),%xmm4
  mulsd  %xmm1,%xmm4
  mulsd  %xmm7,%xmm1
  mulsd  %xmm9,%xmm4
  mulsd  %xmm7,%xmm1
  mulsd  %xmm9,%xmm4
  mulsd  %xmm9,%xmm1
  divsd  D22(%rip),%xmm1
  mulsd  %xmm9,%xmm4
  addsd  %xmm1,%xmm4
  movapd %xmm4,%xmm0
  jmp    L185
  nopl   0x0(%rax)
L137:
  movsd  D22(%rip),%xmm4
  mov    D434(%rip),%rax
  mulsd  %xmm5,%xmm4
  movq   %rax,%xmm1
  addsd  %xmm7,%xmm4
  divsd  D178(%rip),%xmm4
  movapd %xmm4,%xmm0
  movsd  %xmm4,(%rsp)
  divsd  0x38(%rsp),%xmm0
  call   <pow@plt>
  movsd  (%rsp),%xmm4
  pxor   %xmm6,%xmm6
  movsd  0x40(%rsp),%xmm2
  comisd %xmm4,%xmm6
  mulsd  %xmm0,%xmm2
  ja     L122
  comisd %xmm2,%xmm6
  ja     L122
L285:
  movsd  D155(%rip),%xmm1
  movapd %xmm4,%xmm0
  movapd %xmm4,%xmm3
  movapd %xmm4,%xmm5
  mulsd  %xmm4,%xmm0
  mulsd  %xmm2,%xmm1
  divsd  %xmm0,%xmm1
  movsd  D367(%rip),%xmm0
  mulsd  %xmm1,%xmm0
  mulsd  %xmm1,%xmm3
  mulsd  %xmm4,%xmm0
  mulsd  %xmm3,%xmm5
  mulsd  %xmm4,%xmm0
  addsd  %xmm5,%xmm2
  mulsd  %xmm4,%xmm5
  divsd  D22(%rip),%xmm5
  mulsd  %xmm4,%xmm0
  addsd  %xmm5,%xmm0
  jmp    L185
  nopl   0x0(%rax,%rax,1)
L303:
  movapd %xmm7,%xmm2
  jmp    L305
  nopl   0x0(%rax)
L122:
  lea    D376(%rip),%rdi
  movsd  %xmm2,0x8(%rsp)
  movsd  %xmm4,(%rsp)
  call   <printf@plt>
  movsd  0x8(%rsp),%xmm2
  movsd  (%rsp),%xmm4
  jmp    L285
L95:
  movsd  0x88(%rsp),%xmm4
  movsd  0x48(%rsp),%xmm6
  movsd  0x80(%rsp),%xmm1
  movapd %xmm4,%xmm3
  movapd %xmm6,%xmm2
  mulsd  %xmm7,%xmm4
  mulsd  %xmm6,%xmm3
  mulsd  %xmm6,%xmm1
  movapd %xmm4,%xmm0
  mulsd  %xmm7,%xmm0
  mulsd  %xmm3,%xmm2
  addsd  0x50(%rsp),%xmm2
  mulsd  %xmm6,%xmm0
  divsd  D22(%rip),%xmm0
  addsd  %xmm1,%xmm0
  jmp    L185
L111:
  movsd  %xmm2,0x90(%rsp)
  movsd  %xmm3,0x60(%rsp)
  movsd  %xmm5,0x10(%rsp)
  movsd  %xmm7,0x8(%rsp)
  movsd  %xmm1,(%rsp)
  call   <sqrt@plt>
  movsd  0x8(%rsp),%xmm7
  movsd  (%rsp),%xmm1
  mov    D294(%rip),%rax
  movsd  0x10(%rsp),%xmm5
  divsd  %xmm0,%xmm7
  movq   %r15,%xmm0
  movsd  0x90(%rsp),%xmm2
  movsd  0x60(%rsp),%xmm3
  movq   %rax,%xmm4
  subsd  %xmm7,%xmm0
  mulsd  0x18(%rsp),%xmm0
  addsd  %xmm4,%xmm0
  mulsd  %xmm1,%xmm0
  movq   %r14,%xmm1
  subsd  %xmm0,%xmm1
  movapd %xmm2,%xmm0
  subsd  %xmm5,%xmm0
  andpd  D360(%rip),%xmm0
  comisd D450(%rip),%xmm0
  ja     L279
  jmp    L226
L157:
  movapd %xmm6,%xmm0
  movsd  %xmm9,0x18(%rsp)
  movsd  %xmm2,0x10(%rsp)
  movsd  %xmm3,0x8(%rsp)
  movsd  %xmm5,(%rsp)
  call   <sqrt@plt>
  movsd  0x18(%rsp),%xmm9
  movsd  0x10(%rsp),%xmm2
  pxor   %xmm1,%xmm1
  movsd  0x8(%rsp),%xmm3
  movsd  (%rsp),%xmm5
  movapd %xmm0,%xmm6
  jmp    L43
L25:
  call   <sqrt@plt>
  movsd  0x40(%rsp),%xmm3
  movsd  %xmm0,0x38(%rsp)
  jmp    L197
L45:
  mov    %rdi,(%rsp)
  call   <sqrt@plt>
  mov    (%rsp),%rdi
  movsd  %xmm0,0x58(%rsp)
  jmp    L147
L208:
  movsd  %xmm6,0x18(%rsp)
  movsd  %xmm9,0x10(%rsp)
  movsd  %xmm2,0x8(%rsp)
  movsd  %xmm5,(%rsp)
  call   <sqrt@plt>
  movsd  0x18(%rsp),%xmm6
  movsd  0x8(%rsp),%xmm2
  pxor   %xmm4,%xmm4
  movsd  0x10(%rsp),%xmm9
  movsd  (%rsp),%xmm5
  movapd %xmm0,%xmm3
  jmp    L154
L242:
  movapd %xmm6,%xmm0
  movsd  %xmm9,0x10(%rsp)
  movsd  %xmm2,0x8(%rsp)
  movsd  %xmm6,(%rsp)
  call   <sqrt@plt>
  movsd  0x8(%rsp),%xmm2
  movsd  (%rsp),%xmm6
  mov    D294(%rip),%rax
  movsd  0x10(%rsp),%xmm9
  movapd %xmm0,%xmm5
  movq   %rax,%xmm4
  jmp    L281
L302:
  movsd  %xmm6,0x98(%rsp)
  movsd  %xmm9,0x90(%rsp)
  movsd  %xmm8,0x60(%rsp)
  movsd  %xmm5,0x28(%rsp)
  movsd  %xmm7,0x10(%rsp)
  movsd  %xmm2,0x8(%rsp)
  movsd  %xmm1,(%rsp)
  call   <sqrt@plt>
  movsd  0x28(%rsp),%xmm5
  movsd  (%rsp),%xmm1
  mov    D294(%rip),%rax
  movsd  0x60(%rsp),%xmm8
  movsd  0x98(%rsp),%xmm6
  movsd  0x10(%rsp),%xmm7
  movsd  0x90(%rsp),%xmm9
  movsd  0x8(%rsp),%xmm2
  movq   %rax,%xmm4
  jmp    L267
L52:
  movsd  %xmm0,0x8(%rsp)
  movapd %xmm6,%xmm0
  movsd  %xmm9,0x90(%rsp)
  movsd  %xmm5,0x60(%rsp)
  movsd  %xmm7,0x28(%rsp)
  movsd  %xmm2,0x10(%rsp)
  movsd  %xmm6,(%rsp)
  call   <sqrt@plt>
  movsd  0x60(%rsp),%xmm5
  movsd  (%rsp),%xmm6
  mov    D294(%rip),%rax
  movsd  0x28(%rsp),%xmm7
  movsd  0x90(%rsp),%xmm9
  movsd  0x10(%rsp),%xmm2
  movsd  0x8(%rsp),%xmm1
  movq   %rax,%xmm4
  jmp    L198
```

tool_calls: name: unpack_data
arguments: label: D367
data_type: f64
name: unpack_data
arguments: label: D22
data_type: byte[8]
name: unpack_data
arguments: label: D155
data_type: f64
name: unpack_data
arguments: label: D187
data_type: f64
name: unpack_data
arguments: label: D434
data_type: byte[8]
name: unpack_data
arguments: label: D294
data_type: f64
name: unpack_data
arguments: label: D479
data_type: byte[8]
name: unpack_data
arguments: label: D360
data_type: qword[2]
name: unpack_data
arguments: label: D450
data_type: byte[16]
name: unpack_data
arguments: label: D37
data_type: byte[8]
name: unpack_data
arguments: label: D178
data_type: byte[8]
name: unpack_data
arguments: label: D376
data_type: string

tool: D367: 0.5

tool: {"D22": [0x98,0x99,0x99,0x99,0x99,0x99,0xd9,0x3f]}

tool: D155: 1.4

tool: D187: 0.001

tool: {"D434": [0x01,0x00,0x00,0x00,0x00,0x00,0x1c,0x40]}

tool: D294: 1

tool: {"D479": [0xdc,0xb6,0x6d,0xdb,0xb6,0x6d,0xeb,0x3f]}

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

tool: {"D450": [0xbb,0xbd,0xd7,0xd9,0xdf,0x7c,0xdb,0x3d,0x01,0x00,0x00,0x00,0x00,0x00,0x18,0x40]}

tool: {"D37": [0x01,0x00,0x00,0x00,0x00,0x00,0x18,0x40]}

tool: {"D178": [0x33,0x33,0x33,0x33,0x33,0x33,0x03,0x40]}

tool: D376: Negative a or p in Riemann

assistant: ```c
void Riemann(double *U4, double *U1, double *F) {
  const double gamma = 1.4;
  const double g1 = (2 * gamma) / (gamma - 1);
  const double g2 = (gamma + 1) / (2 * gamma);
  const double g3 = (gamma + 1) / (gamma - 1);
  const double tol = 1e-10;
  int i;
  double rho1, u1, p1, a1;
  rho1 = U1[0];
  u1 = U1[1] / rho1;
  p1 = (U1[2] - 0.5 * rho1 * u1 * u1) * (gamma - 1.0);
  a1 = sqrt(gamma * p1 / rho1);
  double rho4, u4, p4, a4;
  rho4 = U4[0];
  u4 = U4[1] / rho4;
  p4 = (U4[2] - 0.5 * rho4 * u4 * u4) * (gamma - 1.0);
  a4 = sqrt(gamma * p4 / rho4);
  double x, y, fx, fy, z, fz;
  x = 0.001 * p4 / p1;
  y = 1.0 * p4 / p1;
  fx = pow(p4 / p1, g1) - pow(x, g1) * (1 + ((gamma - 1) / (2 * a4)) * (u4 - u1 - (a1 / gamma) * (x - 1) / sqrt(g2 * (x - 1) + 1)));
  fy = pow(p4 / p1, g1) - pow(y, g1) * (1 + ((gamma - 1) / (2 * a4)) * (u4 - u1 - (a1 / gamma) * (y - 1) / sqrt(g2 * (y - 1) + 1)));
  while (fabs(x - y) > tol) {
    z = y - fy * (y - x) / (fy - fx);
    fz = pow(p4 / p1, g1) - pow(z, g1) * (1 + ((gamma - 1) / (2 * a4)) * (u4 - u1 - (a1 / gamma) * (z - 1) / sqrt(g2 * (z - 1) + 1)));
    x = y;
    fx = fy;
    y = z;
    fy = fz;
  }
  double rho2, u2, p2, a2;
  p2 = p1 * x;
  u2 = u1 + (a1 / gamma) * ((x - 1) / sqrt(g2 * (x - 1) + 1));
  a2 = a1 * sqrt(x * (g3 + x) / (1 + g3 * x));
  rho2 = gamma * p2 / (a2 * a2);
  double rho3, u3, p3, a3;
  p3 = p2;
  u3 = u2;
  a3 = (u4 + 2.0 * a4 / (gamma - 1) - u3) * (gamma - 1) / 2.0;
  rho3 = gamma * p3 / (a3 * a3);
  double s1, s2, s3, s4;
  s1 = u1 + a1 * sqrt(g2 * (x - 1) + 1);
  s2 = u2;
  s3 = u3 - a3;
  s4 = u4 - a4;
  double f1, f2, f3;
  double rho, a, u, p;
  if (s4 > 0) {
    f1 = rho4 * u4;
    f2 = rho4 * u4 * u4 + p4;
    f3 = 0.5 * rho4 * u4 * u4 * u4 + rho4 * a4 * a4 * u4 / (gamma - 1.0);
  } else if (s3 > 0) {
    u = ((gamma - 1.0) * u4 + 2.0 * a4) / (gamma + 1.0);
    a = u;
    p = p4 * pow(a / a4, 2.0 * gamma / (gamma - 1.0));
    if (a < 0 || p < 0) {
      printf("Negative a or p in Riemann");
    }
    rho = gamma * p / (a * a);
    f1 = rho * u;
    f2 = rho * u * u + p;
    f3 = 0.5 * rho * u * u * u + rho * a * a * u / (gamma - 1.0);
  } else if (s2 > 0) {
    f1 = rho3 * u3;
    f2 = rho3 * u3 * u3 + p3;
    f3 = 0.5 * rho3 * u3 * u3 * u3 + rho3 * a3 * a3 * u3 / (gamma - 1.0);
  } else if (s1 > 0) {
    f1 = rho2 * u2;
    f2 = rho2 * u2 * u2 + p2;
    f3 = 0.5 * rho2 * u2 * u2 * u2 + rho2 * a2 * a2 * u2 / (gamma - 1.0);
  } else {
    f1 = rho1 * u1;
    f2 = rho1 * u1 * u1 + p1;
    f3 = 0.5 * rho1 * u1 * u1 * u1 + rho1 * a1 * a1 * u1 / (gamma - 1.0);
  }
  F[0] = f1;
  F[1] = f2;
  F[2] = f3;
}
```