ylfeng/ReF-Decompile-dataset huggingface dataset:
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<get_if_addr>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rdi,%r13
  mov    %rsi,%rbp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  mov    D21(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,(%rsi)
  mov    $0x0,%edx
  mov    D49(%rip),%rax
  mov    (%rax),%esi
  mov    D32(%rip),%rax
  mov    (%rax),%edi
  call   <socket@plt>
  mov    %eax,%ebx
  cmp    $0xffffffff,%eax
  je     L5
  mov    %rsp,%r12
  mov    $0x8,%edx
  mov    $0x0,%esi
  mov    %r12,%rdi
  call   <memset@plt>
  mov    D4(%rip),%rax
  mov    (%rax),%edx
  mov    %r13,%rsi
  mov    0x4(%rsp),%edi
  call   <strnzcpy@plt>
  mov    %r12,%rdx
  mov    D13(%rip),%rax
  mov    (%rax),%esi
  mov    %ebx,%edi
  call   <ioctl@plt>
  mov    %eax,%r12d
  mov    %ebx,%edi
  call   <close@plt>
  cmp    $0xffffffff,%r12d
  je     L15
  cmp    $0xffffffff,%eax
  je     L15
  mov    %rsp,%rsi
  mov    $0x4,%edx
  mov    %rbp,%rdi
  call   <memcpy@plt>
  mov    $0x0,%ebx
L5:
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L45
  mov    %ebx,%eax
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L15:
  mov    $0xffffffff,%ebx
  jmp    L5
L45:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int get_if_addr(const char *ifname, struct in_addr *addr) {
  int sock_fd;
  struct ifreq ifr;
  int ioctl_ret;
  struct sockaddr_in *sa_in = NULL;
  addr->s_addr = INADDR_NONE;
  sock_fd = socket(AF_INET, SOCK_DGRAM, 0);
  if (sock_fd == -1) {
    return -1;
  }
  memset(&ifr, 0, sizeof(ifr));
  strnzcpy(ifr.ifr_name, ifname, IFNAMSIZ);
  ioctl_ret = ioctl(sock_fd, SIOCGIFADDR, &ifr);
  if (close(sock_fd) == -1) {
    return -1;
  }
  if (ioctl_ret == -1) {
    return -1;
  }
  sa_in = (struct sockaddr_in *)&ifr.ifr_addr;
  memcpy(&addr->s_addr, &sa_in->sin_addr, sizeof(in_addr_t));
  return 0;
}
```
user: 请将以下的汇编代码转换成C语言代码：

```asm
<get_if_addr>:
  endbr64
  push   %r14
  xor    %edx,%edx
  push   %r13
  mov    %rdi,%r13
  push   %r12
  mov    %rsi,%r12
  push   %rbp
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  mov    D43(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,(%rsi)
  mov    D8(%rip),%rax
  mov    (%rax),%esi
  mov    D11(%rip),%rax
  mov    (%rax),%edi
  call   <socket@plt>
  cmp    $0xffffffff,%eax
  je     L8
  mov    %rsp,%r14
  xor    %esi,%esi
  mov    $0x8,%edx
  mov    %eax,%ebp
  mov    %r14,%rdi
  call   <memset@plt>
  mov    D35(%rip),%rax
  mov    0x4(%rsp),%edi
  mov    %r13,%rsi
  mov    (%rax),%edx
  call   <strnzcpy@plt>
  mov    D46(%rip),%rax
  mov    %ebp,%edi
  mov    %r14,%rdx
  mov    (%rax),%esi
  call   <ioctl@plt>
  mov    %ebp,%edi
  mov    %eax,%r13d
  call   <close@plt>
  cmp    $0xffffffff,%eax
  je     L8
  cmp    $0xffffffff,%r13d
  je     L8
  mov    $0x4,%edx
  mov    %r14,%rsi
  mov    %r12,%rdi
  call   <memcpy@plt>
  xor    %eax,%eax
L41:
  mov    0x8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L18
  add    $0x18,%rsp
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  nop
L8:
  mov    $0xffffffff,%eax
  jmp    L41
L18:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int get_if_addr(const char *ifname, struct in_addr *addr) {
  int sock_fd;
  struct ifreq ifr;
  int ioctl_ret;
  struct sockaddr_in *sa_in = NULL;
  addr->s_addr = INADDR_NONE;
  sock_fd = socket(AF_INET, SOCK_DGRAM, 0);
  if (sock_fd == -1) {
    return -1;
  }
  memset(&ifr, 0, sizeof(ifr));
  strnzcpy(ifr.ifr_name, ifname, IFNAMSIZ);
  ioctl_ret = ioctl(sock_fd, SIOCGIFADDR, &ifr);
  if (close(sock_fd) == -1) {
    return -1;
  }
  if (ioctl_ret == -1) {
    return -1;
  }
  sa_in = (struct sockaddr_in *)&ifr.ifr_addr;
  memcpy(&addr->s_addr, &sa_in->sin_addr, sizeof(in_addr_t));
  return 0;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<get_if_addr>:
  endbr64
  push   %r14
  xor    %edx,%edx
  push   %r13
  mov    %rdi,%r13
  push   %r12
  mov    %rsi,%r12
  push   %rbp
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  mov    D23(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,(%rsi)
  mov    D22(%rip),%rax
  mov    (%rax),%esi
  mov    D10(%rip),%rax
  mov    (%rax),%edi
  call   <socket@plt>
  cmp    $0xffffffff,%eax
  je     L22
  mov    %rsp,%r14
  xor    %esi,%esi
  mov    $0x8,%edx
  mov    %eax,%ebp
  mov    %r14,%rdi
  call   <memset@plt>
  mov    D26(%rip),%rax
  mov    0x4(%rsp),%edi
  mov    %r13,%rsi
  mov    (%rax),%edx
  call   <strnzcpy@plt>
  mov    D13(%rip),%rax
  mov    %ebp,%edi
  mov    %r14,%rdx
  mov    (%rax),%esi
  call   <ioctl@plt>
  mov    %ebp,%edi
  mov    %eax,%r13d
  call   <close@plt>
  cmp    $0xffffffff,%eax
  je     L22
  cmp    $0xffffffff,%r13d
  je     L22
  mov    $0x4,%edx
  mov    %r14,%rsi
  mov    %r12,%rdi
  call   <memcpy@plt>
  xor    %eax,%eax
L0:
  mov    0x8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L15
  add    $0x18,%rsp
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  nop
L22:
  mov    $0xffffffff,%eax
  jmp    L0
L15:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int get_if_addr(const char *ifname, struct in_addr *addr) {
  int sock_fd;
  struct ifreq ifr;
  int ioctl_ret;
  struct sockaddr_in *sa_in = NULL;
  addr->s_addr = INADDR_NONE;
  sock_fd = socket(AF_INET, SOCK_DGRAM, 0);
  if (sock_fd == -1) {
    return -1;
  }
  memset(&ifr, 0, sizeof(ifr));
  strnzcpy(ifr.ifr_name, ifname, IFNAMSIZ);
  ioctl_ret = ioctl(sock_fd, SIOCGIFADDR, &ifr);
  if (close(sock_fd) == -1) {
    return -1;
  }
  if (ioctl_ret == -1) {
    return -1;
  }
  sa_in = (struct sockaddr_in *)&ifr.ifr_addr;
  memcpy(&addr->s_addr, &sa_in->sin_addr, sizeof(in_addr_t));
  return 0;
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<ler_acessos>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movl   $0x0,-0x10(%rbp)
  movl   $0xffffff42,-0xc(%rbp)
L24:
  lea    -0x14(%rbp),%rdx
  lea    -0x18(%rbp),%rax
  mov    %rax,%rsi
  lea    D5(%rip),%rax
  mov    %rax,%rdi
  call   <scanf@plt>
  cmp    $0x1,%eax
  jg     L29
  mov    -0x10(%rbp),%eax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L53
  jmp    L14
L29:
  mov    -0x18(%rbp),%eax
  sub    -0xc(%rbp),%eax
  cmp    $0x77,%eax
  jg     L26
  mov    -0x10(%rbp),%eax
  cltq
  shl    $0x2,%rax
  lea    -0x4(%rax),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%ecx
  mov    -0x14(%rbp),%eax
  sub    -0xc(%rbp),%eax
  mov    %eax,%edx
  mov    -0x10(%rbp),%eax
  cltq
  shl    $0x2,%rax
  lea    -0x4(%rax),%rsi
  mov    -0x28(%rbp),%rax
  add    %rsi,%rax
  add    %ecx,%edx
  mov    %edx,(%rax)
  jmp    L3
L26:
  mov    -0x14(%rbp),%ecx
  mov    -0x18(%rbp),%esi
  mov    -0x10(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x10(%rbp)
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  sub    %esi,%ecx
  mov    %ecx,%edx
  mov    %edx,(%rax)
L3:
  mov    -0x14(%rbp),%eax
  mov    %eax,-0xc(%rbp)
  jmp    L24
L14:
  call   <__stack_chk_fail@plt>
L53:
  leave
  ret
```

tool_calls: name: read_data
arguments: data_tag: D5
type_guessed: string

tool: D5: %d %d

assistant: ```c
int ler_acessos(int *tempos) {
  int count = 0;
  int saidaAnterior = -190;
  for (;;) {
    int entrada, saida;
    if (scanf("%d %d", &entrada, &saida) < 2) {
      break;
    }
    if (entrada - saidaAnterior < 120) {
      tempos[count - 1] += saida - saidaAnterior;
    } else {
      tempos[count++] = saida - entrada;
    }
    saidaAnterior = saida;
  }
  return count;
}
```
user: 下面的汇编指令对应的C源代码是什么:

```asm
<ler_acessos>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rdi,%r12
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  mov    $0xffffff42,%ebx
  mov    $0x0,%ebp
  lea    D1(%rip),%r13
  jmp    L25
L22:
  movslq %ebp,%rcx
  mov    0x4(%rsp),%edx
  sub    %eax,%edx
  mov    %edx,(%r12,%rcx,4)
  lea    0x1(%rbp),%ebp
L4:
  mov    0x4(%rsp),%ebx
L25:
  lea    0x4(%rsp),%rdx
  mov    %rsp,%rsi
  mov    %r13,%rdi
  call   <scanf@plt>
  cmp    $0x1,%eax
  jle    L46
  mov    (%rsp),%eax
  mov    %eax,%edx
  sub    %ebx,%edx
  cmp    $0x77,%edx
  jg     L22
  movslq %ebp,%rax
  mov    0x4(%rsp),%edx
  sub    %ebx,%edx
  add    %edx,-0x4(%r12,%rax,4)
  jmp    L4
L46:
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L11
  mov    %ebp,%eax
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L11:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: data_tag: D1
type: string

tool: D1: %d %d

assistant: ```c
int ler_acessos(int *tempos) {
  int count = 0;
  int saidaAnterior = -190;
  for (;;) {
    int entrada, saida;
    if (scanf("%d %d", &entrada, &saida) < 2) {
      break;
    }
    if (entrada - saidaAnterior < 120) {
      tempos[count - 1] += saida - saidaAnterior;
    } else {
      tempos[count++] = saida - entrada;
    }
    saidaAnterior = saida;
  }
  return count;
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<ler_acessos>:
  endbr64
  push   %r15
  mov    $0xffffff42,%r15d
  push   %r14
  push   %r13
  push   %r12
  xor    %r12d,%r12d
  push   %rbp
  lea    D3(%rip),%rbp
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  lea    0x4(%rsp),%r14
  mov    %rsp,%r13
  jmp    L28
  nop
L38:
  mov    %eax,%edx
  sub    %r15d,%edx
  add    %edx,-0x4(%rbx,%rsi,1)
L19:
  mov    %eax,%r15d
L28:
  mov    %r14,%rdx
  mov    %r13,%rsi
  mov    %rbp,%rdi
  call   <scanf@plt>
  cmp    $0x1,%eax
  jle    L36
  mov    (%rsp),%ecx
  movslq %r12d,%rdx
  mov    0x4(%rsp),%eax
  lea    0x0(,%rdx,4),%rsi
  mov    %ecx,%edi
  sub    %r15d,%edi
  cmp    $0x77,%edi
  jle    L38
  mov    %eax,%esi
  add    $0x1,%r12d
  sub    %ecx,%esi
  mov    %esi,(%rbx,%rdx,4)
  jmp    L19
  nopl   0x0(%rax,%rax,1)
L36:
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L12
  add    $0x18,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L12:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: data_tag: D3
type_infered: string

tool: D3: %d %d

assistant: ```c
int ler_acessos(int *tempos) {
  int count = 0;
  int saidaAnterior = -190;
  for (;;) {
    int entrada, saida;
    if (scanf("%d %d", &entrada, &saida) < 2) {
      break;
    }
    if (entrada - saidaAnterior < 120) {
      tempos[count - 1] += saida - saidaAnterior;
    } else {
      tempos[count++] = saida - entrada;
    }
    saidaAnterior = saida;
  }
  return count;
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<ler_acessos>:
  endbr64
  push   %r15
  mov    $0xffffff42,%r15d
  push   %r14
  push   %r13
  push   %r12
  xor    %r12d,%r12d
  push   %rbp
  lea    D4(%rip),%rbp
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  lea    0x4(%rsp),%r14
  mov    %rsp,%r13
  jmp    L41
  nop
L1:
  mov    %eax,%edx
  sub    %r15d,%edx
  add    %edx,-0x4(%rbx,%rsi,1)
L0:
  mov    %eax,%r15d
L41:
  mov    %r14,%rdx
  mov    %r13,%rsi
  mov    %rbp,%rdi
  call   <scanf@plt>
  cmp    $0x1,%eax
  jle    L33
  mov    (%rsp),%ecx
  movslq %r12d,%rdx
  mov    0x4(%rsp),%eax
  lea    0x0(,%rdx,4),%rsi
  mov    %ecx,%edi
  sub    %r15d,%edi
  cmp    $0x77,%edi
  jle    L1
  mov    %eax,%esi
  add    $0x1,%r12d
  sub    %ecx,%esi
  mov    %esi,(%rbx,%rdx,4)
  jmp    L0
  nopl   0x0(%rax,%rax,1)
L33:
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L29
  add    $0x18,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L29:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: data_tag: D4
type_guessed: string

tool: D4: %d %d

assistant: ```c
int ler_acessos(int *tempos) {
  int count = 0;
  int saidaAnterior = -190;
  for (;;) {
    int entrada, saida;
    if (scanf("%d %d", &entrada, &saida) < 2) {
      break;
    }
    if (entrada - saidaAnterior < 120) {
      tempos[count - 1] += saida - saidaAnterior;
    } else {
      tempos[count++] = saida - entrada;
    }
    saidaAnterior = saida;
  }
  return count;
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<AtoiMI>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  mov    %rdi,-0x8(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  je     L26
  mov    -0x8(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L26
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdi
  call   <atoi@plt>
  jmp    L13
L26:
  mov    D3(%rip),%rax
  mov    (%rax),%eax
L13:
  leave
  ret
```

assistant: ```c
int AtoiMI(char *string) {
  if (string != NULL && *string != '\0') {
    return (atoi(string));
  }
  return (INT_MIN);
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<AtoiMI>:
  endbr64
  test   %rdi,%rdi
  je     L5
  cmpb   $0x0,(%rdi)
  jne    L3
L5:
  mov    D2(%rip),%rax
  mov    (%rax),%eax
  ret
L3:
  sub    $0x8,%rsp
  call   <atoi@plt>
  add    $0x8,%rsp
  ret
```

assistant: ```c
int AtoiMI(char *string) {
  if (string != NULL && *string != '\0') {
    return (atoi(string));
  }
  return (INT_MIN);
}
```
user: What is the c source code of the assembly code below:

```asm
<AtoiMI>:
  endbr64
  test   %rdi,%rdi
  je     L2
  cmpb   $0x0,(%rdi)
  jne    L11
L2:
  mov    D1(%rip),%rax
  mov    (%rax),%eax
  ret
  nopl   0x0(%rax,%rax,1)
L11:
  jmp    1050 <atoi@plt>
```

assistant: ```c
int AtoiMI(char *string) {
  if (string != NULL && *string != '\0') {
    return (atoi(string));
  }
  return (INT_MIN);
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<AtoiMI>:
  endbr64
  test   %rdi,%rdi
  je     L19
  cmpb   $0x0,(%rdi)
  jne    L14
L19:
  mov    D4(%rip),%rax
  mov    (%rax),%eax
  ret
  nopl   0x0(%rax,%rax,1)
L14:
  jmp    1050 <atoi@plt>
```

assistant: ```c
int AtoiMI(char *string) {
  if (string != NULL && *string != '\0') {
    return (atoi(string));
  }
  return (INT_MIN);
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<SensorSetMirrorFlip_OV7649>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %edi,%eax
  mov    %al,-0x14(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  cmpb   $0x1,-0x14(%rbp)
  jne    L20
  movb   $0x2,-0x14(%rbp)
  jmp    L15
L20:
  cmpb   $0x2,-0x14(%rbp)
  jne    L15
  movb   $0x1,-0x14(%rbp)
L15:
  lea    -0xa(%rbp),%rax
  mov    %rax,%rsi
  mov    $0x12,%edi
  call   <VIM_SIF_I2cReadByte@plt>
  lea    -0x9(%rbp),%rax
  mov    %rax,%rsi
  mov    $0x75,%edi
  call   <VIM_SIF_I2cReadByte@plt>
  movzbl -0xa(%rbp),%eax
  and    $0xffffffbf,%eax
  mov    %eax,%edx
  movzbl -0x14(%rbp),%eax
  shl    $0x6,%eax
  and    $0x40,%eax
  or     %edx,%eax
  movzbl %al,%eax
  mov    %eax,%esi
  mov    $0x12,%edi
  call   <VIM_SIF_I2cWriteByte@plt>
  movzbl -0x9(%rbp),%eax
  and    $0x7f,%eax
  mov    %eax,%edx
  movzbl -0x14(%rbp),%eax
  shl    $0x6,%eax
  and    $0xffffff80,%eax
  or     %edx,%eax
  movzbl %al,%eax
  mov    %eax,%esi
  mov    $0x75,%edi
  call   <VIM_SIF_I2cWriteByte@plt>
  nop
  mov    -0x8(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L5
  call   <__stack_chk_fail@plt>
L5:
  leave
  ret
```

assistant: ```c
void SensorSetMirrorFlip_OV7649(unsigned char val) {
  unsigned char x1, x2;
  if (val == 1)
    val = 2;
  else if (val == 2)
    val = 1;
  VIM_SIF_I2cReadByte(0x12, &x1);
  VIM_SIF_I2cReadByte(0x75, &x2);
  VIM_SIF_I2cWriteByte(0x12, (unsigned char)((x1 & 0xbf) | ((val & 0x01) << 6)));
  VIM_SIF_I2cWriteByte(0x75, (unsigned char)((x2 & 0x7f) | ((val & 0x02) << 6)));
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<SensorSetMirrorFlip_OV7649>:
  endbr64
  push   %rbx
  sub    $0x10,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  mov    $0x2,%ebx
  cmp    $0x1,%dil
  je     L11
  mov    %edi,%ebx
  cmp    $0x2,%dil
  mov    $0x1,%eax
  cmove  %eax,%ebx
L11:
  lea    0x6(%rsp),%rsi
  mov    $0x12,%edi
  call   <VIM_SIF_I2cReadByte@plt>
  lea    0x7(%rsp),%rsi
  mov    $0x75,%edi
  call   <VIM_SIF_I2cReadByte@plt>
  movzbl %bl,%ebx
  shl    $0x6,%ebx
  movzbl 0x6(%rsp),%esi
  and    $0xffffffbf,%esi
  mov    %ebx,%eax
  and    $0x40,%eax
  or     %eax,%esi
  movzbl %sil,%esi
  mov    $0x12,%edi
  call   <VIM_SIF_I2cWriteByte@plt>
  movzbl 0x7(%rsp),%esi
  and    $0x7f,%esi
  and    $0xffffff80,%ebx
  or     %ebx,%esi
  movzbl %sil,%esi
  mov    $0x75,%edi
  call   <VIM_SIF_I2cWriteByte@plt>
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L13
  add    $0x10,%rsp
  pop    %rbx
  ret
L13:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void SensorSetMirrorFlip_OV7649(unsigned char val) {
  unsigned char x1, x2;
  if (val == 1)
    val = 2;
  else if (val == 2)
    val = 1;
  VIM_SIF_I2cReadByte(0x12, &x1);
  VIM_SIF_I2cReadByte(0x75, &x2);
  VIM_SIF_I2cWriteByte(0x12, (unsigned char)((x1 & 0xbf) | ((val & 0x01) << 6)));
  VIM_SIF_I2cWriteByte(0x75, (unsigned char)((x2 & 0x7f) | ((val & 0x02) << 6)));
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<SensorSetMirrorFlip_OV7649>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  cmp    $0x1,%dil
  je     L46
  cmp    $0x2,%dil
  je     L28
  movzbl %dil,%ebx
  shl    $0x6,%ebx
  mov    %ebx,%ebp
  and    $0xffffff80,%ebx
  and    $0x40,%ebp
L42:
  lea    0x6(%rsp),%rsi
  mov    $0x12,%edi
  call   <VIM_SIF_I2cReadByte@plt>
  lea    0x7(%rsp),%rsi
  mov    $0x75,%edi
  call   <VIM_SIF_I2cReadByte@plt>
  movzbl 0x6(%rsp),%esi
  mov    $0x12,%edi
  and    $0xffffffbf,%esi
  or     %ebp,%esi
  movzbl %sil,%esi
  call   <VIM_SIF_I2cWriteByte@plt>
  movzbl 0x7(%rsp),%esi
  mov    $0x75,%edi
  and    $0x7f,%esi
  or     %ebx,%esi
  movzbl %sil,%esi
  call   <VIM_SIF_I2cWriteByte@plt>
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L29
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  ret
  xchg   %ax,%ax
L28:
  xor    %ebx,%ebx
  mov    $0x40,%ebp
  jmp    L42
  nopl   0x0(%rax)
L46:
  mov    $0xffffff80,%ebx
  xor    %ebp,%ebp
  jmp    L42
L29:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void SensorSetMirrorFlip_OV7649(unsigned char val) {
  unsigned char x1, x2;
  if (val == 1)
    val = 2;
  else if (val == 2)
    val = 1;
  VIM_SIF_I2cReadByte(0x12, &x1);
  VIM_SIF_I2cReadByte(0x75, &x2);
  VIM_SIF_I2cWriteByte(0x12, (unsigned char)((x1 & 0xbf) | ((val & 0x01) << 6)));
  VIM_SIF_I2cWriteByte(0x75, (unsigned char)((x2 & 0x7f) | ((val & 0x02) << 6)));
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<SensorSetMirrorFlip_OV7649>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  cmp    $0x1,%dil
  je     L14
  cmp    $0x2,%dil
  je     L35
  movzbl %dil,%ebx
  shl    $0x6,%ebx
  mov    %ebx,%ebp
  and    $0xffffff80,%ebx
  and    $0x40,%ebp
L1:
  lea    0x6(%rsp),%rsi
  mov    $0x12,%edi
  call   <VIM_SIF_I2cReadByte@plt>
  lea    0x7(%rsp),%rsi
  mov    $0x75,%edi
  call   <VIM_SIF_I2cReadByte@plt>
  movzbl 0x6(%rsp),%esi
  mov    $0x12,%edi
  and    $0xffffffbf,%esi
  or     %ebp,%esi
  movzbl %sil,%esi
  call   <VIM_SIF_I2cWriteByte@plt>
  movzbl 0x7(%rsp),%esi
  mov    $0x75,%edi
  and    $0x7f,%esi
  or     %ebx,%esi
  movzbl %sil,%esi
  call   <VIM_SIF_I2cWriteByte@plt>
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L44
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  ret
  xchg   %ax,%ax
L35:
  xor    %ebx,%ebx
  mov    $0x40,%ebp
  jmp    L1
  nopl   0x0(%rax)
L14:
  mov    $0xffffff80,%ebx
  xor    %ebp,%ebp
  jmp    L1
L44:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void SensorSetMirrorFlip_OV7649(unsigned char val) {
  unsigned char x1, x2;
  if (val == 1)
    val = 2;
  else if (val == 2)
    val = 1;
  VIM_SIF_I2cReadByte(0x12, &x1);
  VIM_SIF_I2cReadByte(0x75, &x2);
  VIM_SIF_I2cWriteByte(0x12, (unsigned char)((x1 & 0xbf) | ((val & 0x01) << 6)));
  VIM_SIF_I2cWriteByte(0x75, (unsigned char)((x2 & 0x7f) | ((val & 0x02) << 6)));
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<trnspt>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%rbp
  mov    %esi,%ebx
  mov    %rdx,%r12
  mov    $0x1,%edi
  call   <ivector@plt>
  mov    %rax,%rdi
  mov    %ebx,%eax
  add    0x8(%r12),%eax
  sub    0x4(%r12),%eax
  cltd
  idiv   %ebx
  mov    %edx,%r9d
  mov    %ebx,%eax
  add    0x14(%r12),%eax
  sub    0x10(%r12),%eax
  cltd
  idiv   %ebx
  mov    %edx,%r11d
  mov    %ebx,%eax
  add    0xc(%r12),%eax
  sub    0x18(%r12),%eax
  cltd
  idiv   %ebx
  mov    %edx,%r8d
  test   %r9d,%r9d
  js     L71
  mov    %r9d,%esi
  add    $0x2,%rsi
  mov    $0x1,%ecx
L54:
  mov    %ecx,%eax
  add    0x4(%r12),%eax
  sub    $0x2,%eax
  cltd
  idiv   %ebx
  add    $0x1,%edx
  movslq %edx,%rdx
  mov    0x0(%rbp,%rdx,4),%eax
  mov    %eax,(%rdi,%rcx,4)
  add    $0x1,%rcx
  cmp    %rsi,%rcx
  jne    L54
  add    $0x2,%r9d
L45:
  test   %r11d,%r11d
  js     L49
  movslq %r9d,%rax
  lea    (%rdi,%rax,4),%rsi
  lea    0x2(%r11),%r10d
  mov    $0x1,%ecx
L56:
  mov    %ecx,%eax
  add    0x10(%r12),%eax
  sub    $0x2,%eax
  cltd
  idiv   %ebx
  add    $0x1,%edx
  movslq %edx,%rdx
  mov    0x0(%rbp,%rdx,4),%eax
  mov    %eax,(%rsi)
  add    $0x1,%ecx
  add    $0x4,%rsi
  cmp    %r10d,%ecx
  jne    L56
  lea    0x1(%r9,%r11,1),%r9d
L49:
  test   %r8d,%r8d
  js     L74
  movslq %r9d,%r9
  lea    (%rdi,%r9,4),%rsi
  add    $0x2,%r8d
  mov    $0x1,%ecx
L26:
  mov    %ecx,%eax
  add    0x18(%r12),%eax
  sub    $0x2,%eax
  cltd
  idiv   %ebx
  add    $0x1,%edx
  movslq %edx,%rdx
  mov    0x0(%rbp,%rdx,4),%eax
  mov    %eax,(%rsi)
  add    $0x1,%ecx
  add    $0x4,%rsi
  cmp    %r8d,%ecx
  jne    L26
L74:
  test   %ebx,%ebx
  jle    L78
  lea    0x1(%rbx),%ecx
  mov    $0x1,%eax
L48:
  mov    (%rdi,%rax,4),%edx
  mov    %edx,0x0(%rbp,%rax,4)
  add    $0x1,%rax
  cmp    %rax,%rcx
  jne    L48
L78:
  mov    %ebx,%edx
  mov    $0x1,%esi
  call   <free_ivector@plt>
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L71:
  mov    $0x1,%r9d
  jmp    L45
```

assistant: ```c
void trnspt(int iorder[], int ncity, int n[]) {
  int m1, m2, m3, nn, j, jj, *jorder;
  jorder = ivector(1, ncity);
  m1 = 1 + ((n[2] - n[1] + ncity) % ncity);
  m2 = 1 + ((n[5] - n[4] + ncity) % ncity);
  m3 = 1 + ((n[3] - n[6] + ncity) % ncity);
  nn = 1;
  for (j = 1; j <= m1; j++) {
    jj = 1 + ((j + n[1] - 2) % ncity);
    jorder[nn++] = iorder[jj];
  }
  for (j = 1; j <= m2; j++) {
    jj = 1 + ((j + n[4] - 2) % ncity);
    jorder[nn++] = iorder[jj];
  }
  for (j = 1; j <= m3; j++) {
    jj = 1 + ((j + n[6] - 2) % ncity);
    jorder[nn++] = iorder[jj];
  }
  for (j = 1; j <= ncity; j++)
    iorder[j] = jorder[j];
  free_ivector(jorder, 1, ncity);
}
```