#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
char EOF;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ lexical_analysis(int /*<<< orphan*/ *, char);
int /*<<< orphan*/ printf(char *);
int main(int argc, char **argv) {
  const char *filename;
  FILE *input_file;
  char current_character;
  if (argc == 1) {
    printf("Introduceti numele fisierului ca parametru in "
           "linia de comanda\n");
    exit(EXIT_FAILURE);
  }
  filename = argv[1];
  input_file = fopen(filename, "r");
  if (input_file == NULL) {
    printf("Fisierul nu exista!\n");
    exit(EXIT_FAILURE);
  }
  while ((current_character = fgetc(input_file)) != EOF)
    lexical_analysis(input_file, current_character);
  fclose(input_file);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    119a <main+0x3a>
lea    0xe79(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e45(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe8f(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11df <main+0x7f>
lea    0xe76(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e00(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
jmp    11e4 <main+0x84>
mov    -0x20(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x21(%rbp)
movsbl %al,%eax
mov    0x2dee(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1217 <main+0xb7>
mov    -0x20(%rbp),%rdi
movsbl -0x21(%rbp),%esi
call   1060 <lexical_analysis@plt>
jmp    11e4 <main+0x84>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
cmp    $0x1,%edi
je     11ca <main+0x6a>
mov    0x8(%rsi),%rdi
lea    0xe8c(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11d3 <main+0x73>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <fgetc@plt>
mov    0x2e58(%rip),%r14
cmp    (%r14),%al
je     11b8 <main+0x58>
cs nopw 0x0(%rax,%rax,1)
nop
movsbl %al,%esi
mov    %rbx,%rdi
call   1060 <lexical_analysis@plt>
mov    %rbx,%rdi
call   1050 <fgetc@plt>
cmp    (%r14),%al
jne    11a0 <main+0x40>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe45(%rip),%rdi
jmp    11da <main+0x7a>
lea    0xe28(%rip),%rdi
call   1030 <puts@plt>
mov    0x2df2(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [64 x i8] c"Introduceti numele fisierului ca parametru in linia de comanda\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [21 x i8] c"Fisierul nu exista!\0A\00"
@EOF = global i8 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = call i32 @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0))
%13 = load i32, i32* @EXIT_FAILURE
%14 = call i32 @exit(i32 %13)
unreachable
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
store i8* %18, i8** %6
%19 = load i8*, i8** %6
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %20, i32** %7
%21 = load i32*, i32** %7
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %27
23: ; preds = %15
%24 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%25 = load i32, i32* @EXIT_FAILURE
%26 = call i32 @exit(i32 %25)
unreachable
27: ; preds = %15
br label %28
28: ; preds = %35, %27
%29 = load i32*, i32** %7
%30 = call signext i8 @fgetc(i32* %29)
store i8 %30, i8* %8
%31 = sext i8 %30 to i32
%32 = load i8, i8* @EOF
%33 = sext i8 %32 to i32
%34 = icmp ne i32 %31, %33
br i1 %34, label %35, label %39
35: ; preds = %28
%36 = load i32*, i32** %7
%37 = load i8, i8* %8
%38 = call i32 @lexical_analysis(i32* %36, i8 signext %37)
br label %28
39: ; preds = %28
%40 = load i32*, i32** %7
%41 = call i32 @fclose(i32* %40)
ret i32 0
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"r\00"
@EOF = global i8 0
@str = [20 x i8] c"Fisierul nu exista!\00"
@str.3 = [63 x i8] c"Introduceti numele fisierului ca parametru in linia de comanda\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @str.3, i64 0, i64 0))
%6 = load i32, i32* @EXIT_FAILURE
%7 = tail call i32 @exit(i32 %6)
unreachable
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %17, label %13
13: ; preds = %8
%14 = tail call signext i8 @fgetc(i32* %11)
%15 = load i8, i8* @EOF
%16 = icmp eq i8 %14, %15
br i1 %16, label %27, label %21
17: ; preds = %8
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%19 = load i32, i32* @EXIT_FAILURE
%20 = tail call i32 @exit(i32 %19)
unreachable
21: ; preds = %13, %21
%22 = phi i8 [ %24, %21 ], [ %14, %13 ]
%23 = tail call i32 @lexical_analysis(i32* %11, i8 signext %22)
%24 = tail call signext i8 @fgetc(i32* %11)
%25 = load i8, i8* @EOF
%26 = icmp eq i8 %24, %25
br i1 %26, label %27, label %21
27: ; preds = %21, %13
%28 = tail call i32 @fclose(i32* %11)
ret i32 0
}