#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int beargit_commit_hw1(char const *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ read_string_from_file(char *, char *, int);
int /*<<< orphan*/ stderr;
scalar_t__ strlen(char *);
int beargit_commit(const char *msg) {
  char current_branch[128];
  read_string_from_file(".beargit/.current_branch", current_branch, 128);
  if (strlen(current_branch) == 0) {
    fprintf(stderr, "ERROR: Need to be on HEAD of a branch to commit\n");
    return 1;
  }
  return beargit_commit_hw1(msg);
}


x86 assembly (clang, -O0):
<beargit_commit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x90(%rbp),%rsi
lea    0xea3(%rip),%rdi
mov    $0x80,%edx
call   1060 <read_string_from_file@plt>
lea    -0x90(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%rax
jne    119e <beargit_commit+0x5e>
mov    0x2e5c(%rip),%rax
mov    (%rax),%edi
lea    0xe8c(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11aa <beargit_commit+0x6a>
mov    -0x10(%rbp),%rdi
call   1050 <beargit_commit_hw1@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<beargit_commit>:
push   %rbx
sub    $0x80,%rsp
mov    %rdi,%rbx
lea    0xebe(%rip),%rdi
mov    %rsp,%rsi
mov    $0x80,%edx
call   1050 <read_string_from_file@plt>
cmpb   $0x0,(%rsp)
je     115f <beargit_commit+0x2f>
mov    %rbx,%rdi
call   1040 <beargit_commit_hw1@plt>
jmp    1179 <beargit_commit+0x49>
mov    0x2e7a(%rip),%rax
mov    (%rax),%edi
lea    0xeaa(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%eax
add    $0x80,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [25 x i8] c".beargit/.current_branch\00"
@stderr = global i32 0
@.str.1 = [49 x i8] c"ERROR: Need to be on HEAD of a branch to commit\0A\00"
define i32 @beargit_commit(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [128 x i8]
store i8* %0, i8** %3
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%6 = call i32 @read_string_from_file(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %5, i32 128)
%7 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%8 = call i64 @strlen(i8* %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %1
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %2
br label %16
13: ; preds = %1
%14 = load i8*, i8** %3
%15 = call i32 @beargit_commit_hw1(i8* %14)
store i32 %15, i32* %2
br label %16
16: ; preds = %13, %10
%17 = load i32, i32* %2
ret i32 %17
}

LLVM IR (-O2):
@.str = [25 x i8] c".beargit/.current_branch\00"
@stderr = global i32 0
@.str.1 = [49 x i8] c"ERROR: Need to be on HEAD of a branch to commit\0A\00"
define i32 @beargit_commit(i8* %0) {
%2 = alloca [128 x i8]
%3 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%4 = call i32 @read_string_from_file(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %3, i32 128)
%5 = load i8, i8* %3
%6 = icmp eq i8 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = load i32, i32* @stderr
%9 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0))
br label %12
10: ; preds = %1
%11 = call i32 @beargit_commit_hw1(i8* %0)
br label %12
12: ; preds = %10, %7
%13 = phi i32 [ 1, %7 ], [ %11, %10 ]
ret i32 %13
}