#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 {
  char *d_name;
};
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int /*<<< orphan*/ errors_2p(int /*<<< orphan*/ *, int /*<<< orphan*/ *, char *,
                             char const *, int, int, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ ok_output(char *);
int /*<<< orphan*/ *opendir(char const *);
int /*<<< orphan*/ printf(char *);
struct dirent *readdir(int /*<<< orphan*/ *);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
void file_exist(const char *dir, char *path, size_t io) {
  DIR *directory;
  struct dirent *direntp;
  if ((directory = opendir(dir)) == NULL) {
    closedir(directory);
    errors_2p(NULL, NULL, "ERROR to open the directory", dir, 13, 1, 1);
  }
  while ((direntp = readdir(directory)) != NULL) {
    if (!strcmp(direntp->d_name, path)) {
      fprintf(stderr,
              "Already exist a file named \"%s\"\nDo you want to change the "
              "name? Y/N\n",
              path);
      char op[1];
      scanf("%s", op);
      if (!strcmp(op, "y") || !strcmp(op, "Y")) {
        printf("Enter the new name\n");
        scanf("%s", path);
        if (!io)
          ok_output(path);
        file_exist(dir, path, io);
        break;
      }
      if (!strcmp(op, "n") || !strcmp(op, "N")) {
        fprintf(stderr, "Do you want to rewrite the existing file? Y/N\n");
        scanf("%s", op);
        if (!strcmp(op, "y") || !strcmp(op, "Y"))
          break;
        if (!strcmp(op, "n") || !strcmp(op, "N")) {
          static char ok = '2';
          char ok2[1];
          strcpy(ok2, "2");
          if (ok == '2') {
            if (!io) {
              path[strlen(path) - 4] = '(';
              path[strlen(path) - 3] = ok++;
              path[strlen(path) - 2] = ')';
              path[strlen(path) - 1] = '\0';
            } else {
              strcat(path, "(");
              strcat(path, ok2);
              strcat(path, ")");
              ok++;
            }
          } else {
            if (ok <= '9') {
              if (!io) {
                path[strlen(path) - 7] = '(';
                path[strlen(path) - 6] = ok++;
                path[strlen(path) - 5] = ')';
              } else {
                path[strlen(path) - 3] = '(';
                path[strlen(path) - 2] = ok++;
                path[strlen(path) - 1] = ')';
              }
            } else {
              printf("\nThat was a lot of enters!\nSpecifically 9\nThe number "
                     "don't pass the 9\n");
              closedir(directory);
              exit(99);
            }
          }
          if (!io)
            ok_output(path);
          fprintf(stderr, "New name = \"%s\"\n", path);
          file_exist(dir, path, io);
          break;
        }
      }
      fprintf(stderr, "Wrong option.\n");
      file_exist(dir, path, io);
      break;
    }
  }
  closedir(directory);
}


x86 assembly (clang, -O0):
<file_exist>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <opendir@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1241 <file_exist+0x61>
mov    -0x20(%rbp),%rdi
call   1070 <closedir@plt>
mov    -0x8(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%esi
lea    0xdda(%rip),%rdx
mov    $0xd,%r8d
mov    $0x1,%r9d
mov    %rsi,%rdi
movl   $0x1,(%rsp)
call   10b0 <errors_2p@plt>
jmp    1246 <file_exist+0x66>
mov    -0x20(%rbp),%rdi
call   10a0 <readdir@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     16a5 <file_exist+0x4c5>
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    16a0 <file_exist+0x4c0>
mov    0x2d63(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xd92(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
lea    -0x29(%rbp),%rsi
lea    0xdc5(%rip),%rdi
call   10d0 <scanf@plt>
lea    -0x29(%rbp),%rdi
lea    0xd6e(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
je     12d3 <file_exist+0xf3>
lea    -0x29(%rbp),%rdi
lea    0xd9f(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    1319 <file_exist+0x139>
lea    0xd8c(%rip),%rdi
call   1060 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xd77(%rip),%rdi
call   10d0 <scanf@plt>
cmpq   $0x0,-0x18(%rbp)
jne    1303 <file_exist+0x123>
mov    -0x10(%rbp),%rdi
call   1100 <ok_output@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   10c0 <file_exist@plt>
jmp    16a5 <file_exist+0x4c5>
lea    -0x29(%rbp),%rdi
lea    0xd56(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
je     134b <file_exist+0x16b>
lea    -0x29(%rbp),%rdi
lea    0xd3f(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    1673 <file_exist+0x493>
mov    0x2c8e(%rip),%rax
mov    (%rax),%edi
lea    0xd23(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
lea    -0x29(%rbp),%rsi
lea    0xcf4(%rip),%rdi
call   10d0 <scanf@plt>
lea    -0x29(%rbp),%rdi
lea    0xc9d(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
je     13a4 <file_exist+0x1c4>
lea    -0x29(%rbp),%rdi
lea    0xcce(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    13a9 <file_exist+0x1c9>
jmp    16a5 <file_exist+0x4c5>
lea    -0x29(%rbp),%rdi
lea    0xcc6(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
je     13db <file_exist+0x1fb>
lea    -0x29(%rbp),%rdi
lea    0xcaf(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    166e <file_exist+0x48e>
lea    -0x2a(%rbp),%rdi
lea    0xcc7(%rip),%rsi
call   1030 <strcpy@plt>
movsbl 0x2c9e(%rip),%eax
cmp    $0x32,%eax
jne    14e2 <file_exist+0x302>
cmpq   $0x0,-0x18(%rbp)
jne    14a2 <file_exist+0x2c2>
mov    -0x10(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x58(%rbp),%rax
sub    $0x4,%ecx
movslq %ecx,%rcx
movb   $0x28,(%rax,%rcx,1)
mov    0x2c63(%rip),%al
mov    %al,-0x49(%rbp)
add    $0x1,%al
mov    %al,0x2c58(%rip)
mov    -0x10(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x49(%rbp),%dl
mov    %eax,%ecx
mov    -0x48(%rbp),%rax
sub    $0x3,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x40(%rbp),%rax
sub    $0x2,%ecx
movslq %ecx,%rcx
movb   $0x29,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    14dd <file_exist+0x2fd>
mov    -0x10(%rbp),%rdi
lea    0xc02(%rip),%rsi
call   10e0 <strcat@plt>
mov    -0x10(%rbp),%rdi
lea    -0x2a(%rbp),%rsi
call   10e0 <strcat@plt>
mov    -0x10(%rbp),%rdi
lea    0xbe7(%rip),%rsi
call   10e0 <strcat@plt>
mov    0x2bbb(%rip),%al
add    $0x1,%al
mov    %al,0x2bb3(%rip)
jmp    1629 <file_exist+0x449>
movsbl 0x2ba7(%rip),%eax
cmp    $0x39,%eax
jg     1605 <file_exist+0x425>
cmpq   $0x0,-0x18(%rbp)
jne    1578 <file_exist+0x398>
mov    -0x10(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x78(%rbp),%rax
sub    $0x7,%ecx
movslq %ecx,%rcx
movb   $0x28,(%rax,%rcx,1)
mov    0x2b6c(%rip),%al
mov    %al,-0x69(%rbp)
add    $0x1,%al
mov    %al,0x2b61(%rip)
mov    -0x10(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x69(%rbp),%dl
mov    %eax,%ecx
mov    -0x68(%rbp),%rax
sub    $0x6,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x60(%rbp),%rax
sub    $0x5,%ecx
movslq %ecx,%rcx
movb   $0x29,(%rax,%rcx,1)
jmp    1600 <file_exist+0x420>
mov    -0x10(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x98(%rbp),%rax
sub    $0x3,%ecx
movslq %ecx,%rcx
movb   $0x28,(%rax,%rcx,1)
mov    0x2aeb(%rip),%al
mov    %al,-0x89(%rbp)
add    $0x1,%al
mov    %al,0x2add(%rip)
mov    -0x10(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x89(%rbp),%dl
mov    %eax,%ecx
mov    -0x88(%rbp),%rax
sub    $0x2,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x80(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x29,(%rax,%rcx,1)
jmp    1624 <file_exist+0x444>
lea    0xaa7(%rip),%rdi
call   1060 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1070 <closedir@plt>
mov    $0x63,%edi
call   10f0 <exit@plt>
jmp    1629 <file_exist+0x449>
cmpq   $0x0,-0x18(%rbp)
jne    163d <file_exist+0x45d>
mov    -0x10(%rbp),%rdi
call   1100 <ok_output@plt>
mov    0x299c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xaa9(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   10c0 <file_exist@plt>
jmp    16a5 <file_exist+0x4c5>
jmp    1673 <file_exist+0x493>
mov    0x2966(%rip),%rax
mov    (%rax),%edi
lea    0xa88(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   10c0 <file_exist@plt>
jmp    16a5 <file_exist+0x4c5>
jmp    1246 <file_exist+0x66>
mov    -0x20(%rbp),%rdi
call   1070 <closedir@plt>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<file_exist>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
call   1050 <opendir@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1240 <file_exist+0x60>
xor    %edi,%edi
call   1070 <closedir@plt>
movl   $0x1,(%rsp)
lea    0xde7(%rip),%rdx
xor    %edi,%edi
xor    %esi,%esi
mov    %r12,%rcx
mov    $0xd,%r8d
mov    $0x1,%r9d
call   10b0 <errors_2p@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   10a0 <readdir@plt>
test   %rax,%rax
je     132a <file_exist+0x14a>
mov    (%rax),%rdi
mov    %r15,%rsi
call   1080 <strcmp@plt>
test   %eax,%eax
jne    1240 <file_exist+0x60>
mov    0x2d79(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xdab(%rip),%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
lea    0xddf(%rip),%rdi
lea    0xa(%rsp),%r13
mov    %r13,%rsi
call   10d0 <scanf@plt>
lea    0xd84(%rip),%rsi
mov    %r13,%rdi
call   1080 <strcmp@plt>
test   %eax,%eax
je     12f4 <file_exist+0x114>
lea    0xdbb(%rip),%rsi
lea    0xa(%rsp),%rdi
call   1080 <strcmp@plt>
test   %eax,%eax
je     12f4 <file_exist+0x114>
lea    0xda8(%rip),%rsi
lea    0xa(%rsp),%rdi
call   1080 <strcmp@plt>
test   %eax,%eax
je     1341 <file_exist+0x161>
lea    0xd95(%rip),%rsi
lea    0xa(%rsp),%rdi
call   1080 <strcmp@plt>
test   %eax,%eax
je     1341 <file_exist+0x161>
mov    0x0(%rbp),%edi
lea    0xdc5(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
jmp    131c <file_exist+0x13c>
lea    0xdc4(%rip),%rdi
call   1040 <puts@plt>
lea    0xd5a(%rip),%rdi
mov    %r15,%rsi
call   10d0 <scanf@plt>
test   %r14,%r14
jne    131c <file_exist+0x13c>
mov    %r15,%rdi
call   1100 <ok_output@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   10c0 <file_exist@plt>
mov    %rbx,%rdi
call   1070 <closedir@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x0(%rbp),%edi
lea    0xd1f(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
lea    0xd08(%rip),%rdi
lea    0xa(%rsp),%r13
mov    %r13,%rsi
call   10d0 <scanf@plt>
lea    0xcad(%rip),%rsi
mov    %r13,%rdi
call   1080 <strcmp@plt>
test   %eax,%eax
je     132a <file_exist+0x14a>
lea    0xce4(%rip),%rsi
lea    0xa(%rsp),%rdi
call   1080 <strcmp@plt>
test   %eax,%eax
je     132a <file_exist+0x14a>
lea    0xcd1(%rip),%rsi
lea    0xa(%rsp),%rdi
call   1080 <strcmp@plt>
test   %eax,%eax
je     13bc <file_exist+0x1dc>
lea    0xcbe(%rip),%rsi
lea    0xa(%rsp),%rdi
call   1080 <strcmp@plt>
test   %eax,%eax
jne    12e1 <file_exist+0x101>
lea    0xcd6(%rip),%rsi
lea    0xb(%rsp),%rdi
call   1030 <strcpy@plt>
mov    0x2cbd(%rip),%al
cmp    $0x32,%al
jne    1417 <file_exist+0x237>
test   %r14,%r14
je     146d <file_exist+0x28d>
lea    0xcb4(%rip),%rsi
mov    %r15,%rdi
call   10e0 <strcat@plt>
lea    0xb(%rsp),%rsi
mov    %r15,%rdi
call   10e0 <strcat@plt>
lea    0xc9a(%rip),%rsi
mov    %r15,%rdi
call   10e0 <strcat@plt>
addb   $0x1,0x2c7e(%rip)
jmp    1517 <file_exist+0x337>
cmp    $0x39,%al
jg     1530 <file_exist+0x350>
mov    %r15,%rdi
call   1060 <strlen@plt>
cltq
test   %r14,%r14
je     14ba <file_exist+0x2da>
movb   $0x28,-0x3(%rax,%r15,1)
mov    0x2c51(%rip),%r13b
lea    0x1(%r13),%eax
mov    %al,0x2c47(%rip)
mov    %r15,%rdi
call   1060 <strlen@plt>
cltq
mov    %r13b,-0x2(%rax,%r15,1)
mov    %r15,%rdi
call   1060 <strlen@plt>
cltq
movb   $0x29,-0x1(%rax,%r15,1)
jmp    1517 <file_exist+0x337>
mov    %r15,%rdi
call   1060 <strlen@plt>
cltq
movb   $0x28,-0x4(%rax,%r15,1)
mov    0x2c0c(%rip),%r13b
lea    0x1(%r13),%eax
mov    %al,0x2c02(%rip)
mov    %r15,%rdi
call   1060 <strlen@plt>
cltq
mov    %r13b,-0x3(%rax,%r15,1)
movl   $0xffffffff,0x10(%rsp)
ff
mov    $0x29,%r13b
movl   $0xfffffffe,0xc(%rsp)
ff
movl   $0x0,0x14(%rsp)
jmp    14e7 <file_exist+0x307>
movb   $0x28,-0x7(%rax,%r15,1)
mov    0x2bc9(%rip),%r13b
lea    0x1(%r13),%eax
mov    %al,0x2bbf(%rip)
mov    $0x29,%al
mov    %eax,0x14(%rsp)
movl   $0xfffffffb,0x10(%rsp)
ff
movl   $0xfffffffa,0xc(%rsp)
ff
mov    %r15,%rdi
call   1060 <strlen@plt>
add    0xc(%rsp),%eax
cltq
mov    %r13b,(%r15,%rax,1)
mov    %r15,%rdi
call   1060 <strlen@plt>
add    0x10(%rsp),%eax
cltq
mov    0x14(%rsp),%ecx
mov    %cl,(%r15,%rax,1)
mov    %r15,%rdi
call   1100 <ok_output@plt>
mov    0x0(%rbp),%edi
lea    0xb7e(%rip),%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
jmp    131c <file_exist+0x13c>
lea    0xb9b(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1070 <closedir@plt>
mov    $0x63,%edi
call   10f0 <exit@plt>

LLVM IR (-O0):
%struct.dirent = type { i8* }
@.str = [28 x i8] c"ERROR to open the directory\00"
@stderr = global i32 0
@.str.1 = [69 x i8] c"Already exist a file named \22%s\22\0ADo you want to change the name? Y/N\0A\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [2 x i8] c"y\00"
@.str.4 = [2 x i8] c"Y\00"
@.str.5 = [20 x i8] c"Enter the new name\0A\00"
@.str.6 = [2 x i8] c"n\00"
@.str.7 = [2 x i8] c"N\00"
@.str.8 = [47 x i8] c"Do you want to rewrite the existing file? Y/N\0A\00"
@file_exist.ok = internal global i8 50
@.str.9 = [2 x i8] c"2\00"
@.str.10 = [2 x i8] c"(\00"
@.str.11 = [2 x i8] c")\00"
@.str.12 = [71 x i8] c"\0AThat was a lot of enters!\0ASpecifically 9\0AThe number don't pass the 9\0A\00"
@.str.13 = [17 x i8] c"New name = \22%s\22\0A\00"
@.str.14 = [15 x i8] c"Wrong option.\0A\00"
define void @file_exist(i8* %0, i8* %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32*
%8 = alloca %struct.dirent*
%9 = alloca [1 x i8]
%10 = alloca [1 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%11 = load i8*, i8** %4
%12 = call i32* @opendir(i8* %11)
store i32* %12, i32** %7
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %19
14: ; preds = %3
%15 = load i32*, i32** %7
%16 = call i32 @closedir(i32* %15)
%17 = load i8*, i8** %4
%18 = call i32 @errors_2p(i32* null, i32* null, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %17, i32 13, i32 1, i32 1)
br label %19
19: ; preds = %14, %3
br label %20
20: ; preds = %209, %19
%21 = load i32*, i32** %7
%22 = call %struct.dirent* @readdir(i32* %21)
store %struct.dirent* %22, %struct.dirent** %8
%23 = icmp ne %struct.dirent* %22, null
br i1 %23, label %24, label %210
24: ; preds = %20
%25 = load %struct.dirent*, %struct.dirent** %8
%26 = getelementptr inbounds %struct.dirent, %struct.dirent* %25, i32 0, i32 0
%27 = load i8*, i8** %26
%28 = load i8*, i8** %5
%29 = call i32 @strcmp(i8* %27, i8* %28)
%30 = icmp ne i32 %29, 0
br i1 %30, label %209, label %31
31: ; preds = %24
%32 = load i32, i32* @stderr
%33 = load i8*, i8** %5
%34 = call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.1, i64 0, i64 0), i8* %33)
%35 = getelementptr inbounds [1 x i8], [1 x i8]* %9, i64 0, i64 0
%36 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %35)
%37 = getelementptr inbounds [1 x i8], [1 x i8]* %9, i64 0, i64 0
%38 = call i32 @strcmp(i8* %37, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %44
40: ; preds = %31
%41 = getelementptr inbounds [1 x i8], [1 x i8]* %9, i64 0, i64 0
%42 = call i32 @strcmp(i8* %41, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%43 = icmp ne i32 %42, 0
br i1 %43, label %57, label %44
44: ; preds = %40, %31
%45 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
%46 = load i8*, i8** %5
%47 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %46)
%48 = load i64, i64* %6
%49 = icmp ne i64 %48, 0
br i1 %49, label %53, label %50
50: ; preds = %44
%51 = load i8*, i8** %5
%52 = call i32 @ok_output(i8* %51)
br label %53
53: ; preds = %50, %44
%54 = load i8*, i8** %4
%55 = load i8*, i8** %5
%56 = load i64, i64* %6
br label %210
57: ; preds = %40
%58 = getelementptr inbounds [1 x i8], [1 x i8]* %9, i64 0, i64 0
%59 = call i32 @strcmp(i8* %58, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%60 = icmp ne i32 %59, 0
br i1 %60, label %61, label %65
61: ; preds = %57
%62 = getelementptr inbounds [1 x i8], [1 x i8]* %9, i64 0, i64 0
%63 = call i32 @strcmp(i8* %62, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%64 = icmp ne i32 %63, 0
br i1 %64, label %203, label %65
65: ; preds = %61, %57
%66 = load i32, i32* @stderr
%67 = call i32 (i32, i8*, ...) @fprintf(i32 %66, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.8, i64 0, i64 0))
%68 = getelementptr inbounds [1 x i8], [1 x i8]* %9, i64 0, i64 0
%69 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %68)
%70 = getelementptr inbounds [1 x i8], [1 x i8]* %9, i64 0, i64 0
%71 = call i32 @strcmp(i8* %70, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%72 = icmp ne i32 %71, 0
br i1 %72, label %73, label %77
73: ; preds = %65
%74 = getelementptr inbounds [1 x i8], [1 x i8]* %9, i64 0, i64 0
%75 = call i32 @strcmp(i8* %74, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%76 = icmp ne i32 %75, 0
br i1 %76, label %78, label %77
77: ; preds = %73, %65
br label %210
78: ; preds = %73
%79 = getelementptr inbounds [1 x i8], [1 x i8]* %9, i64 0, i64 0
%80 = call i32 @strcmp(i8* %79, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%81 = icmp ne i32 %80, 0
br i1 %81, label %82, label %86
82: ; preds = %78
%83 = getelementptr inbounds [1 x i8], [1 x i8]* %9, i64 0, i64 0
%84 = call i32 @strcmp(i8* %83, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%85 = icmp ne i32 %84, 0
br i1 %85, label %202, label %86
86: ; preds = %82, %78
%87 = getelementptr inbounds [1 x i8], [1 x i8]* %10, i64 0, i64 0
%88 = call i32 @strcpy(i8* %87, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%89 = load i8, i8* @file_exist.ok
%90 = sext i8 %89 to i32
%91 = icmp eq i32 %90, 50
br i1 %91, label %92, label %133
92: ; preds = %86
%93 = load i64, i64* %6
%94 = icmp ne i64 %93, 0
br i1 %94, label %122, label %95
95: ; preds = %92
%96 = load i8*, i8** %5
%97 = load i8*, i8** %5
%98 = call i32 @strlen(i8* %97)
%99 = sub nsw i32 %98, 4
%100 = sext i32 %99 to i64
%101 = getelementptr inbounds i8, i8* %96, i64 %100
store i8 40, i8* %101
%102 = load i8, i8* @file_exist.ok
%103 = add i8 %102, 1
store i8 %103, i8* @file_exist.ok
%104 = load i8*, i8** %5
%105 = load i8*, i8** %5
%106 = call i32 @strlen(i8* %105)
%107 = sub nsw i32 %106, 3
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds i8, i8* %104, i64 %108
store i8 %102, i8* %109
%110 = load i8*, i8** %5
%111 = load i8*, i8** %5
%112 = call i32 @strlen(i8* %111)
%113 = sub nsw i32 %112, 2
%114 = sext i32 %113 to i64
%115 = getelementptr inbounds i8, i8* %110, i64 %114
store i8 41, i8* %115
%116 = load i8*, i8** %5
%117 = load i8*, i8** %5
%118 = call i32 @strlen(i8* %117)
%119 = sub nsw i32 %118, 1
%120 = sext i32 %119 to i64
%121 = getelementptr inbounds i8, i8* %116, i64 %120
store i8 0, i8* %121
br label %132
122: ; preds = %92
%123 = load i8*, i8** %5
%124 = call i32 @strcat(i8* %123, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%125 = load i8*, i8** %5
%126 = getelementptr inbounds [1 x i8], [1 x i8]* %10, i64 0, i64 0
%127 = call i32 @strcat(i8* %125, i8* %126)
%128 = load i8*, i8** %5
%129 = call i32 @strcat(i8* %128, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
%130 = load i8, i8* @file_exist.ok
%131 = add i8 %130, 1
store i8 %131, i8* @file_exist.ok
br label %132
132: ; preds = %122, %95
br label %189
133: ; preds = %86
%134 = load i8, i8* @file_exist.ok
%135 = sext i8 %134 to i32
%136 = icmp sle i32 %135, 57
br i1 %136, label %137, label %183
137: ; preds = %133
%138 = load i64, i64* %6
%139 = icmp ne i64 %138, 0
br i1 %139, label %161, label %140
140: ; preds = %137
%141 = load i8*, i8** %5
%142 = load i8*, i8** %5
%143 = call i32 @strlen(i8* %142)
%144 = sub nsw i32 %143, 7
%145 = sext i32 %144 to i64
%146 = getelementptr inbounds i8, i8* %141, i64 %145
store i8 40, i8* %146
%147 = load i8, i8* @file_exist.ok
%148 = add i8 %147, 1
store i8 %148, i8* @file_exist.ok
%149 = load i8*, i8** %5
%150 = load i8*, i8** %5
%151 = call i32 @strlen(i8* %150)
%152 = sub nsw i32 %151, 6
%153 = sext i32 %152 to i64
%154 = getelementptr inbounds i8, i8* %149, i64 %153
store i8 %147, i8* %154
%155 = load i8*, i8** %5
%156 = load i8*, i8** %5
%157 = call i32 @strlen(i8* %156)
%158 = sub nsw i32 %157, 5
%159 = sext i32 %158 to i64
%160 = getelementptr inbounds i8, i8* %155, i64 %159
store i8 41, i8* %160
br label %182
161: ; preds = %137
%162 = load i8*, i8** %5
%163 = load i8*, i8** %5
%164 = call i32 @strlen(i8* %163)
%165 = sub nsw i32 %164, 3
%166 = sext i32 %165 to i64
%167 = getelementptr inbounds i8, i8* %162, i64 %166
store i8 40, i8* %167
%168 = load i8, i8* @file_exist.ok
%169 = add i8 %168, 1
store i8 %169, i8* @file_exist.ok
%170 = load i8*, i8** %5
%171 = load i8*, i8** %5
%172 = call i32 @strlen(i8* %171)
%173 = sub nsw i32 %172, 2
%174 = sext i32 %173 to i64
%175 = getelementptr inbounds i8, i8* %170, i64 %174
store i8 %168, i8* %175
%176 = load i8*, i8** %5
%177 = load i8*, i8** %5
%178 = call i32 @strlen(i8* %177)
%179 = sub nsw i32 %178, 1
%180 = sext i32 %179 to i64
%181 = getelementptr inbounds i8, i8* %176, i64 %180
store i8 41, i8* %181
br label %182
182: ; preds = %161, %140
br label %188
183: ; preds = %133
%184 = call i32 @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.12, i64 0, i64 0))
%185 = load i32*, i32** %7
%186 = call i32 @closedir(i32* %185)
%187 = call i32 @exit(i32 99)
unreachable
188: ; preds = %182
br label %189
189: ; preds = %188, %132
%190 = load i64, i64* %6
%191 = icmp ne i64 %190, 0
br i1 %191, label %195, label %192
192: ; preds = %189
%193 = load i8*, i8** %5
%194 = call i32 @ok_output(i8* %193)
br label %195
195: ; preds = %192, %189
%196 = load i32, i32* @stderr
%197 = load i8*, i8** %5
%198 = call i32 (i32, i8*, ...) @fprintf(i32 %196, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.13, i64 0, i64 0), i8* %197)
%199 = load i8*, i8** %4
%200 = load i8*, i8** %5
%201 = load i64, i64* %6
br label %210
202: ; preds = %82
br label %203
203: ; preds = %202, %61
%204 = load i32, i32* @stderr
%205 = call i32 (i32, i8*, ...) @fprintf(i32 %204, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.14, i64 0, i64 0))
%206 = load i8*, i8** %4
%207 = load i8*, i8** %5
%208 = load i64, i64* %6
br label %210
209: ; preds = %24
br label %20
210: ; preds = %203, %195, %77, %53, %20
%211 = load i32*, i32** %7
%212 = call i32 @closedir(i32* %211)
ret void
}

LLVM IR (-O2):
%struct.dirent = type { i8* }
@.str = [28 x i8] c"ERROR to open the directory\00"
@stderr = global i32 0
@.str.1 = [69 x i8] c"Already exist a file named \22%s\22\0ADo you want to change the name? Y/N\0A\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [2 x i8] c"y\00"
@.str.4 = [2 x i8] c"Y\00"
@.str.6 = [2 x i8] c"n\00"
@.str.7 = [2 x i8] c"N\00"
@.str.8 = [47 x i8] c"Do you want to rewrite the existing file? Y/N\0A\00"
@file_exist.ok = internal unnamed_addr global i8 50
@.str.9 = [2 x i8] c"2\00"
@.str.10 = [2 x i8] c"(\00"
@.str.11 = [2 x i8] c")\00"
@.str.13 = [17 x i8] c"New name = \22%s\22\0A\00"
@.str.14 = [15 x i8] c"Wrong option.\0A\00"
@str = [19 x i8] c"Enter the new name\00"
@str.15 = [70 x i8] c"\0AThat was a lot of enters!\0ASpecifically 9\0AThe number don't pass the 9\00"
define void @file_exist(i8* %0, i8* %1, i64 %2) {
%4 = alloca [1 x i8]
%5 = alloca [1 x i8]
%6 = tail call i32* @opendir(i8* %0)
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %11
8: ; preds = %3
%9 = tail call i32 @closedir(i32* null)
%10 = tail call i32 @errors_2p(i32* null, i32* null, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %0, i32 13, i32 1, i32 1)
br label %11
11: ; preds = %8, %3
br label %12
12: ; preds = %11, %15
%13 = tail call %struct.dirent* @readdir(i32* %6)
%14 = icmp eq %struct.dirent* %13, null
br i1 %14, label %132, label %15
15: ; preds = %12
%16 = getelementptr inbounds %struct.dirent, %struct.dirent* %13, i64 0, i32 0
%17 = load i8*, i8** %16
%18 = tail call i32 @strcmp(i8* dereferenceable(1) %17, i8* dereferenceable(1) %1)
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %12
20: ; preds = %15
%21 = load i32, i32* @stderr
%22 = tail call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%23 = getelementptr inbounds [1 x i8], [1 x i8]* %4, i64 0, i64 0
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %23)
%25 = call i32 @strcmp(i8* %23, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%26 = icmp eq i32 %25, 0
br i1 %26, label %30, label %27
27: ; preds = %20
%28 = call i32 @strcmp(i8* %23, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %37
30: ; preds = %27, %20
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%32 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %1)
%33 = icmp eq i64 %2, 0
br i1 %33, label %34, label %36
34: ; preds = %30
%35 = call i32 @ok_output(i8* %1)
br label %36
36: ; preds = %34, %30
br label %131
37: ; preds = %27
%38 = call i32 @strcmp(i8* %23, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%39 = icmp eq i32 %38, 0
br i1 %39, label %43, label %40
40: ; preds = %37
%41 = call i32 @strcmp(i8* %23, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %128
43: ; preds = %40, %37
%44 = load i32, i32* @stderr
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.8, i64 0, i64 0))
%46 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %23)
%47 = call i32 @strcmp(i8* %23, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%48 = icmp eq i32 %47, 0
br i1 %48, label %131, label %49
49: ; preds = %43
%50 = call i32 @strcmp(i8* %23, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%51 = icmp eq i32 %50, 0
br i1 %51, label %131, label %52
52: ; preds = %49
%53 = call i32 @strcmp(i8* %23, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%54 = icmp eq i32 %53, 0
br i1 %54, label %58, label %55
55: ; preds = %52
%56 = call i32 @strcmp(i8* %23, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%57 = icmp eq i32 %56, 0
br i1 %57, label %58, label %128
58: ; preds = %55, %52
%59 = getelementptr inbounds [1 x i8], [1 x i8]* %5, i64 0, i64 0
%60 = call i32 @strcpy(i8* %59, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%61 = load i8, i8* @file_exist.ok
%62 = icmp eq i8 %61, 50
br i1 %62, label %63, label %82
63: ; preds = %58
%64 = icmp eq i64 %2, 0
br i1 %64, label %65, label %76
65: ; preds = %63
%66 = call i32 @strlen(i8* %1)
%67 = add nsw i32 %66, -4
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i8, i8* %1, i64 %68
store i8 40, i8* %69
%70 = load i8, i8* @file_exist.ok
%71 = add i8 %70, 1
store i8 %71, i8* @file_exist.ok
%72 = call i32 @strlen(i8* %1)
%73 = add nsw i32 %72, -3
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds i8, i8* %1, i64 %74
store i8 %70, i8* %75
br label %111
76: ; preds = %63
%77 = call i32 @strcat(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%78 = call i32 @strcat(i8* %1, i8* %59)
%79 = call i32 @strcat(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
%80 = load i8, i8* @file_exist.ok
%81 = add i8 %80, 1
store i8 %81, i8* @file_exist.ok
br label %125
82: ; preds = %58
%83 = icmp slt i8 %61, 58
br i1 %83, label %84, label %107
84: ; preds = %82
%85 = icmp eq i64 %2, 0
%86 = call i32 @strlen(i8* %1)
br i1 %85, label %87, label %93
87: ; preds = %84
%88 = add nsw i32 %86, -7
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds i8, i8* %1, i64 %89
store i8 40, i8* %90
%91 = load i8, i8* @file_exist.ok
%92 = add i8 %91, 1
store i8 %92, i8* @file_exist.ok
br label %111
93: ; preds = %84
%94 = add nsw i32 %86, -3
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds i8, i8* %1, i64 %95
store i8 40, i8* %96
%97 = load i8, i8* @file_exist.ok
%98 = add i8 %97, 1
store i8 %98, i8* @file_exist.ok
%99 = call i32 @strlen(i8* %1)
%100 = add nsw i32 %99, -2
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds i8, i8* %1, i64 %101
store i8 %97, i8* %102
%103 = call i32 @strlen(i8* %1)
%104 = add nsw i32 %103, -1
%105 = sext i32 %104 to i64
%106 = getelementptr inbounds i8, i8* %1, i64 %105
store i8 41, i8* %106
br label %125
107: ; preds = %82
%108 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([70 x i8], [70 x i8]* @str.15, i64 0, i64 0))
%109 = call i32 @closedir(i32* %6)
%110 = call i32 @exit(i32 99)
unreachable
111: ; preds = %87, %65
%112 = phi i32 [ -6, %87 ], [ -2, %65 ]
%113 = phi i8 [ %91, %87 ], [ 41, %65 ]
%114 = phi i32 [ -5, %87 ], [ -1, %65 ]
%115 = phi i8 [ 41, %87 ], [ 0, %65 ]
%116 = call i32 @strlen(i8* %1)
%117 = add nsw i32 %116, %112
%118 = sext i32 %117 to i64
%119 = getelementptr inbounds i8, i8* %1, i64 %118
store i8 %113, i8* %119
%120 = call i32 @strlen(i8* %1)
%121 = add nsw i32 %120, %114
%122 = sext i32 %121 to i64
%123 = getelementptr inbounds i8, i8* %1, i64 %122
store i8 %115, i8* %123
%124 = call i32 @ok_output(i8* %1)
br label %125
125: ; preds = %76, %93, %111
%126 = load i32, i32* @stderr
%127 = call i32 (i32, i8*, ...) @fprintf(i32 %126, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.13, i64 0, i64 0), i8* %1)
br label %131
128: ; preds = %55, %40
%129 = load i32, i32* @stderr
%130 = call i32 (i32, i8*, ...) @fprintf(i32 %129, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.14, i64 0, i64 0))
br label %131
131: ; preds = %43, %49, %128, %125, %36
br label %132
132: ; preds = %12, %131
%133 = call i32 @closedir(i32* %6)
ret void
}