#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*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
scalar_t__ strncmp(char *, char *, int);
int /*<<< orphan*/ system(char *);
int main(int argc, char **argv) {
  char *str;
  if (argc == 2) {
    if (strncmp(argv[0], "./", 2) == 0) {
      if (1) {
        str = malloc(sizeof(char) *
                     (strlen("unset LIBRARY_PATH;export "
                             "LIBRARY_PATH=$(pwd)/lib:$LIBRARY_PATH;export "
                             "PATH=$ORIGINAL_PATH:$LIBRARY_PATH;./bin/") +
                      strlen(argv[1]) + 1));
        strcpy(str, "unset LIBRARY_PATH;export "
                    "LIBRARY_PATH=$(pwd)/lib:$LIBRARY_PATH;export "
                    "PATH=$ORIGINAL_PATH:$LIBRARY_PATH;./bin/");
      } else {
        str = malloc(
            sizeof(char) *
            (strlen("unset LD_LIBRARY_PATH;export "
                    "LD_LIBRARY_PATH=$(pwd)/so:$LD_LIBRARY_PATH;./bin/") +
             strlen(argv[1]) + 1));
        strcpy(str, "unset LD_LIBRARY_PATH;export "
                    "LD_LIBRARY_PATH=$(pwd)/so:$LD_LIBRARY_PATH;./bin/");
      }
      strcat(str, argv[1]);
    } else {
      str = malloc(sizeof(char) *
                   (strlen("cmd /C \"set PATH=%PATH%;%cd%\\lib&&bin\\\"") +
                    strlen(argv[1]) + 1));
      strcpy(str, "cmd /C \"set PATH=%PATH%;%cd%\\lib&&bin\\");
      strcat(str, argv[1]);
      strcat(str, "\"");
    }
  } else if (argc == 1) {
    if (strncmp(argv[0], "./", 2) == 0) {
      if (1) {
        str = malloc(
            sizeof(char) *
            (strlen("unset LIBRARY_PATH;export "
                    "LIBRARY_PATH=$(pwd)/lib:$LIBRARY_PATH;export "
                    "PATH=$ORIGINAL_PATH:$LIBRARY_PATH;./bin/websocket.exe") +
             1));
        strcpy(str, "unset LIBRARY_PATH;export "
                    "LIBRARY_PATH=$(pwd)/lib:$LIBRARY_PATH;export "
                    "PATH=$ORIGINAL_PATH:$LIBRARY_PATH;./bin/websocket.exe");
      } else {
        str = malloc(sizeof(char) *
                     (strlen("unset LD_LIBRARY_PATH;export "
                             "LD_LIBRARY_PATH=$(pwd)/so:$LD_LIBRARY_PATH;./bin/"
                             "websocket.out") +
                      1));
        strcpy(
            str,
            "unset LD_LIBRARY_PATH;export "
            "LD_LIBRARY_PATH=$(pwd)/so:$LD_LIBRARY_PATH;./bin/websocket.out");
      }
    } else {
      str = malloc(
          sizeof(char) *
          (strlen("cmd /C \"set PATH=%PATH%;%cd%\\lib&&bin\\websocket\"") + 1));
      strcpy(str, "cmd /C \"set PATH=%PATH%;%cd%\\lib&&bin\\websocket\"");
    }
  } else {
    return 1;
  }
  system(str);
  free(str);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    127c <main+0x10c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe62(%rip),%rsi
mov    $0x2,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    120f <main+0x9f>
lea    0xe4a(%rip),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
add    %ecx,%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe0f(%rip),%rsi
call   1050 <strcpy@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1090 <strcat@plt>
jmp    1277 <main+0x107>
lea    0xe5d(%rip),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
add    %ecx,%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe4a(%rip),%rsi
call   1050 <strcpy@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1090 <strcat@plt>
mov    -0x18(%rbp),%rdi
lea    0xe27(%rip),%rsi
call   1090 <strcat@plt>
jmp    1323 <main+0x1b3>
cmpl   $0x1,-0x8(%rbp)
jne    1312 <main+0x1a2>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xd6c(%rip),%rsi
mov    $0x2,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    12dd <main+0x16d>
lea    0xe13(%rip),%rdi
call   1060 <strlen@plt>
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xdef(%rip),%rsi
call   1050 <strcpy@plt>
jmp    130d <main+0x19d>
lea    0xe5b(%rip),%rdi
call   1060 <strlen@plt>
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe37(%rip),%rsi
call   1050 <strcpy@plt>
jmp    131e <main+0x1ae>
movl   $0x1,-0x4(%rbp)
jmp    133c <main+0x1cc>
jmp    1323 <main+0x1b3>
mov    -0x18(%rbp),%rdi
call   1070 <system@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
cmp    $0x1,%edi
je     11ed <main+0x7d>
mov    $0x1,%eax
cmp    $0x2,%edi
jne    1287 <main+0x117>
mov    (%r14),%rdi
lea    0xe6b(%rip),%rsi
mov    $0x2,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     120f <main+0x9f>
lea    0xec8(%rip),%rdi
call   1060 <strlen@plt>
mov    %eax,%ebx
mov    0x8(%r14),%rdi
call   1060 <strlen@plt>
lea    (%rbx,%rax,1),%edi
add    $0x1,%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
lea    0xecb(%rip),%rsi
mov    %rax,%rdi
call   1050 <strcpy@plt>
mov    0x8(%r14),%rsi
mov    %rbx,%rdi
call   1090 <strcat@plt>
lea    0xeae(%rip),%rsi
jmp    1246 <main+0xd6>
mov    (%r14),%rdi
lea    0xe09(%rip),%rsi
mov    $0x2,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     1250 <main+0xe0>
lea    0xf32(%rip),%r14
jmp    1257 <main+0xe7>
lea    0xded(%rip),%r15
mov    %r15,%rdi
call   1060 <strlen@plt>
mov    %eax,%ebx
mov    0x8(%r14),%rdi
call   1060 <strlen@plt>
lea    (%rbx,%rax,1),%edi
add    $0x1,%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r15,%rsi
call   1050 <strcpy@plt>
mov    0x8(%r14),%rsi
mov    %rbx,%rdi
call   1090 <strcat@plt>
jmp    1275 <main+0x105>
lea    0xe6b(%rip),%r14
mov    %r14,%rdi
call   1060 <strlen@plt>
lea    0x1(%rax),%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1050 <strcpy@plt>
mov    %rbx,%rdi
call   1070 <system@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"./\00"
@.str.1 = [112 x i8] c"unset LIBRARY_PATH;export LIBRARY_PATH=$(pwd)/lib:$LIBRARY_PATH;export PATH=$ORIGINAL_PATH:$LIBRARY_PATH;./bin/\00"
@.str.2 = [40 x i8] c"cmd /C \22set PATH=%PATH%;%cd%\\lib&&bin\\\22\00"
@.str.3 = [39 x i8] c"cmd /C \22set PATH=%PATH%;%cd%\\lib&&bin\\\00"
@.str.4 = [2 x i8] c"\22\00"
@.str.5 = [125 x i8] c"unset LIBRARY_PATH;export LIBRARY_PATH=$(pwd)/lib:$LIBRARY_PATH;export PATH=$ORIGINAL_PATH:$LIBRARY_PATH;./bin/websocket.exe\00"
@.str.6 = [49 x i8] c"cmd /C \22set PATH=%PATH%;%cd%\\lib&&bin\\websocket\22\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 2
br i1 %8, label %9, label %56
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 0
%12 = load i8*, i8** %11
%13 = call i64 @strncmp(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %34
15: ; preds = %9
%16 = call i32 @strlen(i8* getelementptr inbounds ([112 x i8], [112 x i8]* @.str.1, i64 0, i64 0))
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32 @strlen(i8* %19)
%21 = add nsw i32 %16, %20
%22 = add nsw i32 %21, 1
%23 = sext i32 %22 to i64
%24 = mul i64 1, %23
%25 = trunc i64 %24 to i32
%26 = call i8* @malloc(i32 %25)
store i8* %26, i8** %6
%27 = load i8*, i8** %6
%28 = call i32 @strcpy(i8* %27, i8* getelementptr inbounds ([112 x i8], [112 x i8]* @.str.1, i64 0, i64 0))
%29 = load i8*, i8** %6
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = call i32 @strcat(i8* %29, i8* %32)
br label %55
34: ; preds = %9
%35 = call i32 @strlen(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 1
%38 = load i8*, i8** %37
%39 = call i32 @strlen(i8* %38)
%40 = add nsw i32 %35, %39
%41 = add nsw i32 %40, 1
%42 = sext i32 %41 to i64
%43 = mul i64 1, %42
%44 = trunc i64 %43 to i32
%45 = call i8* @malloc(i32 %44)
store i8* %45, i8** %6
%46 = load i8*, i8** %6
%47 = call i32 @strcpy(i8* %46, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0))
%48 = load i8*, i8** %6
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 1
%51 = load i8*, i8** %50
%52 = call i32 @strcat(i8* %48, i8* %51)
%53 = load i8*, i8** %6
%54 = call i32 @strcat(i8* %53, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %55
55: ; preds = %34, %15
br label %86
56: ; preds = %2
%57 = load i32, i32* %4
%58 = icmp eq i32 %57, 1
br i1 %58, label %59, label %84
59: ; preds = %56
%60 = load i8**, i8*** %5
%61 = getelementptr inbounds i8*, i8** %60, i64 0
%62 = load i8*, i8** %61
%63 = call i64 @strncmp(i8* %62, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%64 = icmp eq i64 %63, 0
br i1 %64, label %65, label %74
65: ; preds = %59
%66 = call i32 @strlen(i8* getelementptr inbounds ([125 x i8], [125 x i8]* @.str.5, i64 0, i64 0))
%67 = add nsw i32 %66, 1
%68 = sext i32 %67 to i64
%69 = mul i64 1, %68
%70 = trunc i64 %69 to i32
%71 = call i8* @malloc(i32 %70)
store i8* %71, i8** %6
%72 = load i8*, i8** %6
%73 = call i32 @strcpy(i8* %72, i8* getelementptr inbounds ([125 x i8], [125 x i8]* @.str.5, i64 0, i64 0))
br label %83
74: ; preds = %59
%75 = call i32 @strlen(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.6, i64 0, i64 0))
%76 = add nsw i32 %75, 1
%77 = sext i32 %76 to i64
%78 = mul i64 1, %77
%79 = trunc i64 %78 to i32
%80 = call i8* @malloc(i32 %79)
store i8* %80, i8** %6
%81 = load i8*, i8** %6
%82 = call i32 @strcpy(i8* %81, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.6, i64 0, i64 0))
br label %83
83: ; preds = %74, %65
br label %85
84: ; preds = %56
store i32 1, i32* %3
br label %91
85: ; preds = %83
br label %86
86: ; preds = %85, %55
%87 = load i8*, i8** %6
%88 = call i32 @system(i8* %87)
%89 = load i8*, i8** %6
%90 = call i32 @free(i8* %89)
store i32 0, i32* %3
br label %91
91: ; preds = %86, %84
%92 = load i32, i32* %3
ret i32 %92
}

LLVM IR (-O2):
@.str = [3 x i8] c"./\00"
@.str.1 = [112 x i8] c"unset LIBRARY_PATH;export LIBRARY_PATH=$(pwd)/lib:$LIBRARY_PATH;export PATH=$ORIGINAL_PATH:$LIBRARY_PATH;./bin/\00"
@.str.2 = [40 x i8] c"cmd /C \22set PATH=%PATH%;%cd%\\lib&&bin\\\22\00"
@.str.3 = [39 x i8] c"cmd /C \22set PATH=%PATH%;%cd%\\lib&&bin\\\00"
@.str.4 = [2 x i8] c"\22\00"
@.str.5 = [125 x i8] c"unset LIBRARY_PATH;export LIBRARY_PATH=$(pwd)/lib:$LIBRARY_PATH;export PATH=$ORIGINAL_PATH:$LIBRARY_PATH;./bin/websocket.exe\00"
@.str.6 = [49 x i8] c"cmd /C \22set PATH=%PATH%;%cd%\\lib&&bin\\websocket\22\00"
define i32 @main(i32 %0, i8** nocapture %1) {
switch i32 %0, label %48 [
i32 2, label %3
i32 1, label %30
]
3: ; preds = %2
%4 = load i8*, i8** %1
%5 = tail call i64 @strncmp(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %18
7: ; preds = %3
%8 = tail call i32 @strlen(i8* getelementptr inbounds ([112 x i8], [112 x i8]* @.str.1, i64 0, i64 0))
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @strlen(i8* %10)
%12 = add i32 %8, 1
%13 = add i32 %12, %11
%14 = tail call i8* @malloc(i32 %13)
%15 = tail call i32 @strcpy(i8* %14, i8* getelementptr inbounds ([112 x i8], [112 x i8]* @.str.1, i64 0, i64 0))
%16 = load i8*, i8** %9
%17 = tail call i32 @strcat(i8* %14, i8* %16)
br label %44
18: ; preds = %3
%19 = tail call i32 @strlen(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
%20 = getelementptr inbounds i8*, i8** %1, i64 1
%21 = load i8*, i8** %20
%22 = tail call i32 @strlen(i8* %21)
%23 = add i32 %19, 1
%24 = add i32 %23, %22
%25 = tail call i8* @malloc(i32 %24)
%26 = tail call i32 @strcpy(i8* %25, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0))
%27 = load i8*, i8** %20
%28 = tail call i32 @strcat(i8* %25, i8* %27)
%29 = tail call i32 @strcat(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %44
30: ; preds = %2
%31 = load i8*, i8** %1
%32 = tail call i64 @strncmp(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %39
34: ; preds = %30
%35 = tail call i32 @strlen(i8* getelementptr inbounds ([125 x i8], [125 x i8]* @.str.5, i64 0, i64 0))
%36 = add nsw i32 %35, 1
%37 = tail call i8* @malloc(i32 %36)
%38 = tail call i32 @strcpy(i8* %37, i8* getelementptr inbounds ([125 x i8], [125 x i8]* @.str.5, i64 0, i64 0))
br label %44
39: ; preds = %30
%40 = tail call i32 @strlen(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.6, i64 0, i64 0))
%41 = add nsw i32 %40, 1
%42 = tail call i8* @malloc(i32 %41)
%43 = tail call i32 @strcpy(i8* %42, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.6, i64 0, i64 0))
br label %44
44: ; preds = %39, %34, %7, %18
%45 = phi i8* [ %14, %7 ], [ %25, %18 ], [ %37, %34 ], [ %42, %39 ]
%46 = tail call i32 @system(i8* %45)
%47 = tail call i32 @free(i8* %45)
br label %48
48: ; preds = %2, %44
%49 = phi i32 [ 0, %44 ], [ 1, %2 ]
ret i32 %49
}