#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 */
struct dirent {
  scalar_t__ d_type;
  char *d_name;
};
typedef int /*<<< orphan*/ line;
typedef int /*<<< orphan*/ lName;
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
scalar_t__ DT_DIR;
scalar_t__ DT_LNK;
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
scalar_t__ isdigit(char);
int /*<<< orphan*/ *opendir(char *);
int /*<<< orphan*/ printf(char *, char *, ...);
struct dirent *readdir(int /*<<< orphan*/ *);
int readlink(char *, char *, int);
int snprintf(char *, int, char *, char *, ...);
scalar_t__ sscanf(char *, char *, long *);
scalar_t__ strcmp(char *, char *);
int TcpCheckProccesses(unsigned long searchInode) {
  char line[4096];
  int procFdLen, lNameLen, len;
  char lName[4096];
  long inode;
  struct dirent *direProc, *direFd;
  DIR *dirProc = NULL, *dirFd = NULL;
  int isValid = 0;
  if ((dirProc = opendir("/proc")) == NULL)
    return 0;
  while ((direProc = readdir(dirProc)) != NULL) {
    if (direProc->d_type != DT_DIR)
      continue;
    if (isdigit(*direProc->d_name) == 0)
      continue;
    procFdLen = snprintf(line, sizeof(line),
                         "/proc"
                         "/%s/"
                         "fd",
                         direProc->d_name);
    if (procFdLen <= 0 || procFdLen >= sizeof(line) - 5)
      continue;
    dirFd = opendir(line);
    if (dirFd == NULL)
      continue;
    while ((direFd = readdir(dirFd))) {
      if (direFd->d_type != DT_LNK)
        continue;
      len = snprintf(line, sizeof(line),
                     "/proc"
                     "/%s/"
                     "fd"
                     "/%s",
                     direProc->d_name, direFd->d_name);
      if (len <= 0 || len >= sizeof(line))
        continue;
      lNameLen = readlink(line, lName, sizeof(lName) - 1);
      if (lNameLen == -1)
        continue;
      lName[lNameLen] = '\0';
      if (sscanf(lName, "socket:[%ld]", &inode) == 0)
        if (sscanf(lName, "[0000]:%ld", &inode) == 0)
          continue;
      printf("[%s]lname [%s] => inode[%li] // %li\n", line, lName, inode,
             searchInode);
      if (inode == searchInode) {
        len = snprintf(line, sizeof(line),
                       "/proc"
                       "/%s/"
                       "exe",
                       direProc->d_name);
        if (len <= 0 || len >= sizeof(line))
          continue;
        printf("Try to readfile: %s\n", line);
        lNameLen = readlink(line, lName, sizeof(lName) - 1);
        if (lNameLen == -1)
          continue;
        lName[lNameLen] = '\0';
        printf("APP: %s [%i]\n", lName, lNameLen);
        if (strcmp(lName, "/home/teka/Documents/Developpement/MySecureShell/"
                          "mysecureshell-3.x/MSS_client") == 0)
          isValid = 1;
        goto TcpCheckProccesses_end;
      }
    }
    closedir(dirFd);
    dirFd = NULL;
  }
TcpCheckProccesses_end:
  if (dirProc != NULL)
    closedir(dirProc);
  if (dirFd != NULL)
    closedir(dirFd);
  return isValid;
}


