#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*/ printf(char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strlen(char const *);
int /*<<< orphan*/ strncpy(char *, char const *, scalar_t__);
scalar_t__ system(char *);
int main(int argc, const char *argv[]) {
  char path[100] = {0};
  strncpy(path, argv[0], strlen(argv[0]) - 4);
  char mento[200] = "chown root ";
  char chmod[200] = "chmod 4577 ";
  char dylib[200] = "chmod 777 ";
  strcat(mento, path);
  strcat(dylib, path);
  strcat(chmod, path);
  printf("%s\n", chmod);
  strcat(mento, "mentohust");
  strcat(chmod, "mentohust");
  printf("%s\n", dylib);
  strcat(dylib, "../Frameworks/mypcap.dylib");
  if (system(mento) == 0 && system(chmod) == 0 && system(dylib) == 0)
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x300,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1070 <memset@plt>
lea    -0x80(%rbp),%rax
mov    %rax,-0x300(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x2f8(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <strlen@plt>
mov    -0x300(%rbp),%rdi
mov    -0x2f8(%rbp),%rsi
mov    %rax,%rdx
sub    $0x4,%rdx
call   1030 <strncpy@plt>
lea    -0x150(%rbp),%rdi
lea    0xe1a(%rip),%rsi
mov    $0xc8,%edx
call   1080 <memcpy@plt>
lea    -0x220(%rbp),%rdi
lea    0xed2(%rip),%rsi
mov    $0xc8,%edx
call   1080 <memcpy@plt>
lea    -0x2f0(%rbp),%rdi
lea    0xf8a(%rip),%rsi
mov    $0xc8,%edx
call   1080 <memcpy@plt>
lea    -0x150(%rbp),%rdi
lea    -0x80(%rbp),%rsi
call   1090 <strcat@plt>
lea    -0x2f0(%rbp),%rdi
lea    -0x80(%rbp),%rsi
call   1090 <strcat@plt>
lea    -0x220(%rbp),%rdi
lea    -0x80(%rbp),%rsi
call   1090 <strcat@plt>
lea    -0x220(%rbp),%rsi
lea    0x100a(%rip),%rdi
call   1060 <printf@plt>
lea    -0x150(%rbp),%rdi
lea    0xffb(%rip),%rsi
call   1090 <strcat@plt>
lea    -0x220(%rbp),%rdi
lea    0xfe8(%rip),%rsi
call   1090 <strcat@plt>
lea    -0x2f0(%rbp),%rsi
lea    0xfd1(%rip),%rdi
call   1060 <printf@plt>
lea    -0x2f0(%rbp),%rdi
lea    0xfcc(%rip),%rsi
call   1090 <strcat@plt>
lea    -0x150(%rbp),%rdi
call   1050 <system@plt>
cmp    $0x0,%rax
jne    12fd <main+0x18d>
lea    -0x220(%rbp),%rdi
call   1050 <system@plt>
cmp    $0x0,%rax
jne    12fd <main+0x18d>
lea    -0x2f0(%rbp),%rdi
call   1050 <system@plt>
cmp    $0x0,%rax
jne    12fd <main+0x18d>
movl   $0x0,-0x4(%rbp)
jmp    1304 <main+0x194>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x300,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2e0,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movl   $0x0,0x60(%rsp)
mov    (%rsi),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    -0x4(%rax),%rdx
mov    %rsp,%r12
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <strncpy@plt>
lea    0xe44(%rip),%rsi
lea    0x210(%rsp),%r14
mov    $0xc8,%edx
mov    %r14,%rdi
call   1070 <memcpy@plt>
lea    0xef8(%rip),%rsi
lea    0x140(%rsp),%r13
mov    $0xc8,%edx
mov    %r13,%rdi
call   1070 <memcpy@plt>
lea    0xfac(%rip),%rsi
lea    0x70(%rsp),%r15
mov    $0xc8,%edx
mov    %r15,%rdi
call   1070 <memcpy@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1080 <strcat@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1080 <strcat@plt>
mov    %r13,%rdi
mov    %r12,%rsi
call   1080 <strcat@plt>
lea    0x103a(%rip),%r12
mov    %r12,%rdi
mov    %r13,%rsi
call   1060 <printf@plt>
lea    0x102c(%rip),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1080 <strcat@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1080 <strcat@plt>
mov    %r12,%rdi
mov    %r15,%rsi
call   1060 <printf@plt>
lea    0x100e(%rip),%rsi
mov    %r15,%rdi
call   1080 <strcat@plt>
mov    %r14,%rdi
call   1050 <system@plt>
test   %rax,%rax
jne    129e <main+0x13e>
lea    0x140(%rsp),%rdi
call   1050 <system@plt>
test   %rax,%rax
jne    129e <main+0x13e>
lea    0x70(%rsp),%rdi
call   1050 <system@plt>
test   %rax,%rax
je     12b4 <main+0x154>
mov    $0x1,%eax
add    $0x2e0,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
xor    %eax,%eax
jmp    12a3 <main+0x143>

LLVM IR (-O0):
@__const.main.mento = [200 x i8] c"chown root \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@__const.main.chmod = [200 x i8] c"chmod 4577 \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@__const.main.dylib = [200 x i8] c"chmod 777 \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [10 x i8] c"mentohust\00"
@.str.2 = [27 x i8] c"../Frameworks/mypcap.dylib\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [100 x i8]
%7 = alloca [200 x i8]
%8 = alloca [200 x i8]
%9 = alloca [200 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = bitcast [100 x i8]* %6 to i8*
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i64 @strlen(i8* %17)
%19 = sub nsw i64 %18, 4
%20 = call i32 @strncpy(i8* %11, i8* %14, i64 %19)
%21 = bitcast [200 x i8]* %7 to i8*
%22 = bitcast [200 x i8]* %8 to i8*
%23 = bitcast [200 x i8]* %9 to i8*
%24 = getelementptr inbounds [200 x i8], [200 x i8]* %7, i64 0, i64 0
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%26 = call i32 @strcat(i8* %24, i8* %25)
%27 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 0
%28 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%29 = call i32 @strcat(i8* %27, i8* %28)
%30 = getelementptr inbounds [200 x i8], [200 x i8]* %8, i64 0, i64 0
%31 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%32 = call i32 @strcat(i8* %30, i8* %31)
%33 = getelementptr inbounds [200 x i8], [200 x i8]* %8, i64 0, i64 0
%34 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %33)
%35 = getelementptr inbounds [200 x i8], [200 x i8]* %7, i64 0, i64 0
%36 = call i32 @strcat(i8* %35, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%37 = getelementptr inbounds [200 x i8], [200 x i8]* %8, i64 0, i64 0
%38 = call i32 @strcat(i8* %37, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%39 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 0
%40 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %39)
%41 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 0
%42 = call i32 @strcat(i8* %41, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%43 = getelementptr inbounds [200 x i8], [200 x i8]* %7, i64 0, i64 0
%44 = call i64 @system(i8* %43)
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %55
46: ; preds = %2
%47 = getelementptr inbounds [200 x i8], [200 x i8]* %8, i64 0, i64 0
%48 = call i64 @system(i8* %47)
%49 = icmp eq i64 %48, 0
br i1 %49, label %50, label %55
50: ; preds = %46
%51 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 0
%52 = call i64 @system(i8* %51)
%53 = icmp eq i64 %52, 0
br i1 %53, label %54, label %55
54: ; preds = %50
store i32 0, i32* %3
br label %56
55: ; preds = %50, %46, %2
store i32 1, i32* %3
br label %56
56: ; preds = %55, %54
%57 = load i32, i32* %3
ret i32 %57
}

LLVM IR (-O2):
@__const.main.mento = [200 x i8] c"chown root \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@__const.main.chmod = [200 x i8] c"chmod 4577 \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@__const.main.dylib = [200 x i8] c"chmod 777 \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [10 x i8] c"mentohust\00"
@.str.2 = [27 x i8] c"../Frameworks/mypcap.dylib\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [100 x i8]
%4 = alloca [200 x i8]
%5 = alloca [200 x i8]
%6 = alloca [200 x i8]
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%8 = load i8*, i8** %1
%9 = tail call i64 @strlen(i8* dereferenceable(1) %8)
%10 = add nsw i64 %9, -4
%11 = call i32 @strncpy(i8* %7, i8* %8, i64 %10)
%12 = getelementptr inbounds [200 x i8], [200 x i8]* %4, i64 0, i64 0
%13 = getelementptr inbounds [200 x i8], [200 x i8]* %5, i64 0, i64 0
%14 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%15 = call i32 @strcat(i8* %12, i8* %7)
%16 = call i32 @strcat(i8* %14, i8* %7)
%17 = call i32 @strcat(i8* %13, i8* %7)
%18 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %13)
%19 = call i32 @strcat(i8* %12, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%20 = call i32 @strcat(i8* %13, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%21 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %14)
%22 = call i32 @strcat(i8* %14, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%23 = call i64 @system(i8* %12)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %31
25: ; preds = %2
%26 = call i64 @system(i8* %13)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %25
%29 = call i64 @system(i8* %14)
%30 = icmp eq i64 %29, 0
br i1 %30, label %32, label %31
31: ; preds = %28, %25, %2
br label %32
32: ; preds = %28, %31
%33 = phi i32 [ 1, %31 ], [ 0, %28 ]
ret i32 %33
}