#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 *, char *);
int /*<<< orphan*/ read_string_from_file(char *, char *, int);
int /*<<< orphan*/ stdout;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strtok(char *, char *);
int beargit_branch() {
  char current_branch[128];
  read_string_from_file(".beargit/.current_branch", current_branch, 128);
  FILE *findex = fopen(".beargit/.branches", "r");
  char line[128];
  while (fgets(line, sizeof(line), findex)) {
    strtok(line, "\n");
    if (strcmp(line, current_branch) != 0) {
      fprintf(stdout, "%s", "  ");
      fprintf(stdout, "%s\n", line);
    } else {
      fprintf(stdout, "%s", "* ");
      fprintf(stdout, "%s\n", line);
    }
  }
  fclose(findex);
  return 0;
}


x86 assembly (clang, -O0):
<beargit_branch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
lea    -0x80(%rbp),%rsi
lea    0xe7a(%rip),%rdi
mov    $0x80,%edx
call   1090 <read_string_from_file@plt>
lea    0xe82(%rip),%rdi
lea    0xe8e(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x88(%rbp)
lea    -0x110(%rbp),%rdi
mov    -0x88(%rbp),%rdx
mov    $0x80,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     1273 <beargit_branch+0x103>
lea    -0x110(%rbp),%rdi
lea    0xe5c(%rip),%rsi
call   1080 <strtok@plt>
lea    -0x110(%rbp),%rdi
lea    -0x80(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     1236 <beargit_branch+0xc6>
mov    0x2de0(%rip),%rax
mov    (%rax),%edi
lea    0xe25(%rip),%rsi
lea    0xe21(%rip),%rdx
call   1060 <fprintf@plt>
mov    0x2dc4(%rip),%rax
mov    (%rax),%edi
lea    -0x110(%rbp),%rdx
lea    0xe08(%rip),%rsi
call   1060 <fprintf@plt>
jmp    126e <beargit_branch+0xfe>
mov    0x2da3(%rip),%rax
mov    (%rax),%edi
lea    0xde8(%rip),%rsi
lea    0xdeb(%rip),%rdx
call   1060 <fprintf@plt>
mov    0x2d87(%rip),%rax
mov    (%rax),%edi
lea    -0x110(%rbp),%rdx
lea    0xdcb(%rip),%rsi
call   1060 <fprintf@plt>
jmp    11aa <beargit_branch+0x3a>
mov    -0x88(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<beargit_branch>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
lea    0xe78(%rip),%rdi
lea    0x80(%rsp),%rsi
mov    $0x80,%edx
call   1090 <read_string_from_file@plt>
lea    0xe78(%rip),%rdi
lea    0xe84(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r15
mov    %rsp,%rdi
mov    $0x80,%esi
mov    %rax,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     124e <beargit_branch+0xde>
mov    %rsp,%rbx
mov    0x2e0d(%rip),%r14
lea    0xe57(%rip),%r12
lea    0xe4d(%rip),%r13
lea    0xe4c(%rip),%rbp
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
lea    0xe3c(%rip),%rsi
call   1080 <strtok@plt>
mov    %rbx,%rdi
lea    0x80(%rsp),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
mov    (%r14),%edi
mov    %r12,%rdx
lea    0xe19(%rip),%rax
cmove  %rax,%rdx
mov    %r13,%rsi
call   1060 <fprintf@plt>
mov    (%r14),%edi
mov    %rbp,%rsi
mov    %rbx,%rdx
call   1060 <fprintf@plt>
mov    %rbx,%rdi
mov    $0x80,%esi
mov    %r15,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
jne    11f0 <beargit_branch+0x80>
mov    %r15,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c".beargit/.current_branch\00"
@.str.1 = [19 x i8] c".beargit/.branches\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [2 x i8] c"\0A\00"
@stdout = global i32 0
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [3 x i8] c" \00"
@.str.6 = [4 x i8] c"%s\0A\00"
@.str.7 = [3 x i8] c"* \00"
define i32 @beargit_branch() {
%1 = alloca [128 x i8]
%2 = alloca i32*
%3 = alloca [128 x i8]
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 0
%5 = call i32 @read_string_from_file(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %4, i32 128)
%6 = call i32* @fopen(i8* getelementptr inbounds ([19 x i8], [19 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* %6, i32** %2
br label %7
7: ; preds = %31, %0
%8 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%9 = load i32*, i32** %2
%10 = call i64 @fgets(i8* %8, i32 128, i32* %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %32
12: ; preds = %7
%13 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%14 = call i32 @strtok(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%15 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%16 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 0
%17 = call i64 @strcmp(i8* %15, i8* %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %25
19: ; preds = %12
%20 = load i32, i32* @stdout
%21 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%22 = load i32, i32* @stdout
%23 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%24 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %23)
br label %31
25: ; preds = %12
%26 = load i32, i32* @stdout
%27 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%28 = load i32, i32* @stdout
%29 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%30 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %29)
br label %31
31: ; preds = %25, %19
br label %7
32: ; preds = %7
%33 = load i32*, i32** %2
%34 = call i32 @fclose(i32* %33)
ret i32 0
}

LLVM IR (-O2):
@.str = [25 x i8] c".beargit/.current_branch\00"
@.str.1 = [19 x i8] c".beargit/.branches\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [2 x i8] c"\0A\00"
@stdout = global i32 0
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [3 x i8] c" \00"
@.str.6 = [4 x i8] c"%s\0A\00"
@.str.7 = [3 x i8] c"* \00"
define i32 @beargit_branch() {
%1 = alloca [128 x i8]
%2 = alloca [128 x i8]
%3 = getelementptr inbounds [128 x i8], [128 x i8]* %1, 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 = call i32* @fopen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%6 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%7 = call i64 @fgets(i8* %6, i32 128, i32* %5)
%8 = icmp eq i64 %7, 0
br i1 %8, label %20, label %9
9: ; preds = %0, %9
%10 = call i32 @strtok(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%11 = call i64 @strcmp(i8* %6, i8* %3)
%12 = icmp eq i64 %11, 0
%13 = load i32, i32* @stdout
%14 = select i1 %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0)
%15 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %14)
%16 = load i32, i32* @stdout
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %6)
%18 = call i64 @fgets(i8* %6, i32 128, i32* %5)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %9
20: ; preds = %9, %0
%21 = call i32 @fclose(i32* %5)
ret i32 0
}