user: Please show me the C implementation that matches the assembly code listed below:

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  jmp    L11
L69:
  mov    $0x0,%eax
  call   <getchar@plt>
  movl   $0x1,-0x30(%rbp)
  movl   $0x6,-0x2c(%rbp)
  movl   $0x2,-0x28(%rbp)
  movl   $0x5,-0x24(%rbp)
  movl   $0x3,-0x20(%rbp)
  movl   $0x4,-0x1c(%rbp)
  jmp    L48
L57:
  lea    -0x12(%rbp),%rax
  mov    %rax,%rdi
  call   <gets@plt>
  lea    -0x12(%rbp),%rax
  lea    D3(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcasecmp@plt>
  test   %rax,%rax
  jne    L25
  mov    -0x30(%rbp),%eax
  mov    %eax,-0x18(%rbp)
  mov    -0x24(%rbp),%eax
  mov    %eax,-0x30(%rbp)
  mov    -0x2c(%rbp),%eax
  mov    %eax,-0x24(%rbp)
  mov    -0x28(%rbp),%eax
  mov    %eax,-0x2c(%rbp)
  mov    -0x18(%rbp),%eax
  mov    %eax,-0x28(%rbp)
  jmp    L48
L25:
  lea    -0x12(%rbp),%rax
  lea    D13(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcasecmp@plt>
  test   %rax,%rax
  jne    L78
  mov    -0x30(%rbp),%eax
  mov    %eax,-0x18(%rbp)
  mov    -0x20(%rbp),%eax
  mov    %eax,-0x30(%rbp)
  mov    -0x2c(%rbp),%eax
  mov    %eax,-0x20(%rbp)
  mov    -0x1c(%rbp),%eax
  mov    %eax,-0x2c(%rbp)
  mov    -0x18(%rbp),%eax
  mov    %eax,-0x1c(%rbp)
  jmp    L48
L78:
  lea    -0x12(%rbp),%rax
  lea    D45(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcasecmp@plt>
  test   %rax,%rax
  jne    L13
  mov    -0x30(%rbp),%eax
  mov    %eax,-0x18(%rbp)
  mov    -0x28(%rbp),%eax
  mov    %eax,-0x30(%rbp)
  mov    -0x2c(%rbp),%eax
  mov    %eax,-0x28(%rbp)
  mov    -0x24(%rbp),%eax
  mov    %eax,-0x2c(%rbp)
  mov    -0x18(%rbp),%eax
  mov    %eax,-0x24(%rbp)
  jmp    L48
L13:
  lea    -0x12(%rbp),%rax
  lea    D25(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcasecmp@plt>
  test   %rax,%rax
  jne    L48
  mov    -0x30(%rbp),%eax
  mov    %eax,-0x18(%rbp)
  mov    -0x1c(%rbp),%eax
  mov    %eax,-0x30(%rbp)
  mov    -0x2c(%rbp),%eax
  mov    %eax,-0x1c(%rbp)
  mov    -0x20(%rbp),%eax
  mov    %eax,-0x2c(%rbp)
  mov    -0x18(%rbp),%eax
  mov    %eax,-0x20(%rbp)
L48:
  mov    -0x34(%rbp),%eax
  lea    -0x1(%rax),%edx
  mov    %edx,-0x34(%rbp)
  test   %eax,%eax
  jne    L57
  mov    -0x30(%rbp),%eax
  mov    %eax,%esi
  lea    D27(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
L11:
  lea    -0x34(%rbp),%rax
  mov    %rax,%rsi
  lea    D58(%rip),%rax
  mov    %rax,%rdi
  call   <scanf@plt>
  test   %rax,%rax
  je     L70
  mov    -0x34(%rbp),%eax
  test   %eax,%eax
  jne    L69
L70:
  mov    $0x0,%eax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L106
  call   <__stack_chk_fail@plt>
L106:
  leave
  ret
```

tool_calls: name: parse_data
arguments: data_label: D3
type_guessed: string
name: parse_data
arguments: data_label: D13
type_guessed: string
name: parse_data
arguments: data_label: D45
type_guessed: string
name: parse_data
arguments: data_label: D25
type_guessed: string
name: parse_data
arguments: data_label: D27
type_guessed: string
name: parse_data
arguments: data_label: D58
type_guessed: string

tool: D3: north

tool: D13: east

tool: D45: south

tool: D25: west

tool: D27: %d


tool: D58: %d

assistant: ```c
int main() {
  int n, temp;
  char str[10];
  while (scanf("%d", &n) && n) {
    getchar();
    int up = 1, down = 6, north = 2, south = 5, west = 3, east = 4;
    while (n--) {
      gets(str);
      if (strcasecmp(str, "north") == 0) {
        temp = up;
        up = south;
        south = down;
        down = north;
        north = temp;
      } else if (strcasecmp(str, "east") == 0) {
        temp = up;
        up = west;
        west = down;
        down = east;
        east = temp;
      } else if (strcasecmp(str, "south") == 0) {
        temp = up;
        up = north;
        north = down;
        down = south;
        south = temp;
      } else if (strcasecmp(str, "west") == 0) {
        temp = up;
        up = east;
        east = down;
        down = west;
        west = temp;
      }
    }
    printf("%d\n", up);
  }
  return 0;
}
```