#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;
scalar_t__ check_map(int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ env(int **);
int /*<<< orphan*/ ft_putendl_fd(char *, int);
int open(char *, int /*<<< orphan*/);
int **parse(int);
int main(int ac, char **av) {
  int fd;
  int **map;
  if (ac == 2)
    fd = open(av[1], O_RDONLY);
  else
    fd = open("maps/42.fdf", O_RDONLY);
  if (fd > 0) {
    if (check_map(fd)) {
      close(fd);
      if (ac == 2)
        fd = open(av[1], O_RDONLY);
      else
        fd = open("maps/42.fdf", O_RDONLY);
      if (fd > 0)
        if ((map = parse(fd)))
          env(map);
    } else
      ft_putendl_fd("No \\n or more than 2 \\n at the end of file", 2);
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    119e <main+0x3e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e59(%rip),%rax
mov    (%rax),%esi
call   1050 <open@plt>
mov    %eax,-0x14(%rbp)
jmp    11b6 <main+0x56>
mov    0x2e43(%rip),%rax
mov    (%rax),%esi
lea    0xe52(%rip),%rdi
call   1050 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    1263 <main+0x103>
mov    -0x14(%rbp),%edi
call   1060 <check_map@plt>
cmp    $0x0,%rax
je     124d <main+0xed>
mov    -0x14(%rbp),%edi
call   1030 <close@plt>
cmpl   $0x2,-0x8(%rbp)
jne    1202 <main+0xa2>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2df5(%rip),%rax
mov    (%rax),%esi
call   1050 <open@plt>
mov    %eax,-0x14(%rbp)
jmp    121a <main+0xba>
mov    0x2ddf(%rip),%rax
mov    (%rax),%esi
lea    0xdee(%rip),%rdi
call   1050 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    1248 <main+0xe8>
mov    -0x14(%rbp),%edi
call   1070 <parse@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     1243 <main+0xe3>
mov    -0x20(%rbp),%rdi
call   1040 <env@plt>
jmp    1248 <main+0xe8>
jmp    125e <main+0xfe>
lea    0xdb8(%rip),%rdi
mov    $0x2,%esi
call   1080 <ft_putendl_fd@plt>
jmp    1263 <main+0x103>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%ebp
cmp    $0x2,%edi
jne    1177 <main+0x17>
mov    0x8(%r14),%rdi
jmp    117e <main+0x1e>
lea    0xe82(%rip),%rdi
mov    0x2e63(%rip),%r15
mov    (%r15),%esi
call   1050 <open@plt>
test   %eax,%eax
jle    11eb <main+0x8b>
mov    %eax,%ebx
mov    %eax,%edi
call   1060 <check_map@plt>
test   %rax,%rax
je     11b1 <main+0x51>
mov    %ebx,%edi
call   1030 <close@plt>
cmp    $0x2,%ebp
jne    11c4 <main+0x64>
mov    0x8(%r14),%rdi
jmp    11cb <main+0x6b>
lea    0xe54(%rip),%rdi
mov    $0x2,%esi
call   1080 <ft_putendl_fd@plt>
jmp    11eb <main+0x8b>
lea    0xe35(%rip),%rdi
mov    (%r15),%esi
call   1050 <open@plt>
test   %eax,%eax
jle    11eb <main+0x8b>
mov    %eax,%edi
call   1070 <parse@plt>
test   %rax,%rax
je     11eb <main+0x8b>
mov    %rax,%rdi
call   1040 <env@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@O_RDONLY = global i32 0
@.str = [12 x i8] c"maps/42.fdf\00"
@.str.1 = [43 x i8] c"No \\n or more than 2 \\n at the end of file\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, 2
br i1 %9, label %10, label %16
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = load i32, i32* @O_RDONLY
%15 = call i32 @open(i8* %13, i32 %14)
store i32 %15, i32* %6
br label %19
16: ; preds = %2
%17 = load i32, i32* @O_RDONLY
%18 = call i32 @open(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %17)
store i32 %18, i32* %6
br label %19
19: ; preds = %16, %10
%20 = load i32, i32* %6
%21 = icmp sgt i32 %20, 0
br i1 %21, label %22, label %55
22: ; preds = %19
%23 = load i32, i32* %6
%24 = call i64 @check_map(i32 %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %52
26: ; preds = %22
%27 = load i32, i32* %6
%28 = call i32 @close(i32 %27)
%29 = load i32, i32* %4
%30 = icmp eq i32 %29, 2
br i1 %30, label %31, label %37
31: ; preds = %26
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = load i32, i32* @O_RDONLY
%36 = call i32 @open(i8* %34, i32 %35)
store i32 %36, i32* %6
br label %40
37: ; preds = %26
%38 = load i32, i32* @O_RDONLY
%39 = call i32 @open(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %38)
store i32 %39, i32* %6
br label %40
40: ; preds = %37, %31
%41 = load i32, i32* %6
%42 = icmp sgt i32 %41, 0
br i1 %42, label %43, label %51
43: ; preds = %40
%44 = load i32, i32* %6
%45 = call i32** @parse(i32 %44)
store i32** %45, i32*** %7
%46 = icmp ne i32** %45, null
br i1 %46, label %47, label %50
47: ; preds = %43
%48 = load i32**, i32*** %7
%49 = call i32 @env(i32** %48)
br label %50
50: ; preds = %47, %43
br label %51
51: ; preds = %50, %40
br label %54
52: ; preds = %22
%53 = call i32 @ft_putendl_fd(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i32 2)
br label %54
54: ; preds = %52, %51
br label %55
55: ; preds = %54, %19
ret i32 0
}

LLVM IR (-O2):
@O_RDONLY = global i32 0
@.str = [12 x i8] c"maps/42.fdf\00"
@.str.1 = [43 x i8] c"No \\n or more than 2 \\n at the end of file\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
br label %7
7: ; preds = %2, %4
%8 = phi i8* [ %6, %4 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), %2 ]
%9 = load i32, i32* @O_RDONLY
%10 = tail call i32 @open(i8* %8, i32 %9)
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %32
12: ; preds = %7
%13 = tail call i64 @check_map(i32 %10)
%14 = icmp eq i64 %13, 0
br i1 %14, label %30, label %15
15: ; preds = %12
%16 = tail call i32 @close(i32 %10)
br i1 %3, label %17, label %20
17: ; preds = %15
%18 = getelementptr inbounds i8*, i8** %1, i64 1
%19 = load i8*, i8** %18
br label %20
20: ; preds = %15, %17
%21 = phi i8* [ %19, %17 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), %15 ]
%22 = load i32, i32* @O_RDONLY
%23 = tail call i32 @open(i8* %21, i32 %22)
%24 = icmp sgt i32 %23, 0
br i1 %24, label %25, label %32
25: ; preds = %20
%26 = tail call i32** @parse(i32 %23)
%27 = icmp eq i32** %26, null
br i1 %27, label %32, label %28
28: ; preds = %25
%29 = tail call i32 @env(i32** %26)
br label %32
30: ; preds = %12
%31 = tail call i32 @ft_putendl_fd(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i32 2)
br label %32
32: ; preds = %30, %25, %28, %20, %7
ret i32 0
}