// File: /workspace/github_c_makefile_star2_O0/felipelouza[P]egap/util.c
// Function: alloc_merge_arrays
void alloc_merge_arrays(g_data *g) {
  if(g->extMem) { // notice extMem overrules mmap
    int e,fd;
    e = asprintf(&(g->merge_fname),"%s.mrg0_XXXXXX",g->outPath);
    if(e<0) die("merge temp file name creation failed (1)");
    fd = mkstemp(g->merge_fname);
    if(fd == -1) die("merge temp file creation failed (1)");
    if(close(fd)!=0) die("merge temp file close failed (1)");  // we don't need it now
    e = asprintf(&(g->newmerge_fname),"%s.mrg1_XXXXXX",g->outPath);
    if(e<0) die("merge temp file name creation failed (2)");
    fd = mkstemp(g->newmerge_fname);
    if(fd == -1) die("merge temp file creation failed (2)");
    if(close(fd)!=0) die("merge temp file close failed (2)");  // we don't need it now
    g->mergeColor = g->newMergeColor = NULL;
  }
  else if(g->mmapZ) {
    g->mergeColor = mmap(NULL,g->mergeLen*sizeof(palette),PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANONYMOUS,-1,0);
    if(g->mergeColor== MAP_FAILED) die(__func__);
    g->newMergeColor =  mmap(NULL,g->mergeLen*sizeof(palette),PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANONYMOUS,-1,0);
    if(g->newMergeColor== MAP_FAILED) die(__func__);
  }
  else {
    g->mergeColor =     malloc(g->mergeLen*sizeof(palette)); 
    g->newMergeColor =  malloc(g->mergeLen*sizeof(palette));
     if(!g->mergeColor || !g->newMergeColor) die(__func__);
  }
  // make sure these are not used 
  g->mergeColor16=NULL;
  g->array32 = NULL;
}

// Assembly:
subq $0x18, %rsp
movq %rdi, 0x10(%rsp)
movq 0x10(%rsp), %rax
testb $0x1, 0x69(%rax)
je 0x657b
movq 0x10(%rsp), %rdi
addq $0x50d8, %rdi           # imm = 0x50D8
movq 0x10(%rsp), %rax
movq 0x80(%rax), %rdx
leaq 0xed2a(%rip), %rsi      # 0x151a1
movb $0x0, %al
callq 0x2270
movl %eax, 0xc(%rsp)
cmpl $0x0, 0xc(%rsp)
jge 0x6495
leaq 0xed20(%rip), %rdi      # 0x151b0
callq 0x3ce0
movq 0x10(%rsp), %rax
movq 0x50d8(%rax), %rdi
callq 0x2190
movl %eax, 0x8(%rsp)
cmpl $-0x1, 0x8(%rsp)
jne 0x64bd
leaq 0xed21(%rip), %rdi      # 0x151d9
callq 0x3ce0
movl 0x8(%rsp), %edi
callq 0x2150
cmpl $0x0, %eax
je 0x64d7
leaq 0xed2b(%rip), %rdi      # 0x151fd
callq 0x3ce0
movq 0x10(%rsp), %rdi
addq $0x50e0, %rdi           # imm = 0x50E0
movq 0x10(%rsp), %rax
movq 0x80(%rax), %rdx
leaq 0xed28(%rip), %rsi      # 0x1521e
movb $0x0, %al
callq 0x2270
movl %eax, 0xc(%rsp)
cmpl $0x0, 0xc(%rsp)
jge 0x6514
leaq 0xed1e(%rip), %rdi      # 0x1522d
callq 0x3ce0
movq 0x10(%rsp), %rax
movq 0x50e0(%rax), %rdi
callq 0x2190
movl %eax, 0x8(%rsp)
cmpl $-0x1, 0x8(%rsp)
jne 0x653c
leaq 0xed1f(%rip), %rdi      # 0x15256
callq 0x3ce0
movl 0x8(%rsp), %edi
callq 0x2150
cmpl $0x0, %eax
je 0x6556
leaq 0xed29(%rip), %rdi      # 0x1527a
callq 0x3ce0
movq 0x10(%rsp), %rax
movq $0x0, 0x50f0(%rax)
movq 0x10(%rsp), %rax
movq $0x0, 0x50e8(%rax)
jmp 0x66b0
movq 0x10(%rsp), %rax
testb $0x1, 0x70(%rax)
je 0x6640
movq 0x10(%rsp), %rax
movq 0x28(%rax), %rsi
shlq $0x0, %rsi
xorl %eax, %eax
movl %eax, %r9d
movl $0x3, %edx
movl $0x22, %ecx
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
movq %r9, %rdi
callq 0x2220
movq %rax, %rcx
movq 0x10(%rsp), %rax
movq %rcx, 0x50e8(%rax)
movq 0x10(%rsp), %rax
movq $-0x1, %rcx
cmpq %rcx, 0x50e8(%rax)
jne 0x65e4
leaq 0xecbc(%rip), %rdi      # 0x1529b
callq 0x3ce0
movq 0x10(%rsp), %rax
movq 0x28(%rax), %rsi
shlq $0x0, %rsi
xorl %eax, %eax
movl %eax, %r9d
movl $0x3, %edx
movl $0x22, %ecx
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
movq %r9, %rdi
callq 0x2220
movq %rax, %rcx
movq 0x10(%rsp), %rax
movq %rcx, 0x50f0(%rax)
movq 0x10(%rsp), %rax
movq $-0x1, %rcx
cmpq %rcx, 0x50f0(%rax)
jne 0x663e
leaq 0xec62(%rip), %rdi      # 0x1529b
callq 0x3ce0
jmp 0x66ae
movq 0x10(%rsp), %rax
movq 0x28(%rax), %rdi
shlq $0x0, %rdi
callq 0x127b0
movq %rax, %rcx
movq 0x10(%rsp), %rax
movq %rcx, 0x50e8(%rax)
movq 0x10(%rsp), %rax
movq 0x28(%rax), %rdi
shlq $0x0, %rdi
callq 0x127b0
movq %rax, %rcx
movq 0x10(%rsp), %rax
movq %rcx, 0x50f0(%rax)
movq 0x10(%rsp), %rax
cmpq $0x0, 0x50e8(%rax)
je 0x66a0
movq 0x10(%rsp), %rax
cmpq $0x0, 0x50f0(%rax)
jne 0x66ac
leaq 0xebf4(%rip), %rdi      # 0x1529b
callq 0x3ce0
jmp 0x66ae
jmp 0x66b0
movq 0x10(%rsp), %rax
movq $0x0, 0x50f8(%rax)
movq 0x10(%rsp), %rax
movq $0x0, 0x5100(%rax)
addq $0x18, %rsp
retq
nopw %cs:(%rax,%rax)