// File: /workspace/github_c_makefile_star2_O0/jsh58[P]Genrich/Genrich.c
// Function: openRead
bool openRead(char* inFile, File* in) {

  // open file or stdin
  bool stdinBool = ! strcmp(inFile, "-");
  FILE* dummy = (stdinBool ? stdin : fopen(inFile, "r"));
  if (dummy == NULL)
    exit(error(inFile, ERROPEN));

  // check for gzip compression: magic number 0x1F, 0x8B
  bool gzip = true;
  int save = 0;  // first char to pushback (for stdin)
  int i, j;
  for (i = 0; i < 2; i++) {
    j = fgetc(dummy);
    if (j == EOF)
      exit(error(inFile, ERROPEN));
    if ( (i && (unsigned char) j != 0x8B)
        || (! i && (unsigned char) j != 0x1F) ) {
      gzip = false;
      break;
    }
    if (! i)
      save = j;
  }

  // for stdin, push back chars
  if (stdinBool) {
    if (gzip)
      exit(error("", ERRGZIP));
    if (ungetc(j, dummy) == EOF)
      exit(error("", ERRUNGET));
    if (i && ungetc(save, dummy) == EOF)
      exit(error("", ERRUNGET));
  }

  // open file
  if (gzip) {
    if (fclose(dummy))
      exit(error("<dummy>", ERRCLOSE));
    in->gzf = gzopen(inFile, "r");
    if (in->gzf == NULL)
      exit(error(inFile, ERROPEN));
  } else {
    if (! stdinBool)
      rewind(dummy);
    in->f = dummy;
  }

  return gzip;
}

// Assembly:
subq $0x38, %rsp
movq %rdi, 0x30(%rsp)
movq %rsi, 0x28(%rsp)
movq 0x30(%rsp), %rdi
leaq 0x688f(%rip), %rsi      # 0x1fd69
callq 0x21a0
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
andb $0x1, %al
movb %al, 0x27(%rsp)
testb $0x1, 0x27(%rsp)
je 0x19504
movq 0x9acd(%rip), %rax      # 0x22fc8
movq (%rax), %rax
movq %rax, (%rsp)
jmp 0x19519
movq 0x30(%rsp), %rdi
leaq 0x545a(%rip), %rsi      # 0x1e96a
callq 0x2270
movq %rax, (%rsp)
movq (%rsp), %rax
movq %rax, 0x18(%rsp)
cmpq $0x0, 0x18(%rsp)
jne 0x19540
movq 0x30(%rsp), %rdi
movl $0x1, %esi
callq 0x2840
movl %eax, %edi
callq 0x22b0
movb $0x1, 0x17(%rsp)
movl $0x0, 0x10(%rsp)
movl $0x0, 0xc(%rsp)
cmpl $0x2, 0xc(%rsp)
jge 0x195d4
movq 0x18(%rsp), %rdi
callq 0x2150
movl %eax, 0x8(%rsp)
cmpl $-0x1, 0x8(%rsp)
jne 0x19587
movq 0x30(%rsp), %rdi
movl $0x1, %esi
callq 0x2840
movl %eax, %edi
callq 0x22b0
cmpl $0x0, 0xc(%rsp)
je 0x1959c
movl 0x8(%rsp), %eax
movzbl %al, %eax
cmpl $0x8b, %eax
jne 0x195af
cmpl $0x0, 0xc(%rsp)
jne 0x195b6
movl 0x8(%rsp), %eax
movzbl %al, %eax
cmpl $0x1f, %eax
je 0x195b6
movb $0x0, 0x17(%rsp)
jmp 0x195d4
cmpl $0x0, 0xc(%rsp)
jne 0x195c5
movl 0x8(%rsp), %eax
movl %eax, 0x10(%rsp)
jmp 0x195c7
movl 0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
jmp 0x19555
testb $0x1, 0x27(%rsp)
je 0x19659
testb $0x1, 0x17(%rsp)
je 0x195fa
leaq 0x6789(%rip), %rdi      # 0x1fd72
movl $0x2a, %esi
callq 0x2840
movl %eax, %edi
callq 0x22b0
movl 0x8(%rsp), %edi
movq 0x18(%rsp), %rsi
callq 0x2240
cmpl $-0x1, %eax
jne 0x19625
leaq 0x675e(%rip), %rdi      # 0x1fd72
movl $0x29, %esi
callq 0x2840
movl %eax, %edi
callq 0x22b0
cmpl $0x0, 0xc(%rsp)
je 0x19657
movl 0x10(%rsp), %edi
movq 0x18(%rsp), %rsi
callq 0x2240
cmpl $-0x1, %eax
jne 0x19657
leaq 0x672c(%rip), %rdi      # 0x1fd72
movl $0x29, %esi
callq 0x2840
movl %eax, %edi
callq 0x22b0
jmp 0x19659
testb $0x1, 0x17(%rsp)
je 0x196c6
movq 0x18(%rsp), %rdi
callq 0x20d0
cmpl $0x0, %eax
je 0x19687
leaq 0x66fd(%rip), %rdi      # 0x1fd73
movl $0x3, %esi
callq 0x2840
movl %eax, %edi
callq 0x22b0
movq 0x30(%rsp), %rdi
leaq 0x52d7(%rip), %rsi      # 0x1e96a
callq 0x2260
movq %rax, %rcx
movq 0x28(%rsp), %rax
movq %rcx, (%rax)
movq 0x28(%rsp), %rax
cmpq $0x0, (%rax)
jne 0x196c4
movq 0x30(%rsp), %rdi
movl $0x1, %esi
callq 0x2840
movl %eax, %edi
callq 0x22b0
jmp 0x196e4
testb $0x1, 0x27(%rsp)
jne 0x196d7
movq 0x18(%rsp), %rdi
callq 0x2120
movq 0x18(%rsp), %rcx
movq 0x28(%rsp), %rax
movq %rcx, (%rax)
movb 0x17(%rsp), %al
andb $0x1, %al
addq $0x38, %rsp
retq
nop