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

```asm
<iterative_merge>:
  endbr64
  push   %r15
  mov    %rsi,%rax
  push   %r14
  shr    %rax
  push   %r13
  push   %r12
  mov    %rdi,%r12
  mov    %eax,%edi
  push   %rbp
  push   %rbx
  sub    $0x38,%rsp
  mov    %rsi,(%rsp)
  mov    %rax,0x8(%rsp)
  call   <log@plt>
  mov    $0x2,%edi
  mov    %eax,%ebx
  call   <log@plt>
  mov    %eax,%r9d
  mov    %ebx,%eax
  cltd
  idiv   %r9d
  mov    %eax,%edi
  call   <floor@plt>
  mov    $0x2,%edi
  mov    %eax,%esi
  call   <pow@plt>
  mov    (%rsp),%r8
  movslq %eax,%rdx
  lea    (%rdx,%rdx,1),%ecx
  mov    %r8,%rax
  mov    %r8,0x10(%rsp)
  movslq %ecx,%rcx
  sub    %rcx,%rax
  cmp    %rdx,%rax
  cmovb  %rdx,%rax
  lea    0x0(,%rax,4),%r13d
  mov    %r13d,%edi
  call   <malloc@plt>
  mov    %r13d,%edx
  xor    %esi,%esi
  mov    %rax,%rdi
  mov    %rax,%r15
  call   <memset@plt>
  mov    0x10(%rsp),%r8
  movq   $0x1,(%rsp)
  cmp    $0x1,%r8
  jbe    L128
  lea    -0x1(%r8),%eax
  mov    $0x1,%r11d
  mov    %eax,0x10(%rsp)
  lea    0x4(%r12),%rax
  mov    %rax,0x28(%rsp)
  nopl   0x0(%rax)
L156:
  mov    (%rsp),%rbx
  cmp    %rbx,0x8(%rsp)
  jb     L241
  lea    -0x1(%r11),%r13d
  mov    %r11d,%ebp
  lea    0x0(%r13,%r11,1),%r14d
L61:
  xor    %ebx,%ebx
  xor    %eax,%eax
  nopw   0x0(%rax,%rax,1)
L165:
  mov    (%rsp),%rsi
  sub    %eax,%r13d
  cmp    %rsi,0x8(%rsp)
  jae    L154
L60:
  test   %r13d,%r13d
  js     L71
  cmp    %r14d,%ebp
  jg     L15
  add    $0x1,%ebx
  xor    %eax,%eax
  movslq %ebx,%rdx
  jmp    L194
  nopw   0x0(%rax,%rax,1)
L266:
  mov    %ecx,-0x4(%r12,%rdx,4)
  add    $0x1,%ebp
  mov    %edx,%ebx
  cmp    %r13d,%eax
  jg     L71
L36:
  add    $0x1,%rdx
  cmp    %r14d,%ebp
  jg     L107
L194:
  movslq %ebp,%rcx
  movslq %eax,%rsi
  mov    (%r12,%rcx,4),%ecx
  mov    (%r15,%rsi,4),%esi
  cmp    %esi,%ecx
  jl     L266
  mov    %esi,%ecx
  add    $0x1,%eax
  mov    %edx,%ebx
  mov    %ecx,-0x4(%r12,%rdx,4)
  cmp    %r13d,%eax
  jle    L36
L71:
  mov    %ebp,%eax
  cmp    %r14d,%ebp
  jg     L31
  movslq %ebx,%rax
  movslq %ebp,%rsi
  mov    %r14d,%edi
  lea    0x0(,%rax,4),%rcx
  lea    0x4(,%rsi,4),%rdx
  sub    %ebp,%edi
  mov    %rcx,%r9
  sub    %rdx,%r9
  cmp    $0x8,%r9
  jbe    L251
  cmp    $0x2,%edi
  jbe    L251
  lea    0x1(%rdi),%r9d
  lea    -0x4(%r12,%rdx,1),%rsi
  add    %r12,%rcx
  xor    %eax,%eax
  mov    %r9d,%edx
  shr    $0x2,%edx
  shl    $0x4,%rdx
  cs nopw 0x0(%rax,%rax,1)
L254:
  movdqu (%rsi,%rax,1),%xmm0
  movups %xmm0,(%rcx,%rax,1)
  add    $0x10,%rax
  cmp    %rdx,%rax
  jne    L254
  mov    %r9d,%eax
  and    $0xfffffffc,%eax
  add    %eax,%ebp
  lea    (%rbx,%rax,1),%edx
  cmp    %r9d,%eax
  je     L315
  movslq %ebp,%rsi
  lea    0x1(%rdx),%ecx
  lea    0x1(%rbp),%eax
  movslq %edx,%rdx
  mov    (%r12,%rsi,4),%esi
  mov    %esi,(%r12,%rdx,4)
  cmp    %r14d,%eax
  jg     L315
  cltq
  movslq %ecx,%rcx
  add    $0x2,%ebp
  lea    0x0(,%rax,4),%rdx
  mov    (%r12,%rax,4),%eax
  lea    0x0(,%rcx,4),%rsi
  mov    %eax,(%r12,%rcx,4)
  cmp    %r14d,%ebp
  jg     L315
  mov    0x4(%r12,%rdx,1),%eax
  mov    %eax,0x4(%r12,%rsi,1)
L315:
  lea    0x1(%r14),%eax
  lea    0x1(%rbx,%rdi,1),%ebx
L31:
  lea    (%r11,%rax,1),%ebp
  mov    0x10(%rsp),%edi
  movslq %ebp,%rdx
  cmp    %r8,%rdx
  cmovae %edi,%ebp
  lea    -0x1(%rbp),%r13d
  lea    0x0(%r13,%r11,1),%r14d
  movslq %r14d,%rdx
  cmp    %r8,%rdx
  movslq %ebx,%rdx
  cmovae %edi,%r14d
  cmp    %r8,%rdx
  jb     L165
  add    %r11d,%r11d
  movslq %r11d,%rax
  mov    %rax,(%rsp)
  cmp    %r8,%rax
  jb     L156
L128:
  add    $0x38,%rsp
  mov    %r15,%rdi
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    10c0 <free@plt>
L15:
  xor    %eax,%eax
  nopl   (%rax)
L107:
  movslq %ebx,%rsi
  mov    %r13d,%r9d
  movslq %eax,%r10
  lea    0x0(,%rsi,4),%rdi
  sub    %eax,%r9d
  shl    $0x2,%r10
  mov    %rdi,0x20(%rsp)
  add    %r12,%rdi
  cmp    $0x2,%r9d
  lea    (%r10,%r15,1),%rdx
  seta   0x18(%rsp)
  cmp    %r13d,%eax
  movzbl 0x18(%rsp),%esi
  setle  %cl
  test   %cl,%sil
  lea    0x4(%rdx),%rcx
  je     L160
  mov    %rdi,%rsi
  sub    %rcx,%rsi
  cmp    $0x8,%rsi
  jbe    L160
  cmp    %r13d,%eax
  mov    $0x1,%esi
  lea    0x1(%r9),%ecx
  cmovg  %esi,%ecx
  sub    %rdx,%rdi
  mov    %ecx,%esi
  shr    $0x2,%esi
  sub    $0x1,%esi
  shl    $0x4,%rsi
  lea    0x10(%rdx,%rsi,1),%rsi
  nopl   0x0(%rax,%rax,1)
L144:
  movdqu (%rdx),%xmm1
  movups %xmm1,(%rdi,%rdx,1)
  add    $0x10,%rdx
  cmp    %rsi,%rdx
  jne    L144
  mov    %ecx,%edi
  and    $0xfffffffc,%edi
  lea    (%rbx,%rdi,1),%esi
  lea    (%rax,%rdi,1),%edx
  cmp    %edi,%ecx
  je     L117
  movslq %edx,%r10
  lea    0x1(%rsi),%edi
  lea    0x1(%rdx),%ecx
  movslq %esi,%rsi
  mov    (%r15,%r10,4),%r10d
  mov    %r10d,(%r12,%rsi,4)
  cmp    %r13d,%ecx
  jg     L117
  movslq %ecx,%rcx
  movslq %edi,%rdi
  add    $0x2,%edx
  lea    0x0(,%rcx,4),%rsi
  mov    (%r15,%rcx,4),%ecx
  lea    0x0(,%rdi,4),%r10
  mov    %ecx,(%r12,%rdi,4)
  cmp    %edx,%r13d
  jl     L117
  mov    0x4(%r15,%rsi,1),%edx
  mov    %edx,0x4(%r12,%r10,1)
L117:
  cmp    %r13d,%eax
  mov    $0x0,%eax
  cmovg  %eax,%r9d
  lea    0x1(%rbx,%r9,1),%ebx
  jmp    L71
  nop
L154:
  cltq
  lea    0x4(,%r13,4),%edx
  mov    %r15,%rdi
  mov    %r8,0x20(%rsp)
  lea    (%r12,%rax,4),%rsi
  mov    %r11d,0x18(%rsp)
  call   <memcpy@plt>
  mov    0x20(%rsp),%r8
  mov    0x18(%rsp),%r11d
  jmp    L60
  nop
L251:
  mov    0x28(%rsp),%r10
  mov    %edi,%ecx
  lea    -0x4(%r12,%rdx,1),%rdx
  sub    %rsi,%rax
  add    %rsi,%rcx
  lea    (%r10,%rcx,4),%rcx
  cs nopw 0x0(%rax,%rax,1)
L224:
  mov    (%rdx),%esi
  mov    %esi,(%rdx,%rax,4)
  add    $0x4,%rdx
  cmp    %rdx,%rcx
  jne    L224
  jmp    L315
L160:
  mov    0x20(%rsp),%rsi
  sub    %r10,%rsi
  sub    %r15,%rsi
  lea    (%r12,%rsi,1),%rdi
  mov    %eax,%esi
  jmp    L195
  cs nopw 0x0(%rax,%rax,1)
L180:
  add    $0x4,%rcx
L195:
  mov    (%rdx),%r10d
  add    $0x1,%esi
  mov    %r10d,(%rdi,%rdx,1)
  mov    %rcx,%rdx
  cmp    %esi,%r13d
  jge    L180
  jmp    L117
L241:
  mov    %rbx,%rax
  mov    %r8,%rbx
  mov    %r8d,%ebp
  mov    %r15,%rdi
  sub    %rax,%rbx
  lea    (%r12,%rax,4),%rsi
  sub    %r11d,%ebp
  mov    %r11d,0x20(%rsp)
  lea    0x0(,%rbx,4),%edx
  mov    %r8,0x18(%rsp)
  mov    0x10(%rsp),%r14d
  lea    -0x1(%rbp),%r13d
  call   <memcpy@plt>
  mov    (%rsp),%eax
  lea    (%r12,%rbx,4),%rdi
  mov    %r12,%rsi
  lea    0x0(,%rax,4),%edx
  call   <memmove@plt>
  mov    0x18(%rsp),%r8
  mov    0x20(%rsp),%r11d
  jmp    L61
```

