#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*/ adddat_dir(char *);
int /*<<< orphan*/ adddat_file(char *, int);
int /*<<< orphan*/ adddat_zip(char *);
int checkfile(char *);
int /*<<< orphan*/ opendir(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
scalar_t__ strcmp(char *, char *);
int strlen(char *);
int /*<<< orphan*/ upper_case(char *);
int ident(char *fn) {
  int l;
  char fncopy[256];
  int status = checkfile(fn);
  if (status == -1) {
    printf("'%s' path/file not found !\n", fn);
    return 1;
  };
  if (fn[strlen(fn) - 1] != '.') {
    if (!opendir(fn)) {
      l = strlen(fn);
      if (l > 4) {
        sprintf(fncopy, "%s", fn);
        upper_case(fncopy);
        if (strcmp(&fncopy[l - 4], ".ZIP") == 0) {
          adddat_zip(fn);
        } else {
          adddat_file(fn, -1);
        }
      } else {
        adddat_file(fn, -1);
      };
    } else {
      adddat_dir(fn);
    };
  }
  return 0;
}


x86 assembly (clang, -O0):
<ident>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1080 <checkfile@plt>
mov    %eax,-0x124(%rbp)
cmpl   $0xffffffff,-0x124(%rbp)
jne    11e7 <ident+0x47>
mov    -0x10(%rbp),%rsi
lea    0xe2a(%rip),%rdi
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12d3 <ident+0x133>
mov    -0x10(%rbp),%rax
mov    %rax,-0x130(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x130(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
je     12cc <ident+0x12c>
mov    -0x10(%rbp),%rdi
call   1040 <opendir@plt>
cmp    $0x0,%eax
jne    12be <ident+0x11e>
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
jle    12ab <ident+0x10b>
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xdcb(%rip),%rsi
call   10b0 <sprintf@plt>
lea    -0x120(%rbp),%rdi
call   1070 <upper_case@plt>
mov    -0x14(%rbp),%eax
sub    $0x4,%eax
cltq
lea    -0x120(%rbp),%rdi
add    %rax,%rdi
lea    0xda4(%rip),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    1298 <ident+0xf8>
mov    -0x10(%rbp),%rdi
call   1030 <adddat_zip@plt>
jmp    12a6 <ident+0x106>
mov    -0x10(%rbp),%rdi
mov    $0xffffffff,%esi
call   10c0 <adddat_file@plt>
jmp    12b9 <ident+0x119>
mov    -0x10(%rbp),%rdi
mov    $0xffffffff,%esi
call   10c0 <adddat_file@plt>
jmp    12c7 <ident+0x127>
mov    -0x10(%rbp),%rdi
call   10a0 <adddat_dir@plt>
jmp    12cc <ident+0x12c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ident>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %rdi,%rbx
call   1090 <checkfile@plt>
cmp    $0xffffffff,%eax
je     11e7 <ident+0x47>
mov    %rbx,%rdi
call   1060 <strlen@plt>
cltq
xor    %ebp,%ebp
cmpb   $0x2e,-0x1(%rax,%rbx,1)
je     1253 <ident+0xb3>
mov    %rbx,%rdi
call   1050 <opendir@plt>
test   %eax,%eax
je     11fd <ident+0x5d>
mov    %rbx,%rdi
call   10b0 <adddat_dir@plt>
jmp    1253 <ident+0xb3>
lea    0xe12(%rip),%rdi
mov    %rbx,%rsi
call   1070 <printf@plt>
mov    $0x1,%ebp
jmp    1253 <ident+0xb3>
mov    %rbx,%rdi
call   1060 <strlen@plt>
cmp    $0x5,%eax
jl     123c <ident+0x9c>
mov    %eax,%r14d
mov    %rsp,%r15
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %r15,%rdi
call   1080 <upper_case@plt>
add    $0xfffffffc,%r14d
lea    (%rsp,%r14,1),%rdi
lea    0xdea(%rip),%rsi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     124b <ident+0xab>
mov    %rbx,%rdi
mov    $0xffffffff,%esi
call   10c0 <adddat_file@plt>
jmp    1253 <ident+0xb3>
mov    %rbx,%rdi
call   1040 <adddat_zip@plt>
mov    %ebp,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"'%s' path/file not found !\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [5 x i8] c".ZIP\00"
define i32 @ident(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [256 x i8]
%6 = alloca i32
store i8* %0, i8** %3
%7 = load i8*, i8** %3
%8 = call i32 @checkfile(i8* %7)
store i32 %8, i32* %6
%9 = load i32, i32* %6
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %14
11: ; preds = %1
%12 = load i8*, i8** %3
%13 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %12)
store i32 1, i32* %2
br label %61
14: ; preds = %1
%15 = load i8*, i8** %3
%16 = load i8*, i8** %3
%17 = call i32 @strlen(i8* %16)
%18 = sub nsw i32 %17, 1
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %15, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 46
br i1 %23, label %24, label %60
24: ; preds = %14
%25 = load i8*, i8** %3
%26 = call i32 @opendir(i8* %25)
%27 = icmp ne i32 %26, 0
br i1 %27, label %56, label %28
28: ; preds = %24
%29 = load i8*, i8** %3
%30 = call i32 @strlen(i8* %29)
store i32 %30, i32* %4
%31 = load i32, i32* %4
%32 = icmp sgt i32 %31, 4
br i1 %32, label %33, label %52
33: ; preds = %28
%34 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%35 = load i8*, i8** %3
%36 = call i32 @sprintf(i8* %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %35)
%37 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%38 = call i32 @upper_case(i8* %37)
%39 = load i32, i32* %4
%40 = sub nsw i32 %39, 4
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 %41
%43 = call i64 @strcmp(i8* %42, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %48
45: ; preds = %33
%46 = load i8*, i8** %3
%47 = call i32 @adddat_zip(i8* %46)
br label %51
48: ; preds = %33
%49 = load i8*, i8** %3
%50 = call i32 @adddat_file(i8* %49, i32 -1)
br label %51
51: ; preds = %48, %45
br label %55
52: ; preds = %28
%53 = load i8*, i8** %3
%54 = call i32 @adddat_file(i8* %53, i32 -1)
br label %55
55: ; preds = %52, %51
br label %59
56: ; preds = %24
%57 = load i8*, i8** %3
%58 = call i32 @adddat_dir(i8* %57)
br label %59
59: ; preds = %56, %55
br label %60
60: ; preds = %59, %14
store i32 0, i32* %2
br label %61
61: ; preds = %60, %11
%62 = load i32, i32* %2
ret i32 %62
}

LLVM IR (-O2):
@.str = [28 x i8] c"'%s' path/file not found !\0A\00"
@.str.2 = [5 x i8] c".ZIP\00"
define i32 @ident(i8* %0) {
%2 = alloca [256 x i8]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%4 = tail call i32 @checkfile(i8* %0)
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %37
8: ; preds = %1
%9 = tail call i32 @strlen(i8* %0)
%10 = add nsw i32 %9, -1
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 46
br i1 %14, label %37, label %15
15: ; preds = %8
%16 = tail call i32 @opendir(i8* %0)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %35
18: ; preds = %15
%19 = tail call i32 @strlen(i8* %0)
%20 = icmp sgt i32 %19, 4
br i1 %20, label %21, label %33
21: ; preds = %18
%22 = call i8* @strcpy(i8* %3, i8* dereferenceable(1) %0)
%23 = call i32 @upper_case(i8* %3)
%24 = add nsw i32 %19, -4
%25 = zext i32 %24 to i64
%26 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 %25
%27 = call i64 @strcmp(i8* %26, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %21
%30 = call i32 @adddat_zip(i8* %0)
br label %37
31: ; preds = %21
%32 = call i32 @adddat_file(i8* %0, i32 -1)
br label %37
33: ; preds = %18
%34 = tail call i32 @adddat_file(i8* %0, i32 -1)
br label %37
35: ; preds = %15
%36 = tail call i32 @adddat_dir(i8* %0)
br label %37
37: ; preds = %8, %33, %31, %29, %35, %6
%38 = phi i32 [ 1, %6 ], [ 0, %35 ], [ 0, %29 ], [ 0, %31 ], [ 0, %33 ], [ 0, %8 ]
ret i32 %38
}