// File: /workspace/github_c_makefile_star2_O0/josch[P]stride/rdmap.c
// Function: ReadPhiPsiMap
int ReadPhiPsiMap(char *MapFile, float ***PhiPsiMap, COMMAND *Cmd)
{

  int i, j, NFields, Cnt=0;
  FILE *fi;
  BUFFER Buffer;
  char *Fields[MAX_FIELD];

  Cmd->NPixel = 0;

  if( (fi = fopen(MapFile,"r")) != 0 ) {

    while( fgets(Buffer,BUFSZ,fi) != NULL ) {
      if( !(NFields = SplitString(Buffer,Fields,MAX_FIELD)) ) continue;
      if( Cmd->NPixel == 0 ) {
	if( !strcmp(tolostr(Fields[0]),"npixel") ) {
	  Cmd->NPixel = atoi(Fields[1]);
	  if( Cmd->NPixel < 1 || Cmd->NPixel > 1000 ) 
	    die("Wrong number of pixels in the PhiPsi Map file %s\n",MapFile);
	  *PhiPsiMap = FloatMatrix(Cmd->NPixel,Cmd->NPixel);
	}
      }
      else  {
	if( !strcmp(tolostr(Fields[0]),"pixel") ) {
	  if( (i = atoi(Fields[1])) >= 0 && i < Cmd->NPixel &&
	      (j = atoi(Fields[2])) >= 0 && j < Cmd->NPixel &&
	     Cnt ==  i*Cmd->NPixel+j &&  NFields >= 4 ) {
	    (*PhiPsiMap)[i][j] = atof(Fields[5]);
	    Cnt++;
	  }
	  else die("Error in the PhiPsi Map file %s\n",MapFile);
	}
      }
    }
    fclose(fi);
    Cmd->PhiPsiStep = (MAXPHIPSI - MINPHIPSI)/(float)Cmd->NPixel;
  }
  
  if( !Cmd->NPixel ) die("Error reading PhiPsiMap file %s\n",MapFile);

  return(Cmd->NPixel);
}

// Assembly:
subq $0x5c8, %rsp            # imm = 0x5C8
movq %rdi, 0x5c0(%rsp)
movq %rsi, 0x5b8(%rsp)
movq %rdx, 0x5b0(%rsp)
movl $0x0, 0x5a0(%rsp)
movq 0x5b0(%rsp), %rax
movl $0x0, 0x1cf4(%rax)
movq 0x5c0(%rsp), %rdi
leaq 0x21032(%rip), %rsi     # 0x2c89d
callq 0x2190
movq %rax, 0x598(%rsp)
cmpq $0x0, %rax
je 0xbae8
jmp 0xb884
leaq 0x190(%rsp), %rdi
movq 0x598(%rsp), %rdx
movl $0x400, %esi            # imm = 0x400
callq 0x2110
cmpq $0x0, %rax
je 0xbaa7
leaq 0x190(%rsp), %rdi
movq %rsp, %rsi
movl $0x32, %edx
callq 0x37c0
movl %eax, 0x5a4(%rsp)
cmpl $0x0, %eax
jne 0xb8cb
jmp 0xb884
movq 0x5b0(%rsp), %rax
cmpl $0x0, 0x1cf4(%rax)
jne 0xb98a
movq (%rsp), %rdi
callq 0x6030
movq %rax, %rdi
leaq 0x2034d(%rip), %rsi     # 0x2bc40
callq 0x2130
cmpl $0x0, %eax
jne 0xb985
movq 0x8(%rsp), %rdi
callq 0x21d0
movl %eax, %ecx
movq 0x5b0(%rsp), %rax
movl %ecx, 0x1cf4(%rax)
movq 0x5b0(%rsp), %rax
cmpl $0x1, 0x1cf4(%rax)
jl 0xb940
movq 0x5b0(%rsp), %rax
cmpl $0x3e8, 0x1cf4(%rax)    # imm = 0x3E8
jle 0xb956
movq 0x5c0(%rsp), %rsi
leaq 0x202f8(%rip), %rdi     # 0x2bc47
movb $0x0, %al
callq 0xc970
movq 0x5b0(%rsp), %rax
movl 0x1cf4(%rax), %edi
movq 0x5b0(%rsp), %rax
movl 0x1cf4(%rax), %esi
callq 0x73a0
movq %rax, %rcx
movq 0x5b8(%rsp), %rax
movq %rcx, (%rax)
jmp 0xbaa2
movq (%rsp), %rdi
callq 0x6030
movq %rax, %rdi
leaq 0x202a4(%rip), %rsi     # 0x2bc41
callq 0x2130
cmpl $0x0, %eax
jne 0xbaa0
movq 0x8(%rsp), %rdi
callq 0x21d0
movl %eax, 0x5ac(%rsp)
cmpl $0x0, %eax
jl 0xba88
movl 0x5ac(%rsp), %eax
movq 0x5b0(%rsp), %rcx
cmpl 0x1cf4(%rcx), %eax
jge 0xba88
movq 0x10(%rsp), %rdi
callq 0x21d0
movl %eax, 0x5a8(%rsp)
cmpl $0x0, %eax
jl 0xba88
movl 0x5a8(%rsp), %eax
movq 0x5b0(%rsp), %rcx
cmpl 0x1cf4(%rcx), %eax
jge 0xba88
movl 0x5a0(%rsp), %eax
movl 0x5ac(%rsp), %ecx
movq 0x5b0(%rsp), %rdx
imull 0x1cf4(%rdx), %ecx
addl 0x5a8(%rsp), %ecx
cmpl %ecx, %eax
jne 0xba88
cmpl $0x4, 0x5a4(%rsp)
jl 0xba88
movq 0x28(%rsp), %rdi
callq 0x2080
cvtsd2ss %xmm0, %xmm0
movq 0x5b8(%rsp), %rax
movq (%rax), %rax
movslq 0x5ac(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movslq 0x5a8(%rsp), %rcx
movss %xmm0, (%rax,%rcx,4)
movl 0x5a0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x5a0(%rsp)
jmp 0xba9e
movq 0x5c0(%rsp), %rsi
leaq 0x201e2(%rip), %rdi     # 0x2bc79
movb $0x0, %al
callq 0xc970
jmp 0xbaa0
jmp 0xbaa2
jmp 0xb884
movq 0x598(%rsp), %rdi
callq 0x20a0
movq 0x5b0(%rsp), %rax
cvtsi2ssl 0x1cf4(%rax), %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x20168(%rip), %xmm0    # 0x2bc38
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movq 0x5b0(%rsp), %rax
movss %xmm0, 0x1d08(%rax)
movq 0x5b0(%rsp), %rax
cmpl $0x0, 0x1cf4(%rax)
jne 0xbb0f
movq 0x5c0(%rsp), %rsi
leaq 0x20192(%rip), %rdi     # 0x2bc9a
movb $0x0, %al
callq 0xc970
movq 0x5b0(%rsp), %rax
movl 0x1cf4(%rax), %eax
addq $0x5c8, %rsp            # imm = 0x5C8
retq
nopw %cs:(%rax,%rax)