assistant: ```c
void iterative_merge(int a[], size_t n) {
  int t = pow(2, floor(log(n / 2) / log(2)));
  int tempsize = (t > n - 2 * t) ? t : n - 2 * t;
  int *temparray = (int *)malloc(tempsize * sizeof(int));
  memset(temparray, 0, tempsize * sizeof(int));
  int l, l_max, r, r_max, incr, i, j, cpy_size;
  incr = 1;
  while (incr < n) {
    if (incr <= n / 2) {
      l = 0;
      r = incr;
      l_max = r - 1;
      r_max = l_max + incr;
    } else {
      l = 0;
      r = n - incr;
      l_max = r - 1;
      r_max = n - 1;
      memcpy(temparray, &a[incr], (n - incr) * sizeof(int));
      memmove(&a[n - incr], &a[0], incr * sizeof(int));
    }
    i = j = 0;
    while (i < n) {
      if (incr <= n / 2) {
        cpy_size = l_max - l + 1;
        memcpy(temparray, &a[l], cpy_size * sizeof(int));
      }
      j = 0;
      while (j <= l_max - l && r <= r_max) {
        if (a[r] < temparray[j]) {
          a[i] = a[r++];
        } else {
          a[i] = temparray[j++];
        }
        ++i;
      }
      while (j <= l_max - l) {
        a[i++] = temparray[j++];
      }
      while (r <= r_max) {
        a[i++] = a[r++];
      }
      l = r;
      r = (r + incr < n) ? r + incr : n - 1;
      l_max = r - 1;
      r_max = (l_max + incr < n) ? l_max + incr : n - 1;
    }
    incr *= 2;
  }
  free(temparray);
  return;
}
```