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

```asm
<swi_gen_filename>:
  endbr64
  push   %rbp
  mov    %rsi,%rbp
  push   %rbx
  sub    $0x38,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x28(%rsp)
  xor    %eax,%eax
  cmp    $0xa,%edi
  jg     L56
  cmp    $0x1,%edi
  jg     L94
  test   %edi,%edi
  je     L94
  cmp    $0x1,%edi
  jne    L58
  lea    D28(%rip),%rsi
  mov    %rbp,%rdi
  movsd  %xmm0,0x8(%rsp)
  call   <strcpy@plt>
  movsd  0x8(%rsp),%xmm0
L78:
  comisd D117(%rip),%xmm0
  lea    0x18(%rsp),%rcx
  lea    0x14(%rsp),%rdx
  lea    0x1c(%rsp),%rsi
  lea    0x20(%rsp),%r8
  jae    L76
  xor    %edi,%edi
  call   <swe_revjul@plt>
L126:
  movslq 0x1c(%rsp),%rbx
  mov    %rbx,%rax
  imul   $0x51eb851f,%rbx,%rbx
  cltd
  sar    $0x25,%rbx
  sub    %edx,%ebx
  test   %eax,%eax
  js     L133
  imul   $0xaaaaaaab,%ebx,%eax
  add    $0x2aaaaaaa,%eax
  ror    %eax
  cmp    $0x2aaaaaaa,%eax
  jbe    L100
  cs nopw 0x0(%rax,%rax,1)
L34:
  sub    $0x1,%ebx
L66:
  imul   $0xaaaaaaab,%ebx,%eax
  add    $0x2aaaaaaa,%eax
  ror    %eax
  cmp    $0x2aaaaaaa,%eax
  ja     L34
  test   %ebx,%ebx
  js     L132
L100:
  lea    D95(%rip),%rsi
  mov    %rbp,%rdi
  call   <strcat@plt>
L44:
  mov    %rbp,%rdi
  call   <strlen@plt>
  mov    %ebx,%edx
  lea    D69(%rip),%rcx
  lea    D81(%rip),%rsi
  neg    %edx
  cltq
  cmovs  %ebx,%edx
  lea    0x0(%rbp,%rax,1),%rdi
  xor    %eax,%eax
  call   <sprintf@plt>
  mov    0x28(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L125
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  ret
  nopl   0x0(%rax)
L56:
  lea    -0xc(%rdi),%eax
  cmp    $0x5,%eax
  ja     L85
  lea    D114(%rip),%rsi
  mov    %rbp,%rdi
  movsd  %xmm0,0x8(%rsp)
  call   <strcpy@plt>
  movsd  0x8(%rsp),%xmm0
  jmp    L78
  nopl   0x0(%rax)
L76:
  mov    $0x1,%edi
  call   <swe_revjul@plt>
  jmp    L126
  nopw   0x0(%rax,%rax,1)
L133:
  imul   $0xc28f5c29,%eax,%eax
  add    $0x51eb850,%eax
  ror    $0x2,%eax
  cmp    $0x28f5c28,%eax
  jbe    L66
  sub    $0x1,%ebx
  imul   $0xaaaaaaab,%ebx,%eax
  add    $0x2aaaaaaa,%eax
  ror    %eax
  cmp    $0x2aaaaaaa,%eax
  ja     L34
  nopl   0x0(%rax)
L132:
  lea    D108(%rip),%rsi
  mov    %rbp,%rdi
  call   <strcat@plt>
  jmp    L44
  nopl   0x0(%rax)
L94:
  lea    D129(%rip),%rsi
  mov    %rbp,%rdi
  movsd  %xmm0,0x8(%rsp)
  call   <strcpy@plt>
  movsd  0x8(%rsp),%xmm0
  jmp    L78
L85:
  cmp    $0x1adb0,%edi
  lea    D54(%rip),%rsi
  lea    D33(%rip),%rax
  cmovge %rax,%rsi
L165:
  lea    -0x2710(%rdi),%r8d
  mov    0x28(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L125
  movslq %r8d,%rdx
  mov    %r8d,%eax
  add    $0x38,%rsp
  mov    %rbp,%rdi
  imul   $0x10624dd3,%rdx,%rdx
  sar    $0x1f,%eax
  pop    %rbx
  pop    %rbp
  lea    D69(%rip),%r9
  lea    D25(%rip),%rcx
  sar    $0x26,%rdx
  sub    %eax,%edx
  xor    %eax,%eax
  jmp    10f0 <sprintf@plt>
L125:
  call   <__stack_chk_fail@plt>
L58:
  lea    D54(%rip),%rsi
  jmp    L165
```

tool_calls: name: read_data
arguments: data_label: D28
type_guessed: string
name: read_data
arguments: data_label: D117
type_guessed: f64
name: read_data
arguments: data_label: D95
type_guessed: string
name: read_data
arguments: data_label: D69
type_guessed: string
name: read_data
arguments: data_label: D81
type_guessed: string
name: read_data
arguments: data_label: D114
type_guessed: string
name: read_data
arguments: data_label: D108
type_guessed: string
name: read_data
arguments: data_label: D129
type_guessed: string
name: read_data
arguments: data_label: D54
type_guessed: string
name: read_data
arguments: data_label: D33
type_guessed: string
name: read_data
arguments: data_label: D25
type_guessed: string

tool: D28: semo

tool: D117: 2305447.5

tool: D95: _

tool: D69: se1

tool: D81: %02d.%s

tool: D114: seas

tool: D108: m

tool: D129: sepl

tool: D54: ast%d%sse%05d.%s

tool: D33: ast%d%ss%06d.%s

tool: D25: /

assistant: ```c
void swi_gen_filename(double tjd, int ipli, char *fname) {
  int icty;
  int ncties = (int)6.0;
  short gregflag;
  int jmon, jday, jyear, sgn;
  double jut;
  char *sform;
  switch (ipli) {
  case 1:
    strcpy(fname, "semo");
    break;
  case 0:
  case 2:
  case 3:
  case 4:
  case 5:
  case 6:
  case 7:
  case 8:
  case 9:
  case 10:
    strcpy(fname, "sepl");
    break;
  case 14:
  case 15:
  case 16:
  case 17:
  case 12:
  case 13:
    strcpy(fname, "seas");
    break;
  default:
    sform = "ast%d%sse%05d.%s";
    if (ipli - 10000 > 99999)
      sform = "ast%d%ss%06d.%s";
    sprintf(fname, sform, (ipli - 10000) / 1000, "/", ipli - 10000, "se1");
    return;
  }
  if (tjd >= 2305447.5) {
    gregflag = 1;
    swe_revjul(tjd, gregflag, &jyear, &jmon, &jday, &jut);
  } else {
    gregflag = 0;
    swe_revjul(tjd, gregflag, &jyear, &jmon, &jday, &jut);
  }
  if (jyear < 0)
    sgn = -1;
  else
    sgn = 1;
  icty = jyear / 100;
  if (sgn < 0 && jyear % 100 != 0)
    icty -= 1;
  while (icty % ncties != 0)
    icty--;
  if (icty < 0)
    strcat(fname, "m");
  else
    strcat(fname, "_");
  icty = abs(icty);
  sprintf(fname + strlen(fname), "%02d.%s", icty, "se1");
}
```