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

```asm
<open_pty_master>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  lea    D98(%rip),%r13
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  movzbl D98(%rip),%eax
  test   %al,%al
  je     L48
  mov    D176(%rip),%rbx
  mov    %r13,%r14
  lea    D231(%rip),%rbp
  jmp    L37
  nopw   0x0(%rax,%rax,1)
L30:
  movzbl 0x1(%r14),%eax
  add    $0x1,%r14
  test   %al,%al
  je     L48
L37:
  mov    (%rbx),%esi
  xor    %edx,%edx
  mov    %rbp,%rdi
  mov    %al,D174(%rip)
  call   <open@plt>
  test   %eax,%eax
  js     L30
  movb   $0x73,D33(%rip)
  mov    %rbp,(%r12)
L55:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L48:
  movzbl D161(%rip),%eax
  test   %al,%al
  je     L59
  lea    D161(%rip),%r14
  lea    D214(%rip),%rbp
L100:
  mov    %al,D88(%rip)
  movzbl 0x0(%r13),%eax
  test   %al,%al
  je     L227
  mov    D176(%rip),%rbx
  lea    D98(%rip),%r15
  jmp    L200
L136:
  movzbl 0x1(%r15),%eax
  add    $0x1,%r15
  test   %al,%al
  je     L103
L200:
  mov    (%rbx),%esi
  xor    %edx,%edx
  mov    %rbp,%rdi
  mov    %al,D94(%rip)
  call   <open@plt>
  test   %eax,%eax
  js     L136
  movzbl (%r15),%ecx
  xor    %edx,%edx
  mov    (%r14),%dl
  mov    %cl,%dh
  lea    D34(%rip),%rcx
  mov    %dx,D228(%rip)
  mov    %rcx,(%r12)
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nop
L103:
  movzbl 0x1(%r14),%eax
  add    $0x1,%r14
  test   %al,%al
  jne    L100
L98:
  movzbl D161(%rip),%eax
  test   %al,%al
  je     L59
  lea    D161(%rip),%r14
  lea    D202(%rip),%rbp
L67:
  mov    %al,D167(%rip)
  movzbl 0x0(%r13),%eax
  test   %al,%al
  je     L122
  mov    D176(%rip),%rbx
  lea    D98(%rip),%r15
  jmp    L208
  nopl   0x0(%rax)
L199:
  movzbl 0x1(%r15),%eax
  add    $0x1,%r15
  test   %al,%al
  je     L171
L208:
  mov    (%rbx),%esi
  xor    %edx,%edx
  mov    %rbp,%rdi
  mov    %al,D21(%rip)
  call   <open@plt>
  test   %eax,%eax
  js     L199
  movb   $0x74,D136(%rip)
  mov    %rbp,(%r12)
  jmp    L55
L227:
  movzbl 0x1(%r14),%eax
  lea    0x1(%r14),%rdx
  test   %al,%al
  je     L98
  nopl   0x0(%rax,%rax,1)
L176:
  add    $0x1,%rdx
  mov    %eax,%ecx
  movzbl (%rdx),%eax
  test   %al,%al
  jne    L176
  mov    %cl,D13(%rip)
  jmp    L98
L122:
  movzbl 0x1(%r14),%eax
  lea    0x1(%r14),%rdx
  test   %al,%al
  je     L59
  nopl   (%rax)
L182:
  add    $0x1,%rdx
  mov    %eax,%ecx
  movzbl (%rdx),%eax
  test   %al,%al
  jne    L182
  mov    %cl,D13(%rip)
L59:
  mov    $0xffffffff,%eax
  jmp    L55
L171:
  movzbl 0x1(%r14),%eax
  add    $0x1,%r14
  test   %al,%al
  jne    L67
  jmp    L59
```

assistant: ```c
int open_pty_master(char **ptyslave) {
  int mfd;
  char *major, *minor;
  static char majorchars[] = "pqrstuvwxyzabcdePQRSTUVWXYZABCDE";
  static char minorchars[] = "0123456789abcdefghijklmnopqrstuv"
                             "wxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_+";
  {
    static char ptyname[] = "/dev/pty/mX";
    for (minor = minorchars; *minor; minor++) {
      ptyname[10] = *minor;
      if ((mfd = open(ptyname, O_RDWR, 0)) >= 0) {
        ptyname[9] = 's';
        *ptyslave = ptyname;
        return mfd;
      }
    }
  }
  {
    static char ptyname[] = "/dev/ptym/ptyXY";
    static char ttyname[] = "/dev/pty/ttyXY";
    for (major = majorchars; *major; major++) {
      ptyname[13] = *major;
      for (minor = minorchars; *minor; minor++) {
        ptyname[14] = *minor;
        if ((mfd = open(ptyname, O_RDWR, 0)) >= 0) {
          ttyname[12] = *major;
          ttyname[13] = *minor;
          *ptyslave = ttyname;
          return mfd;
        }
      }
    }
  }
  {
    static char ptyname[] = "/dev/ptyXY";
    for (major = majorchars; *major; major++) {
      ptyname[8] = *major;
      for (minor = minorchars; *minor; minor++) {
        ptyname[9] = *minor;
        if ((mfd = open(ptyname, O_RDWR, 0)) >= 0) {
          ptyname[5] = 't';
          *ptyslave = ptyname;
          return mfd;
        }
      }
    }
  }
  return -1;
}
```