#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_add(char *);
int beargit_branch();
int beargit_checkout(char *, int);
int beargit_commit(char *);
int beargit_init();
int beargit_log();
int beargit_rm(char *);
int beargit_status();
int /*<<< orphan*/ check_filename(char *);
scalar_t__ check_initialized();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int strlen(char *);
int main(int argc, char **argv) {
  if (argc < 2) {
    fprintf(stderr, "Usage: %s <command> [<args>]\n", argv[0]);
    return 2;
  }
  if (strcmp(argv[1], "init") == 0) {
    if (check_initialized()) {
      fprintf(stderr, "ERROR: Repository is already initialized\n");
      return 1;
    }
    return beargit_init();
  } else {
    if (!check_initialized()) {
      fprintf(stderr, "ERROR: Repository is not initialized\n");
      return 1;
    }
    if (strcmp(argv[1], "add") == 0 || strcmp(argv[1], "rm") == 0) {
      if (argc < 3 || !check_filename(argv[2])) {
        fprintf(stderr, "ERROR: No or invalid filename given\n");
        return 1;
      }
      if (strcmp(argv[1], "rm") == 0) {
        return beargit_rm(argv[2]);
      } else {
        return beargit_add(argv[2]);
      }
    } else if (strcmp(argv[1], "commit") == 0) {
      if (argc < 4 || strcmp(argv[2], "-m") != 0) {
        fprintf(stderr, "ERROR: Need a commit message (-m <msg>)\n");
        return 1;
      }
      if (strlen(argv[3]) > 512 - 1) {
        fprintf(stderr, "ERROR: Message is too long!\n");
        return 1;
      }
      return beargit_commit(argv[3]);
    } else if (strcmp(argv[1], "status") == 0) {
      return beargit_status();
    } else if (strcmp(argv[1], "log") == 0) {
      return beargit_log();
    } else if (strcmp(argv[1], "branch") == 0) {
      return beargit_branch();
    } else if (strcmp(argv[1], "checkout") == 0) {
      int branch_new = 0;
      char *arg = NULL;
      for (int i = 2; i < argc; i++) {
        if (argv[i][0] == '-') {
          if (strcmp(argv[i], "-b") == 0) {
            branch_new = 1;
            continue;
          } else {
            fprintf(stderr, "ERROR: Invalid argument: %s", argv[i]);
            return 1;
          }
        }
        if (arg) {
          fprintf(stderr, "ERROR: Too many arguments for checkout!");
          return 1;
        }
        arg = argv[i];
      }
      return beargit_checkout(arg, branch_new);
    } else {
      fprintf(stderr, "ERROR: Unknown command \"%s\"\n", argv[1]);
      return 1;
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    121a <main+0x4a>
mov    0x2de9(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdf9(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    15f1 <main+0x421>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdf5(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    127b <main+0xab>
mov    $0x0,%al
call   1040 <check_initialized@plt>
cmp    $0x0,%rax
je     126c <main+0x9c>
mov    0x2d90(%rip),%rax
mov    (%rax),%edi
lea    0xdca(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    15f1 <main+0x421>
mov    $0x0,%al
call   1080 <beargit_init@plt>
mov    %eax,-0x4(%rbp)
jmp    15f1 <main+0x421>
mov    $0x0,%al
call   1040 <check_initialized@plt>
cmp    $0x0,%rax
jne    12af <main+0xdf>
mov    0x2d4d(%rip),%rax
mov    (%rax),%edi
lea    0xdb1(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    15f1 <main+0x421>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdb5(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     12eb <main+0x11b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd9b(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1376 <main+0x1a6>
cmpl   $0x3,-0x8(%rbp)
jl     130b <main+0x13b>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10e0 <check_filename@plt>
cmp    $0x0,%eax
jne    132e <main+0x15e>
mov    0x2cce(%rip),%rax
mov    (%rax),%edi
lea    0xd5f(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    15f1 <main+0x421>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd3a(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1361 <main+0x191>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10f0 <beargit_rm@plt>
mov    %eax,-0x4(%rbp)
jmp    15f1 <main+0x421>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10d0 <beargit_add@plt>
mov    %eax,-0x4(%rbp)
jmp    15f1 <main+0x421>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd1a(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    142f <main+0x25f>
cmpl   $0x4,-0x8(%rbp)
jl     13bc <main+0x1ec>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xcf9(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     13df <main+0x20f>
mov    0x2c1d(%rip),%rax
mov    (%rax),%edi
lea    0xcdd(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    15f1 <main+0x421>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1050 <strlen@plt>
cmp    $0x1ff,%eax
jle    141a <main+0x24a>
mov    0x2be2(%rip),%rax
mov    (%rax),%edi
lea    0xccb(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    15f1 <main+0x421>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   10b0 <beargit_commit@plt>
mov    %eax,-0x4(%rbp)
jmp    15f1 <main+0x421>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xcb1(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    145c <main+0x28c>
mov    $0x0,%al
call   10c0 <beargit_status@plt>
mov    %eax,-0x4(%rbp)
jmp    15f1 <main+0x421>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xc8b(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1489 <main+0x2b9>
mov    $0x0,%al
call   1060 <beargit_log@plt>
mov    %eax,-0x4(%rbp)
jmp    15f1 <main+0x421>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xc62(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    14b6 <main+0x2e6>
mov    $0x0,%al
call   1030 <beargit_branch@plt>
mov    %eax,-0x4(%rbp)
jmp    15f1 <main+0x421>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xc3c(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    15cb <main+0x3fb>
movl   $0x0,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x2,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    15b7 <main+0x3e7>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    156b <main+0x39b>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xbe9(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    153c <main+0x36c>
movl   $0x1,-0x14(%rbp)
jmp    15a9 <main+0x3d9>
mov    0x2a9d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xbb5(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    15f1 <main+0x421>
cmpq   $0x0,-0x20(%rbp)
je     1599 <main+0x3c9>
mov    0x2a63(%rip),%rax
mov    (%rax),%edi
lea    0xba3(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    15f1 <main+0x421>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    14ea <main+0x31a>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   10a0 <beargit_checkout@plt>
mov    %eax,-0x4(%rbp)
jmp    15f1 <main+0x421>
mov    0x2a0e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xb6e(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r15
cmp    $0x1,%edi
jg     1204 <main+0x34>
mov    0x2df9(%rip),%rax
mov    (%rax),%edi
mov    (%r15),%rdx
lea    0xe0d(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x2,%eax
jmp    13c0 <main+0x1f0>
mov    %edi,%ebp
mov    0x8(%r15),%rdi
lea    0xe0d(%rip),%rsi
call   1070 <strcmp@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1040 <check_initialized@plt>
test   %rbx,%rbx
je     1301 <main+0x131>
test   %rax,%rax
je     1357 <main+0x187>
mov    0x8(%r15),%rdi
lea    0xe36(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     131b <main+0x14b>
mov    0x8(%r15),%rdi
lea    0xe21(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     131b <main+0x14b>
mov    0x8(%r15),%rdi
lea    0xe30(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     138a <main+0x1ba>
mov    0x8(%r15),%rdi
lea    0xe67(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     13c9 <main+0x1f9>
mov    0x8(%r15),%rdi
lea    0xe55(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     13e5 <main+0x215>
mov    0x8(%r15),%rdi
lea    0xe40(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     13f4 <main+0x224>
mov    0x8(%r15),%rdi
lea    0xe2e(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1425 <main+0x255>
mov    0x2cf8(%rip),%rax
mov    (%rax),%edi
mov    0x8(%r15),%rdx
lea    0xe5c(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
jmp    13bb <main+0x1eb>
test   %rax,%rax
je     137b <main+0x1ab>
mov    0x2cd3(%rip),%rax
mov    (%rax),%edi
lea    0xd0d(%rip),%rsi
jmp    13b4 <main+0x1e4>
cmp    $0x3,%ebp
jb     1369 <main+0x199>
mov    0x10(%r15),%rdi
call   10e0 <check_filename@plt>
test   %eax,%eax
je     1369 <main+0x199>
mov    0x8(%r15),%rdi
lea    0xd3f(%rip),%rsi
call   1070 <strcmp@plt>
mov    0x10(%r15),%rdi
test   %rax,%rax
je     13d8 <main+0x208>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    10d0 <beargit_add@plt>
mov    0x2c82(%rip),%rax
mov    (%rax),%edi
lea    0xce6(%rip),%rsi
jmp    13b4 <main+0x1e4>
mov    0x2c70(%rip),%rax
mov    (%rax),%edi
lea    0xd01(%rip),%rsi
jmp    13b4 <main+0x1e4>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1080 <beargit_init@plt>
cmp    $0x4,%ebp
jb     13a4 <main+0x1d4>
mov    0x10(%r15),%rdi
lea    0xd0c(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1403 <main+0x233>
mov    0x2c35(%rip),%rax
mov    (%rax),%edi
lea    0xcf5(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x1,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    10c0 <beargit_status@plt>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    10f0 <beargit_rm@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <beargit_log@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <beargit_branch@plt>
mov    0x18(%r15),%rdi
call   1050 <strlen@plt>
cmp    $0x200,%eax
jl     1484 <main+0x2b4>
mov    0x2bc6(%rip),%rax
mov    (%rax),%edi
lea    0xcaf(%rip),%rsi
jmp    13b4 <main+0x1e4>
cmp    $0x3,%ebp
jb     1495 <main+0x2c5>
mov    %ebp,%r12d
xor    %ebp,%ebp
mov    $0x2,%ebx
lea    0xccf(%rip),%r14
xor    %esi,%esi
jmp    1450 <main+0x280>
test   %rbp,%rbp
mov    %rdi,%rbp
jne    14a9 <main+0x2d9>
add    $0x1,%rbx
cmp    %rbx,%r12
je     1499 <main+0x2c9>
mov    (%r15,%rbx,8),%rdi
cmpb   $0x2d,(%rdi)
jne    143f <main+0x26f>
mov    %r14,%rsi
call   1070 <strcmp@plt>
mov    $0x1,%esi
test   %rax,%rax
je     1447 <main+0x277>
mov    0x2b6e(%rip),%rax
mov    (%rax),%edi
mov    (%r15,%rbx,8),%rdx
lea    0xc8e(%rip),%rsi
jmp    12f5 <main+0x125>
mov    0x18(%r15),%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    10b0 <beargit_commit@plt>
xor    %esi,%esi
xor    %ebp,%ebp
mov    %rbp,%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    10a0 <beargit_checkout@plt>
mov    0x2b30(%rip),%rax
mov    (%rax),%edi
lea    0xc70(%rip),%rsi
jmp    13b4 <main+0x1e4>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [30 x i8] c"Usage: %s <command> [<args>]\0A\00"
@.str.1 = [5 x i8] c"init\00"
@.str.2 = [42 x i8] c"ERROR: Repository is already initialized\0A\00"
@.str.3 = [38 x i8] c"ERROR: Repository is not initialized\0A\00"
@.str.4 = [4 x i8] c"add\00"
@.str.5 = [3 x i8] c"rm\00"
@.str.6 = [37 x i8] c"ERROR: No or invalid filename given\0A\00"
@.str.7 = [7 x i8] c"commit\00"
@.str.8 = [3 x i8] c"-m\00"
@.str.9 = [41 x i8] c"ERROR: Need a commit message (-m <msg>)\0A\00"
@.str.10 = [29 x i8] c"ERROR: Message is too long!\0A\00"
@.str.11 = [7 x i8] c"status\00"
@.str.12 = [4 x i8] c"log\00"
@.str.13 = [7 x i8] c"branch\00"
@.str.14 = [9 x i8] c"checkout\00"
@.str.15 = [3 x i8] c"-b\00"
@.str.16 = [28 x i8] c"ERROR: Invalid argument: %s\00"
@.str.17 = [40 x i8] c"ERROR: Too many arguments for checkout!\00"
@.str.18 = [29 x i8] c"ERROR: Unknown command \22%s\22\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %17
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %15)
store i32 2, i32* %3
br label %196
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %31
23: ; preds = %17
%24 = call i64 (...) @check_initialized()
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %23
%27 = load i32, i32* @stderr
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %196
29: ; preds = %23
%30 = call i32 (...) @beargit_init()
store i32 %30, i32* %3
br label %196
31: ; preds = %17
%32 = call i64 (...) @check_initialized()
%33 = icmp ne i64 %32, 0
br i1 %33, label %37, label %34
34: ; preds = %31
%35 = load i32, i32* @stderr
%36 = call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %196
37: ; preds = %31
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 1
%40 = load i8*, i8** %39
%41 = call i64 @strcmp(i8* %40, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%42 = icmp eq i64 %41, 0
br i1 %42, label %49, label %43
43: ; preds = %37
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 1
%46 = load i8*, i8** %45
%47 = call i64 @strcmp(i8* %46, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %77
49: ; preds = %43, %37
%50 = load i32, i32* %4
%51 = icmp slt i32 %50, 3
br i1 %51, label %58, label %52
52: ; preds = %49
%53 = load i8**, i8*** %5
%54 = getelementptr inbounds i8*, i8** %53, i64 2
%55 = load i8*, i8** %54
%56 = call i32 @check_filename(i8* %55)
%57 = icmp ne i32 %56, 0
br i1 %57, label %61, label %58
58: ; preds = %52, %49
%59 = load i32, i32* @stderr
%60 = call i32 (i32, i8*, ...) @fprintf(i32 %59, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %3
br label %196
61: ; preds = %52
%62 = load i8**, i8*** %5
%63 = getelementptr inbounds i8*, i8** %62, i64 1
%64 = load i8*, i8** %63
%65 = call i64 @strcmp(i8* %64, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%66 = icmp eq i64 %65, 0
br i1 %66, label %67, label %72
67: ; preds = %61
%68 = load i8**, i8*** %5
%69 = getelementptr inbounds i8*, i8** %68, i64 2
%70 = load i8*, i8** %69
%71 = call i32 @beargit_rm(i8* %70)
store i32 %71, i32* %3
br label %196
72: ; preds = %61
%73 = load i8**, i8*** %5
%74 = getelementptr inbounds i8*, i8** %73, i64 2
%75 = load i8*, i8** %74
%76 = call i32 @beargit_add(i8* %75)
store i32 %76, i32* %3
br label %196
77: ; preds = %43
%78 = load i8**, i8*** %5
%79 = getelementptr inbounds i8*, i8** %78, i64 1
%80 = load i8*, i8** %79
%81 = call i64 @strcmp(i8* %80, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%82 = icmp eq i64 %81, 0
br i1 %82, label %83, label %109
83: ; preds = %77
%84 = load i32, i32* %4
%85 = icmp slt i32 %84, 4
br i1 %85, label %92, label %86
86: ; preds = %83
%87 = load i8**, i8*** %5
%88 = getelementptr inbounds i8*, i8** %87, i64 2
%89 = load i8*, i8** %88
%90 = call i64 @strcmp(i8* %89, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%91 = icmp ne i64 %90, 0
br i1 %91, label %92, label %95
92: ; preds = %86, %83
%93 = load i32, i32* @stderr
%94 = call i32 (i32, i8*, ...) @fprintf(i32 %93, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.9, i64 0, i64 0))
store i32 1, i32* %3
br label %196
95: ; preds = %86
%96 = load i8**, i8*** %5
%97 = getelementptr inbounds i8*, i8** %96, i64 3
%98 = load i8*, i8** %97
%99 = call i32 @strlen(i8* %98)
%100 = icmp sgt i32 %99, 511
br i1 %100, label %101, label %104
101: ; preds = %95
%102 = load i32, i32* @stderr
%103 = call i32 (i32, i8*, ...) @fprintf(i32 %102, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0))
store i32 1, i32* %3
br label %196
104: ; preds = %95
%105 = load i8**, i8*** %5
%106 = getelementptr inbounds i8*, i8** %105, i64 3
%107 = load i8*, i8** %106
%108 = call i32 @beargit_commit(i8* %107)
store i32 %108, i32* %3
br label %196
109: ; preds = %77
%110 = load i8**, i8*** %5
%111 = getelementptr inbounds i8*, i8** %110, i64 1
%112 = load i8*, i8** %111
%113 = call i64 @strcmp(i8* %112, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0))
%114 = icmp eq i64 %113, 0
br i1 %114, label %115, label %117
115: ; preds = %109
%116 = call i32 (...) @beargit_status()
store i32 %116, i32* %3
br label %196
117: ; preds = %109
%118 = load i8**, i8*** %5
%119 = getelementptr inbounds i8*, i8** %118, i64 1
%120 = load i8*, i8** %119
%121 = call i64 @strcmp(i8* %120, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0))
%122 = icmp eq i64 %121, 0
br i1 %122, label %123, label %125
123: ; preds = %117
%124 = call i32 (...) @beargit_log()
store i32 %124, i32* %3
br label %196
125: ; preds = %117
%126 = load i8**, i8*** %5
%127 = getelementptr inbounds i8*, i8** %126, i64 1
%128 = load i8*, i8** %127
%129 = call i64 @strcmp(i8* %128, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.13, i64 0, i64 0))
%130 = icmp eq i64 %129, 0
br i1 %130, label %131, label %133
131: ; preds = %125
%132 = call i32 (...) @beargit_branch()
store i32 %132, i32* %3
br label %196
133: ; preds = %125
%134 = load i8**, i8*** %5
%135 = getelementptr inbounds i8*, i8** %134, i64 1
%136 = load i8*, i8** %135
%137 = call i64 @strcmp(i8* %136, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.14, i64 0, i64 0))
%138 = icmp eq i64 %137, 0
br i1 %138, label %139, label %190
139: ; preds = %133
store i32 0, i32* %6
store i8* null, i8** %7
store i32 2, i32* %8
br label %140
140: ; preds = %183, %139
%141 = load i32, i32* %8
%142 = load i32, i32* %4
%143 = icmp slt i32 %141, %142
br i1 %143, label %144, label %186
144: ; preds = %140
%145 = load i8**, i8*** %5
%146 = load i32, i32* %8
%147 = sext i32 %146 to i64
%148 = getelementptr inbounds i8*, i8** %145, i64 %147
%149 = load i8*, i8** %148
%150 = getelementptr inbounds i8, i8* %149, i64 0
%151 = load i8, i8* %150
%152 = sext i8 %151 to i32
%153 = icmp eq i32 %152, 45
br i1 %153, label %154, label %171
154: ; preds = %144
%155 = load i8**, i8*** %5
%156 = load i32, i32* %8
%157 = sext i32 %156 to i64
%158 = getelementptr inbounds i8*, i8** %155, i64 %157
%159 = load i8*, i8** %158
%160 = call i64 @strcmp(i8* %159, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.15, i64 0, i64 0))
%161 = icmp eq i64 %160, 0
br i1 %161, label %162, label %163
162: ; preds = %154
store i32 1, i32* %6
br label %183
163: ; preds = %154
%164 = load i32, i32* @stderr
%165 = load i8**, i8*** %5
%166 = load i32, i32* %8
%167 = sext i32 %166 to i64
%168 = getelementptr inbounds i8*, i8** %165, i64 %167
%169 = load i8*, i8** %168
%170 = call i32 (i32, i8*, ...) @fprintf(i32 %164, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.16, i64 0, i64 0), i8* %169)
store i32 1, i32* %3
br label %196
171: ; preds = %144
%172 = load i8*, i8** %7
%173 = icmp ne i8* %172, null
br i1 %173, label %174, label %177
174: ; preds = %171
%175 = load i32, i32* @stderr
%176 = call i32 (i32, i8*, ...) @fprintf(i32 %175, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.17, i64 0, i64 0))
store i32 1, i32* %3
br label %196
177: ; preds = %171
%178 = load i8**, i8*** %5
%179 = load i32, i32* %8
%180 = sext i32 %179 to i64
%181 = getelementptr inbounds i8*, i8** %178, i64 %180
%182 = load i8*, i8** %181
store i8* %182, i8** %7
br label %183
183: ; preds = %177, %162
%184 = load i32, i32* %8
%185 = add nsw i32 %184, 1
store i32 %185, i32* %8
br label %140
186: ; preds = %140
%187 = load i8*, i8** %7
%188 = load i32, i32* %6
%189 = call i32 @beargit_checkout(i8* %187, i32 %188)
store i32 %189, i32* %3
br label %196
190: ; preds = %133
%191 = load i32, i32* @stderr
%192 = load i8**, i8*** %5
%193 = getelementptr inbounds i8*, i8** %192, i64 1
%194 = load i8*, i8** %193
%195 = call i32 (i32, i8*, ...) @fprintf(i32 %191, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.18, i64 0, i64 0), i8* %194)
store i32 1, i32* %3
br label %196
196: ; preds = %190, %186, %174, %163, %131, %123, %115, %104, %101, %92, %72, %67, %58, %34, %29, %26, %11
%197 = load i32, i32* %3
ret i32 %197
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [30 x i8] c"Usage: %s <command> [<args>]\0A\00"
@.str.1 = [5 x i8] c"init\00"
@.str.2 = [42 x i8] c"ERROR: Repository is already initialized\0A\00"
@.str.3 = [38 x i8] c"ERROR: Repository is not initialized\0A\00"
@.str.4 = [4 x i8] c"add\00"
@.str.5 = [3 x i8] c"rm\00"
@.str.6 = [37 x i8] c"ERROR: No or invalid filename given\0A\00"
@.str.7 = [7 x i8] c"commit\00"
@.str.8 = [3 x i8] c"-m\00"
@.str.9 = [41 x i8] c"ERROR: Need a commit message (-m <msg>)\0A\00"
@.str.10 = [29 x i8] c"ERROR: Message is too long!\0A\00"
@.str.11 = [7 x i8] c"status\00"
@.str.12 = [4 x i8] c"log\00"
@.str.13 = [7 x i8] c"branch\00"
@.str.14 = [9 x i8] c"checkout\00"
@.str.15 = [3 x i8] c"-b\00"
@.str.16 = [28 x i8] c"ERROR: Invalid argument: %s\00"
@.str.17 = [40 x i8] c"ERROR: Too many arguments for checkout!\00"
@.str.18 = [29 x i8] c"ERROR: Unknown command \22%s\22\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %138
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
%13 = tail call i64 (...) @check_initialized()
%14 = icmp eq i64 %13, 0
br i1 %12, label %15, label %21
15: ; preds = %8
br i1 %14, label %19, label %16
16: ; preds = %15
%17 = load i32, i32* @stderr
%18 = tail call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
br label %138
19: ; preds = %15
%20 = tail call i32 (...) @beargit_init()
br label %138
21: ; preds = %8
br i1 %14, label %22, label %25
22: ; preds = %21
%23 = load i32, i32* @stderr
%24 = tail call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0))
br label %138
25: ; preds = %21
%26 = load i8*, i8** %9
%27 = tail call i64 @strcmp(i8* %26, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %33, label %29
29: ; preds = %25
%30 = load i8*, i8** %9
%31 = tail call i64 @strcmp(i8* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %52
33: ; preds = %29, %25
%34 = icmp ult i32 %0, 3
br i1 %34, label %40, label %35
35: ; preds = %33
%36 = getelementptr inbounds i8*, i8** %1, i64 2
%37 = load i8*, i8** %36
%38 = tail call i32 @check_filename(i8* %37)
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %43
40: ; preds = %35, %33
%41 = load i32, i32* @stderr
%42 = tail call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0))
br label %138
43: ; preds = %35
%44 = load i8*, i8** %9
%45 = tail call i64 @strcmp(i8* %44, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%46 = icmp eq i64 %45, 0
%47 = load i8*, i8** %36
br i1 %46, label %48, label %50
48: ; preds = %43
%49 = tail call i32 @beargit_rm(i8* %47)
br label %138
50: ; preds = %43
%51 = tail call i32 @beargit_add(i8* %47)
br label %138
52: ; preds = %29
%53 = load i8*, i8** %9
%54 = tail call i64 @strcmp(i8* %53, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%55 = icmp eq i64 %54, 0
br i1 %55, label %56, label %77
56: ; preds = %52
%57 = icmp ult i32 %0, 4
br i1 %57, label %63, label %58
58: ; preds = %56
%59 = getelementptr inbounds i8*, i8** %1, i64 2
%60 = load i8*, i8** %59
%61 = tail call i64 @strcmp(i8* %60, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%62 = icmp eq i64 %61, 0
br i1 %62, label %66, label %63
63: ; preds = %58, %56
%64 = load i32, i32* @stderr
%65 = tail call i32 (i32, i8*, ...) @fprintf(i32 %64, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.9, i64 0, i64 0))
br label %138
66: ; preds = %58
%67 = getelementptr inbounds i8*, i8** %1, i64 3
%68 = load i8*, i8** %67
%69 = tail call i32 @strlen(i8* %68)
%70 = icmp sgt i32 %69, 511
br i1 %70, label %71, label %74
71: ; preds = %66
%72 = load i32, i32* @stderr
%73 = tail call i32 (i32, i8*, ...) @fprintf(i32 %72, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0))
br label %138
74: ; preds = %66
%75 = load i8*, i8** %67
%76 = tail call i32 @beargit_commit(i8* %75)
br label %138
77: ; preds = %52
%78 = load i8*, i8** %9
%79 = tail call i64 @strcmp(i8* %78, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0))
%80 = icmp eq i64 %79, 0
br i1 %80, label %81, label %83
81: ; preds = %77
%82 = tail call i32 (...) @beargit_status()
br label %138
83: ; preds = %77
%84 = load i8*, i8** %9
%85 = tail call i64 @strcmp(i8* %84, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0))
%86 = icmp eq i64 %85, 0
br i1 %86, label %87, label %89
87: ; preds = %83
%88 = tail call i32 (...) @beargit_log()
br label %138
89: ; preds = %83
%90 = load i8*, i8** %9
%91 = tail call i64 @strcmp(i8* %90, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.13, i64 0, i64 0))
%92 = icmp eq i64 %91, 0
br i1 %92, label %93, label %95
93: ; preds = %89
%94 = tail call i32 (...) @beargit_branch()
br label %138
95: ; preds = %89
%96 = load i8*, i8** %9
%97 = tail call i64 @strcmp(i8* %96, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.14, i64 0, i64 0))
%98 = icmp eq i64 %97, 0
br i1 %98, label %99, label %134
99: ; preds = %95
%100 = icmp ugt i32 %0, 2
br i1 %100, label %101, label %130
101: ; preds = %99
%102 = zext i32 %0 to i64
br label %103
103: ; preds = %101, %125
%104 = phi i64 [ 2, %101 ], [ %128, %125 ]
%105 = phi i8* [ null, %101 ], [ %127, %125 ]
%106 = phi i32 [ 0, %101 ], [ %126, %125 ]
%107 = getelementptr inbounds i8*, i8** %1, i64 %104
%108 = load i8*, i8** %107
%109 = load i8, i8* %108
%110 = icmp eq i8 %109, 45
br i1 %110, label %111, label %120
111: ; preds = %103
%112 = tail call i64 @strcmp(i8* %108, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.15, i64 0, i64 0))
%113 = icmp eq i64 %112, 0
br i1 %113, label %125, label %114
114: ; preds = %111
%115 = and i64 %104, 4294967295
%116 = getelementptr inbounds i8*, i8** %1, i64 %115
%117 = load i32, i32* @stderr
%118 = load i8*, i8** %116
%119 = tail call i32 (i32, i8*, ...) @fprintf(i32 %117, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.16, i64 0, i64 0), i8* %118)
br label %138
120: ; preds = %103
%121 = icmp eq i8* %105, null
br i1 %121, label %125, label %122
122: ; preds = %120
%123 = load i32, i32* @stderr
%124 = tail call i32 (i32, i8*, ...) @fprintf(i32 %123, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.17, i64 0, i64 0))
br label %138
125: ; preds = %120, %111
%126 = phi i32 [ 1, %111 ], [ %106, %120 ]
%127 = phi i8* [ %105, %111 ], [ %108, %120 ]
%128 = add nuw nsw i64 %104, 1
%129 = icmp eq i64 %128, %102
br i1 %129, label %130, label %103
130: ; preds = %125, %99
%131 = phi i32 [ 0, %99 ], [ %126, %125 ]
%132 = phi i8* [ null, %99 ], [ %127, %125 ]
%133 = tail call i32 @beargit_checkout(i8* %132, i32 %131)
br label %138
134: ; preds = %95
%135 = load i32, i32* @stderr
%136 = load i8*, i8** %9
%137 = tail call i32 (i32, i8*, ...) @fprintf(i32 %135, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.18, i64 0, i64 0), i8* %136)
br label %138
138: ; preds = %122, %114, %130, %134, %93, %87, %81, %74, %71, %63, %50, %48, %40, %22, %19, %16, %4
%139 = phi i32 [ 2, %4 ], [ 1, %16 ], [ %20, %19 ], [ 1, %40 ], [ %49, %48 ], [ %51, %50 ], [ 1, %63 ], [ 1, %71 ], [ %76, %74 ], [ %82, %81 ], [ %88, %87 ], [ %94, %93 ], [ 1, %134 ], [ 1, %22 ], [ %133, %130 ], [ 1, %114 ], [ 1, %122 ]
ret i32 %139
}