#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 */
char EOF;
int /*<<< orphan*/ exit(int);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
int /*<<< orphan*/ print_log(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sprintf(char *, char *, int, int, int);
int /*<<< orphan*/ sscanf(char *, char *, int *, int *, int *);
int system(char *);
void check_for_vagrant() {
  print_log("checking for vagrant");
  int exit_code = system("which vagrant >/dev/null 2>&1");
  if (exit_code == 256) {
    printf("I cannot find Vagrant on your computer.\n");
    printf("Please install Vagrant 1.4.3+, then run me again.\n");
    exit(1);
  } else if (exit_code == 0) {
    print_log("-- vagrant exists");
    print_log("checking version");
    FILE *stream = popen("vagrant -v | grep -o '[0-9]\\.[0-9]\\.[0-9]'", "r");
    char character;
    char output[150];
    int i = 0;
    while ((character = fgetc(stream)) != EOF) {
      output[i++] = character;
    }
    pclose(stream);
    int major, minor, revision;
    sscanf(output, "%d.%d.%d", &major, &minor, &revision);
    char version_message[24];
    sprintf(version_message, "-- version %d.%d.%d", major, minor, revision);
    print_log(version_message);
    if (major < 1 || minor < 2 || revision < 3) {
      printf("Vagrant 1.4.3+ is required.\n");
      printf("Upgrade to version 1.4.3+ and try me again.\n");
      exit(1);
    } else {
      print_log("-- moving on...");
    }
  } else {
    printf("I could not find Vagrant on your computer.\n");
    printf("I got an error when I looked for it.\n");
    exit(1);
  }
}


x86 assembly (clang, -O0):
<check_for_vagrant>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
lea    0xe5e(%rip),%rdi
call   1030 <print_log@plt>
lea    0xe67(%rip),%rdi
call   1040 <system@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x100,-0x4(%rbp)
jne    11e5 <check_for_vagrant+0x55>
lea    0xe69(%rip),%rdi
call   1050 <printf@plt>
lea    0xe86(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
cmpl   $0x0,-0x4(%rbp)
jne    1328 <check_for_vagrant+0x198>
lea    0xe99(%rip),%rdi
call   1030 <print_log@plt>
lea    0xe9f(%rip),%rdi
call   1030 <print_log@plt>
lea    0xea4(%rip),%rdi
lea    0xec8(%rip),%rsi
call   1090 <popen@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0xb4(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <fgetc@plt>
mov    %al,-0x11(%rbp)
movsbl %al,%eax
mov    0x2daa(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     126b <check_for_vagrant+0xdb>
mov    -0x11(%rbp),%cl
mov    -0xb4(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0xb4(%rbp)
cltq
mov    %cl,-0xb0(%rbp,%rax,1)
jmp    1228 <check_for_vagrant+0x98>
mov    -0x10(%rbp),%rdi
call   1060 <pclose@plt>
lea    -0xb0(%rbp),%rdi
lea    0xe68(%rip),%rsi
lea    -0xb8(%rbp),%rdx
lea    -0xbc(%rbp),%rcx
lea    -0xc0(%rbp),%r8
call   1080 <sscanf@plt>
lea    -0xe0(%rbp),%rdi
mov    -0xb8(%rbp),%edx
mov    -0xbc(%rbp),%ecx
mov    -0xc0(%rbp),%r8d
lea    0xe22(%rip),%rsi
call   10a0 <sprintf@plt>
lea    -0xe0(%rbp),%rdi
call   1030 <print_log@plt>
cmpl   $0x1,-0xb8(%rbp)
jl     12f5 <check_for_vagrant+0x165>
cmpl   $0x2,-0xbc(%rbp)
jl     12f5 <check_for_vagrant+0x165>
cmpl   $0x3,-0xc0(%rbp)
jge    1317 <check_for_vagrant+0x187>
lea    0xdf7(%rip),%rdi
call   1050 <printf@plt>
lea    0xe08(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
lea    0xe1f(%rip),%rdi
call   1030 <print_log@plt>
jmp    134a <check_for_vagrant+0x1ba>
lea    0xe1e(%rip),%rdi
call   1050 <printf@plt>
lea    0xe3e(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
jmp    134f <check_for_vagrant+0x1bf>
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_for_vagrant>:
push   %r15
push   %r14
push   %rbx
sub    $0xd0,%rsp
lea    0xe5d(%rip),%rdi
call   1040 <print_log@plt>
lea    0xe66(%rip),%rdi
call   1050 <system@plt>
test   %eax,%eax
jne    12a2 <check_for_vagrant+0x112>
lea    0xe70(%rip),%rdi
call   1040 <print_log@plt>
lea    0xe76(%rip),%rdi
call   1040 <print_log@plt>
lea    0xe7b(%rip),%rdi
lea    0xe9f(%rip),%rsi
call   1090 <popen@plt>
mov    %rax,%r15
mov    %rax,%rdi
call   1070 <fgetc@plt>
mov    0x2def(%rip),%r14
cmp    (%r14),%al
je     1223 <check_for_vagrant+0x93>
lea    0x30(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %al,(%rbx)
mov    %r15,%rdi
call   1070 <fgetc@plt>
add    $0x1,%rbx
cmp    (%r14),%al
jne    1210 <check_for_vagrant+0x80>
mov    %r15,%rdi
call   1060 <pclose@plt>
lea    0xe5c(%rip),%rsi
lea    0x30(%rsp),%rdi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
lea    0x4(%rsp),%r8
call   1080 <sscanf@plt>
mov    0xc(%rsp),%edx
mov    0x8(%rsp),%ecx
mov    0x4(%rsp),%r8d
lea    0xe24(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   10a0 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <print_log@plt>
cmpl   $0x0,0xc(%rsp)
jle    12be <check_for_vagrant+0x12e>
cmpl   $0x2,0x8(%rsp)
jl     12be <check_for_vagrant+0x12e>
cmpl   $0x2,0x4(%rsp)
jle    12be <check_for_vagrant+0x12e>
lea    0xe07(%rip),%rdi
call   1040 <print_log@plt>
add    $0xd0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
cmp    $0x100,%eax
jne    12d3 <check_for_vagrant+0x143>
lea    0xe8f(%rip),%rdi
call   1030 <puts@plt>
lea    0xeab(%rip),%rdi
jmp    12e6 <check_for_vagrant+0x156>
lea    0xe32(%rip),%rdi
call   1030 <puts@plt>
lea    0xe42(%rip),%rdi
jmp    12e6 <check_for_vagrant+0x156>
lea    0xdcd(%rip),%rdi
call   1030 <puts@plt>
lea    0xdec(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [21 x i8] c"checking for vagrant\00"
@.str.1 = [30 x i8] c"which vagrant >/dev/null 2>&1\00"
@.str.2 = [41 x i8] c"I cannot find Vagrant on your computer.\0A\00"
@.str.3 = [51 x i8] c"Please install Vagrant 1.4.3+, then run me again.\0A\00"
@.str.4 = [18 x i8] c"-- vagrant exists\00"
@.str.5 = [17 x i8] c"checking version\00"
@.str.6 = [43 x i8] c"vagrant -v | grep -o '[0-9]\\.[0-9]\\.[0-9]'\00"
@.str.7 = [2 x i8] c"r\00"
@EOF = global i8 0
@.str.8 = [9 x i8] c"%d.%d.%d\00"
@.str.9 = [20 x i8] c"-- version %d.%d.%d\00"
@.str.10 = [29 x i8] c"Vagrant 1.4.3+ is required.\0A\00"
@.str.11 = [45 x i8] c"Upgrade to version 1.4.3+ and try me again.\0A\00"
@.str.12 = [16 x i8] c"-- moving on...\00"
@.str.13 = [44 x i8] c"I could not find Vagrant on your computer.\0A\00"
@.str.14 = [38 x i8] c"I got an error when I looked for it.\0A\00"
define void @check_for_vagrant() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i8
%4 = alloca [150 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [24 x i8]
%10 = call i32 @print_log(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @system(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
store i32 %11, i32* %1
%12 = load i32, i32* %1
%13 = icmp eq i32 %12, 256
br i1 %13, label %14, label %18
14: ; preds = %0
%15 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0))
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %0
%19 = load i32, i32* %1
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %65
21: ; preds = %18
%22 = call i32 @print_log(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
%23 = call i32 @print_log(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
%24 = call i32* @popen(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i32* %24, i32** %2
store i32 0, i32* %5
br label %25
25: ; preds = %32, %21
%26 = load i32*, i32** %2
%27 = call signext i8 @fgetc(i32* %26)
store i8 %27, i8* %3
%28 = sext i8 %27 to i32
%29 = load i8, i8* @EOF
%30 = sext i8 %29 to i32
%31 = icmp ne i32 %28, %30
br i1 %31, label %32, label %38
32: ; preds = %25
%33 = load i8, i8* %3
%34 = load i32, i32* %5
%35 = add nsw i32 %34, 1
store i32 %35, i32* %5
%36 = sext i32 %34 to i64
%37 = getelementptr inbounds [150 x i8], [150 x i8]* %4, i64 0, i64 %36
store i8 %33, i8* %37
br label %25
38: ; preds = %25
%39 = load i32*, i32** %2
%40 = call i32 @pclose(i32* %39)
%41 = getelementptr inbounds [150 x i8], [150 x i8]* %4, i64 0, i64 0
%42 = call i32 @sscanf(i8* %41, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), i32* %6, i32* %7, i32* %8)
%43 = getelementptr inbounds [24 x i8], [24 x i8]* %9, i64 0, i64 0
%44 = load i32, i32* %6
%45 = load i32, i32* %7
%46 = load i32, i32* %8
%47 = call i32 @sprintf(i8* %43, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0), i32 %44, i32 %45, i32 %46)
%48 = getelementptr inbounds [24 x i8], [24 x i8]* %9, i64 0, i64 0
%49 = call i32 @print_log(i8* %48)
%50 = load i32, i32* %6
%51 = icmp slt i32 %50, 1
br i1 %51, label %58, label %52
52: ; preds = %38
%53 = load i32, i32* %7
%54 = icmp slt i32 %53, 2
br i1 %54, label %58, label %55
55: ; preds = %52
%56 = load i32, i32* %8
%57 = icmp slt i32 %56, 3
br i1 %57, label %58, label %62
58: ; preds = %55, %52, %38
%59 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0))
%60 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.11, i64 0, i64 0))
%61 = call i32 @exit(i32 1)
unreachable
62: ; preds = %55
%63 = call i32 @print_log(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.12, i64 0, i64 0))
br label %64
64: ; preds = %62
br label %69
65: ; preds = %18
%66 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.13, i64 0, i64 0))
%67 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.14, i64 0, i64 0))
%68 = call i32 @exit(i32 1)
unreachable
69: ; preds = %64
br label %70
70: ; preds = %69
ret void
}

LLVM IR (-O2):
@.str = [21 x i8] c"checking for vagrant\00"
@.str.1 = [30 x i8] c"which vagrant >/dev/null 2>&1\00"
@.str.4 = [18 x i8] c"-- vagrant exists\00"
@.str.5 = [17 x i8] c"checking version\00"
@.str.6 = [43 x i8] c"vagrant -v | grep -o '[0-9]\\.[0-9]\\.[0-9]'\00"
@.str.7 = [2 x i8] c"r\00"
@EOF = global i8 0
@.str.8 = [9 x i8] c"%d.%d.%d\00"
@.str.9 = [20 x i8] c"-- version %d.%d.%d\00"
@.str.12 = [16 x i8] c"-- moving on...\00"
@str = [43 x i8] c"I could not find Vagrant on your computer.\00"
@str.15 = [37 x i8] c"I got an error when I looked for it.\00"
@str.16 = [28 x i8] c"Vagrant 1.4.3+ is required.\00"
@str.17 = [44 x i8] c"Upgrade to version 1.4.3+ and try me again.\00"
@str.18 = [40 x i8] c"I cannot find Vagrant on your computer.\00"
@str.19 = [50 x i8] c"Please install Vagrant 1.4.3+, then run me again.\00"
define void @check_for_vagrant() {
%1 = alloca [150 x i8]
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [24 x i8]
%6 = tail call i32 @print_log(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @system(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
switch i32 %7, label %54 [
i32 256, label %8
i32 0, label %12
]
8: ; preds = %0
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.18, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str.19, i64 0, i64 0))
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %0
%13 = tail call i32 @print_log(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
%14 = tail call i32 @print_log(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
%15 = tail call i32* @popen(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%16 = getelementptr inbounds [150 x i8], [150 x i8]* %1, i64 0, i64 0
%17 = tail call signext i8 @fgetc(i32* %15)
%18 = load i8, i8* @EOF
%19 = icmp eq i8 %17, %18
br i1 %19, label %28, label %20
20: ; preds = %12, %20
%21 = phi i64 [ %23, %20 ], [ 0, %12 ]
%22 = phi i8 [ %25, %20 ], [ %17, %12 ]
%23 = add nuw i64 %21, 1
%24 = getelementptr inbounds [150 x i8], [150 x i8]* %1, i64 0, i64 %21
store i8 %22, i8* %24
%25 = tail call signext i8 @fgetc(i32* %15)
%26 = load i8, i8* @EOF
%27 = icmp eq i8 %25, %26
br i1 %27, label %28, label %20
28: ; preds = %20, %12
%29 = tail call i32 @pclose(i32* %15)
%30 = bitcast i32* %2 to i8*
%31 = bitcast i32* %3 to i8*
%32 = bitcast i32* %4 to i8*
%33 = call i32 @sscanf(i8* %16, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), i32* %2, i32* %3, i32* %4)
%34 = getelementptr inbounds [24 x i8], [24 x i8]* %5, i64 0, i64 0
%35 = load i32, i32* %2
%36 = load i32, i32* %3
%37 = load i32, i32* %4
%38 = call i32 @sprintf(i8* %34, i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0), i32 %35, i32 %36, i32 %37)
%39 = call i32 @print_log(i8* %34)
%40 = load i32, i32* %2
%41 = icmp slt i32 %40, 1
%42 = load i32, i32* %3
%43 = icmp slt i32 %42, 2
%44 = select i1 %41, i1 true, i1 %43
%45 = load i32, i32* %4
%46 = icmp slt i32 %45, 3
%47 = select i1 %44, i1 true, i1 %46
br i1 %47, label %48, label %52
48: ; preds = %28
%49 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.16, i64 0, i64 0))
%50 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str.17, i64 0, i64 0))
%51 = call i32 @exit(i32 1)
unreachable
52: ; preds = %28
%53 = call i32 @print_log(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.12, i64 0, i64 0))
ret void
54: ; preds = %0
%55 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str, i64 0, i64 0))
%56 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.15, i64 0, i64 0))
%57 = tail call i32 @exit(i32 1)
unreachable
}