#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*/ O_RDONLY;
int checking_ext(char **);
int /*<<< orphan*/ my_putstr(char *);
int open(char *, int /*<<< orphan*/);
int checking_is_file(char **av) {
  int e_check;
  e_check = 0;
  if ((e_check = (open(av[1], O_RDONLY))) == -1) {
    my_putstr("Error on open\n");
    return (1);
  } else {
    my_putstr("File is existing\n");
    e_check = checking_ext(av);
  }
  return (e_check);
}


x86 assembly (clang, -O0):
<checking_is_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e96(%rip),%rax
mov    (%rax),%esi
call   1040 <open@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
jne    117d <checking_is_file+0x4d>
lea    0xe94(%rip),%rdi
call   1030 <my_putstr@plt>
movl   $0x1,-0x4(%rbp)
jmp    119b <checking_is_file+0x6b>
lea    0xe8b(%rip),%rdi
call   1030 <my_putstr@plt>
mov    -0x10(%rbp),%rdi
call   1050 <checking_ext@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checking_is_file>:
push   %rbx
mov    %rdi,%rbx
mov    0x8(%rdi),%rdi
mov    0x2ea9(%rip),%rax
mov    (%rax),%esi
call   1040 <open@plt>
cmp    $0xffffffff,%eax
je     1160 <checking_is_file+0x30>
lea    0xebd(%rip),%rdi
call   1030 <my_putstr@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1050 <checking_ext@plt>
lea    0xe99(%rip),%rdi
call   1030 <my_putstr@plt>
mov    $0x1,%eax
pop    %rbx
ret

LLVM IR (-O0):
@O_RDONLY = global i32 0
@.str = [15 x i8] c"Error on open\0A\00"
@.str.1 = [18 x i8] c"File is existing\0A\00"
define i32 @checking_is_file(i8** %0) {
%2 = alloca i32
%3 = alloca i8**
%4 = alloca i32
store i8** %0, i8*** %3
store i32 0, i32* %4
%5 = load i8**, i8*** %3
%6 = getelementptr inbounds i8*, i8** %5, i64 1
%7 = load i8*, i8** %6
%8 = load i32, i32* @O_RDONLY
%9 = call i32 @open(i8* %7, i32 %8)
store i32 %9, i32* %4
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %13
11: ; preds = %1
%12 = call i32 @my_putstr(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %2
br label %19
13: ; preds = %1
%14 = call i32 @my_putstr(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%15 = load i8**, i8*** %3
%16 = call i32 @checking_ext(i8** %15)
store i32 %16, i32* %4
br label %17
17: ; preds = %13
%18 = load i32, i32* %4
store i32 %18, i32* %2
br label %19
19: ; preds = %17, %11
%20 = load i32, i32* %2
ret i32 %20
}

LLVM IR (-O2):
@O_RDONLY = global i32 0
@.str = [15 x i8] c"Error on open\0A\00"
@.str.1 = [18 x i8] c"File is existing\0A\00"
define i32 @checking_is_file(i8** %0) {
%2 = getelementptr inbounds i8*, i8** %0, i64 1
%3 = load i8*, i8** %2
%4 = load i32, i32* @O_RDONLY
%5 = tail call i32 @open(i8* %3, i32 %4)
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = tail call i32 @my_putstr(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %12
9: ; preds = %1
%10 = tail call i32 @my_putstr(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%11 = tail call i32 @checking_ext(i8** %0)
br label %12
12: ; preds = %9, %7
%13 = phi i32 [ 1, %7 ], [ %11, %9 ]
ret i32 %13
}