user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<a2b_ord2>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x70,%rsp
  mov    %edi,-0x44(%rbp)
  mov    %esi,-0x48(%rbp)
  mov    %rdx,-0x50(%rbp)
  mov    %rcx,-0x58(%rbp)
  mov    %r8,-0x60(%rbp)
  mov    %r9,-0x68(%rbp)
  movsd  D45(%rip),%xmm0
  movsd  %xmm0,-0x18(%rbp)
  mov    -0x44(%rbp),%eax
  add    $0x1,%eax
  mov    %eax,-0x20(%rbp)
  mov    -0x48(%rbp),%eax
  add    $0x1,%eax
  mov    %eax,-0x1c(%rbp)
  mov    -0x44(%rbp),%eax
  add    $0x2,%eax
  cltq
  shl    $0x3,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x10(%rbp)
  mov    -0x48(%rbp),%eax
  add    $0x2,%eax
  cltq
  shl    $0x3,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x8(%rbp)
  cmpl   $0x0,0x20(%rbp)
  je     L231
  movl   $0x1,-0x30(%rbp)
  jmp    L347
L231:
  movl   $0x0,-0x30(%rbp)
L347:
  cmpl   $0x0,0x28(%rbp)
  je     L10
  mov    -0x44(%rbp),%eax
  mov    %eax,-0x2c(%rbp)
  jmp    L8
L10:
  mov    -0x20(%rbp),%eax
  mov    %eax,-0x2c(%rbp)
L8:
  cmpl   $0x0,0x30(%rbp)
  je     L50
  movl   $0x1,-0x28(%rbp)
  jmp    L119
L50:
  movl   $0x0,-0x28(%rbp)
L119:
  cmpl   $0x0,0x38(%rbp)
  je     L391
  mov    -0x48(%rbp),%eax
  mov    %eax,-0x24(%rbp)
  jmp    L148
L391:
  mov    -0x1c(%rbp),%eax
  mov    %eax,-0x24(%rbp)
L148:
  mov    -0x28(%rbp),%eax
  mov    %eax,-0x34(%rbp)
  jmp    L354
L27:
  mov    -0x30(%rbp),%eax
  mov    %eax,-0x38(%rbp)
  jmp    L311
