user: Translate the below assembly code into C programming language:

```asm
<__cmpxchg>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %rdx,-0x28(%rbp)
  mov    %ecx,-0x2c(%rbp)
  cmpl   $0x8,-0x2c(%rbp)
  je     L42
  cmpl   $0x8,-0x2c(%rbp)
  jg     L93
  cmpl   $0x4,-0x2c(%rbp)
  je     L89
  cmpl   $0x4,-0x2c(%rbp)
  jg     L93
  cmpl   $0x1,-0x2c(%rbp)
  je     L97
  cmpl   $0x2,-0x2c(%rbp)
  je     L62
  jmp    L93
L97:
  mov    -0x28(%rbp),%rdx
  mov    -0x18(%rbp),%rcx
  mov    -0x20(%rbp),%rax
  lock cmpxchg %dl,(%rcx)
  mov    %rax,-0x8(%rbp)
  mov    -0x8(%rbp),%rax
  jmp    L78
L62:
  mov    -0x28(%rbp),%rdx
  mov    -0x18(%rbp),%rcx
  mov    -0x20(%rbp),%rax
  lock cmpxchg %dx,(%rcx)
  mov    %rax,-0x8(%rbp)
  mov    -0x8(%rbp),%rax
  jmp    L78
L89:
  mov    -0x28(%rbp),%rdx
  mov    -0x18(%rbp),%rcx
  mov    -0x20(%rbp),%rax
  lock cmpxchg %edx,(%rcx)
  mov    %rax,-0x8(%rbp)
  mov    -0x8(%rbp),%rax
  jmp    L78
L42:
  mov    -0x28(%rbp),%rdx
  mov    -0x18(%rbp),%rcx
  mov    -0x20(%rbp),%rax
  lock cmpxchg %rdx,(%rcx)
  mov    %rax,-0x8(%rbp)
  mov    -0x8(%rbp),%rax
  jmp    L78
L93:
  mov    -0x20(%rbp),%rax
L78:
  pop    %rbp
  ret
```

assistant: ```c
__attribute__((always_)) unsigned long __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size) {
  unsigned long prev;
  switch (size) {
  case 1:
    asm volatile(".section .smp_locks,\"a\"\n"
                 " "
                 ".balign 8"
                 " "
                 "\n"
                 " "
                 ".quad"
                 " "
                 "661f\n"
                 ".previous\n"
                 "661:\n\tlock; "
                 "cmpxchgb %b1,%2"
                 : "=a"(prev)
                 : "q"(new), "m"(*((volatile long *)(ptr))), "0"(old)
                 : "memory");
    return prev;
  case 2:
    asm volatile(".section .smp_locks,\"a\"\n"
                 " "
                 ".balign 8"
                 " "
                 "\n"
                 " "
                 ".quad"
                 " "
                 "661f\n"
                 ".previous\n"
                 "661:\n\tlock; "
                 "cmpxchgw %w1,%2"
                 : "=a"(prev)
                 : "r"(new), "m"(*((volatile long *)(ptr))), "0"(old)
                 : "memory");
    return prev;
  case 4:
    asm volatile(".section .smp_locks,\"a\"\n"
                 " "
                 ".balign 8"
                 " "
                 "\n"
                 " "
                 ".quad"
                 " "
                 "661f\n"
                 ".previous\n"
                 "661:\n\tlock; "
                 "cmpxchgl %k1,%2"
                 : "=a"(prev)
                 : "r"(new), "m"(*((volatile long *)(ptr))), "0"(old)
                 : "memory");
    return prev;
  case 8:
    asm volatile(".section .smp_locks,\"a\"\n"
                 " "
                 ".balign 8"
                 " "
                 "\n"
                 " "
                 ".quad"
                 " "
                 "661f\n"
                 ".previous\n"
                 "661:\n\tlock; "
                 "cmpxchgq %1,%2"
                 : "=a"(prev)
                 : "r"(new), "m"(*((volatile long *)(ptr))), "0"(old)
                 : "memory");
    return prev;
  }
  return old;
}
```