x86 assembly (clang, -O0):
<TcpCheckProccesses>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2050,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x2040(%rbp)
movq   $0x0,-0x2048(%rbp)
movl   $0x0,-0x204c(%rbp)
lea    0xe3a(%rip),%rdi
call   1050 <opendir@plt>
mov    %rax,-0x2040(%rbp)
cmp    $0x0,%rax
jne    11e8 <TcpCheckProccesses+0x58>
movl   $0x0,-0x4(%rbp)
jmp    1574 <TcpCheckProccesses+0x3e4>
jmp    11ed <TcpCheckProccesses+0x5d>
mov    -0x2040(%rbp),%rdi
call   10a0 <readdir@plt>
mov    %rax,-0x2030(%rbp)
cmp    $0x0,%rax
je     1532 <TcpCheckProccesses+0x3a2>
mov    -0x2030(%rbp),%rax
mov    (%rax),%rax
mov    0x2dc5(%rip),%rcx
cmp    (%rcx),%rax
je     1229 <TcpCheckProccesses+0x99>
jmp    11ed <TcpCheckProccesses+0x5d>
mov    -0x2030(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
jne    124b <TcpCheckProccesses+0xbb>
jmp    11ed <TcpCheckProccesses+0x5d>
lea    -0x1010(%rbp),%rdi
mov    -0x2030(%rbp),%rax
mov    0x8(%rax),%rcx
mov    $0x1000,%esi
lea    0xd9d(%rip),%rdx
mov    $0x0,%al
call   1070 <snprintf@plt>
mov    %eax,-0x1014(%rbp)
cmpl   $0x0,-0x1014(%rbp)
jle    1296 <TcpCheckProccesses+0x106>
movslq -0x1014(%rbp),%rax
cmp    $0xffb,%rax
jb     129b <TcpCheckProccesses+0x10b>
jmp    11ed <TcpCheckProccesses+0x5d>
lea    -0x1010(%rbp),%rdi
call   1050 <opendir@plt>
mov    %rax,-0x2048(%rbp)
cmpq   $0x0,-0x2048(%rbp)
jne    12c1 <TcpCheckProccesses+0x131>
jmp    11ed <TcpCheckProccesses+0x5d>
jmp    12c6 <TcpCheckProccesses+0x136>
mov    -0x2048(%rbp),%rdi
call   10a0 <readdir@plt>
mov    %rax,-0x2038(%rbp)
cmp    $0x0,%rax
je     1516 <TcpCheckProccesses+0x386>
mov    -0x2038(%rbp),%rax
mov    (%rax),%rax
mov    0x2ce4(%rip),%rcx
cmp    (%rcx),%rax
je     1302 <TcpCheckProccesses+0x172>
jmp    12c6 <TcpCheckProccesses+0x136>
lea    -0x1010(%rbp),%rdi
mov    -0x2030(%rbp),%rax
mov    0x8(%rax),%rcx
mov    -0x2038(%rbp),%rax
mov    0x8(%rax),%r8
mov    $0x1000,%esi
lea    0xce7(%rip),%rdx
mov    $0x0,%al
call   1070 <snprintf@plt>
mov    %eax,-0x101c(%rbp)
cmpl   $0x0,-0x101c(%rbp)
jle    1358 <TcpCheckProccesses+0x1c8>
movslq -0x101c(%rbp),%rax
cmp    $0x1000,%rax
jb     135d <TcpCheckProccesses+0x1cd>
jmp    12c6 <TcpCheckProccesses+0x136>
lea    -0x1010(%rbp),%rdi
lea    -0x2020(%rbp),%rsi
mov    $0xfff,%edx
call   1040 <readlink@plt>
mov    %eax,-0x1018(%rbp)
cmpl   $0xffffffff,-0x1018(%rbp)
jne    138d <TcpCheckProccesses+0x1fd>
jmp    12c6 <TcpCheckProccesses+0x136>
movslq -0x1018(%rbp),%rax
movb   $0x0,-0x2020(%rbp,%rax,1)
lea    -0x2020(%rbp),%rdi
lea    0xc77(%rip),%rsi
lea    -0x2028(%rbp),%rdx
call   10b0 <sscanf@plt>
cmp    $0x0,%rax
jne    13ee <TcpCheckProccesses+0x25e>
lea    -0x2020(%rbp),%rdi
lea    0xc60(%rip),%rsi
lea    -0x2028(%rbp),%rdx
call   10b0 <sscanf@plt>
cmp    $0x0,%rax
jne    13e9 <TcpCheckProccesses+0x259>
jmp    12c6 <TcpCheckProccesses+0x136>
jmp    13ee <TcpCheckProccesses+0x25e>
lea    -0x1010(%rbp),%rsi
lea    -0x2020(%rbp),%rdx
mov    -0x2028(%rbp),%rcx
mov    -0x10(%rbp),%r8
lea    0xc2b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x2028(%rbp),%rax
cmp    -0x10(%rbp),%rax
jne    1511 <TcpCheckProccesses+0x381>
lea    -0x1010(%rbp),%rdi
mov    -0x2030(%rbp),%rax
mov    0x8(%rax),%rcx
mov    $0x1000,%esi
lea    0xc1a(%rip),%rdx
mov    $0x0,%al
call   1070 <snprintf@plt>
mov    %eax,-0x101c(%rbp)
cmpl   $0x0,-0x101c(%rbp)
jle    1471 <TcpCheckProccesses+0x2e1>
movslq -0x101c(%rbp),%rax
cmp    $0x1000,%rax
jb     1476 <TcpCheckProccesses+0x2e6>
jmp    12c6 <TcpCheckProccesses+0x136>
lea    -0x1010(%rbp),%rsi
lea    0xbe7(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x1010(%rbp),%rdi
lea    -0x2020(%rbp),%rsi
mov    $0xfff,%edx
call   1040 <readlink@plt>
mov    %eax,-0x1018(%rbp)
cmpl   $0xffffffff,-0x1018(%rbp)
jne    14bb <TcpCheckProccesses+0x32b>
jmp    12c6 <TcpCheckProccesses+0x136>
movslq -0x1018(%rbp),%rax
movb   $0x0,-0x2020(%rbp,%rax,1)
lea    -0x2020(%rbp),%rsi
mov    -0x1018(%rbp),%edx
lea    0xba2(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x2020(%rbp),%rdi
lea    0xb9b(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    150c <TcpCheckProccesses+0x37c>
movl   $0x1,-0x204c(%rbp)
jmp    1537 <TcpCheckProccesses+0x3a7>
jmp    12c6 <TcpCheckProccesses+0x136>
mov    -0x2048(%rbp),%rdi
call   1080 <closedir@plt>
movq   $0x0,-0x2048(%rbp)
jmp    11ed <TcpCheckProccesses+0x5d>
jmp    1537 <TcpCheckProccesses+0x3a7>
cmpq   $0x0,-0x2040(%rbp)
je     1551 <TcpCheckProccesses+0x3c1>
mov    -0x2040(%rbp),%rdi
call   1080 <closedir@plt>
cmpq   $0x0,-0x2048(%rbp)
je     156b <TcpCheckProccesses+0x3db>
mov    -0x2048(%rbp),%rdi
call   1080 <closedir@plt>
mov    -0x204c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x2050,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TcpCheckProccesses>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2028,%rsp
mov    %rdi,0x18(%rsp)
lea    0xe53(%rip),%rdi
call   1050 <opendir@plt>
xor    %ebx,%ebx
test   %rax,%rax
je     13fb <TcpCheckProccesses+0x26b>
mov    %rax,%r13
mov    %rax,%rdi
call   10a0 <readdir@plt>
test   %rax,%rax
je     13f1 <TcpCheckProccesses+0x261>
mov    %rax,%rbx
mov    0x2e05(%rip),%rbp
lea    0x1020(%rsp),%r12
mov    0x2dee(%rip),%r15
lea    0xe21(%rip),%r14
jmp    1214 <TcpCheckProccesses+0x84>
mov    0x8(%rsp),%rdi
call   1080 <closedir@plt>
nopl   (%rax)
mov    %r13,%rdi
call   10a0 <readdir@plt>
mov    %rax,%rbx
test   %rax,%rax
je     13f1 <TcpCheckProccesses+0x261>
mov    (%rbx),%rax
cmp    0x0(%rbp),%rax
jne    1200 <TcpCheckProccesses+0x70>
mov    0x8(%rbx),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     1200 <TcpCheckProccesses+0x70>
mov    0x8(%rbx),%rcx
mov    %r12,%rdi
mov    $0x1000,%esi
lea    0xdc5(%rip),%rdx
xor    %eax,%eax
call   1070 <snprintf@plt>
add    $0xfffff005,%eax
cmp    $0xfffff006,%eax
jb     1200 <TcpCheckProccesses+0x70>
mov    %r12,%rdi
call   1050 <opendir@plt>
test   %rax,%rax
je     1200 <TcpCheckProccesses+0x70>
mov    %rax,0x8(%rsp)
mov    %rax,%rdi
jmp    1275 <TcpCheckProccesses+0xe5>
nopl   0x0(%rax,%rax,1)
mov    0x8(%rsp),%rdi
call   10a0 <readdir@plt>
test   %rax,%rax
je     11f3 <TcpCheckProccesses+0x63>
mov    (%rax),%rcx
cmp    (%r15),%rcx
jne    1270 <TcpCheckProccesses+0xe0>
mov    0x8(%rbx),%rcx
mov    0x8(%rax),%r8
mov    %r12,%rdi
mov    $0x1000,%esi
mov    %r14,%rdx
xor    %eax,%eax
call   1070 <snprintf@plt>
add    $0xfffff000,%eax
cmp    $0xfffff001,%eax
jb     1270 <TcpCheckProccesses+0xe0>
mov    %r12,%rdi
lea    0x20(%rsp),%rsi
mov    $0xfff,%edx
call   1040 <readlink@plt>
cmp    $0xffffffff,%eax
je     1270 <TcpCheckProccesses+0xe0>
cltq
movb   $0x0,0x20(%rsp,%rax,1)
lea    0x20(%rsp),%rdi
lea    0xd46(%rip),%rsi
lea    0x10(%rsp),%rdx
call   10b0 <sscanf@plt>
test   %rax,%rax
jne    1309 <TcpCheckProccesses+0x179>
lea    0x20(%rsp),%rdi
lea    0xd38(%rip),%rsi
lea    0x10(%rsp),%rdx
call   10b0 <sscanf@plt>
test   %rax,%rax
je     1270 <TcpCheckProccesses+0xe0>
mov    0x10(%rsp),%rcx
lea    0xd24(%rip),%rdi
mov    %r12,%rsi
lea    0x20(%rsp),%rdx
mov    %r12,%r14
mov    %r13,%r12
mov    %r15,%r13
mov    0x18(%rsp),%r15
mov    %r15,%r8
xor    %eax,%eax
call   1060 <printf@plt>
cmp    %r15,0x10(%rsp)
mov    %r13,%r15
mov    %r12,%r13
mov    %r14,%r12
lea    0xcc8(%rip),%r14
jne    1270 <TcpCheckProccesses+0xe0>
mov    0x8(%rbx),%rcx
mov    %r12,%rdi
mov    $0x1000,%esi
lea    0xcfb(%rip),%rdx
xor    %eax,%eax
call   1070 <snprintf@plt>
add    $0xfffff000,%eax
cmp    $0xfffff001,%eax
jb     1270 <TcpCheckProccesses+0xe0>
lea    0xcea(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r12,%rdi
lea    0x20(%rsp),%rsi
mov    $0xfff,%edx
call   1040 <readlink@plt>
cmp    $0xffffffff,%eax
je     1270 <TcpCheckProccesses+0xe0>
movslq %eax,%rcx
movb   $0x0,0x20(%rsp,%rcx,1)
lea    0xccb(%rip),%rdi
lea    0x20(%rsp),%rbx
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xcc1(%rip),%rsi
mov    %rbx,%rdi
call   1090 <strcmp@plt>
xor    %ebx,%ebx
test   %rax,%rax
sete   %bl
mov    %r13,%rdi
call   1080 <closedir@plt>
mov    0x8(%rsp),%rdi
call   1080 <closedir@plt>
jmp    13fb <TcpCheckProccesses+0x26b>
mov    %r13,%rdi
call   1080 <closedir@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x2028,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.dirent = type { i64, i8* }
@.str = [6 x i8] c"/proc\00"
@DT_DIR = global i64 0
@.str.1 = [12 x i8] c"/proc/%s/fd\00"
@DT_LNK = global i64 0
@.str.2 = [15 x i8] c"/proc/%s/fd/%s\00"
@.str.3 = [13 x i8] c"socket:[%ld]\00"
@.str.4 = [11 x i8] c"[0000]:%ld\00"
@.str.5 = [37 x i8] c"[%s]lname [%s] => inode[%li] // %li\0A\00"
@.str.6 = [13 x i8] c"/proc/%s/exe\00"
@.str.7 = [21 x i8] c"Try to readfile: %s\0A\00"
@.str.8 = [14 x i8] c"APP: %s [%i]\0A\00"
@.str.9 = [78 x i8] c"/home/teka/Documents/Developpement/MySecureShell/mysecureshell-3.x/MSS_client\00"
define i32 @TcpCheckProccesses(i64 %0) {
%2 = alloca i32
%3 = alloca i64
%4 = alloca [4096 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [4096 x i8]
%9 = alloca i64
%10 = alloca %struct.dirent*
%11 = alloca %struct.dirent*
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32
store i64 %0, i64* %3
store i32* null, i32** %12
store i32* null, i32** %13
store i32 0, i32* %14
%15 = call i32* @opendir(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i32* %15, i32** %12
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %18
17: ; preds = %1
store i32 0, i32* %2
br label %167
18: ; preds = %1
br label %19
19: ; preds = %149, %56, %50, %37, %29, %18
%20 = load i32*, i32** %12
%21 = call %struct.dirent* @readdir(i32* %20)
store %struct.dirent* %21, %struct.dirent** %10
%22 = icmp ne %struct.dirent* %21, null
br i1 %22, label %23, label %152
23: ; preds = %19
%24 = load %struct.dirent*, %struct.dirent** %10
%25 = getelementptr inbounds %struct.dirent, %struct.dirent* %24, i32 0, i32 0
%26 = load i64, i64* %25
%27 = load i64, i64* @DT_DIR
%28 = icmp ne i64 %26, %27
br i1 %28, label %29, label %30
29: ; preds = %23
br label %19
30: ; preds = %23
%31 = load %struct.dirent*, %struct.dirent** %10
%32 = getelementptr inbounds %struct.dirent, %struct.dirent* %31, i32 0, i32 1
%33 = load i8*, i8** %32
%34 = load i8, i8* %33
%35 = call i64 @isdigit(i8 signext %34)
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %30
br label %19
38: ; preds = %30
%39 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%40 = load %struct.dirent*, %struct.dirent** %10
%41 = getelementptr inbounds %struct.dirent, %struct.dirent* %40, i32 0, i32 1
%42 = load i8*, i8** %41
%43 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %39, i32 4096, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %42)
store i32 %43, i32* %5
%44 = load i32, i32* %5
%45 = icmp sle i32 %44, 0
br i1 %45, label %50, label %46
46: ; preds = %38
%47 = load i32, i32* %5
%48 = sext i32 %47 to i64
%49 = icmp uge i64 %48, 4091
br i1 %49, label %50, label %51
50: ; preds = %46, %38
br label %19
51: ; preds = %46
%52 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%53 = call i32* @opendir(i8* %52)
store i32* %53, i32** %13
%54 = load i32*, i32** %13
%55 = icmp eq i32* %54, null
br i1 %55, label %56, label %57
56: ; preds = %51
br label %19
57: ; preds = %51
br label %58
58: ; preds = %148, %135, %126, %103, %91, %84, %68, %57
%59 = load i32*, i32** %13
%60 = call %struct.dirent* @readdir(i32* %59)
store %struct.dirent* %60, %struct.dirent** %11
%61 = icmp ne %struct.dirent* %60, null
br i1 %61, label %62, label %149
62: ; preds = %58
%63 = load %struct.dirent*, %struct.dirent** %11
%64 = getelementptr inbounds %struct.dirent, %struct.dirent* %63, i32 0, i32 0
%65 = load i64, i64* %64
%66 = load i64, i64* @DT_LNK
%67 = icmp ne i64 %65, %66
br i1 %67, label %68, label %69
68: ; preds = %62
br label %58
69: ; preds = %62
%70 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%71 = load %struct.dirent*, %struct.dirent** %10
%72 = getelementptr inbounds %struct.dirent, %struct.dirent* %71, i32 0, i32 1
%73 = load i8*, i8** %72
%74 = load %struct.dirent*, %struct.dirent** %11
%75 = getelementptr inbounds %struct.dirent, %struct.dirent* %74, i32 0, i32 1
%76 = load i8*, i8** %75
%77 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %70, i32 4096, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %73, i8* %76)
store i32 %77, i32* %7
%78 = load i32, i32* %7
%79 = icmp sle i32 %78, 0
br i1 %79, label %84, label %80
80: ; preds = %69
%81 = load i32, i32* %7
%82 = sext i32 %81 to i64
%83 = icmp uge i64 %82, 4096
br i1 %83, label %84, label %85
84: ; preds = %80, %69
br label %58
85: ; preds = %80
%86 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%87 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%88 = call i32 @readlink(i8* %86, i8* %87, i32 4095)
store i32 %88, i32* %6
%89 = load i32, i32* %6
%90 = icmp eq i32 %89, -1
br i1 %90, label %91, label %92
91: ; preds = %85
br label %58
92: ; preds = %85
%93 = load i32, i32* %6
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 %94
store i8 0, i8* %95
%96 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%97 = call i64 @sscanf(i8* %96, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i64* %9)
%98 = icmp eq i64 %97, 0
br i1 %98, label %99, label %105
99: ; preds = %92
%100 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%101 = call i64 @sscanf(i8* %100, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i64* %9)
%102 = icmp eq i64 %101, 0
br i1 %102, label %103, label %104
103: ; preds = %99
br label %58
104: ; preds = %99
br label %105
105: ; preds = %104, %92
%106 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%107 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%108 = load i64, i64* %9
%109 = load i64, i64* %3
%110 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0), i8* %106, i8* %107, i64 %108, i64 %109)
%111 = load i64, i64* %9
%112 = load i64, i64* %3
%113 = icmp eq i64 %111, %112
br i1 %113, label %114, label %148
114: ; preds = %105
%115 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%116 = load %struct.dirent*, %struct.dirent** %10
%117 = getelementptr inbounds %struct.dirent, %struct.dirent* %116, i32 0, i32 1
%118 = load i8*, i8** %117
%119 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %115, i32 4096, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i8* %118)
store i32 %119, i32* %7
%120 = load i32, i32* %7
%121 = icmp sle i32 %120, 0
br i1 %121, label %126, label %122
122: ; preds = %114
%123 = load i32, i32* %7
%124 = sext i32 %123 to i64
%125 = icmp uge i64 %124, 4096
br i1 %125, label %126, label %127
126: ; preds = %122, %114
br label %58
127: ; preds = %122
%128 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%129 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i8* %128)
%130 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%131 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%132 = call i32 @readlink(i8* %130, i8* %131, i32 4095)
store i32 %132, i32* %6
%133 = load i32, i32* %6
%134 = icmp eq i32 %133, -1
br i1 %134, label %135, label %136
135: ; preds = %127
br label %58
136: ; preds = %127
%137 = load i32, i32* %6
%138 = sext i32 %137 to i64
%139 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 %138
store i8 0, i8* %139
%140 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%141 = load i32, i32* %6
%142 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0), i8* %140, i32 %141)
%143 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%144 = call i64 @strcmp(i8* %143, i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str.9, i64 0, i64 0))
%145 = icmp eq i64 %144, 0
br i1 %145, label %146, label %147
146: ; preds = %136
store i32 1, i32* %14
br label %147
147: ; preds = %146, %136
br label %153
148: ; preds = %105
br label %58
149: ; preds = %58
%150 = load i32*, i32** %13
%151 = call i32 @closedir(i32* %150)
store i32* null, i32** %13
br label %19
152: ; preds = %19
br label %153
153: ; preds = %152, %147
%154 = load i32*, i32** %12
%155 = icmp ne i32* %154, null
br i1 %155, label %156, label %159
156: ; preds = %153
%157 = load i32*, i32** %12
%158 = call i32 @closedir(i32* %157)
br label %159
159: ; preds = %156, %153
%160 = load i32*, i32** %13
%161 = icmp ne i32* %160, null
br i1 %161, label %162, label %165
162: ; preds = %159
%163 = load i32*, i32** %13
%164 = call i32 @closedir(i32* %163)
br label %165
165: ; preds = %162, %159
%166 = load i32, i32* %14
store i32 %166, i32* %2
br label %167
167: ; preds = %165, %17
%168 = load i32, i32* %2
ret i32 %168
}