L272:
  mov    -0x44(%rbp),%eax
  add    $0x2,%eax
  imul   -0x34(%rbp),%eax
  mov    %eax,%edx
  mov    -0x38(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  mov    -0x44(%rbp),%eax
  add    $0x2,%eax
  imul   -0x34(%rbp),%eax
  mov    %eax,%edx
  mov    -0x38(%rbp),%eax
  add    %edx,%eax
  cltq
  add    $0x1,%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  addsd  %xmm0,%xmm1
  mov    -0x34(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    -0x44(%rbp),%eax
  add    $0x2,%eax
  imul   %eax,%edx
  mov    -0x38(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  addsd  %xmm0,%xmm1
  mov    -0x34(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    -0x44(%rbp),%eax
  add    $0x2,%eax
  imul   %eax,%edx
  mov    -0x38(%rbp),%eax
  add    %edx,%eax
  cltq
  add    $0x1,%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  addsd  %xmm0,%xmm1
  mov    -0x34(%rbp),%eax
  imul   -0x20(%rbp),%eax
  mov    %eax,%edx
  mov    -0x38(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x18(%rbp),%rax
  add    %rdx,%rax
  movsd  D90(%rip),%xmm0
  mulsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
  addl   $0x1,-0x38(%rbp)
L311:
  mov    -0x38(%rbp),%eax
  cmp    -0x2c(%rbp),%eax
  jl     L272
  addl   $0x1,-0x34(%rbp)
L354:
  mov    -0x34(%rbp),%eax
  cmp    -0x24(%rbp),%eax
  jl     L27
  cmpl   $0x0,0x20(%rbp)
  je     L43
  cmpl   $0x0,0x30(%rbp)
  je     L43
  mov    -0x44(%rbp),%eax
  add    $0x2,%eax
  cltq
  add    $0x1,%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  mov    -0x44(%rbp),%eax
  add    $0x2,%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  addsd  %xmm0,%xmm1
  mov    -0x50(%rbp),%rax
  add    $0x8,%rax
  movsd  (%rax),%xmm0
  addsd  %xmm1,%xmm0
  mulsd  -0x18(%rbp),%xmm0
  mov    0x18(%rbp),%rax
  movsd  %xmm0,(%rax)
L43:
  cmpl   $0x0,0x28(%rbp)
  je     L313
  cmpl   $0x0,0x30(%rbp)
  je     L313
  mov    -0x44(%rbp),%eax
  lea    0x2(%rax),%edx
  mov    -0x44(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  mov    -0x44(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  addsd  %xmm0,%xmm1
  mov    -0x44(%rbp),%eax
  lea    0x2(%rax),%edx
  mov    -0x20(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  addsd  %xmm1,%xmm0
  mov    -0x44(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x18(%rbp),%rax
  add    %rdx,%rax
  mulsd  -0x18(%rbp),%xmm0
  movsd  %xmm0,(%rax)
L313:
  cmpl   $0x0,0x28(%rbp)
  je     L106
  cmpl   $0x0,0x38(%rbp)
  je     L106
  mov    -0x44(%rbp),%eax
  add    $0x2,%eax
  imul   -0x48(%rbp),%eax
  mov    %eax,%edx
  mov    -0x44(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  mov    -0x44(%rbp),%eax
  add    $0x2,%eax
  imul   -0x48(%rbp),%eax
  mov    %eax,%edx
  mov    -0x20(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  addsd  %xmm0,%xmm1
  mov    -0x44(%rbp),%eax
  add    $0x2,%eax
  imul   -0x1c(%rbp),%eax
  mov    %eax,%edx
  mov    -0x44(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  addsd  %xmm1,%xmm0
  mov    -0x48(%rbp),%eax
  imul   -0x20(%rbp),%eax
  mov    %eax,%edx
  mov    -0x44(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x18(%rbp),%rax
  add    %rdx,%rax
  mulsd  -0x18(%rbp),%xmm0
  movsd  %xmm0,(%rax)
L106:
  cmpl   $0x0,0x20(%rbp)
  je     L308
  cmpl   $0x0,0x38(%rbp)
  je     L308
  mov    -0x44(%rbp),%eax
  add    $0x2,%eax
  imul   -0x48(%rbp),%eax
  cltq
  add    $0x1,%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  mov    -0x44(%rbp),%eax
  add    $0x2,%eax
  imul   -0x48(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  addsd  %xmm0,%xmm1
  mov    -0x44(%rbp),%eax
  add    $0x2,%eax
  imul   -0x1c(%rbp),%eax
  cltq
  add    $0x1,%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  addsd  %xmm1,%xmm0
  mov    -0x48(%rbp),%eax
  imul   -0x20(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x18(%rbp),%rax
  add    %rdx,%rax
  mulsd  -0x18(%rbp),%xmm0
  movsd  %xmm0,(%rax)
L308:
  cmpl   $0x0,0x20(%rbp)
  je     L260
  mov    -0x28(%rbp),%eax
  mov    %eax,-0x34(%rbp)
  jmp    L353
L196:
  mov    -0x44(%rbp),%eax
  add    $0x2,%eax
  imul   -0x34(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  mov    -0x44(%rbp),%eax
  add    $0x2,%eax
  imul   -0x34(%rbp),%eax
  cltq
  add    $0x1,%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  addsd  %xmm0,%xmm1
  mov    -0x34(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movsd  D19(%rip),%xmm0
  mulsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
  addl   $0x1,-0x34(%rbp)
L353:
  mov    -0x34(%rbp),%eax
  cmp    -0x24(%rbp),%eax
  jle    L196
  mov    -0x28(%rbp),%eax
  mov    %eax,-0x34(%rbp)
  jmp    L300
L124:
  mov    -0x34(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x58(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  mov    -0x34(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  mulsd  %xmm0,%xmm1
  mov    -0x34(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x58(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm3
  movsd  D30(%rip),%xmm0
  movapd %xmm0,%xmm2
  subsd  %xmm3,%xmm2
  mov    -0x34(%rbp),%eax
  cltq
  add    $0x1,%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  mulsd  %xmm2,%xmm0
  mov    -0x34(%rbp),%eax
  imul   -0x20(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x18(%rbp),%rax
  add    %rdx,%rax
  addsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
  addl   $0x1,-0x34(%rbp)
L300:
  mov    -0x34(%rbp),%eax
  cmp    -0x24(%rbp),%eax
  jl     L124
L260:
  cmpl   $0x0,0x28(%rbp)
  je     L203
  mov    -0x28(%rbp),%eax
  mov    %eax,-0x34(%rbp)
  jmp    L321
L210:
  mov    -0x44(%rbp),%eax
  add    $0x2,%eax
  imul   -0x34(%rbp),%eax
  mov    %eax,%edx
  mov    -0x44(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  mov    -0x44(%rbp),%eax
  add    $0x2,%eax
  imul   -0x34(%rbp),%eax
  mov    %eax,%edx
  mov    -0x20(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  addsd  %xmm0,%xmm1
  mov    -0x34(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movsd  D19(%rip),%xmm0
  mulsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
  addl   $0x1,-0x34(%rbp)
L321:
  mov    -0x34(%rbp),%eax
  cmp    -0x24(%rbp),%eax
  jle    L210
  mov    -0x28(%rbp),%eax
  mov    %eax,-0x34(%rbp)
  jmp    L153
L147:
  mov    -0x34(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x60(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  mov    -0x34(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  mulsd  %xmm0,%xmm1
  mov    -0x34(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x60(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm3
  movsd  D30(%rip),%xmm0
  movapd %xmm0,%xmm2
  subsd  %xmm3,%xmm2
  mov    -0x34(%rbp),%eax
  cltq
  add    $0x1,%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  mulsd  %xmm2,%xmm0
  mov    -0x34(%rbp),%eax
  imul   -0x20(%rbp),%eax
  mov    %eax,%edx
  mov    -0x44(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x18(%rbp),%rax
  add    %rdx,%rax
  addsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
  addl   $0x1,-0x34(%rbp)
L153:
  mov    -0x34(%rbp),%eax
  cmp    -0x24(%rbp),%eax
  jl     L147
L203:
  cmpl   $0x0,0x30(%rbp)
  je     L110
  mov    -0x30(%rbp),%eax
  mov    %eax,-0x38(%rbp)
  jmp    L284
L137:
  mov    -0x38(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  mov    -0x44(%rbp),%eax
  lea    0x2(%rax),%edx
  mov    -0x38(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  addsd  %xmm0,%xmm1
  mov    -0x38(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  movsd  D19(%rip),%xmm0
  mulsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
  addl   $0x1,-0x38(%rbp)
L284:
  mov    -0x38(%rbp),%eax
  cmp    -0x2c(%rbp),%eax
  jle    L137
  mov    -0x30(%rbp),%eax
  mov    %eax,-0x38(%rbp)
  jmp    L282
L346:
  mov    -0x38(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x68(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  mov    -0x38(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  mulsd  %xmm0,%xmm1
  mov    -0x38(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x68(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm3
  movsd  D30(%rip),%xmm0
  movapd %xmm0,%xmm2
  subsd  %xmm3,%xmm2
  mov    -0x38(%rbp),%eax
  cltq
  add    $0x1,%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  mulsd  %xmm2,%xmm0
  mov    -0x38(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x18(%rbp),%rax
  add    %rdx,%rax
  addsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
  addl   $0x1,-0x38(%rbp)
L282:
  mov    -0x38(%rbp),%eax
  cmp    -0x2c(%rbp),%eax
  jl     L346
L110:
  cmpl   $0x0,0x38(%rbp)
  je     L57
  mov    -0x30(%rbp),%eax
  mov    %eax,-0x38(%rbp)
  jmp    L207
L6:
  mov    -0x44(%rbp),%eax
  add    $0x2,%eax
  imul   -0x48(%rbp),%eax
  mov    %eax,%edx
  mov    -0x38(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  mov    -0x44(%rbp),%eax
  add    $0x2,%eax
  imul   -0x1c(%rbp),%eax
  mov    %eax,%edx
  mov    -0x38(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  addsd  %xmm0,%xmm1
  mov    -0x38(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  movsd  D19(%rip),%xmm0
  mulsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
  addl   $0x1,-0x38(%rbp)
L207:
  mov    -0x38(%rbp),%eax
  cmp    -0x2c(%rbp),%eax
  jle    L6
  mov    -0x30(%rbp),%eax
  mov    %eax,-0x38(%rbp)
  jmp    L54
L61:
  mov    -0x38(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x10(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  mov    -0x38(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  mulsd  %xmm0,%xmm1
  mov    -0x38(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x10(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm3
  movsd  D30(%rip),%xmm0
  movapd %xmm0,%xmm2
  subsd  %xmm3,%xmm2
  mov    -0x38(%rbp),%eax
  cltq
  add    $0x1,%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  mulsd  %xmm2,%xmm0
  mov    -0x48(%rbp),%eax
  imul   -0x20(%rbp),%eax
  mov    %eax,%edx
  mov    -0x38(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    0x18(%rbp),%rax
  add    %rdx,%rax
  addsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
  addl   $0x1,-0x38(%rbp)
L54:
  mov    -0x38(%rbp),%eax
  cmp    -0x2c(%rbp),%eax
  jl     L61
L57:
  mov    -0x10(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  nop
  leave
  ret
```

tool_calls: name: extract_symbolic_data
arguments: data_label: D45
datatype: byte[8]
name: extract_symbolic_data
arguments: data_label: D90
datatype: f64
name: extract_symbolic_data
arguments: data_label: D19
datatype: f64
name: extract_symbolic_data
arguments: data_label: D30
datatype: f64

tool: {"D45": [0x55,0x55,0x55,0x55,0x55,0x55,0xd5,0x3f]}

tool: D90: 0.25

tool: D19: 0.5

tool: D30: 1

assistant: ```c
void a2b_ord2(int nx, int ny, const double *qin, const double *edge_w, const double *edge_e, const double *edge_s, const double *edge_n, double *qout, int on_west_edge, int on_east_edge, int on_south_edge, int on_north_edge) {
  int nxp, nyp, i, j;
  int istart, iend, jstart, jend;
  double *q1, *q2;
  const double r3 = 1. / 3.;
  nxp = nx + 1;
  nyp = ny + 1;
  q1 = (double *)malloc((nx + 2) * sizeof(double));
  q2 = (double *)malloc((ny + 2) * sizeof(double));
  if (on_west_edge)
    istart = 1;
  else
    istart = 0;
  if (on_east_edge)
    iend = nx;
  else
    iend = nxp;
  if (on_south_edge)
    jstart = 1;
  else
    jstart = 0;
  if (on_north_edge)
    jend = ny;
  else
    jend = nyp;
  for (j = jstart; j < jend; j++)
    for (i = istart; i < iend; i++) {
      qout[j * nxp + i] = 0.25 * (qin[j * (nx + 2) + i] + qin[j * (nx + 2) + i + 1] + qin[(j + 1) * (nx + 2) + i] + qin[(j + 1) * (nx + 2) + i + 1]);
    }
  if (on_west_edge && on_south_edge)
    qout[0] = r3 * (qin[1 * (nx + 2) + 1] + qin[1 * (nx + 2)] + qin[1]);
  if (on_east_edge && on_south_edge)
    qout[nx] = r3 * (qin[1 * (nx + 2) + nx] + qin[nx] + qin[1 * (nx + 2) + nxp]);
  if (on_east_edge && on_north_edge)
    qout[ny * nxp + nx] = r3 * (qin[ny * (nx + 2) + nx] + qin[ny * (nx + 2) + nxp] + qin[nyp * (nx + 2) + nx]);
  if (on_west_edge && on_north_edge)
    qout[ny * nxp] = r3 * (qin[ny * (nx + 2) + 1] + qin[ny * (nx + 2)] + qin[nyp * (nx + 2) + 1]);
  if (on_west_edge) {
    for (j = jstart; j <= jend; j++) {
      q2[j] = 0.5 * (qin[j * (nx + 2)] + qin[j * (nx + 2) + 1]);
    }
    for (j = jstart; j < jend; j++) {
      qout[j * nxp] = edge_w[j] * q2[j] + (1 - edge_w[j]) * q2[j + 1];
    }
  }
  if (on_east_edge) {
    for (j = jstart; j <= jend; j++) {
      q2[j] = 0.5 * (qin[j * (nx + 2) + nx] + qin[j * (nx + 2) + nxp]);
    }
    for (j = jstart; j < jend; j++) {
      qout[j * nxp + nx] = edge_e[j] * q2[j] + (1 - edge_e[j]) * q2[j + 1];
    }
  }
  if (on_south_edge) {
    for (i = istart; i <= iend; i++) {
      q1[i] = 0.5 * (qin[i] + qin[(nx + 2) + i]);
    }
    for (i = istart; i < iend; i++) {
      qout[i] = edge_s[i] * q1[i] + (1 - edge_s[i]) * q1[i + 1];
    }
  }
  if (on_north_edge) {
    for (i = istart; i <= iend; i++) {
      q1[i] = 0.5 * (qin[ny * (nx + 2) + i] + qin[nyp * (nx + 2) + i]);
    }
    for (i = istart; i < iend; i++) {
      qout[ny * nxp + i] = edge_n[i] * q1[i] + (1 - edge_n[i]) * q1[i + 1];
    }
  }
  free(q1);
  free(q2);
}
```