// File: /workspace/github_c_makefile_star2_O0/felipelouza[P]egap/io.c
// Function: bitfile_create
void bitfile_create(bitfile *b, size_t size, char *path, int order) {
  // create local copy of template
  char s[Filename_size];
  if(order==0) { // this is a temp file create unique name 
    sprintf(s,"%s.bitXXXXXX",path);
    // get file descriptor for tmp file fill it with 0s and delete file  
    b->fd = mkstemp(s);
    if(b->fd == -1) die("bitfile_create: Tempfile creation failed");
    int e = ftruncate(b->fd,(size+7)/8); // fill with size 0 bits
    if(e!=0)        die("bitfile_create: Tempfile ftruncate failed");
    e = unlink(s);
    if(e!=0)        die("bitfile_create: Tempfile unlink failed");
    }
  else { // we keep this file (to compute the DB-graph) 
    sprintf(s,"%s.%d.lcpbit1",path,order);
    // get file descriptor for bitfile fill it with 0s  
    b->fd = open(s,O_RDWR|O_CREAT|O_TRUNC, 0666);
    if(b->fd == -1) die("bitfile_create: bitfile creation failed");
    int e = ftruncate(b->fd,(size+7)/8); // fill with size 0 bits
    if(e!=0)        die("bitfile_create: bitfile ftruncate failed");
  }
  // initialization of other fields for b
  b->filesize = size;  // total size of the bitfile (in bits) 
  b->buffer = malloc(Bitfile_bufsize_bytes);
  if(!b->buffer)  die("bitfile_create: malloc error");
  b->size = 0;         // current size of the buffer in bits
  b->cur = 0;          // bit index inside buffer
  b->offset = 0;       // offset in bytes in the file 
}

// Assembly:
subq $0x1038, %rsp           # imm = 0x1038
movq %rdi, 0x1030(%rsp)
movq %rsi, 0x1028(%rsp)
movq %rdx, 0x1020(%rsp)
movl %ecx, 0x101c(%rsp)
cmpl $0x0, 0x101c(%rsp)
jne 0x7cea
leaq 0x10(%rsp), %rdi
movq 0x1020(%rsp), %rdx
leaq 0xda0b(%rip), %rsi      # 0x15663
movb $0x0, %al
callq 0x2360
leaq 0x10(%rsp), %rdi
callq 0x2190
movl %eax, %ecx
movq 0x1030(%rsp), %rax
movl %ecx, (%rax)
movq 0x1030(%rsp), %rax
cmpl $-0x1, (%rax)
jne 0x7c8e
leaq 0xd9e7(%rip), %rdi      # 0x15670
callq 0x3ce0
movq 0x1030(%rsp), %rax
movl (%rax), %edi
movq 0x1028(%rsp), %rsi
addq $0x7, %rsi
shrq $0x3, %rsi
callq 0x22a0
movl %eax, 0xc(%rsp)
cmpl $0x0, 0xc(%rsp)
je 0x7cc4
leaq 0xd9da(%rip), %rdi      # 0x15699
callq 0x3ce0
leaq 0x10(%rsp), %rdi
callq 0x2050
movl %eax, 0xc(%rsp)
cmpl $0x0, 0xc(%rsp)
je 0x7ce5
leaq 0xd9e3(%rip), %rdi      # 0x156c3
callq 0x3ce0
jmp 0x7d7f
leaq 0x10(%rsp), %rdi
movq 0x1020(%rsp), %rdx
movl 0x101c(%rsp), %ecx
leaq 0xd9e5(%rip), %rsi      # 0x156ea
movb $0x0, %al
callq 0x2360
leaq 0x10(%rsp), %rdi
movl $0x242, %esi            # imm = 0x242
movl $0x1b6, %edx            # imm = 0x1B6
movb $0x0, %al
callq 0x22e0
movl %eax, %ecx
movq 0x1030(%rsp), %rax
movl %ecx, (%rax)
movq 0x1030(%rsp), %rax
cmpl $-0x1, (%rax)
jne 0x7d47
leaq 0xd9b6(%rip), %rdi      # 0x156f8
callq 0x3ce0
movq 0x1030(%rsp), %rax
movl (%rax), %edi
movq 0x1028(%rsp), %rsi
addq $0x7, %rsi
shrq $0x3, %rsi
callq 0x22a0
movl %eax, 0x8(%rsp)
cmpl $0x0, 0x8(%rsp)
je 0x7d7d
leaq 0xd9a8(%rip), %rdi      # 0x15720
callq 0x3ce0
jmp 0x7d7f
movq 0x1028(%rsp), %rcx
movq 0x1030(%rsp), %rax
movq %rcx, 0x18(%rax)
movl $0x10000, %edi          # imm = 0x10000
callq 0x127b0
movq %rax, %rcx
movq 0x1030(%rsp), %rax
movq %rcx, 0x10(%rax)
movq 0x1030(%rsp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x7dc7
leaq 0xd987(%rip), %rdi      # 0x15749
callq 0x3ce0
movq 0x1030(%rsp), %rax
movl $0x0, 0x20(%rax)
movq 0x1030(%rsp), %rax
movl $0x0, 0x24(%rax)
movq 0x1030(%rsp), %rax
movq $0x0, 0x8(%rax)
addq $0x1038, %rsp           # imm = 0x1038
retq
nopl (%rax)