// File: /workspace/github_c_makefile_star2_O3/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
xorl %eax, %eax
movq 0x403f(%rip), %rdx      # 0x70e0
xorl %ecx, %ecx
movl %eax, %esi
movb (%rdi,%rsi), %sil
testb %sil, %sil
je 0x326f
movslq %ecx, %r8
cmpb %sil, (%rdx,%r8)
jne 0x30c4
incl %ecx
movl $0x1, %esi
jmp 0x30d7
testl %eax, %eax
sete %sil
testl %ecx, %ecx
sete %cl
orb %sil, %cl
movzbl %cl, %esi
xorl %ecx, %ecx
addl %esi, %eax
cmpl $0x9, %ecx
jne 0x30a3
movq %rdi, -0x30(%rbp)
leaq 0x10a5(%rip), %r15      # 0x418e
leaq -0xa0(%rbp), %rbx
movq %r15, %rdi
movq %rbx, %rsi
movl $0x29, %edx
callq 0x328e
movq %rbx, %rdi
callq 0x32e1
leaq 0x1181(%rip), %r12      # 0x4290
leaq 0x1142(%rip), %rdx      # 0x4258
leaq -0x70(%rbp), %r14
movq %r14, %rdi
movq %r12, %rsi
movq %rbx, %rcx
xorl %eax, %eax
callq 0x1170
movq %r14, %rdi
callq 0x2c6b
leaq 0x1031(%rip), %rcx      # 0x416a
leaq -0x190(%rbp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rdx
xorl %eax, %eax
callq 0x1170
leaq 0x100b(%rip), %r13      # 0x4162
movq %r13, %rdi
movq %rbx, %rsi
callq 0x3363
leaq 0x102d(%rip), %rcx      # 0x4196
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 0x3363
leaq 0xffa(%rip), %rsi       # 0x418c
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 0x3211
leaq -0x390(%rbp), %r13
leaq 0x113f(%rip), %r14      # 0x4303
leaq -0xf0(%rbp), %rbx
leaq -0x70(%rbp), %r12
movq %r13, %rdi
leaq 0x11d5(%rip), %rsi      # 0x43ae
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 0x3363
movq %r13, %rdi
movl $0x200, %esi            # imm = 0x200
movq %r15, %rdx
callq 0x10b0
testq %rax, %rax
jne 0x31cf
leaq 0x10eb(%rip), %rsi      # 0x4303
leaq 0x1077(%rip), %rcx      # 0x4296
leaq -0xf0(%rbp), %rbx
leaq -0x70(%rbp), %rdx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x1170
movq %rbx, %rdi
movq -0x30(%rbp), %rsi
callq 0x2caf
leaq 0xf47(%rip), %rdi       # 0x418e
leaq -0xa0(%rbp), %rsi
callq 0x2caf
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
movq 0x3d82(%rip), %rax      # 0x6ff8
movq (%rax), %rdi
leaq 0xfb6(%rip), %rsi       # 0x4236
xorl %eax, %eax
callq 0x10d0
movl $0x1, %eax
jmp 0x325d