#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 EXIT_SUCCESS;
int /*<<< orphan*/ F_OK;
int /*<<< orphan*/ access(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int show_error(char *);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ system(char *);
int kext_admin(unsigned int id, char src[]) {
  char cmd[300];
  switch (id) {
  case 41:
    if (access(src, F_OK) == 0) {
      char kext_name[100];
      int kext_count = 0;
      long int i;
      int j;
      i = strlen(src) - 1;
      printf("Installing the kext...\n");
      if (src[i] == '/') {
        src[i] = '\0';
        i--;
      }
      for (; i >= 0; i--) {
        if (src[i] == '/') {
          break;
        }
        kext_count++;
      }
      i++;
      for (j = 0; j < kext_count; j++) {
        kext_name[j] = src[i + j];
      }
      kext_name[j] = '\0';
      sprintf(cmd,
              "if [ -d \"/System/Library/Extensions/%s\" ]; then sudo mv "
              "\"/System/Library/Extensions/%s\" ~/Desktop/%s; fi",
              kext_name, kext_name, kext_name);
      system(cmd);
      sprintf(cmd, "sudo cp -R \"%s\" \"/System/Library/Extensions/%s\"", src,
              kext_name);
      if (system(cmd) != 0)
        return show_error("Installing kext failed!");
      kext_admin(43, kext_name);
    } else
      return show_error("Inaccessible or invalid source.");
    break;
  case 42:
    if (access(src, F_OK) == 0) {
      printf("Removing the kext...\n");
      sprintf(cmd, "sudo mv \"%s\" ~/Desktop/", src);
      system(cmd);
      kext_admin(44, "");
    } else
      return show_error("Inaccessible or invalid source.");
    break;
  case 43:
    printf("Fixing permissions...\n");
    if (strcmp(src, "") != 0) {
      sprintf(cmd, "sudo chown -R root:wheel /System/Library/Extensions/%s",
              src);
    } else {
      sprintf(cmd, "sudo chown -R root:wheel /System/Library/Extensions/*");
    }
    if (system(cmd) != 0)
      return show_error("Fixing permission failed!");
    kext_admin(44, "");
    break;
  case 44:
    printf("Rebuilding Cache...\n");
    if (system("sudo touch /S*/L*/Extensions && sudo kextcache -Boot -U /") !=
        0)
      return show_error("Rebuilding Kernel Cache failed!");
    printf("Done.\n");
    break;
  default:
    return show_error("Invalid Argument(s).");
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<kext_admin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1d0,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffd7,%eax
mov    %eax,%ecx
mov    %rcx,-0x1d0(%rbp)
sub    $0x3,%eax
ja     1513 <kext_admin+0x393>
mov    -0x1d0(%rbp),%rax
lea    0xe48(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rdi
mov    0x2e04(%rip),%rax
mov    (%rax),%esi
call   1090 <access@plt>
cmp    $0x0,%eax
jne    13a2 <kext_admin+0x222>
movl   $0x0,-0x1b4(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
cltq
mov    %rax,-0x1c0(%rbp)
lea    0xe0e(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rax
mov    -0x1c0(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    1240 <kext_admin+0xc0>
mov    -0x10(%rbp),%rax
mov    -0x1c0(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x1c0(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x1c0(%rbp)
jmp    1245 <kext_admin+0xc5>
cmpq   $0x0,-0x1c0(%rbp)
jl     1296 <kext_admin+0x116>
mov    -0x10(%rbp),%rax
mov    -0x1c0(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    1270 <kext_admin+0xf0>
jmp    1296 <kext_admin+0x116>
mov    -0x1b4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1b4(%rbp)
mov    -0x1c0(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x1c0(%rbp)
jmp    1245 <kext_admin+0xc5>
mov    -0x1c0(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1c0(%rbp)
movl   $0x0,-0x1c4(%rbp)
mov    -0x1c4(%rbp),%eax
cmp    -0x1b4(%rbp),%eax
jge    12fe <kext_admin+0x17e>
mov    -0x10(%rbp),%rax
mov    -0x1c0(%rbp),%rcx
movslq -0x1c4(%rbp),%rdx
add    %rdx,%rcx
mov    (%rax,%rcx,1),%cl
movslq -0x1c4(%rbp),%rax
mov    %cl,-0x1b0(%rbp,%rax,1)
mov    -0x1c4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c4(%rbp)
jmp    12b2 <kext_admin+0x132>
movslq -0x1c4(%rbp),%rax
movb   $0x0,-0x1b0(%rbp,%rax,1)
lea    -0x140(%rbp),%rdi
lea    -0x1b0(%rbp),%rdx
lea    -0x1b0(%rbp),%rcx
lea    -0x1b0(%rbp),%r8
lea    0xcf8(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x140(%rbp),%rdi
call   1040 <system@plt>
lea    -0x140(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    -0x1b0(%rbp),%rcx
lea    0xd35(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x140(%rbp),%rdi
call   1040 <system@plt>
cmp    $0x0,%eax
je     138c <kext_admin+0x20c>
lea    0xd42(%rip),%rdi
call   1080 <show_error@plt>
mov    %eax,-0x4(%rbp)
jmp    1533 <kext_admin+0x3b3>
lea    -0x1b0(%rbp),%rsi
mov    $0x2b,%edi
call   1060 <kext_admin@plt>
jmp    13b6 <kext_admin+0x236>
lea    0xd30(%rip),%rdi
call   1080 <show_error@plt>
mov    %eax,-0x4(%rbp)
jmp    1533 <kext_admin+0x3b3>
jmp    1527 <kext_admin+0x3a7>
mov    -0x10(%rbp),%rdi
mov    0x2c0a(%rip),%rax
mov    (%rax),%esi
call   1090 <access@plt>
cmp    $0x0,%eax
jne    141d <kext_admin+0x29d>
lea    0xd1c(%rip),%rdi
call   1050 <printf@plt>
lea    -0x140(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xd1b(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x140(%rbp),%rdi
call   1040 <system@plt>
mov    $0x2c,%edi
lea    0xdc6(%rip),%rsi
call   1060 <kext_admin@plt>
jmp    1431 <kext_admin+0x2b1>
lea    0xcb5(%rip),%rdi
call   1080 <show_error@plt>
mov    %eax,-0x4(%rbp)
jmp    1533 <kext_admin+0x3b3>
jmp    1527 <kext_admin+0x3a7>
lea    0xcea(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    0xd8c(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
je     1479 <kext_admin+0x2f9>
lea    -0x140(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xcd1(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
jmp    148e <kext_admin+0x30e>
lea    -0x140(%rbp),%rdi
lea    0xcee(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x140(%rbp),%rdi
call   1040 <system@plt>
cmp    $0x0,%eax
je     14b7 <kext_admin+0x337>
lea    0xd01(%rip),%rdi
call   1080 <show_error@plt>
mov    %eax,-0x4(%rbp)
jmp    1533 <kext_admin+0x3b3>
mov    $0x2c,%edi
lea    0xd16(%rip),%rsi
call   1060 <kext_admin@plt>
jmp    1527 <kext_admin+0x3a7>
lea    0xcf1(%rip),%rdi
call   1050 <printf@plt>
lea    0xcfa(%rip),%rdi
call   1040 <system@plt>
cmp    $0x0,%eax
je     1502 <kext_admin+0x382>
lea    0xd1f(%rip),%rdi
call   1080 <show_error@plt>
mov    %eax,-0x4(%rbp)
jmp    1533 <kext_admin+0x3b3>
lea    0xd2b(%rip),%rdi
call   1050 <printf@plt>
jmp    1527 <kext_admin+0x3a7>
lea    0xd21(%rip),%rdi
call   1080 <show_error@plt>
mov    %eax,-0x4(%rbp)
jmp    1533 <kext_admin+0x3b3>
mov    0x2ab2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1d0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kext_admin>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1a0,%rsp
add    $0xffffffd7,%edi
cmp    $0x3,%edi
ja     1236 <kext_admin+0xb6>
mov    %rsi,%r12
lea    0xe5b(%rip),%rax
movslq (%rax,%rdi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
mov    0x2e1b(%rip),%rax
mov    (%rax),%esi
mov    %r12,%rdi
call   1090 <access@plt>
test   %eax,%eax
jne    1257 <kext_admin+0xd7>
mov    %r12,%rdi
call   1040 <strlen@plt>
movslq %eax,%rbp
lea    -0x1(%rbp),%rbx
lea    0x1057(%rip),%rdi
call   1030 <puts@plt>
cmpb   $0x2f,-0x1(%r12,%rbp,1)
jne    11f3 <kext_admin+0x73>
movb   $0x0,(%r12,%rbx,1)
add    $0xffffffffffffffff,%rbx
test   %rbx,%rbx
js     13ba <kext_admin+0x23a>
lea    0x1(%rbx),%ebp
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmpb   $0x2f,(%r12,%rbx,1)
je     13a0 <kext_admin+0x220>
add    $0x1,%eax
lea    -0x1(%rbx),%rcx
test   %rbx,%rbx
mov    %rcx,%rbx
jg     1210 <kext_admin+0x90>
mov    $0xffffffffffffffff,%rbx
jmp    13a2 <kext_admin+0x222>
lea    0xf9d(%rip),%rdi
jmp    133d <kext_admin+0x1bd>
mov    0x2d87(%rip),%rax
mov    (%rax),%esi
mov    %r12,%rdi
call   1090 <access@plt>
test   %eax,%eax
je     12bd <kext_admin+0x13d>
lea    0xe63(%rip),%rdi
jmp    133d <kext_admin+0x1bd>
lea    0xf9f(%rip),%rdi
call   1030 <puts@plt>
cmpb   $0x0,(%r12)
je     12ec <kext_admin+0x16c>
lea    0xe7c(%rip),%rsi
lea    0x70(%rsp),%rdi
mov    %r12,%rdx
xor    %eax,%eax
call   10a0 <sprintf@plt>
jmp    1328 <kext_admin+0x1a8>
lea    0xf57(%rip),%rdi
call   1030 <puts@plt>
lea    0xedc(%rip),%rdi
call   1050 <system@plt>
test   %eax,%eax
je     137b <kext_admin+0x1fb>
lea    0xf02(%rip),%rdi
jmp    133d <kext_admin+0x1bd>
lea    0xf5b(%rip),%rdi
call   1030 <puts@plt>
lea    0xe11(%rip),%rsi
lea    0x70(%rsp),%r14
mov    %r14,%rdi
mov    %r12,%rdx
xor    %eax,%eax
call   10a0 <sprintf@plt>
mov    %r14,%rdi
call   1050 <system@plt>
jmp    1351 <kext_admin+0x1d1>
movups 0xe5d(%rip),%xmm0
movaps %xmm0,0x90(%rsp)
movups 0xe3e(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
movups 0xe1f(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movabs $0x2a2f736e6f6973,%rax
mov    %rax,0x9e(%rsp)
lea    0x70(%rsp),%rdi
call   1050 <system@plt>
test   %eax,%eax
je     1351 <kext_admin+0x1d1>
lea    0xe29(%rip),%rdi
add    $0x1a0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1080 <show_error@plt>
lea    0xe97(%rip),%rdi
call   1030 <puts@plt>
lea    0xe1c(%rip),%rdi
call   1050 <system@plt>
test   %eax,%eax
je     137b <kext_admin+0x1fb>
lea    0xe46(%rip),%rdi
call   1080 <show_error@plt>
jmp    1387 <kext_admin+0x207>
lea    0xe81(%rip),%rdi
call   1030 <puts@plt>
mov    0x2c52(%rip),%rax
mov    (%rax),%eax
add    $0x1a0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebp
test   %ebp,%ebp
je     13ba <kext_admin+0x23a>
lea    (%rbx,%r12,1),%rsi
add    $0x1,%rsi
mov    %ebp,%edx
mov    %rsp,%rdi
call   1070 <memcpy@plt>
jmp    13bc <kext_admin+0x23c>
xor    %ebp,%ebp
mov    %ebp,%eax
movb   $0x0,(%rsp,%rax,1)
lea    0xc47(%rip),%rsi
lea    0x70(%rsp),%r14
mov    %rsp,%r15
mov    %r14,%rdi
mov    %r15,%rdx
mov    %r15,%rcx
mov    %r15,%r8
xor    %eax,%eax
call   10a0 <sprintf@plt>
mov    %r14,%rdi
call   1050 <system@plt>
lea    0xc86(%rip),%rsi
mov    %r14,%rdi
mov    %r12,%rdx
mov    %r15,%rcx
xor    %eax,%eax
call   10a0 <sprintf@plt>
mov    %r14,%rdi
call   1050 <system@plt>
test   %eax,%eax
je     1420 <kext_admin+0x2a0>
lea    0xc93(%rip),%rdi
call   1080 <show_error@plt>
jmp    1390 <kext_admin+0x210>
mov    %rsp,%rsi
mov    $0x2b,%edi
call   1060 <kext_admin@plt>
jmp    1387 <kext_admin+0x207>

LLVM IR (-O0):
@F_OK = global i32 0
@.str = [24 x i8] c"Installing the kext...\0A\00"
@.str.1 = [105 x i8] c"if [ -d \22/System/Library/Extensions/%s\22 ]; then sudo mv \22/System/Library/Extensions/%s\22 ~/Desktop/%s; fi\00"
@.str.2 = [48 x i8] c"sudo cp -R \22%s\22 \22/System/Library/Extensions/%s\22\00"
@.str.3 = [24 x i8] c"Installing kext failed!\00"
@.str.4 = [32 x i8] c"Inaccessible or invalid source.\00"
@.str.5 = [22 x i8] c"Removing the kext...\0A\00"
@.str.6 = [24 x i8] c"sudo mv \22%s\22 ~/Desktop/\00"
@.str.7 = [1 x i8] zeroinitializer
@.str.8 = [23 x i8] c"Fixing permissions...\0A\00"
@.str.9 = [55 x i8] c"sudo chown -R root:wheel /System/Library/Extensions/%s\00"
@.str.10 = [54 x i8] c"sudo chown -R root:wheel /System/Library/Extensions/*\00"
@.str.11 = [26 x i8] c"Fixing permission failed!\00"
@.str.12 = [21 x i8] c"Rebuilding Cache...\0A\00"
@.str.13 = [58 x i8] c"sudo touch /S*/L*/Extensions && sudo kextcache -Boot -U /\00"
@.str.14 = [32 x i8] c"Rebuilding Kernel Cache failed!\00"
@.str.15 = [7 x i8] c"Done.\0A\00"
@.str.16 = [21 x i8] c"Invalid Argument(s).\00"
@EXIT_SUCCESS = global i32 0
define i32 @kext_admin(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca [300 x i8]
%7 = alloca [100 x i8]
%8 = alloca i32
%9 = alloca i64
%10 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
%11 = load i32, i32* %4
switch i32 %11, label %144 [
i32 41, label %12
i32 42, label %100
i32 43, label %116
i32 44, label %136
]
12: ; preds = %2
%13 = load i8*, i8** %5
%14 = load i32, i32* @F_OK
%15 = call i32 @access(i8* %13, i32 %14)
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %97
17: ; preds = %12
store i32 0, i32* %8
%18 = load i8*, i8** %5
%19 = call i32 @strlen(i8* %18)
%20 = sub nsw i32 %19, 1
%21 = sext i32 %20 to i64
store i64 %21, i64* %9
%22 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%23 = load i8*, i8** %5
%24 = load i64, i64* %9
%25 = getelementptr inbounds i8, i8* %23, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 47
br i1 %28, label %29, label %35
29: ; preds = %17
%30 = load i8*, i8** %5
%31 = load i64, i64* %9
%32 = getelementptr inbounds i8, i8* %30, i64 %31
store i8 0, i8* %32
%33 = load i64, i64* %9
%34 = add nsw i64 %33, -1
store i64 %34, i64* %9
br label %35
35: ; preds = %29, %17
br label %36
36: ; preds = %50, %35
%37 = load i64, i64* %9
%38 = icmp sge i64 %37, 0
br i1 %38, label %39, label %53
39: ; preds = %36
%40 = load i8*, i8** %5
%41 = load i64, i64* %9
%42 = getelementptr inbounds i8, i8* %40, i64 %41
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 47
br i1 %45, label %46, label %47
46: ; preds = %39
br label %53
47: ; preds = %39
%48 = load i32, i32* %8
%49 = add nsw i32 %48, 1
store i32 %49, i32* %8
br label %50
50: ; preds = %47
%51 = load i64, i64* %9
%52 = add nsw i64 %51, -1
store i64 %52, i64* %9
br label %36
53: ; preds = %46, %36
%54 = load i64, i64* %9
%55 = add nsw i64 %54, 1
store i64 %55, i64* %9
store i32 0, i32* %10
br label %56
56: ; preds = %71, %53
%57 = load i32, i32* %10
%58 = load i32, i32* %8
%59 = icmp slt i32 %57, %58
br i1 %59, label %60, label %74
60: ; preds = %56
%61 = load i8*, i8** %5
%62 = load i64, i64* %9
%63 = load i32, i32* %10
%64 = sext i32 %63 to i64
%65 = add nsw i64 %62, %64
%66 = getelementptr inbounds i8, i8* %61, i64 %65
%67 = load i8, i8* %66
%68 = load i32, i32* %10
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 %69
store i8 %67, i8* %70
br label %71
71: ; preds = %60
%72 = load i32, i32* %10
%73 = add nsw i32 %72, 1
store i32 %73, i32* %10
br label %56
74: ; preds = %56
%75 = load i32, i32* %10
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 %76
store i8 0, i8* %77
%78 = getelementptr inbounds [300 x i8], [300 x i8]* %6, i64 0, i64 0
%79 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%80 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%81 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%82 = call i32 (i8*, i8*, ...) @sprintf(i8* %78, i8* getelementptr inbounds ([105 x i8], [105 x i8]* @.str.1, i64 0, i64 0), i8* %79, i8* %80, i8* %81)
%83 = getelementptr inbounds [300 x i8], [300 x i8]* %6, i64 0, i64 0
%84 = call i32 @system(i8* %83)
%85 = getelementptr inbounds [300 x i8], [300 x i8]* %6, i64 0, i64 0
%86 = load i8*, i8** %5
%87 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%88 = call i32 (i8*, i8*, ...) @sprintf(i8* %85, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i8* %86, i8* %87)
%89 = getelementptr inbounds [300 x i8], [300 x i8]* %6, i64 0, i64 0
%90 = call i32 @system(i8* %89)
%91 = icmp ne i32 %90, 0
br i1 %91, label %92, label %94
92: ; preds = %74
%93 = call i32 @show_error(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
store i32 %93, i32* %3
br label %148
94: ; preds = %74
%95 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%96 = call i32 @kext_admin(i32 43, i8* %95)
br label %99
97: ; preds = %12
%98 = call i32 @show_error(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0))
store i32 %98, i32* %3
br label %148
99: ; preds = %94
br label %146
100: ; preds = %2
%101 = load i8*, i8** %5
%102 = load i32, i32* @F_OK
%103 = call i32 @access(i8* %101, i32 %102)
%104 = icmp eq i32 %103, 0
br i1 %104, label %105, label %113
105: ; preds = %100
%106 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
%107 = getelementptr inbounds [300 x i8], [300 x i8]* %6, i64 0, i64 0
%108 = load i8*, i8** %5
%109 = call i32 (i8*, i8*, ...) @sprintf(i8* %107, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), i8* %108)
%110 = getelementptr inbounds [300 x i8], [300 x i8]* %6, i64 0, i64 0
%111 = call i32 @system(i8* %110)
%112 = call i32 @kext_admin(i32 44, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0))
br label %115
113: ; preds = %100
%114 = call i32 @show_error(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0))
store i32 %114, i32* %3
br label %148
115: ; preds = %105
br label %146
116: ; preds = %2
%117 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0))
%118 = load i8*, i8** %5
%119 = call i32 @strcmp(i8* %118, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0))
%120 = icmp ne i32 %119, 0
br i1 %120, label %121, label %125
121: ; preds = %116
%122 = getelementptr inbounds [300 x i8], [300 x i8]* %6, i64 0, i64 0
%123 = load i8*, i8** %5
%124 = call i32 (i8*, i8*, ...) @sprintf(i8* %122, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.9, i64 0, i64 0), i8* %123)
br label %128
125: ; preds = %116
%126 = getelementptr inbounds [300 x i8], [300 x i8]* %6, i64 0, i64 0
%127 = call i32 (i8*, i8*, ...) @sprintf(i8* %126, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.10, i64 0, i64 0))
br label %128
128: ; preds = %125, %121
%129 = getelementptr inbounds [300 x i8], [300 x i8]* %6, i64 0, i64 0
%130 = call i32 @system(i8* %129)
%131 = icmp ne i32 %130, 0
br i1 %131, label %132, label %134
132: ; preds = %128
%133 = call i32 @show_error(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0))
store i32 %133, i32* %3
br label %148
134: ; preds = %128
%135 = call i32 @kext_admin(i32 44, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0))
br label %146
136: ; preds = %2
%137 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.12, i64 0, i64 0))
%138 = call i32 @system(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.13, i64 0, i64 0))
%139 = icmp ne i32 %138, 0
br i1 %139, label %140, label %142
140: ; preds = %136
%141 = call i32 @show_error(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.14, i64 0, i64 0))
store i32 %141, i32* %3
br label %148
142: ; preds = %136
%143 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.15, i64 0, i64 0))
br label %146
144: ; preds = %2
%145 = call i32 @show_error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.16, i64 0, i64 0))
store i32 %145, i32* %3
br label %148
146: ; preds = %142, %134, %115, %99
%147 = load i32, i32* @EXIT_SUCCESS
store i32 %147, i32* %3
br label %148
148: ; preds = %146, %144, %140, %132, %113, %97, %92
%149 = load i32, i32* %3
ret i32 %149
}

LLVM IR (-O2):
@F_OK = global i32 0
@.str.1 = [105 x i8] c"if [ -d \22/System/Library/Extensions/%s\22 ]; then sudo mv \22/System/Library/Extensions/%s\22 ~/Desktop/%s; fi\00"
@.str.2 = [48 x i8] c"sudo cp -R \22%s\22 \22/System/Library/Extensions/%s\22\00"
@.str.3 = [24 x i8] c"Installing kext failed!\00"
@.str.4 = [32 x i8] c"Inaccessible or invalid source.\00"
@.str.6 = [24 x i8] c"sudo mv \22%s\22 ~/Desktop/\00"
@.str.9 = [55 x i8] c"sudo chown -R root:wheel /System/Library/Extensions/%s\00"
@.str.10 = [54 x i8] c"sudo chown -R root:wheel /System/Library/Extensions/*\00"
@.str.11 = [26 x i8] c"Fixing permission failed!\00"
@.str.13 = [58 x i8] c"sudo touch /S*/L*/Extensions && sudo kextcache -Boot -U /\00"
@.str.14 = [32 x i8] c"Rebuilding Kernel Cache failed!\00"
@.str.16 = [21 x i8] c"Invalid Argument(s).\00"
@EXIT_SUCCESS = global i32 0
@str = [20 x i8] c"Rebuilding Cache...\00"
@str.17 = [6 x i8] c"Done.\00"
@str.18 = [22 x i8] c"Fixing permissions...\00"
@str.19 = [21 x i8] c"Removing the kext...\00"
@str.20 = [23 x i8] c"Installing the kext...\00"
define i32 @kext_admin(i32 %0, i8* %1) {
%3 = alloca [300 x i8]
%4 = alloca [100 x i8]
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%6 = getelementptr inbounds [300 x i8], [300 x i8]* %3, i64 0, i64 0
switch i32 %0, label %106 [
i32 41, label %7
i32 42, label %61
i32 43, label %78
i32 44, label %98
]
7: ; preds = %2
%8 = load i32, i32* @F_OK
%9 = tail call i32 @access(i8* %1, i32 %8)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %59
11: ; preds = %7
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%13 = tail call i32 @strlen(i8* %1)
%14 = add nsw i32 %13, -1
%15 = sext i32 %14 to i64
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.20, i64 0, i64 0))
%17 = getelementptr inbounds i8, i8* %1, i64 %15
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 47
br i1 %19, label %20, label %22
20: ; preds = %11
store i8 0, i8* %17
%21 = add nsw i64 %15, -1
br label %22
22: ; preds = %20, %11
%23 = phi i64 [ %21, %20 ], [ %15, %11 ]
%24 = icmp sgt i64 %23, -1
br i1 %24, label %25, label %46
25: ; preds = %22
%26 = trunc i64 %23 to i32
%27 = add nuw nsw i32 %26, 1
br label %28
28: ; preds = %25, %34
%29 = phi i64 [ %36, %34 ], [ %23, %25 ]
%30 = phi i32 [ %35, %34 ], [ 0, %25 ]
%31 = getelementptr inbounds i8, i8* %1, i64 %29
%32 = load i8, i8* %31
%33 = icmp eq i8 %32, 47
br i1 %33, label %38, label %34
34: ; preds = %28
%35 = add nuw nsw i32 %30, 1
%36 = add nsw i64 %29, -1
%37 = icmp sgt i64 %29, 0
br i1 %37, label %28, label %38
38: ; preds = %34, %28
%39 = phi i32 [ %27, %34 ], [ %30, %28 ]
%40 = phi i64 [ -1, %34 ], [ %29, %28 ]
%41 = icmp eq i32 %39, 0
br i1 %41, label %46, label %42
42: ; preds = %38
%43 = add nsw i64 %40, 1
%44 = getelementptr i8, i8* %1, i64 %43
%45 = zext i32 %39 to i64
br label %46
46: ; preds = %22, %42, %38
%47 = phi i32 [ 0, %38 ], [ %39, %42 ], [ 0, %22 ]
%48 = zext i32 %47 to i64
%49 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 %48
store i8 0, i8* %49
%50 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([105 x i8], [105 x i8]* @.str.1, i64 0, i64 0), i8* %12, i8* %12, i8* %12)
%51 = call i32 @system(i8* %6)
%52 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0), i8* %1, i8* %12)
%53 = call i32 @system(i8* %6)
%54 = icmp eq i32 %53, 0
br i1 %54, label %55, label %57
55: ; preds = %46
%56 = call i32 @kext_admin(i32 43, i8* %12)
br label %108
57: ; preds = %46
%58 = call i32 @show_error(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
br label %110
59: ; preds = %7
%60 = tail call i32 @show_error(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0))
br label %110
61: ; preds = %2
%62 = load i32, i32* @F_OK
%63 = tail call i32 @access(i8* %1, i32 %62)
%64 = icmp eq i32 %63, 0
br i1 %64, label %65, label %76
65: ; preds = %61
%66 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.19, i64 0, i64 0))
%67 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0), i8* %1)
%68 = call i32 @system(i8* %6)
%69 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%70 = tail call i32 @system(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.13, i64 0, i64 0))
%71 = icmp eq i32 %70, 0
br i1 %71, label %74, label %72
72: ; preds = %65
%73 = tail call i32 @show_error(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.14, i64 0, i64 0))
br label %108
74: ; preds = %65
%75 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.17, i64 0, i64 0))
br label %108
76: ; preds = %61
%77 = tail call i32 @show_error(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0))
br label %110
78: ; preds = %2
%79 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.18, i64 0, i64 0))
%80 = load i8, i8* %1
%81 = icmp eq i8 %80, 0
br i1 %81, label %84, label %82
82: ; preds = %78
%83 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.9, i64 0, i64 0), i8* %1)
br label %85
84: ; preds = %78
br label %85
85: ; preds = %84, %82
%86 = call i32 @system(i8* %6)
%87 = icmp eq i32 %86, 0
br i1 %87, label %90, label %88
88: ; preds = %85
%89 = tail call i32 @show_error(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0))
br label %110
90: ; preds = %85
%91 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%92 = tail call i32 @system(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.13, i64 0, i64 0))
%93 = icmp eq i32 %92, 0
br i1 %93, label %96, label %94
94: ; preds = %90
%95 = tail call i32 @show_error(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.14, i64 0, i64 0))
br label %108
96: ; preds = %90
%97 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.17, i64 0, i64 0))
br label %108
98: ; preds = %2
%99 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%100 = tail call i32 @system(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.13, i64 0, i64 0))
%101 = icmp eq i32 %100, 0
br i1 %101, label %104, label %102
102: ; preds = %98
%103 = tail call i32 @show_error(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.14, i64 0, i64 0))
br label %110
104: ; preds = %98
%105 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str.17, i64 0, i64 0))
br label %108
106: ; preds = %2
%107 = tail call i32 @show_error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.16, i64 0, i64 0))
br label %110
108: ; preds = %96, %94, %74, %72, %55, %104
%109 = load i32, i32* @EXIT_SUCCESS
br label %110
110: ; preds = %57, %108, %106, %102, %88, %76, %59
%111 = phi i32 [ %107, %106 ], [ %103, %102 ], [ %109, %108 ], [ %89, %88 ], [ %77, %76 ], [ %58, %57 ], [ %60, %59 ]
ret i32 %111
}