#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ fs_mkdir(char *);
int /*<<< orphan*/ write_string_to_file(char *, char *);
int beargit_init(void) {
  fs_mkdir(".beargit");
  FILE *findex = fopen(".beargit/.index", "w");
  fclose(findex);
  FILE *fbranches = fopen(".beargit/.branches", "w");
  fprintf(fbranches, "%s\n", "master");
  fclose(fbranches);
  write_string_to_file(".beargit/.prev",
                       "0000000000000000000000000000000000000000");
  write_string_to_file(".beargit/.current_branch", "master");
  return 0;
}


x86 assembly (clang, -O0):
<beargit_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xea1(%rip),%rdi
call   1040 <fs_mkdir@plt>
lea    0xe9e(%rip),%rdi
lea    0xea7(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xe90(%rip),%rdi
lea    0xe87(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe88(%rip),%rsi
lea    0xe85(%rip),%rdx
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xe77(%rip),%rdi
lea    0xe7f(%rip),%rsi
call   1070 <write_string_to_file@plt>
lea    0xe9c(%rip),%rdi
lea    0xe56(%rip),%rsi
call   1070 <write_string_to_file@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<beargit_init>:
push   %r14
push   %rbx
push   %rax
lea    0xea5(%rip),%rdi
call   1040 <fs_mkdir@plt>
lea    0xea2(%rip),%rdi
lea    0xeab(%rip),%rbx
mov    %rbx,%rsi
call   1060 <fopen@plt>
mov    %rax,%rdi
call   1030 <fclose@plt>
lea    0xe96(%rip),%rdi
mov    %rbx,%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
lea    0xe97(%rip),%rsi
lea    0xe94(%rip),%r14
mov    %rax,%rdi
mov    %r14,%rdx
call   1050 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
lea    0xe81(%rip),%rdi
lea    0xe89(%rip),%rsi
call   1070 <write_string_to_file@plt>
lea    0xea6(%rip),%rdi
mov    %r14,%rsi
call   1070 <write_string_to_file@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [9 x i8] c".beargit\00"
@.str.1 = [16 x i8] c".beargit/.index\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [19 x i8] c".beargit/.branches\00"
@.str.4 = [4 x i8] c"%s\0A\00"
@.str.5 = [7 x i8] c"master\00"
@.str.6 = [15 x i8] c".beargit/.prev\00"
@.str.7 = [41 x i8] c"0000000000000000000000000000000000000000\00"
@.str.8 = [25 x i8] c".beargit/.current_branch\00"
define i32 @beargit_init() {
%1 = alloca i32*
%2 = alloca i32*
%3 = call i32 @fs_mkdir(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%4 = call i32* @fopen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %4, i32** %1
%5 = load i32*, i32** %1
%6 = call i32 @fclose(i32* %5)
%7 = call i32* @fopen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %7, i32** %2
%8 = load i32*, i32** %2
%9 = call i32 @fprintf(i32* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%10 = load i32*, i32** %2
%11 = call i32 @fclose(i32* %10)
%12 = call i32 @write_string_to_file(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.7, i64 0, i64 0))
%13 = call i32 @write_string_to_file(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c".beargit\00"
@.str.1 = [16 x i8] c".beargit/.index\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [19 x i8] c".beargit/.branches\00"
@.str.4 = [4 x i8] c"%s\0A\00"
@.str.5 = [7 x i8] c"master\00"
@.str.6 = [15 x i8] c".beargit/.prev\00"
@.str.7 = [41 x i8] c"0000000000000000000000000000000000000000\00"
@.str.8 = [25 x i8] c".beargit/.current_branch\00"
define i32 @beargit_init() {
%1 = tail call i32 @fs_mkdir(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%3 = tail call i32 @fclose(i32* %2)
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%5 = tail call i32 @fprintf(i32* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%6 = tail call i32 @fclose(i32* %4)
%7 = tail call i32 @write_string_to_file(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.7, i64 0, i64 0))
%8 = tail call i32 @write_string_to_file(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}