// File: /workspace/github_c_makefile_star2_O0/MicBrain[P]Git-Sample/beargit.c
// Function: beargit_commit_hw1
int beargit_commit_hw1(const char* msg) {
  if (!is_commit_msg_ok(msg)) {
    fprintf(stderr, "ERROR: Message must contain \"%s\"\n", go_bears);
    return 1;
  } else {
    char commit_id[COMMIT_ID_SIZE];
    read_string_from_file(".beargit/.prev", commit_id, COMMIT_ID_SIZE);
    next_commit_id(commit_id);
    char new_directory[COMMIT_ID_SIZE + 15];
    sprintf(new_directory, "%s%s", ".beargit/", commit_id);
    fs_mkdir(new_directory);
    char index_directory[COMMIT_ID_SIZE + 25];
    sprintf(index_directory, "%s%s", new_directory, "/.index");
    fs_cp(".beargit/.index", index_directory);
    char prev_directory[COMMIT_ID_SIZE + 25];
    sprintf(prev_directory, "%s%s", new_directory, "/.prev");
    fs_cp(".beargit/.prev", prev_directory);
    FILE* index_file = fopen(".beargit/.index", "r");
    char name_of_file[FILENAME_SIZE];
    while (fgets(name_of_file, sizeof(name_of_file), index_file)) {
      strtok(name_of_file, "\n");
      char current_file_dir[COMMIT_ID_SIZE + 25];
      sprintf(current_file_dir, "%s/%s", new_directory, name_of_file);
      fs_cp(name_of_file, current_file_dir);
    }
    char msg_filename[COMMIT_ID_SIZE + 25];
    sprintf(msg_filename, "%s/%s", new_directory, ".msg");
    write_string_to_file(msg_filename, msg);
    write_string_to_file(".beargit/.prev", commit_id);
    fclose(index_file);
    return 0;
  } 
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x3d0, %rsp            # imm = 0x3D0
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x3690
cmpl $0x0, %eax
jne 0x3898
movq 0x5784(%rip), %rax      # 0x8ff8
movq (%rax), %rdi
movq 0x5852(%rip), %rdx      # 0x90d0
leaq 0x29b7(%rip), %rsi      # 0x623c
movb $0x0, %al
callq 0x10c0
movl $0x1, -0x4(%rbp)
jmp 0x3a15
leaq -0x40(%rbp), %rsi
leaq 0x28f1(%rip), %rdi      # 0x6194
movl $0x29, %edx
callq 0x3a30
leaq -0x40(%rbp), %rdi
callq 0x3cc0
leaq -0x80(%rbp), %rdi
leaq -0x40(%rbp), %rcx
leaq 0x29d1(%rip), %rsi      # 0x6296
leaq 0x2992(%rip), %rdx      # 0x625e
movb $0x0, %al
callq 0x1150
leaq -0x80(%rbp), %rdi
callq 0x1810
leaq -0xd0(%rbp), %rdi
leaq -0x80(%rbp), %rdx
leaq 0x29a8(%rip), %rsi      # 0x6296
leaq 0x287b(%rip), %rcx      # 0x6170
movb $0x0, %al
callq 0x1150
leaq -0xd0(%rbp), %rsi
leaq 0x285e(%rip), %rdi      # 0x6168
callq 0x3d80
leaq -0x120(%rbp), %rdi
leaq -0x80(%rbp), %rdx
leaq 0x2975(%rip), %rsi      # 0x6296
leaq 0x2874(%rip), %rcx      # 0x619c
movb $0x0, %al
callq 0x1150
leaq -0x120(%rbp), %rsi
leaq 0x2857(%rip), %rdi      # 0x6194
callq 0x3d80
leaq 0x281f(%rip), %rdi      # 0x6168
leaq 0x2842(%rip), %rsi      # 0x6192
callq 0x1100
movq %rax, -0x128(%rbp)
leaq -0x330(%rbp), %rdi
movq -0x128(%rbp), %rdx
movl $0x200, %esi            # imm = 0x200
callq 0x10a0
cmpq $0x0, %rax
je 0x39c2
leaq -0x330(%rbp), %rdi
leaq 0x2a2c(%rip), %rsi      # 0x63b4
callq 0x1110
leaq -0x380(%rbp), %rdi
leaq -0x80(%rbp), %rdx
leaq -0x330(%rbp), %rcx
leaq 0x2963(%rip), %rsi      # 0x6309
movb $0x0, %al
callq 0x1150
leaq -0x330(%rbp), %rdi
leaq -0x380(%rbp), %rsi
callq 0x3d80
jmp 0x395c
leaq -0x3d0(%rbp), %rdi
leaq -0x80(%rbp), %rdx
leaq 0x2935(%rip), %rsi      # 0x6309
leaq 0x28c1(%rip), %rcx      # 0x629c
movb $0x0, %al
callq 0x1150
leaq -0x3d0(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x1f10
leaq -0x40(%rbp), %rsi
leaq 0x2797(%rip), %rdi      # 0x6194
callq 0x1f10
movq -0x128(%rbp), %rdi
callq 0x1060
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x3d0, %rsp            # imm = 0x3D0
popq %rbp
retq
nopw %cs:(%rax,%rax)