#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;
char *calloc(int, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ find(char *, int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
scalar_t__ read(int, char *, int);
int strlen(char *);
int main(int argc, char *argv[]) {
  int f, length;
  char *buf;
  if (argc != 2) {
    printf("Errore\n");
    exit(1);
  }
  if ((f = open(argv[1], O_RDONLY)) < 0) {
    printf("Errore\n");
    exit(2);
  }
  buf = calloc(100, sizeof(char));
  if (read(f, buf, 100) > 0) {
    length = strlen(buf);
    find(buf, length);
  }
  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)
je     11a6 <main+0x36>
lea    0xe69(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e33(%rip),%rax
mov    (%rax),%esi
call   1080 <open@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    11de <main+0x6e>
lea    0xe31(%rip),%rdi
call   1040 <printf@plt>
mov    $0x2,%edi
call   1090 <exit@plt>
mov    $0x64,%edi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    $0x64,%edx
call   1050 <read@plt>
cmp    $0x0,%rax
jle    1224 <main+0xb4>
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x18(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1070 <find@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    11d1 <main+0x61>
mov    0x8(%rsi),%rdi
mov    0x2e65(%rip),%rax
mov    (%rax),%esi
call   1080 <open@plt>
test   %eax,%eax
js     11e7 <main+0x77>
mov    %eax,%ebp
mov    $0x64,%edi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,%rbx
mov    %ebp,%edi
mov    %rax,%rsi
mov    $0x64,%edx
call   1050 <read@plt>
test   %rax,%rax
jle    11c8 <main+0x58>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1070 <find@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe28(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
lea    0xe12(%rip),%rdi
call   1030 <puts@plt>
mov    $0x2,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"Errore\0A\00"
@O_RDONLY = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%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 ne i32 %9, 2
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = load i32, i32* @O_RDONLY
%19 = call i32 @open(i8* %17, i32 %18)
store i32 %19, i32* %6
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %14
%22 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%23 = call i32 @exit(i32 2)
unreachable
24: ; preds = %14
%25 = call i8* @calloc(i32 100, i32 1)
store i8* %25, i8** %8
%26 = load i32, i32* %6
%27 = load i8*, i8** %8
%28 = call i64 @read(i32 %26, i8* %27, i32 100)
%29 = icmp sgt i64 %28, 0
br i1 %29, label %30, label %36
30: ; preds = %24
%31 = load i8*, i8** %8
%32 = call i32 @strlen(i8* %31)
store i32 %32, i32* %7
%33 = load i8*, i8** %8
%34 = load i32, i32* %7
%35 = call i32 @find(i8* %33, i32 %34)
br label %36
36: ; preds = %30, %24
ret i32 0
}

LLVM IR (-O2):
@O_RDONLY = global i32 0
@str.1 = [7 x i8] c"Errore\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.1, i64 0, i64 0))
%6 = tail call i32 @exit(i32 1)
unreachable
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = load i32, i32* @O_RDONLY
%11 = tail call i32 @open(i8* %9, i32 %10)
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %7
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.1, i64 0, i64 0))
%15 = tail call i32 @exit(i32 2)
unreachable
16: ; preds = %7
%17 = tail call dereferenceable_or_null(100) i8* @calloc(i32 100, i32 1)
%18 = tail call i64 @read(i32 %11, i8* %17, i32 100)
%19 = icmp sgt i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %16
%21 = tail call i32 @strlen(i8* %17)
%22 = tail call i32 @find(i8* %17, i32 %21)
br label %23
23: ; preds = %20, %16
ret i32 0
}