// File: /workspace/github_c_makefile_star2_O0/simh[P]simtools/converters/cosy/cosy.c
// Function: decompressCard
int decompressCard(
  FILE *src
)
{
  int ch, i, spcount;

  idx = 0;

  while ((ch = fgetc(src)) != -1) {
    if (ch == 0)
      continue;

    if (ch == PREFIX) {
      if ((ch = fgetc(src)) == -1)
        break;

      switch (ch) {
        case 0x21: case 0x22: case 0x23: case 0x24: case 0x25:
          spcount = ch - 0x21 + 3;
          goto fill;

        case 0x27: case 0x28: case 0x29: case 0x2A: case 0x2B:
        case 0x2C: case 0x2D: case 0x2E: case 0x2F: case 0x30:
        case 0x31: case 0x32: case 0x33: case 0x34: case 0x35:
        case 0x36: case 0x37: case 0x38: case 0x39: case 0x3A:
        case 0x3B: case 0x3C: case 0x3D: case 0x3E: case 0x3F:
        case 0x40: case 0x41: case 0x42: case 0x43: case 0x44:
        case 0x45: case 0x46: case 0x47: case 0x48: case 0x49:
        case 0x4A: case 0x4B: case 0x4C: case 0x4D: case 0x4E:
        case 0x4F: case 0x50: case 0x51: case 0x52: case 0x53:
        case 0x54: case 0x55: case 0x56: case 0x57: case 0x58:
        case 0x59: case 0x5A: case 0x5B: case 0x5C: case 0x5D:
          spcount = ch - 0x27 + 8;
      fill:
          for (i = 0; i< spcount; i++) {
            if (idx != CARDLEN)
              card[idx++] = ' ';
          }
          break;

        case 0x5E:
          card[idx] = '\0';
          return 0;

        case 0x5F:
          card[idx] = '\0';
          return -2;
      }
    } else {
      if (idx != CARDLEN)
        card[idx++] = ch;
    }
  }
  card[idx] = '\0';
  return -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movl $0x0, 0x2e8a(%rip)      # 0x42c0
movq -0x10(%rbp), %rdi
callq 0x1090
movl %eax, -0x14(%rbp)
cmpl $-0x1, %eax
je 0x1567
cmpl $0x0, -0x14(%rbp)
jne 0x1453
jmp 0x1436
cmpl $0x5f, -0x14(%rbp)
jne 0x1534
movq -0x10(%rbp), %rdi
callq 0x1090
movl %eax, -0x14(%rbp)
cmpl $-0x1, %eax
jne 0x1473
jmp 0x1567
movl -0x14(%rbp), %eax
addl $-0x21, %eax
movl %eax, %ecx
movq %rcx, -0x28(%rbp)
subl $0x3e, %eax
ja 0x1532
movq -0x28(%rbp), %rax
leaq 0xb71(%rip), %rcx       # 0x2004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl -0x14(%rbp), %eax
subl $0x21, %eax
addl $0x3, %eax
movl %eax, -0x1c(%rbp)
jmp 0x14b6
movl -0x14(%rbp), %eax
subl $0x27, %eax
addl $0x8, %eax
movl %eax, -0x1c(%rbp)
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x14fa
cmpl $0x50, 0x2df4(%rip)     # 0x42c0
je 0x14ed
movl 0x2dec(%rip), %eax      # 0x42c0
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, 0x2de1(%rip)      # 0x42c0
movslq %eax, %rcx
leaq 0x2de7(%rip), %rax      # 0x42d0
movb $0x20, (%rax,%rcx)
jmp 0x14ef
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x14bd
jmp 0x1532
movslq 0x2dbd(%rip), %rcx      # 0x42c0
leaq 0x2dc6(%rip), %rax      # 0x42d0
movb $0x0, (%rax,%rcx)
movl $0x0, -0x4(%rbp)
jmp 0x1580
movslq 0x2da2(%rip), %rcx      # 0x42c0
leaq 0x2dab(%rip), %rax      # 0x42d0
movb $0x0, (%rax,%rcx)
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x1580
jmp 0x1562
cmpl $0x50, 0x2d85(%rip)     # 0x42c0
je 0x1560
movl -0x14(%rbp), %eax
movb %al, %dl
movl 0x2d78(%rip), %eax      # 0x42c0
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, 0x2d6d(%rip)      # 0x42c0
movslq %eax, %rcx
leaq 0x2d73(%rip), %rax      # 0x42d0
movb %dl, (%rax,%rcx)
jmp 0x1562
jmp 0x1436
movslq 0x2d52(%rip), %rcx      # 0x42c0
leaq 0x2d5b(%rip), %rax      # 0x42d0
movb $0x0, (%rax,%rcx)
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)