LLVM IR (-O2):
%struct.dirent = type { i64, i8* }
@.str = [6 x i8] c"/proc\00"
@DT_DIR = global i64 0
@.str.1 = [12 x i8] c"/proc/%s/fd\00"
@DT_LNK = global i64 0
@.str.2 = [15 x i8] c"/proc/%s/fd/%s\00"
@.str.3 = [13 x i8] c"socket:[%ld]\00"
@.str.4 = [11 x i8] c"[0000]:%ld\00"
@.str.5 = [37 x i8] c"[%s]lname [%s] => inode[%li] // %li\0A\00"
@.str.6 = [13 x i8] c"/proc/%s/exe\00"
@.str.7 = [21 x i8] c"Try to readfile: %s\0A\00"
@.str.8 = [14 x i8] c"APP: %s [%i]\0A\00"
@.str.9 = [78 x i8] c"/home/teka/Documents/Developpement/MySecureShell/mysecureshell-3.x/MSS_client\00"
define i32 @TcpCheckProccesses(i64 %0) {
%2 = alloca [4096 x i8]
%3 = alloca [4096 x i8]
%4 = alloca i64
%5 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%7 = bitcast i64* %4 to i8*
%8 = tail call i32* @opendir(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %93, label %10
10: ; preds = %1
%11 = call %struct.dirent* @readdir(i32* %8)
%12 = icmp eq %struct.dirent* %11, null
br i1 %12, label %13, label %15
13: ; preds = %81, %10
%14 = call i32 @closedir(i32* %8)
br label %93
15: ; preds = %10, %81
%16 = phi %struct.dirent* [ %82, %81 ], [ %11, %10 ]
%17 = getelementptr inbounds %struct.dirent, %struct.dirent* %16, i64 0, i32 0
%18 = load i64, i64* %17
%19 = load i64, i64* @DT_DIR
%20 = icmp eq i64 %18, %19
br i1 %20, label %21, label %81
21: ; preds = %15
%22 = getelementptr inbounds %struct.dirent, %struct.dirent* %16, i64 0, i32 1
%23 = load i8*, i8** %22
%24 = load i8, i8* %23
%25 = call i64 @isdigit(i8 signext %24)
%26 = icmp eq i64 %25, 0
br i1 %26, label %81, label %27
27: ; preds = %21
%28 = load i8*, i8** %22
%29 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %5, i32 4096, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %28)
%30 = add i32 %29, -4091
%31 = icmp ult i32 %30, -4090
br i1 %31, label %81, label %32
32: ; preds = %27
%33 = call i32* @opendir(i8* %5)
%34 = icmp eq i32* %33, null
br i1 %34, label %81, label %35
35: ; preds = %32
%36 = call %struct.dirent* @readdir(i32* %33)
%37 = icmp eq %struct.dirent* %36, null
br i1 %37, label %79, label %38
38: ; preds = %35, %44
%39 = phi %struct.dirent* [ %45, %44 ], [ %36, %35 ]
%40 = getelementptr inbounds %struct.dirent, %struct.dirent* %39, i64 0, i32 0
%41 = load i64, i64* %40
%42 = load i64, i64* @DT_LNK
%43 = icmp eq i64 %41, %42
br i1 %43, label %47, label %44
44: ; preds = %38, %47, %54, %62, %70, %75, %65
%45 = call %struct.dirent* @readdir(i32* %33)
%46 = icmp eq %struct.dirent* %45, null
br i1 %46, label %79, label %38
47: ; preds = %38
%48 = load i8*, i8** %22
%49 = getelementptr inbounds %struct.dirent, %struct.dirent* %39, i64 0, i32 1
%50 = load i8*, i8** %49
%51 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %5, i32 4096, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %48, i8* %50)
%52 = add i32 %51, -4096
%53 = icmp ult i32 %52, -4095
br i1 %53, label %44, label %54
54: ; preds = %47
%55 = call i32 @readlink(i8* %5, i8* %6, i32 4095)
%56 = icmp eq i32 %55, -1
br i1 %56, label %44, label %57
57: ; preds = %54
%58 = sext i32 %55 to i64
%59 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 %58
store i8 0, i8* %59
%60 = call i64 @sscanf(i8* %6, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i64* %4)
%61 = icmp eq i64 %60, 0
br i1 %61, label %62, label %65
62: ; preds = %57
%63 = call i64 @sscanf(i8* %6, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i64* %4)
%64 = icmp eq i64 %63, 0
br i1 %64, label %44, label %65
65: ; preds = %62, %57
%66 = load i64, i64* %4
%67 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0), i8* %5, i8* %6, i64 %66, i64 %0)
%68 = load i64, i64* %4
%69 = icmp eq i64 %68, %0
br i1 %69, label %70, label %44
70: ; preds = %65
%71 = load i8*, i8** %22
%72 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %5, i32 4096, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i8* %71)
%73 = add i32 %72, -4096
%74 = icmp ult i32 %73, -4095
br i1 %74, label %44, label %75
75: ; preds = %70
%76 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i8* %5)
%77 = call i32 @readlink(i8* %5, i8* %6, i32 4095)
%78 = icmp eq i32 %77, -1
br i1 %78, label %44, label %84
79: ; preds = %44, %35
%80 = call i32 @closedir(i32* %33)
br label %81
81: ; preds = %79, %15, %21, %27, %32
%82 = call %struct.dirent* @readdir(i32* %8)
%83 = icmp eq %struct.dirent* %82, null
br i1 %83, label %13, label %15
84: ; preds = %75
%85 = sext i32 %77 to i64
%86 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 %85
store i8 0, i8* %86
%87 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0), i8* %6, i32 %77)
%88 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str.9, i64 0, i64 0))
%89 = icmp eq i64 %88, 0
%90 = call i32 @closedir(i32* %8)
%91 = call i32 @closedir(i32* %33)
%92 = zext i1 %89 to i32
br label %93
93: ; preds = %13, %84, %1
%94 = phi i32 [ 0, %1 ], [ %92, %84 ], [ 0, %13 ]
ret i32 %94
}