#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 /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ read_string_from_file(char *, char *, int);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
scalar_t__ strcmp(char *, char *);
int beargit_log() {
  char last_commit[(40 + 1)];
  int index = 0;
  int checker = 10;
  read_string_from_file(".beargit/.prev", last_commit, (40 + 1));
  while (strcmp(last_commit, "0000000000000000000000000000000000000000") != 0) {
    char content[100];
    fprintf(stdout, "\ncommit %s", last_commit);
    checker = 50;
    sprintf(content, "%s%s%s", ".beargit/", last_commit, "/.msg");
    read_string_from_file(content, content, 120);
    char lastSource[100];
    fprintf(stdout, "\n    %s\n", content);
    sprintf(lastSource, "%s%s%s", ".beargit/", last_commit, "/.prev");
    read_string_from_file(lastSource, last_commit, (40 + 1));
  }
  if (checker == 10) {
    fprintf(stderr, "ERROR: There are no commits!\n");
    return 1;
  }
  if (checker == 50)
    fprintf(stdout, "\n");
  return 0;
}


x86 assembly (clang, -O0):
<beargit_log>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
movl   $0x0,-0x34(%rbp)
movl   $0xa,-0x38(%rbp)
lea    -0x30(%rbp),%rsi
lea    0xe9c(%rip),%rdi
mov    $0x29,%edx
call   1050 <read_string_from_file@plt>
lea    -0x30(%rbp),%rdi
lea    0xe96(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     1244 <beargit_log+0x104>
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
lea    -0x30(%rbp),%rdx
lea    0xe9c(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x32,-0x38(%rbp)
lea    -0xa0(%rbp),%rdi
lea    -0x30(%rbp),%rcx
lea    0xe87(%rip),%rsi
lea    0xe87(%rip),%rdx
lea    0xe8a(%rip),%r8
call   1060 <sprintf@plt>
lea    -0xa0(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
mov    $0x78,%edx
call   1050 <read_string_from_file@plt>
mov    0x2dea(%rip),%rax
mov    (%rax),%edi
lea    -0xa0(%rbp),%rdx
lea    0xe5c(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
lea    -0x110(%rbp),%rdi
lea    -0x30(%rbp),%rcx
lea    0xe2c(%rip),%rsi
lea    0xe2c(%rip),%rdx
lea    0xde3(%rip),%r8
call   1060 <sprintf@plt>
lea    -0x110(%rbp),%rdi
lea    -0x30(%rbp),%rsi
mov    $0x29,%edx
call   1050 <read_string_from_file@plt>
jmp    116e <beargit_log+0x2e>
cmpl   $0xa,-0x38(%rbp)
jne    1271 <beargit_log+0x131>
mov    0x2d8b(%rip),%rax
mov    (%rax),%edi
lea    0xe05(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1299 <beargit_log+0x159>
cmpl   $0x32,-0x38(%rbp)
jne    1292 <beargit_log+0x152>
mov    0x2d56(%rip),%rax
mov    (%rax),%edi
lea    0xdf4(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<beargit_log>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
lea    0xea8(%rip),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
mov    $0x29,%edx
call   1050 <read_string_from_file@plt>
lea    0xe9e(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
mov    $0x1,%ebx
lea    0xede(%rip),%rsi
mov    0x2e54(%rip),%rcx
test   %rax,%rax
je     1287 <beargit_log+0x147>
mov    %rax,0x8(%rsp)
mov    0x2e37(%rip),%r15
lea    0x10(%rsp),%rbp
lea    0xe96(%rip),%rbx
lea    0xe96(%rip),%r14
lea    0xb0(%rsp),%r12
lea    0x40(%rsp),%r13
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r15),%edi
lea    0xe5e(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %rbp,%rcx
lea    0xe5d(%rip),%r8
call   1060 <sprintf@plt>
mov    %r12,%rdi
mov    %r12,%rsi
mov    $0x78,%edx
call   1050 <read_string_from_file@plt>
mov    (%r15),%edi
lea    0xe44(%rip),%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %rbp,%rcx
lea    0xdd5(%rip),%r8
call   1060 <sprintf@plt>
mov    %r13,%rdi
mov    %rbp,%rsi
mov    $0x29,%edx
call   1050 <read_string_from_file@plt>
mov    %rbp,%rdi
lea    0xdbd(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
jne    11d0 <beargit_log+0x90>
cmpq   $0x0,0x8(%rsp)
mov    $0x1,%ebx
lea    0xdf1(%rip),%rsi
mov    0x2d67(%rip),%rcx
je     1287 <beargit_log+0x147>
xor    %ebx,%ebx
lea    0xdfb(%rip),%rsi
mov    %r15,%rcx
mov    (%rcx),%edi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    %ebx,%eax
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c".beargit/.prev\00"
@.str.1 = [41 x i8] c"0000000000000000000000000000000000000000\00"
@stdout = global i32 0
@.str.2 = [11 x i8] c"\0Acommit %s\00"
@.str.3 = [7 x i8] c"%s%s%s\00"
@.str.4 = [10 x i8] c".beargit/\00"
@.str.5 = [6 x i8] c"/.msg\00"
@.str.6 = [9 x i8] c"\0A %s\0A\00"
@.str.7 = [7 x i8] c"/.prev\00"
@stderr = global i32 0
@.str.8 = [30 x i8] c"ERROR: There are no commits!\0A\00"
@.str.9 = [2 x i8] c"\0A\00"
define i32 @beargit_log() {
%1 = alloca i32
%2 = alloca [41 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca [100 x i8]
%6 = alloca [100 x i8]
store i32 0, i32* %3
store i32 10, i32* %4
%7 = getelementptr inbounds [41 x i8], [41 x i8]* %2, i64 0, i64 0
%8 = call i32 @read_string_from_file(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %7, i32 41)
br label %9
9: ; preds = %13, %0
%10 = getelementptr inbounds [41 x i8], [41 x i8]* %2, i64 0, i64 0
%11 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %32
13: ; preds = %9
%14 = load i32, i32* @stdout
%15 = getelementptr inbounds [41 x i8], [41 x i8]* %2, i64 0, i64 0
%16 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %15)
store i32 50, i32* %4
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%18 = getelementptr inbounds [41 x i8], [41 x i8]* %2, i64 0, i64 0
%19 = call i32 @sprintf(i8* %17, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %18, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%22 = call i32 @read_string_from_file(i8* %20, i8* %21, i32 120)
%23 = load i32, i32* @stdout
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i8* %24)
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%27 = getelementptr inbounds [41 x i8], [41 x i8]* %2, i64 0, i64 0
%28 = call i32 @sprintf(i8* %26, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %27, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%30 = getelementptr inbounds [41 x i8], [41 x i8]* %2, i64 0, i64 0
%31 = call i32 @read_string_from_file(i8* %29, i8* %30, i32 41)
br label %9
32: ; preds = %9
%33 = load i32, i32* %4
%34 = icmp eq i32 %33, 10
br i1 %34, label %35, label %38
35: ; preds = %32
%36 = load i32, i32* @stderr
%37 = call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0))
store i32 1, i32* %1
br label %45
38: ; preds = %32
%39 = load i32, i32* %4
%40 = icmp eq i32 %39, 50
br i1 %40, label %41, label %44
41: ; preds = %38
%42 = load i32, i32* @stdout
%43 = call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
br label %44
44: ; preds = %41, %38
store i32 0, i32* %1
br label %45
45: ; preds = %44, %35
%46 = load i32, i32* %1
ret i32 %46
}

LLVM IR (-O2):
@.str = [15 x i8] c".beargit/.prev\00"
@.str.1 = [41 x i8] c"0000000000000000000000000000000000000000\00"
@stdout = global i32 0
@.str.2 = [11 x i8] c"\0Acommit %s\00"
@.str.3 = [7 x i8] c"%s%s%s\00"
@.str.4 = [10 x i8] c".beargit/\00"
@.str.5 = [6 x i8] c"/.msg\00"
@.str.6 = [9 x i8] c"\0A %s\0A\00"
@.str.7 = [7 x i8] c"/.prev\00"
@stderr = global i32 0
@.str.8 = [30 x i8] c"ERROR: There are no commits!\0A\00"
@.str.9 = [2 x i8] c"\0A\00"
define i32 @beargit_log() {
%1 = alloca [41 x i8]
%2 = alloca [100 x i8]
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [41 x i8], [41 x i8]* %1, i64 0, i64 0
%5 = call i32 @read_string_from_file(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %4, i32 41)
%6 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %24, label %8
8: ; preds = %0
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
br label %11
11: ; preds = %8, %11
%12 = load i32, i32* @stdout
%13 = call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%14 = call i32 @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%15 = call i32 @read_string_from_file(i8* %9, i8* %9, i32 120)
%16 = load i32, i32* @stdout
%17 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i8* %9)
%18 = call i32 @sprintf(i8* %10, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%19 = call i32 @read_string_from_file(i8* %10, i8* %4, i32 41)
%20 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %11
22: ; preds = %11
br i1 %7, label %24, label %23
23: ; preds = %22
br label %24
24: ; preds = %22, %0, %23
%25 = phi i32* [ @stdout, %23 ], [ @stderr, %0 ], [ @stderr, %22 ]
%26 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), %23 ], [ getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0), %0 ], [ getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0), %22 ]
%27 = phi i32 [ 0, %23 ], [ 1, %0 ], [ 1, %22 ]
%28 = load i32, i32* %25
%29 = call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* %26)
ret i32 %27
}