#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*/ exit(int);
int /*<<< orphan*/ print_log(char *);
int /*<<< orphan*/ printf(char *);
int system(char *);
void check_for_git() {
  print_log("checking for git");
  int exit_code = system("which git >/dev/null 2>&1");
  if (exit_code == 256) {
    printf("I cannot find git on your computer.\n");
    printf("Please install git, then run me again.\n");
    exit(1);
  } else if (exit_code == 0) {
    print_log("-- git exists");
    print_log("-- moving on...");
  } else {
    printf("I could not find git on your computer.\n");
    printf("I got an error when I looked for it.\n");
    exit(1);
  }
}


x86 assembly (clang, -O0):
<check_for_git>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
call   1030 <print_log@plt>
lea    0xeb6(%rip),%rdi
call   1040 <system@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x100,-0x4(%rbp)
jne    1192 <check_for_git+0x52>
lea    0xeb4(%rip),%rdi
call   1050 <printf@plt>
lea    0xecd(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
cmpl   $0x0,-0x4(%rbp)
jne    11b9 <check_for_git+0x79>
lea    0xed5(%rip),%rdi
call   1030 <print_log@plt>
lea    0xed7(%rip),%rdi
call   1030 <print_log@plt>
jmp    11db <check_for_git+0x9b>
lea    0xed6(%rip),%rdi
call   1050 <printf@plt>
lea    0xef2(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
jmp    11e0 <check_for_git+0xa0>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_for_git>:
push   %rax
lea    0xeb8(%rip),%rdi
call   1040 <print_log@plt>
lea    0xebd(%rip),%rdi
call   1050 <system@plt>
test   %eax,%eax
jne    1176 <check_for_git+0x36>
lea    0xec7(%rip),%rdi
call   1040 <print_log@plt>
lea    0xec9(%rip),%rdi
pop    %rax
jmp    1040 <print_log@plt>
cmp    $0x100,%eax
jne    1192 <check_for_git+0x52>
lea    0xf11(%rip),%rdi
call   1030 <puts@plt>
lea    0xf29(%rip),%rdi
jmp    11a5 <check_for_git+0x65>
lea    0xeb0(%rip),%rdi
call   1030 <puts@plt>
lea    0xecb(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"checking for git\00"
@.str.1 = [26 x i8] c"which git >/dev/null 2>&1\00"
@.str.2 = [37 x i8] c"I cannot find git on your computer.\0A\00"
@.str.3 = [40 x i8] c"Please install git, then run me again.\0A\00"
@.str.4 = [14 x i8] c"-- git exists\00"
@.str.5 = [16 x i8] c"-- moving on...\00"
@.str.6 = [40 x i8] c"I could not find git on your computer.\0A\00"
@.str.7 = [38 x i8] c"I got an error when I looked for it.\0A\00"
define void @check_for_git() {
%1 = alloca i32
%2 = call i32 @print_log(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @system(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
store i32 %3, i32* %1
%4 = load i32, i32* %1
%5 = icmp eq i32 %4, 256
br i1 %5, label %6, label %10
6: ; preds = %0
%7 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
%9 = call i32 @exit(i32 1)
unreachable
10: ; preds = %0
%11 = load i32, i32* %1
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = call i32 @print_log(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%15 = call i32 @print_log(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
br label %20
16: ; preds = %10
%17 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.6, i64 0, i64 0))
%18 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.7, i64 0, i64 0))
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %13
br label %21
21: ; preds = %20
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"checking for git\00"
@.str.1 = [26 x i8] c"which git >/dev/null 2>&1\00"
@.str.4 = [14 x i8] c"-- git exists\00"
@.str.5 = [16 x i8] c"-- moving on...\00"
@str = [39 x i8] c"I could not find git on your computer.\00"
@str.8 = [37 x i8] c"I got an error when I looked for it.\00"
@str.9 = [36 x i8] c"I cannot find git on your computer.\00"
@str.10 = [39 x i8] c"Please install git, then run me again.\00"
define void @check_for_git() {
%1 = tail call i32 @print_log(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @system(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
switch i32 %2, label %10 [
i32 256, label %3
i32 0, label %7
]
3: ; preds = %0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.9, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.10, i64 0, i64 0))
%6 = tail call i32 @exit(i32 1)
unreachable
7: ; preds = %0
%8 = tail call i32 @print_log(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%9 = tail call i32 @print_log(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
ret void
10: ; preds = %0
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str, i64 0, i64 0))
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.8, i64 0, i64 0))
%13 = tail call i32 @exit(i32 1)
unreachable
}