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

```asm
<Mali_test_reg>:
  endbr64
  push   %r15
  push   %r14
  mov    %edx,%r14d
  push   %r13
  mov    %ecx,%r13d
  push   %r12
  mov    %esi,%r12d
  push   %rbp
  mov    %edi,%ebp
  push   %rbx
  mov    %r8d,%ebx
  sub    $0x18,%rsp
  mov    %r9d,0xc(%rsp)
  call   <Mali_RdReg@plt>
  mov    %ebp,%edx
  mov    %r12d,%ecx
  shl    $0x1c,%edx
  shl    $0x10,%ecx
  mov    %edx,%r9d
  add    %ecx,%r9d
  lea    (%r9,%r14,1),%r15d
  cmp    0xc(%rsp),%eax
  jne    L68
  mov    0x50(%rsp),%eax
  test   %eax,%eax
  jne    L40
  mov    %ebx,%ecx
  mov    %r14d,%edx
  mov    %r12d,%esi
  mov    %ebp,%edi
  call   <Mali_WrReg@plt>
  mov    %r14d,%edx
  mov    %r12d,%esi
  mov    %ebp,%edi
  call   <Mali_RdReg@plt>
  mov    %ebx,%ecx
  and    %r13d,%eax
  and    %r13d,%ecx
  cmp    %ecx,%eax
  jne    L32
  and    $0x12345678,%ebx
  mov    %r14d,%edx
  mov    %r12d,%esi
  mov    %ebp,%edi
  mov    %ebx,%ecx
  call   <Mali_WrReg@plt>
  mov    %r14d,%edx
  mov    %r12d,%esi
  mov    %ebp,%edi
  call   <Mali_RdReg@plt>
  and    %r13d,%eax
  and    %ebx,%r13d
  cmp    %eax,%r13d
  jne    L50
L40:
  mov    0x58(%rsp),%rdx
  mov    %r15d,%esi
  lea    D4(%rip),%rdi
  xor    %eax,%eax
  call   <printk@plt>
  xor    %eax,%eax
L21:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L50:
  mov    0x58(%rsp),%r8
  mov    %r13d,%ecx
L1:
  mov    %eax,%edx
  mov    %r15d,%esi
  lea    D22(%rip),%rdi
  xor    %eax,%eax
  call   <printk@plt>
  mov    $0xfffffffe,%eax
  jmp    L21
L68:
  mov    0x58(%rsp),%r8
  mov    0xc(%rsp),%ecx
  mov    %eax,%edx
  mov    %r15d,%esi
  lea    D13(%rip),%rdi
  xor    %eax,%eax
  call   <printk@plt>
  mov    $0xffffffff,%eax
  jmp    L21
L32:
  mov    0x58(%rsp),%r8
  jmp    L1
```

tool_calls: name: read_data
arguments: label: D4
type_guessed: string
name: read_data
arguments: label: D22
type_guessed: string
name: read_data
arguments: label: D13
type_guessed: string

tool: D4: Register %08x:  for %s  Success!


tool: D22: FAILURE: Wrong value. Addr: 0x%08x Value: 0x%08x Expected: 0x%08x for %s


tool: D13: FAILURE: Wrong reset value. Addr: 0x%08x Value: 0x%08x Expected: 0x%08x for %s


assistant: ```c
int Mali_test_reg(int unit, int core, int regnum, int read_mask, int write_mask, int reset_value, int access, char *reg_str) {
  int value = Mali_RdReg(unit, core, regnum);
  if (value != reset_value) {
    printk("FAILURE: Wrong reset value. Addr: 0x%08x Value: 0x%08x Expected: 0x%08x for %s\n", (unit << 28) + (core << 16) + regnum, value, reset_value, reg_str);
    return -1;
  }
  if (access == 0) {
    Mali_WrReg(unit, core, regnum, (0xffffffff & write_mask));
    value = Mali_RdReg(unit, core, regnum) & read_mask;
    if (value != (0xffffffff & write_mask & read_mask)) {
      printk("FAILURE: Wrong value. Addr: 0x%08x Value: 0x%08x Expected: 0x%08x for %s\n", (unit << 28) + (core << 16) + regnum, value, (0xffffffff & write_mask & read_mask), reg_str);
      return -2;
    }
    Mali_WrReg(unit, core, regnum, (0x12345678 & write_mask));
    value = Mali_RdReg(unit, core, regnum) & read_mask;
    if (value != (0x12345678 & write_mask & read_mask)) {
      printk("FAILURE: Wrong value. Addr: 0x%08x Value: 0x%08x Expected: 0x%08x for %s\n", (unit << 28) + (core << 16) + regnum, value, (0x12345678 & write_mask & read_mask), reg_str);
      return -2;
    }
  }
  printk("Register %08x:  for %s  Success!\n", (unit << 28) + (core << 16) + regnum, reg_str);
  return 0;
}
```