#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 */
char *getcwd(char *, int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strlen(char *);
int /*<<< orphan*/ *strstr(char *, char *);
int /*<<< orphan*/ *strtok(char *, char *);
int main(int argc, char *argv[], char *env[]) {
  char buffer[1024];
  char *dir = getcwd(buffer, 1024);
  printf("Le dossier \"%s\" ", dir);
  int r = 0;
  int i = 0;
  while (strstr(env[i], "PATH=.") == NULL)
    i++;
  char *path = env[i];
  while (strtok(path, ":") != NULL && path != env[i + 1]) {
    if (strstr(path, dir) != NULL && strlen(path) == strlen(dir))
      r = 1;
    path += strlen(path) + 1;
  }
  if (r == 1)
    printf("est");
  else
    printf("n'est pas");
  printf(" dans la variable PATH.\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x450,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x420(%rbp),%rdi
mov    $0x400,%esi
call   1050 <getcwd@plt>
mov    %rax,-0x428(%rbp)
mov    -0x428(%rbp),%rsi
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x42c(%rbp)
movl   $0x0,-0x430(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x430(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe4d(%rip),%rsi
call   1070 <strstr@plt>
cmp    $0x0,%rax
jne    11e7 <main+0x97>
mov    -0x430(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x430(%rbp)
jmp    11ae <main+0x5e>
mov    -0x18(%rbp),%rax
movslq -0x430(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x438(%rbp)
mov    -0x438(%rbp),%rdi
lea    0xe0d(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x439(%rbp)
je     1249 <main+0xf9>
mov    -0x438(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    -0x430(%rbp),%edx
add    $0x1,%edx
movslq %edx,%rdx
cmp    (%rcx,%rdx,8),%rax
setne  %al
mov    %al,-0x439(%rbp)
mov    -0x439(%rbp),%al
test   $0x1,%al
jne    125c <main+0x10c>
jmp    12d8 <main+0x188>
mov    -0x438(%rbp),%rdi
mov    -0x428(%rbp),%rsi
call   1070 <strstr@plt>
cmp    $0x0,%rax
je     12b5 <main+0x165>
mov    -0x438(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x448(%rbp)
mov    -0x428(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x448(%rbp),%rax
cmp    %rcx,%rax
jne    12b5 <main+0x165>
movl   $0x1,-0x42c(%rbp)
mov    -0x438(%rbp),%rdi
call   1030 <strlen@plt>
add    $0x1,%rax
add    -0x438(%rbp),%rax
mov    %rax,-0x438(%rbp)
jmp    11fd <main+0xad>
cmpl   $0x1,-0x42c(%rbp)
jne    12f8 <main+0x1a8>
lea    0xd2e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1306 <main+0x1b6>
lea    0xd1f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd1b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x450,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x408,%rsp
mov    %rdx,%r15
mov    %rsp,%rdi
mov    $0x400,%esi
call   1060 <getcwd@plt>
mov    %rax,%r14
lea    0xe75(%rip),%rdi
xor    %ebp,%ebp
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe73(%rip),%r12
xchg   %ax,%ax
mov    (%r15,%rbp,8),%rbx
mov    %rbx,%rdi
mov    %r12,%rsi
call   1080 <strstr@plt>
add    $0x1,%rbp
test   %rax,%rax
je     11a0 <main+0x40>
lea    0xe59(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strtok@plt>
test   %rax,%rax
je     1247 <main+0xe7>
mov    %ebp,%r12d
xor    %ebp,%ebp
jmp    1203 <main+0xa3>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
call   1040 <strlen@plt>
add    %rax,%rbx
add    $0x1,%rbx
mov    %rbx,%rdi
lea    0xe1f(%rip),%rsi
call   1070 <strtok@plt>
test   %rax,%rax
je     1239 <main+0xd9>
cmp    (%r15,%r12,8),%rbx
je     1239 <main+0xd9>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1080 <strstr@plt>
test   %rax,%rax
je     11e0 <main+0x80>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rax,%r13
mov    %r14,%rdi
call   1040 <strlen@plt>
cmp    %rax,%r13
mov    $0x1,%eax
cmove  %eax,%ebp
jmp    11e0 <main+0x80>
cmp    $0x1,%ebp
jne    1247 <main+0xe7>
lea    0xdd5(%rip),%rdi
jmp    124e <main+0xee>
lea    0xdd0(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xdcc(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"Le dossier \22%s\22 \00"
@.str.1 = [7 x i8] c"PATH=.\00"
@.str.2 = [2 x i8] c":\00"
@.str.3 = [4 x i8] c"est\00"
@.str.4 = [10 x i8] c"n'est pas\00"
@.str.5 = [25 x i8] c" dans la variable PATH.\0A\00"
define i32 @main(i32 %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca [1024 x i8]
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
store i32 0, i32* %4
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%14 = call i8* @getcwd(i8* %13, i32 1024)
store i8* %14, i8** %9
%15 = load i8*, i8** %9
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %15)
store i32 0, i32* %10
store i32 0, i32* %11
br label %17
17: ; preds = %25, %3
%18 = load i8**, i8*** %7
%19 = load i32, i32* %11
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8*, i8** %18, i64 %20
%22 = load i8*, i8** %21
%23 = call i32* @strstr(i8* %22, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %28
25: ; preds = %17
%26 = load i32, i32* %11
%27 = add nsw i32 %26, 1
store i32 %27, i32* %11
br label %17
28: ; preds = %17
%29 = load i8**, i8*** %7
%30 = load i32, i32* %11
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8*, i8** %29, i64 %31
%33 = load i8*, i8** %32
store i8* %33, i8** %12
br label %34
34: ; preds = %61, %28
%35 = load i8*, i8** %12
%36 = call i32* @strtok(i8* %35, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%37 = icmp ne i32* %36, null
br i1 %37, label %38, label %47
38: ; preds = %34
%39 = load i8*, i8** %12
%40 = load i8**, i8*** %7
%41 = load i32, i32* %11
%42 = add nsw i32 %41, 1
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8*, i8** %40, i64 %43
%45 = load i8*, i8** %44
%46 = icmp ne i8* %39, %45
br label %47
47: ; preds = %38, %34
%48 = phi i1 [ false, %34 ], [ %46, %38 ]
br i1 %48, label %49, label %67
49: ; preds = %47
%50 = load i8*, i8** %12
%51 = load i8*, i8** %9
%52 = call i32* @strstr(i8* %50, i8* %51)
%53 = icmp ne i32* %52, null
br i1 %53, label %54, label %61
54: ; preds = %49
%55 = load i8*, i8** %12
%56 = call i64 @strlen(i8* %55)
%57 = load i8*, i8** %9
%58 = call i64 @strlen(i8* %57)
%59 = icmp eq i64 %56, %58
br i1 %59, label %60, label %61
60: ; preds = %54
store i32 1, i32* %10
br label %61
61: ; preds = %60, %54, %49
%62 = load i8*, i8** %12
%63 = call i64 @strlen(i8* %62)
%64 = add nsw i64 %63, 1
%65 = load i8*, i8** %12
%66 = getelementptr inbounds i8, i8* %65, i64 %64
store i8* %66, i8** %12
br label %34
67: ; preds = %47
%68 = load i32, i32* %10
%69 = icmp eq i32 %68, 1
br i1 %69, label %70, label %72
70: ; preds = %67
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %74
72: ; preds = %67
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
br label %74
74: ; preds = %72, %70
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"Le dossier \22%s\22 \00"
@.str.1 = [7 x i8] c"PATH=.\00"
@.str.2 = [2 x i8] c":\00"
@.str.3 = [4 x i8] c"est\00"
@.str.4 = [10 x i8] c"n'est pas\00"
@str = [24 x i8] c" dans la variable PATH.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1, i8** nocapture %2) {
%4 = alloca [1024 x i8]
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%6 = call i8* @getcwd(i8* %5, i32 1024)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %8
8: ; preds = %8, %3
%9 = phi i64 [ %14, %8 ], [ 0, %3 ]
%10 = getelementptr inbounds i8*, i8** %2, i64 %9
%11 = load i8*, i8** %10
%12 = call i32* @strstr(i8* dereferenceable(1) %11, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i32* %12, null
%14 = add nuw i64 %9, 1
br i1 %13, label %8, label %15
15: ; preds = %8
%16 = add i64 %9, 1
%17 = and i64 %16, 4294967295
%18 = getelementptr inbounds i8*, i8** %2, i64 %17
%19 = call i32* @strtok(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp eq i32* %19, null
br i1 %20, label %44, label %21
21: ; preds = %15, %34
%22 = phi i8* [ %38, %34 ], [ %11, %15 ]
%23 = phi i32 [ %35, %34 ], [ 0, %15 ]
%24 = load i8*, i8** %18
%25 = icmp eq i8* %22, %24
br i1 %25, label %41, label %26
26: ; preds = %21
%27 = call i32* @strstr(i8* dereferenceable(1) %22, i8* dereferenceable(1) %6)
%28 = icmp eq i32* %27, null
br i1 %28, label %34, label %29
29: ; preds = %26
%30 = call i64 @strlen(i8* dereferenceable(1) %22)
%31 = call i64 @strlen(i8* dereferenceable(1) %6)
%32 = icmp eq i64 %30, %31
%33 = select i1 %32, i32 1, i32 %23
br label %34
34: ; preds = %29, %26
%35 = phi i32 [ %23, %26 ], [ %33, %29 ]
%36 = call i64 @strlen(i8* dereferenceable(1) %22)
%37 = add nsw i64 %36, 1
%38 = getelementptr inbounds i8, i8* %22, i64 %37
%39 = call i32* @strtok(i8* %38, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%40 = icmp eq i32* %39, null
br i1 %40, label %41, label %21
41: ; preds = %21, %34
%42 = phi i32 [ %23, %21 ], [ %35, %34 ]
%43 = icmp eq i32 %42, 1
br i1 %43, label %45, label %44
44: ; preds = %15, %41
br label %45
45: ; preds = %41, %44
%46 = phi i8* [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), %44 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), %41 ]
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %46)
%48 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
ret i32 0
}