user: Converte this assembly snippet into its equivalent C code:

```asm
<i2_handle_position_lost_in_2>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %edi,%ebx
  mov    %esi,%ebp
  mov    %edx,%r12d
  mov    %ecx,0x4(%rsp)
  mov    %r8d,0x8(%rsp)
  mov    %r9d,0xc(%rsp)
  mov    0x50(%rsp),%r13d
  mov    0x58(%rsp),%r14d
  mov    0x68(%rsp),%r15d
  test   %di,%di
  je     L35
  mov    %edi,%edx
  sar    $0xf,%dx
  shr    $0xe,%dx
  lea    (%rdx,%rdi,1),%eax
  and    $0x3,%eax
  sub    %edx,%eax
  sub    $0x1,%eax
  mov    $0x0,%edx
  cmp    $0x1,%ax
  ja     L14
  mov    %esi,%eax
  or     %edi,%eax
L76:
  or     %r12w,%ax
  jne    L25
  mov    0x4(%rsp),%eax
  test   %ax,%ax
  je     L25
  mov    %eax,%edx
  sar    $0xf,%dx
  shr    $0xe,%dx
  add    %edx,%eax
  and    $0x3,%eax
  sub    %edx,%eax
  sub    $0x1,%eax
  mov    $0x0,%edx
  cmp    $0x1,%ax
  jbe    L25
  jmp    L14
L35:
  test   %si,%si
  je     L123
  mov    %esi,%edx
  sar    $0xf,%dx
  shr    $0xe,%dx
  lea    (%rdx,%rsi,1),%eax
  and    $0x3,%eax
  sub    %edx,%eax
  sub    $0x1,%eax
  mov    $0x0,%edx
  cmp    $0x1,%ax
  ja     L14
L25:
  movswl 0x4(%rsp),%ecx
  movswl %r12w,%edx
  movswl %bp,%esi
  movswl %bx,%edi
  movswl %r14w,%eax
  push   %rax
  movswl %r13w,%eax
  push   %rax
  movswl 0x1c(%rsp),%r9d
  movswl 0x18(%rsp),%r8d
  call   <get_first_losing_move@plt>
  add    $0x10,%rsp
  mov    $0x0,%edx
  cmp    %r15w,%ax
  je     L21
L14:
  mov    %rdx,%rax
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L123:
  mov    %esi,%eax
  or     %edi,%eax
  test   %dx,%dx
  je     L76
  test   %ax,%ax
  jne    L76
  sar    $0xf,%dx
  shr    $0xe,%dx
  lea    (%rdx,%r12,1),%eax
  and    $0x3,%eax
  sub    %edx,%eax
  sub    $0x1,%eax
  mov    $0x0,%edx
  cmp    $0x1,%ax
  jbe    L25
  jmp    L14
L21:
  movswq %bx,%rbx
  shl    $0x5,%rbx
  movswq %bp,%rbp
  or     %rbx,%rbp
  shl    $0x5,%rbp
  movswq %r12w,%r12
  or     %rbp,%r12
  shl    $0x5,%r12
  movswq 0x4(%rsp),%rax
  or     %r12,%rax
  shl    $0x5,%rax
  movswq 0x8(%rsp),%rdx
  or     %rax,%rdx
  shl    $0x5,%rdx
  movswq 0xc(%rsp),%rax
  or     %rdx,%rax
  shl    $0x5,%rax
  movswq %r13w,%r13
  or     %rax,%r13
  shl    $0x5,%r13
  movswl %r15w,%ecx
  movswq %r14w,%rdx
  or     %r13,%rdx
  lea    D4(%rip),%rsi
  mov    0x60(%rsp),%rdi
  call   <fprintf@plt>
  mov    $0x1,%edx
  jmp    L14
```

tool_calls: name: disassemble_data
arguments: data_label: D4
data_type: string

tool: D4: %ld %hi 2


assistant: ```c
long i2_handle_position_lost_in_2(short a, short b, short c, short d, short e, short f, short g, short h, FILE *fp, short undoneMove) {
  long position;
  {
    if ((a != 0 && a % 4 != 1 && a % 4 != 2) || (a == 0 && b != 0 && b % 4 != 1 && b % 4 != 2) || (a == 0 && b == 0 && c != 0 && c % 4 != 1 && c % 4 != 2) || (a == 0 && b == 0 && c == 0 && d != 0 && d % 4 != 1 && d % 4 != 2)) {
      return 0;
    }
  }
  if (get_first_losing_move(a, b, c, d, e, f, g, h) != undoneMove)
    return 0;
  {
    position = 0;
    position |= a;
    position <<= 5;
    position |= b;
    position <<= 5;
    position |= c;
    position <<= 5;
    position |= d;
    position <<= 5;
    position |= e;
    position <<= 5;
    position |= f;
    position <<= 5;
    position |= g;
    position <<= 5;
    position |= h;
  }
  fprintf(fp, "%ld %hi 2\n", position, undoneMove);
  return 1;
}
```