// File: /workspace/github_c_makefile_star2_O1/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 0x306d
testl %eax, %eax
je 0x32dc
movq %rbx, -0x30(%rbp)
leaq 0x103e(%rip), %r15      # 0x4194
leaq -0xa0(%rbp), %rbx
movq %r15, %rdi
movq %rbx, %rsi
movl $0x29, %edx
callq 0x32e8
movq %rbx, %rdi
callq 0x333b
leaq 0x111a(%rip), %r12      # 0x4296
leaq 0x10db(%rip), %rdx      # 0x425e
leaq -0x70(%rbp), %r14
movq %r14, %rdi
movq %r12, %rsi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x1170
movq %r14, %rdi
callq 0x2d1f
leaq 0xfca(%rip), %rcx       # 0x4170
leaq -0x190(%rbp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x1170
leaq 0xfa4(%rip), %r13       # 0x4168
movq %r13, %rdi
movq %rbx, %rsi
callq 0x33bd
leaq 0xfc6(%rip), %rcx       # 0x419c
leaq -0x140(%rbp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x1170
movq %r15, %rdi
movq %rbx, %rsi
callq 0x33bd
leaq 0xf93(%rip), %rsi       # 0x4192
movq %r13, %rdi
callq 0x1120
movq %rax, %r15
leaq -0x390(%rbp), %rdi
movl $0x200, %esi            # imm = 0x200
movq %rax, %rdx
callq 0x10b0
testq %rax, %rax
je 0x327e
leaq -0x390(%rbp), %r13
leaq 0x10d8(%rip), %r14      # 0x4309
leaq -0xf0(%rbp), %rbx
leaq -0x70(%rbp), %r12
movq %r13, %rdi
leaq 0x116e(%rip), %rsi      # 0x43b4
callq 0x1130
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %r13, %rcx
xorl %eax, %eax
callq 0x1170
movq %r13, %rdi
movq %rbx, %rsi
callq 0x33bd
movq %r13, %rdi
movl $0x200, %esi            # imm = 0x200
movq %r15, %rdx
callq 0x10b0
testq %rax, %rax
jne 0x323c
leaq 0x1084(%rip), %rsi      # 0x4309
leaq 0x1010(%rip), %rcx      # 0x429c
leaq -0xf0(%rbp), %rbx
leaq -0x70(%rbp), %rdx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x1170
movq %rbx, %rdi
movq -0x30(%rbp), %rsi
callq 0x2d63
leaq 0xee0(%rip), %rdi       # 0x4194
leaq -0xa0(%rbp), %rsi
callq 0x2d63
movq %r15, %rdi
callq 0x1070
xorl %eax, %eax
addq $0x368, %rsp            # imm = 0x368
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x1f6a
movl $0x1, %eax
jmp 0x32ca