// File: /workspace/github_c_makefile_star2_O0/simh[P]simtools/converters/fsio/os8.c
// Function: os8Set
static void os8Set(
  struct mountedFS *mount,
  uint8_t UNUSED(unit),
  uint8_t UNUSED(present)
)
{
  struct OS8data *data = &mount->os8data;
  int idx = 0;
  unsigned long year;
  char *endptr;

  while (setCmds[idx] != NULL) {
    if (strcmp(words[1], setCmds[idx]) == 0) {
      switch (idx) {
        case OS8SET_YEAR:
          if (args == 3) {
            if (strcmp(words[2], "none") == 0) {
              data->date = 0;
              return;
            }
            year = strtoul(words[2], &endptr, 10);
            if ((*endptr == '\0') && (year <= 7)) {
              struct tm tm;
              time_t now = time(NULL);

              localtime_r(&now, &tm);

              data->date = (tm.tm_mon + 1) << 8;
              data->date |= (tm.tm_mday + 1) << 3;
              data->date |= year;
              return;
            }
          }
          fprintf(stderr, "os8: Invalid syntax for \"set year\"\n");
          return;

        default:
          fprintf(stderr, "os8: \"%s\" not implemented\n", words[1]);
          return;
      }
    }
    idx++;
  }
  fprintf(stderr, "os8: Unknown set command \"%s\"\n", words[1]);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movb %dl, %al
movb %sil, %cl
movq %rdi, -0x8(%rbp)
movb %cl, -0x9(%rbp)
movb %al, -0xa(%rbp)
movq -0x8(%rbp), %rax
addq $0x48, %rax
movq %rax, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movslq -0x1c(%rbp), %rcx
leaq 0x8fab(%rip), %rax      # 0x1f140
cmpq $0x0, (%rax,%rcx,8)
je 0x162f5
leaq 0x9131(%rip), %rax      # 0x1f2d8
movq (%rax), %rax
movq 0x8(%rax), %rdi
movslq -0x1c(%rbp), %rcx
leaq 0x8f87(%rip), %rax      # 0x1f140
movq (%rax,%rcx,8), %rsi
callq 0x31b0
cmpl $0x0, %eax
jne 0x162e7
movl -0x1c(%rbp), %eax
testl %eax, %eax
jne 0x162bf
jmp 0x161d8
leaq 0x90f1(%rip), %rax      # 0x1f2d0
cmpl $0x3, (%rax)
jne 0x162a5
leaq 0x90e9(%rip), %rax      # 0x1f2d8
movq (%rax), %rax
movq 0x10(%rax), %rdi
leaq 0x4850(%rip), %rsi      # 0x1aa4d
callq 0x31b0
cmpl $0x0, %eax
jne 0x16216
movq -0x18(%rbp), %rax
movw $0x0, 0x12(%rax)
jmp 0x1631b
leaq 0x90bb(%rip), %rax      # 0x1f2d8
movq (%rax), %rax
movq 0x10(%rax), %rdi
leaq -0x30(%rbp), %rsi
movl $0xa, %edx
callq 0x3280
movq %rax, -0x28(%rbp)
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x162a3
cmpq $0x7, -0x28(%rbp)
ja 0x162a3
xorl %eax, %eax
movl %eax, %edi
callq 0x31e0
movq %rax, -0x70(%rbp)
leaq -0x70(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x30a0
movl -0x58(%rbp), %eax
addl $0x1, %eax
shll $0x8, %eax
movw %ax, %cx
movq -0x18(%rbp), %rax
movw %cx, 0x12(%rax)
movl -0x5c(%rbp), %edx
addl $0x1, %edx
shll $0x3, %edx
movq -0x18(%rbp), %rax
movzwl 0x12(%rax), %ecx
orl %edx, %ecx
movw %cx, 0x12(%rax)
movq -0x28(%rbp), %rdx
movq -0x18(%rbp), %rax
movzwl 0x12(%rax), %ecx
orq %rdx, %rcx
movw %cx, 0x12(%rax)
jmp 0x1631b
jmp 0x162a5
movq 0x7d4c(%rip), %rax      # 0x1dff8
movq (%rax), %rdi
leaq 0x479c(%rip), %rsi      # 0x1aa52
movb $0x0, %al
callq 0x31c0
jmp 0x1631b
movq 0x7d32(%rip), %rax      # 0x1dff8
movq (%rax), %rdi
leaq 0x9008(%rip), %rax      # 0x1f2d8
movq (%rax), %rax
movq 0x8(%rax), %rdx
leaq 0x4798(%rip), %rsi      # 0x1aa76
movb $0x0, %al
callq 0x31c0
jmp 0x1631b
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x1618a
movq 0x7cfc(%rip), %rax      # 0x1dff8
movq (%rax), %rdi
leaq 0x8fd2(%rip), %rax      # 0x1f2d8
movq (%rax), %rax
movq 0x8(%rax), %rdx
leaq 0x477d(%rip), %rsi      # 0x1aa91
movb $0x0, %al
callq 0x31c0
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)