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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strtok(char *, char *);
int beargit_status() {
  FILE *findex = fopen(".beargit/.index", "r");
  char line[512];
  int counter = 0;
  fprintf(stdout, "%s\n", "Tracked files:");
  while (fgets(line, sizeof(line), findex)) {
    counter++;
    strtok(line, "\n");
    printf("\n");
    fprintf(stdout, "%s", "  ");
    fprintf(stdout, "%s", line);
  }
  fprintf(stdout, "\n\n");
  fprintf(stdout, "%d", counter);
  fprintf(stdout, "%s", " ");
  fprintf(stdout, "%s\n", "files total");
  fclose(findex);
  return 0;
}


x86 assembly (clang, -O0):
<beargit_status>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
lea    0xe8e(%rip),%rdi
lea    0xe97(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x8(%rbp)
movl   $0x0,-0x214(%rbp)
mov    0x2e4d(%rip),%rax
mov    (%rax),%edi
lea    0xe76(%rip),%rsi
lea    0xe73(%rip),%rdx
mov    $0x0,%al
call   1060 <fprintf@plt>
lea    -0x210(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x200,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     1238 <beargit_status+0xd8>
mov    -0x214(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x214(%rbp)
lea    -0x210(%rbp),%rdi
lea    0xe46(%rip),%rsi
call   1080 <strtok@plt>
lea    0xe3a(%rip),%rdi
call   1040 <printf@plt>
mov    0x2de2(%rip),%rax
mov    (%rax),%edi
lea    0xe1e(%rip),%rsi
lea    0xe1a(%rip),%rdx
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2dc4(%rip),%rax
mov    (%rax),%edi
lea    -0x210(%rbp),%rdx
lea    0xdf9(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    11aa <beargit_status+0x4a>
mov    0x2da1(%rip),%rax
mov    (%rax),%edi
lea    0xde3(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2d8a(%rip),%rax
mov    (%rax),%edi
mov    -0x214(%rbp),%edx
lea    0xdc9(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2d6d(%rip),%rax
mov    (%rax),%edi
lea    0xda9(%rip),%rsi
lea    0xda6(%rip),%rdx
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2d4f(%rip),%rax
mov    (%rax),%edi
lea    0xd78(%rip),%rsi
lea    0xd90(%rip),%rdx
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<beargit_status>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x208,%rsp
lea    0xe88(%rip),%rdi
lea    0xe91(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r15
mov    0x2e52(%rip),%r14
mov    (%r14),%edi
lea    0xe7a(%rip),%rsi
lea    0xe77(%rip),%rdx
xor    %ebp,%ebp
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %rsp,%rdi
mov    $0x200,%esi
mov    %r15,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     1221 <beargit_status+0xc1>
mov    %rsp,%rbx
lea    0xe5e(%rip),%r12
lea    0xe5a(%rip),%r13
xor    %ebp,%ebp
add    $0x1,%ebp
mov    %rbx,%rdi
lea    0xe4f(%rip),%rsi
call   1080 <strtok@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    (%r14),%edi
mov    %r12,%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    (%r14),%edi
mov    %r12,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %rbx,%rdi
mov    $0x200,%esi
mov    %r15,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
jne    11d0 <beargit_status+0x70>
mov    (%r14),%edi
lea    0xe00(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    (%r14),%edi
lea    0xdf2(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    (%r14),%edi
lea    0xdd6(%rip),%rsi
lea    0xdd3(%rip),%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    (%r14),%edi
lea    0xdab(%rip),%rsi
lea    0xdc3(%rip),%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x208,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c".beargit/.index\00"
@.str.1 = [2 x i8] c"r\00"
@stdout = global i32 0
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [15 x i8] c"Tracked files:\00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [3 x i8] c"%s\00"
@.str.6 = [3 x i8] c" \00"
@.str.7 = [3 x i8] c"\0A\0A\00"
@.str.8 = [3 x i8] c"%d\00"
@.str.9 = [2 x i8] c" \00"
@.str.10 = [12 x i8] c"files total\00"
define i32 @beargit_status() {
%1 = alloca i32*
%2 = alloca [512 x i8]
%3 = alloca i32
%4 = call i32* @fopen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %4, i32** %1
store i32 0, i32* %3
%5 = load i32, i32* @stdout
%6 = call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
br label %7
7: ; preds = %12, %0
%8 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%9 = load i32*, i32** %1
%10 = call i64 @fgets(i8* %8, i32 512, i32* %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %23
12: ; preds = %7
%13 = load i32, i32* %3
%14 = add nsw i32 %13, 1
store i32 %14, i32* %3
%15 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%16 = call i32 @strtok(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%17 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%18 = load i32, i32* @stdout
%19 = call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%20 = load i32, i32* @stdout
%21 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %21)
br label %7
23: ; preds = %7
%24 = load i32, i32* @stdout
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%26 = load i32, i32* @stdout
%27 = load i32, i32* %3
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32 %27)
%29 = load i32, i32* @stdout
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%31 = load i32, i32* @stdout
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
%33 = load i32*, i32** %1
%34 = call i32 @fclose(i32* %33)
ret i32 0
}

LLVM IR (-O2):
@.str = [16 x i8] c".beargit/.index\00"
@.str.1 = [2 x i8] c"r\00"
@stdout = global i32 0
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [15 x i8] c"Tracked files:\00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [3 x i8] c"%s\00"
@.str.6 = [3 x i8] c" \00"
@.str.7 = [3 x i8] c"\0A\0A\00"
@.str.8 = [3 x i8] c"%d\00"
@.str.9 = [2 x i8] c" \00"
@.str.10 = [12 x i8] c"files total\00"
define i32 @beargit_status() {
%1 = alloca [512 x i8]
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%3 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%4 = load i32, i32* @stdout
%5 = tail call i32 (i32, i8*, ...) @fprintf(i32 %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%6 = call i64 @fgets(i8* %3, i32 512, i32* %2)
%7 = icmp eq i64 %6, 0
br i1 %7, label %19, label %8
8: ; preds = %0, %8
%9 = phi i32 [ %10, %8 ], [ 0, %0 ]
%10 = add nuw nsw i32 %9, 1
%11 = call i32 @strtok(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%12 = call i32 @putchar(i32 10)
%13 = load i32, i32* @stdout
%14 = call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%15 = load i32, i32* @stdout
%16 = call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %3)
%17 = call i64 @fgets(i8* %3, i32 512, i32* %2)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %8
19: ; preds = %8, %0
%20 = phi i32 [ 0, %0 ], [ %10, %8 ]
%21 = load i32, i32* @stdout
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%23 = load i32, i32* @stdout
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32 %20)
%25 = load i32, i32* @stdout
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%27 = load i32, i32* @stdout
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
%29 = call i32 @fclose(i32* %2)
ret i32 0
}