// File: /workspace/github_c_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x368, %rsp            # imm = 0x368
movq %rdi, %rbx
callq 0x2476
testl %eax, %eax
je 0x26d9
movq %rbx, -0x30(%rbp)
leaq 0x1c24(%rip), %r15      # 0x418e
leaq -0xa0(%rbp), %rbx
pushq $0x29
popq %rdx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x26fd
movq %rbx, %rdi
callq 0x287b
leaq 0x1d02(%rip), %r12      # 0x4290
leaq 0x1cc3(%rip), %rdx      # 0x4258
leaq -0x70(%rbp), %r13
movq %r13, %rdi
movq %r12, %rsi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x1170
movq %r13, %rdi
callq 0x16ff
leaq 0x1bb2(%rip), %rcx      # 0x416a
leaq -0x190(%rbp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
xorl %eax, %eax
callq 0x1170
leaq 0x1b8c(%rip), %r14      # 0x4162
movq %r14, %rdi
movq %rbx, %rsi
callq 0x28e9
leaq 0x1bae(%rip), %rcx      # 0x4196
leaq -0x140(%rbp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
xorl %eax, %eax
callq 0x1170
movq %r15, %rdi
movq %rbx, %rsi
callq 0x28e9
leaq 0x1b7b(%rip), %rsi      # 0x418c
movq %r14, %rdi
callq 0x1120
movq %rax, %r15
leaq -0x390(%rbp), %r12
leaq 0x1d84(%rip), %r13      # 0x43ae
leaq 0x1cd2(%rip), %rbx      # 0x4303
leaq -0xf0(%rbp), %r14
movq %r12, %rdi
movl $0x200, %esi            # imm = 0x200
movq %r15, %rdx
callq 0x10b0
testq %rax, %rax
je 0x2679
movq %r12, %rdi
movq %r13, %rsi
callq 0x1130
movq %r14, %rdi
movq %rbx, %rsi
leaq -0x70(%rbp), %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x1170
movq %r12, %rdi
movq %r14, %rsi
callq 0x28e9
jmp 0x2638
leaq 0x1c83(%rip), %rsi      # 0x4303
leaq 0x1c0f(%rip), %rcx      # 0x4296
xorl %ebx, %ebx
leaq -0xf0(%rbp), %r14
leaq -0x70(%rbp), %rdx
movq %r14, %rdi
xorl %eax, %eax
callq 0x1170
movq %r14, %rdi
movq -0x30(%rbp), %rsi
callq 0x1a45
leaq 0x1add(%rip), %rdi      # 0x418e
leaq -0xa0(%rbp), %rsi
callq 0x1a45
movq %r15, %rdi
callq 0x1070
movl %ebx, %eax
addq $0x368, %rsp            # imm = 0x368
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x4918(%rip), %rax      # 0x6ff8
movq (%rax), %rdi
movq 0x49f6(%rip), %rdx      # 0x70e0
leaq 0x1b45(%rip), %rsi      # 0x4236
xorl %eax, %eax
callq 0x10d0
pushq $0x1
popq %rbx
jmp 0x26c5