user: Please show me the C implementation that matches the assembly code listed below:

```asm
<islandPerimeter>:
  endbr64
  mov    %esi,%r10d
  test   %esi,%esi
  jle    L438
  lea    -0x1(%rdx),%r11d
  xor    %r9d,%r9d
  xor    %eax,%eax
  push   %r13
  cmp    %r11d,%edx
  mov    %r11d,%r8d
  push   %r12
  mov    %edx,%esi
  cmovle %edx,%r8d
  push   %rbp
  push   %rbx
  lea    -0x1(%r10),%ebx
  xchg   %ax,%ax
L622:
  test   %esi,%esi
  jle    L348
  mov    (%rdi),%rcx
  cmp    %r9d,%ebx
  jg     L719
  test   %r9d,%r9d
  je     L576
  test   %r11d,%r11d
  jle    L322
  xor    %ebp,%ebp
  xor    %edx,%edx
  jmp    L452
  nopl   0x0(%rax)
L192:
  add    $0x1,%edx
  add    $0x4,%rbp
  cmp    %r8d,%edx
  jge    L361
L452:
  cmpl   $0x1,(%rcx,%rbp,1)
  jne    L192
  mov    -0x8(%rdi),%r13
  lea    0x4(%rax),%r12d
  add    $0x3,%eax
  cmpl   $0x1,0x0(%r13,%rbp,1)
  cmovne %r12d,%eax
  cmpl   $0x1,0x4(%rcx,%rbp,1)
  je     L722
L592:
  test   %edx,%edx
  je     L192
  cmpl   $0x1,-0x4(%rcx,%rbp,1)
  jne    L192
  add    $0x1,%edx
  sub    $0x1,%eax
  add    $0x4,%rbp
  cmp    %r8d,%edx
  jl     L452
  nopl   0x0(%rax)
L361:
  cmp    %edx,%esi
  jle    L348
L339:
  movslq %edx,%rdx
  jmp    L11
  nopl   0x0(%rax)
L556:
  add    $0x1,%rdx
  cmp    %edx,%esi
  jle    L348
L11:
  cmpl   $0x1,(%rcx,%rdx,4)
  jne    L556
  mov    -0x8(%rdi),%rbp
  lea    0x4(%rax),%r12d
  add    $0x3,%eax
  cmpl   $0x1,0x0(%rbp,%rdx,4)
  je     L578
  mov    %r12d,%eax
L578:
  test   %edx,%edx
  je     L556
  cmpl   $0x1,-0x4(%rcx,%rdx,4)
  jne    L556
  add    $0x1,%rdx
  sub    $0x1,%eax
  cmp    %edx,%esi
  jg     L11
  nopl   0x0(%rax)
L348:
  add    $0x1,%r9d
  add    $0x8,%rdi
  cmp    %r9d,%r10d
  jne    L622
L534:
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   0x0(%rax,%rax,1)
L719:
  test   %r9d,%r9d
  je     L62
  test   %r11d,%r11d
  jle    L202
  xor    %ebp,%ebp
  xor    %edx,%edx
  jmp    L319
  nopl   0x0(%rax,%rax,1)
L336:
  add    $0x1,%edx
  add    $0x4,%rbp
  cmp    %r8d,%edx
  jge    L426
L319:
  cmpl   $0x1,(%rcx,%rbp,1)
  jne    L336
  mov    -0x8(%rdi),%r12
  lea    0x4(%rax),%r13d
  add    $0x3,%eax
  cmpl   $0x1,(%r12,%rbp,1)
  je     L459
  mov    %r13d,%eax
L459:
  cmpl   $0x1,0x4(%rcx,%rbp,1)
  je     L103
L393:
  mov    0x8(%rdi),%r12
  cmpl   $0x1,(%r12,%rbp,1)
  sete   %r12b
  movzbl %r12b,%r12d
  sub    %r12d,%eax
  test   %edx,%edx
  je     L336
  cmpl   $0x1,-0x4(%rcx,%rbp,1)
  jne    L336
  add    $0x1,%edx
  sub    $0x1,%eax
  add    $0x4,%rbp
  cmp    %r8d,%edx
  jl     L319
L426:
  cmp    %edx,%esi
  jg     L52
  add    $0x1,%r9d
  add    $0x8,%rdi
  cmp    %r9d,%r10d
  jne    L622
  jmp    L534
  nopw   0x0(%rax,%rax,1)
L202:
  xor    %edx,%edx
L52:
  movslq %edx,%rdx
  jmp    L15
  nopw   0x0(%rax,%rax,1)
L710:
  add    $0x1,%rdx
  cmp    %edx,%esi
  jle    L348
L15:
  cmpl   $0x1,(%rcx,%rdx,4)
  jne    L710
  mov    -0x8(%rdi),%r13
  lea    0x4(%rax),%ebp
  add    $0x3,%eax
  cmpl   $0x1,0x0(%r13,%rdx,4)
  cmovne %ebp,%eax
  mov    0x8(%rdi),%rbp
  cmpl   $0x1,0x0(%rbp,%rdx,4)
  sete   %bpl
  movzbl %bpl,%ebp
  sub    %ebp,%eax
  test   %edx,%edx
  je     L710
  cmpl   $0x1,-0x4(%rcx,%rdx,4)
  jne    L710
  sub    $0x1,%eax
  jmp    L710
  nopl   0x0(%rax,%rax,1)
L322:
  xor    %edx,%edx
  jmp    L339
  nopw   0x0(%rax,%rax,1)
L576:
  test   %r11d,%r11d
  jle    L196
  mov    %rcx,%rbp
  xor    %edx,%edx
  jmp    L492
  nopl   0x0(%rax)
L668:
  add    $0x1,%edx
  add    $0x4,%rbp
  cmp    %r8d,%edx
  jge    L318
L492:
  cmpl   $0x1,0x0(%rbp)
  jne    L668
  lea    0x4(%rax),%r12d
  add    $0x3,%eax
  cmpl   $0x1,0x4(%rbp)
  je     L269
  mov    %r12d,%eax
L269:
  test   %edx,%edx
  je     L668
  xor    %r12d,%r12d
  cmpl   $0x1,-0x4(%rbp)
  sete   %r12b
  add    $0x1,%edx
  add    $0x4,%rbp
  sub    %r12d,%eax
  cmp    %r8d,%edx
  jl     L492
L318:
  cmp    %edx,%esi
  jg     L90
  add    $0x1,%r9d
  add    $0x8,%rdi
  cmp    %r9d,%r10d
  jne    L622
  jmp    L534
  nopw   0x0(%rax,%rax,1)
L196:
  xor    %edx,%edx
L90:
  movslq %edx,%rdx
  jmp    L705
  nopw   0x0(%rax,%rax,1)
L435:
  add    $0x1,%rdx
  cmp    %edx,%esi
  jle    L348
L705:
  cmpl   $0x1,(%rcx,%rdx,4)
  jne    L435
  lea    0x4(%rax),%ebp
  test   %edx,%edx
  je     L40
  add    $0x3,%eax
  cmpl   $0x1,-0x4(%rcx,%rdx,4)
  je     L435
L40:
  mov    %ebp,%eax
  jmp    L435
  nopw   0x0(%rax,%rax,1)
L62:
  xor    %edx,%edx
  test   %r11d,%r11d
  jle    L47
  xor    %ebp,%ebp
  jmp    L335
  nopl   0x0(%rax,%rax,1)
L254:
  add    $0x1,%edx
  add    $0x4,%rbp
  cmp    %r8d,%edx
  jge    L545
L335:
  cmpl   $0x1,(%rcx,%rbp,1)
  jne    L254
  lea    0x4(%rax),%r12d
  add    $0x3,%eax
  cmpl   $0x1,0x4(%rcx,%rbp,1)
  cmovne %r12d,%eax
  mov    0x8(%rdi),%r12
  cmpl   $0x1,(%r12,%rbp,1)
  sete   %r12b
  movzbl %r12b,%r12d
  sub    %r12d,%eax
  test   %edx,%edx
  je     L254
  cmpl   $0x1,-0x4(%rcx,%rbp,1)
  jne    L254
  add    $0x1,%edx
  sub    $0x1,%eax
  add    $0x4,%rbp
  cmp    %r8d,%edx
  jl     L335
L545:
  cmp    %edx,%esi
  jle    L348
L47:
  movslq %edx,%rdx
  jmp    L292
  nopl   (%rax)
L694:
  add    $0x1,%rdx
  cmp    %edx,%esi
  jle    L348
L292:
  cmpl   $0x1,(%rcx,%rdx,4)
  jne    L694
  mov    0x8(%rdi),%rbp
  lea    0x4(%rax),%r12d
  add    $0x3,%eax
  cmpl   $0x1,0x0(%rbp,%rdx,4)
  je     L506
  mov    %r12d,%eax
L506:
  test   %edx,%edx
  je     L694
  cmpl   $0x1,-0x4(%rcx,%rdx,4)
  jne    L694
  sub    $0x1,%eax
  jmp    L694
  nopw   0x0(%rax,%rax,1)
L722:
  sub    $0x1,%eax
  jmp    L592
  nopl   0x0(%rax,%rax,1)
L103:
  sub    $0x1,%eax
  jmp    L393
L438:
  xor    %eax,%eax
  ret
```

assistant: ```c
int islandPerimeter(int **grid, int gridRowSize, int gridColSize) {
  int sum = 0;
  int i, j;
  for (i = 0; i < gridRowSize; i++) {
    for (j = 0; j < gridColSize; j++) {
      if (grid[i][j] == 1) {
        sum += 4;
        if (i > 0 && (grid[i - 1][j] == 1)) {
          sum -= 1;
        }
        if ((j < gridColSize - 1) && (grid[i][j + 1] == 1)) {
          sum -= 1;
        }
        if ((i < gridRowSize - 1) && (grid[i + 1][j] == 1)) {
          sum -= 1;
        }
        if (j > 0 && (grid[i][j - 1]) == 1) {
          sum -= 1;
        }
      }
    }
  }
  return sum;
}
```