// File: /workspace/github_c_makefile_star2_O0/alexgirao[P]aimant/str.c
// Function: str_formattime
void str_formattime(struct str *sa, int cat, const char *fmt, struct tm *tm)
{
  char buf0[0x0fff + 1 /* 4096 */], *buf;
  int buf_len;
  int n;

  buf = buf0;
  buf_len = sizeof(buf0);

  n = strftime(buf, buf_len, fmt, tm);
  if (n == 0 || n >= buf_len) {
    /* try with more space
     */
    buf_len = 0x1fff + 1 /* 8192 */;
    assert((buf = malloc(buf_len)) != NULL);
    n = strftime(buf, buf_len, fmt, tm);
    if (n == 0 || n >= buf_len) {
      free(buf);
      buf_len = 0xffff + 1 /* 64K */;
      assert((buf = malloc(buf_len)) != NULL);
      n = strftime(buf, buf_len, fmt, tm);
      if (n == 0 || n >= buf_len) {
        free(buf);
        buf_len = 0xfffff + 1; /* 1M */
        assert((buf = malloc(buf_len)) != NULL);
        n = strftime(buf, buf_len, fmt, tm);
        if (n == 0 || n >= buf_len) {
          /* give up */
          free(buf);
          fprintf(stderr, "error: str_vformattime(): too large input (> %i)\n", 0xfffff + 1);
          exit(1);
        }
      }
    }
  }

  assert(buf != NULL);

  if (cat) {
    str_catn(sa, buf, n);
  } else {
    str_copyn(sa, buf, n);
  }

  if (buf && buf != buf0) {
    free(buf);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1030, %rsp           # imm = 0x1030
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
leaq -0x1020(%rbp), %rax
movq %rax, -0x1028(%rbp)
movl $0x1000, -0x102c(%rbp)  # imm = 0x1000
movq -0x1028(%rbp), %rdi
movslq -0x102c(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
callq 0x22c0
movl %eax, -0x1030(%rbp)
cmpl $0x0, -0x1030(%rbp)
je 0xe9ae
movl -0x1030(%rbp), %eax
cmpl -0x102c(%rbp), %eax
jl 0xeb7b
movl $0x2000, -0x102c(%rbp)  # imm = 0x2000
movslq -0x102c(%rbp), %rdi
callq 0x22a0
movq %rax, -0x1028(%rbp)
cmpq $0x0, %rax
je 0xe9d3
jmp 0xe9f2
leaq 0x3afc(%rip), %rdi      # 0x124d6
leaq 0x3a37(%rip), %rsi      # 0x12418
movl $0x13d, %edx            # imm = 0x13D
leaq 0x3b09(%rip), %rcx      # 0x124f6
callq 0x21a0
movq -0x1028(%rbp), %rdi
movslq -0x102c(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
callq 0x22c0
movl %eax, -0x1030(%rbp)
cmpl $0x0, -0x1030(%rbp)
je 0xea2e
movl -0x1030(%rbp), %eax
cmpl -0x102c(%rbp), %eax
jl 0xeb79
movq -0x1028(%rbp), %rdi
callq 0x2050
movl $0x10000, -0x102c(%rbp) # imm = 0x10000
movslq -0x102c(%rbp), %rdi
callq 0x22a0
movq %rax, -0x1028(%rbp)
cmpq $0x0, %rax
je 0xea5f
jmp 0xea7e
leaq 0x3a70(%rip), %rdi      # 0x124d6
leaq 0x39ab(%rip), %rsi      # 0x12418
movl $0x142, %edx            # imm = 0x142
leaq 0x3a7d(%rip), %rcx      # 0x124f6
callq 0x21a0
movq -0x1028(%rbp), %rdi
movslq -0x102c(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
callq 0x22c0
movl %eax, -0x1030(%rbp)
cmpl $0x0, -0x1030(%rbp)
je 0xeaba
movl -0x1030(%rbp), %eax
cmpl -0x102c(%rbp), %eax
jl 0xeb77
movq -0x1028(%rbp), %rdi
callq 0x2050
movl $0x100000, -0x102c(%rbp) # imm = 0x100000
movslq -0x102c(%rbp), %rdi
callq 0x22a0
movq %rax, -0x1028(%rbp)
cmpq $0x0, %rax
je 0xeaeb
jmp 0xeb0a
leaq 0x39e4(%rip), %rdi      # 0x124d6
leaq 0x391f(%rip), %rsi      # 0x12418
movl $0x147, %edx            # imm = 0x147
leaq 0x39f1(%rip), %rcx      # 0x124f6
callq 0x21a0
movq -0x1028(%rbp), %rdi
movslq -0x102c(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
callq 0x22c0
movl %eax, -0x1030(%rbp)
cmpl $0x0, -0x1030(%rbp)
je 0xeb42
movl -0x1030(%rbp), %eax
cmpl -0x102c(%rbp), %eax
jl 0xeb75
movq -0x1028(%rbp), %rdi
callq 0x2050
movq 0x74a3(%rip), %rax      # 0x15ff8
movq (%rax), %rdi
leaq 0x39d9(%rip), %rsi      # 0x12538
movl $0x100000, %edx         # imm = 0x100000
movb $0x0, %al
callq 0x2230
movl $0x1, %edi
callq 0x2350
jmp 0xeb77
jmp 0xeb79
jmp 0xeb7b
cmpq $0x0, -0x1028(%rbp)
je 0xeb87
jmp 0xeba6
leaq 0x39dc(%rip), %rdi      # 0x1256a
leaq 0x3883(%rip), %rsi      # 0x12418
movl $0x153, %edx            # imm = 0x153
leaq 0x3955(%rip), %rcx      # 0x124f6
callq 0x21a0
cmpl $0x0, -0xc(%rbp)
je 0xebc4
movq -0x8(%rbp), %rdi
movq -0x1028(%rbp), %rsi
movl -0x1030(%rbp), %edx
callq 0xe660
jmp 0xebda
movq -0x8(%rbp), %rdi
movq -0x1028(%rbp), %rsi
movl -0x1030(%rbp), %edx
callq 0xe540
cmpq $0x0, -0x1028(%rbp)
je 0xec03
movq -0x1028(%rbp), %rax
leaq -0x1020(%rbp), %rcx
cmpq %rcx, %rax
je 0xec03
movq -0x1028(%rbp), %rdi
callq 0x2050
addq $0x1030, %rsp           # imm = 0x1030
popq %rbp
retq
nopl (%rax)