#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 /*<<< orphan*/ close(int);
int /*<<< orphan*/ my_putstr2(char *);
int open(char *, int /*<<< orphan*/);
int read(int, char *, int);
int check_chars(char *path) {
  int fd;
  int i;
  int j;
  char buff[4097];
  if ((path == NULL) || (fd = open(path, O_RDONLY)) < 0)
    return (0);
  while (read(fd, buff, 1) > 0 && buff[0] != '\n')
    ;
  while ((j = read(fd, buff, 4096)) > 0) {
    i = -1;
    buff[j] = '\0';
    while (++i < 4096 && buff[i] != '\0') {
      if (buff[i] != '.' && buff[i] != 'o' && buff[i] != '\n' &&
          buff[i] != '\0') {
        my_putstr2("Error : an invalid caracter was found\n");
        close(fd);
        return (0);
      }
    }
  }
  close(fd);
  return (1);
}


x86 assembly (clang, -O0):
<check_chars>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1030,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1178 <check_chars+0x38>
mov    -0x10(%rbp),%rdi
mov    0x2e83(%rip),%rax
mov    (%rax),%esi
call   1060 <open@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    1184 <check_chars+0x44>
movl   $0x0,-0x4(%rbp)
jmp    12e8 <check_chars+0x1a8>
jmp    1189 <check_chars+0x49>
mov    -0x14(%rbp),%edi
lea    -0x1020(%rbp),%rsi
mov    $0x1,%edx
call   1040 <read@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x1021(%rbp)
jle    11c3 <check_chars+0x83>
movsbl -0x1020(%rbp),%eax
cmp    $0xa,%eax
setne  %al
mov    %al,-0x1021(%rbp)
mov    -0x1021(%rbp),%al
test   $0x1,%al
jne    11d6 <check_chars+0x96>
jmp    11db <check_chars+0x9b>
jmp    1189 <check_chars+0x49>
jmp    11e0 <check_chars+0xa0>
mov    -0x14(%rbp),%edi
lea    -0x1020(%rbp),%rsi
mov    $0x1000,%edx
call   1040 <read@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jle    12d9 <check_chars+0x199>
movl   $0xffffffff,-0x18(%rbp)
movslq -0x1c(%rbp),%rax
movb   $0x0,-0x1020(%rbp,%rax,1)
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,-0x18(%rbp)
xor    %eax,%eax
cmp    $0x1000,%ecx
mov    %al,-0x1022(%rbp)
jge    1248 <check_chars+0x108>
movslq -0x18(%rbp),%rax
movsbl -0x1020(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
setne  %al
mov    %al,-0x1022(%rbp)
mov    -0x1022(%rbp),%al
test   $0x1,%al
jne    125b <check_chars+0x11b>
jmp    12d4 <check_chars+0x194>
movslq -0x18(%rbp),%rax
movsbl -0x1020(%rbp,%rax,1),%eax
ff
cmp    $0x2e,%eax
je     12cf <check_chars+0x18f>
movslq -0x18(%rbp),%rax
movsbl -0x1020(%rbp,%rax,1),%eax
ff
cmp    $0x6f,%eax
je     12cf <check_chars+0x18f>
movslq -0x18(%rbp),%rax
movsbl -0x1020(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
je     12cf <check_chars+0x18f>
movslq -0x18(%rbp),%rax
movsbl -0x1020(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     12cf <check_chars+0x18f>
lea    0xd4a(%rip),%rdi
call   1050 <my_putstr2@plt>
mov    -0x14(%rbp),%edi
call   1030 <close@plt>
movl   $0x0,-0x4(%rbp)
jmp    12e8 <check_chars+0x1a8>
jmp    1213 <check_chars+0xd3>
jmp    11e0 <check_chars+0xa0>
mov    -0x14(%rbp),%edi
call   1030 <close@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_chars>:
push   %rbp
push   %r14
push   %rbx
sub    $0x1010,%rsp
xor    %ebp,%ebp
test   %rdi,%rdi
je     1372 <check_chars+0x232>
mov    0x2e8b(%rip),%rax
mov    (%rax),%esi
call   1060 <open@plt>
test   %eax,%eax
js     1372 <check_chars+0x232>
mov    %eax,%ebx
mov    %rsp,%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0x1,%edx
call   1040 <read@plt>
test   %eax,%eax
jle    1199 <check_chars+0x59>
cmpb   $0xa,(%rsp)
jne    1180 <check_chars+0x40>
mov    %rsp,%rsi
mov    %ebx,%edi
mov    $0x1000,%edx
call   1040 <read@plt>
mov    $0x1,%ebp
test   %eax,%eax
jle    136b <check_chars+0x22b>
mov    %rsp,%r14
mov    %eax,%eax
movb   $0x0,(%rsp,%rax,1)
xor    %eax,%eax
jmp    11e9 <check_chars+0xa9>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmp    $0xa,%cl
jne    1340 <check_chars+0x200>
add    $0x8,%rax
cmp    $0x1000,%rax
je     1344 <check_chars+0x204>
movzbl (%rsp,%rax,1),%ecx
cmp    $0x2d,%cl
jle    1210 <check_chars+0xd0>
cmp    $0x2e,%cl
je     1219 <check_chars+0xd9>
cmp    $0x6f,%cl
je     1219 <check_chars+0xd9>
jmp    135d <check_chars+0x21d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmp    $0xa,%cl
jne    1340 <check_chars+0x200>
movzbl 0x1(%rsp,%rax,1),%ecx
cmp    $0x2d,%cl
jle    1240 <check_chars+0x100>
cmp    $0x6f,%cl
je     1249 <check_chars+0x109>
cmp    $0x2e,%cl
je     1249 <check_chars+0x109>
jmp    135d <check_chars+0x21d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmp    $0xa,%cl
jne    1340 <check_chars+0x200>
movzbl 0x2(%rsp,%rax,1),%ecx
cmp    $0x2d,%cl
jle    1270 <check_chars+0x130>
cmp    $0x6f,%cl
je     1279 <check_chars+0x139>
cmp    $0x2e,%cl
je     1279 <check_chars+0x139>
jmp    135d <check_chars+0x21d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmp    $0xa,%cl
jne    1340 <check_chars+0x200>
movzbl 0x3(%rsp,%rax,1),%ecx
cmp    $0x2d,%cl
jle    12a0 <check_chars+0x160>
cmp    $0x6f,%cl
je     12a9 <check_chars+0x169>
cmp    $0x2e,%cl
je     12a9 <check_chars+0x169>
jmp    135d <check_chars+0x21d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmp    $0xa,%cl
jne    1340 <check_chars+0x200>
movzbl 0x4(%rsp,%rax,1),%ecx
cmp    $0x2d,%cl
jle    12d0 <check_chars+0x190>
cmp    $0x6f,%cl
je     12d5 <check_chars+0x195>
cmp    $0x2e,%cl
je     12d5 <check_chars+0x195>
jmp    135d <check_chars+0x21d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmp    $0xa,%cl
jne    1340 <check_chars+0x200>
movzbl 0x5(%rsp,%rax,1),%ecx
cmp    $0x2d,%cl
jle    12f0 <check_chars+0x1b0>
cmp    $0x6f,%cl
je     12f5 <check_chars+0x1b5>
cmp    $0x2e,%cl
je     12f5 <check_chars+0x1b5>
jmp    135d <check_chars+0x21d>
nopl   0x0(%rax,%rax,1)
cmp    $0xa,%cl
jne    1340 <check_chars+0x200>
movzbl 0x6(%rsp,%rax,1),%ecx
cmp    $0x2d,%cl
jle    1310 <check_chars+0x1d0>
cmp    $0x6f,%cl
je     1315 <check_chars+0x1d5>
cmp    $0x2e,%cl
je     1315 <check_chars+0x1d5>
jmp    135d <check_chars+0x21d>
nopl   0x0(%rax,%rax,1)
cmp    $0xa,%cl
jne    1340 <check_chars+0x200>
movzbl 0x7(%rsp,%rax,1),%ecx
cmp    $0x2d,%cl
jle    11d0 <check_chars+0x90>
cmp    $0x6f,%cl
je     11d9 <check_chars+0x99>
cmp    $0x2e,%cl
je     11d9 <check_chars+0x99>
jmp    135d <check_chars+0x21d>
nopw   0x0(%rax,%rax,1)
test   %cl,%cl
jne    135d <check_chars+0x21d>
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x1000,%edx
call   1040 <read@plt>
test   %eax,%eax
jg     11b8 <check_chars+0x78>
jmp    136b <check_chars+0x22b>
lea    0xc9c(%rip),%rdi
call   1050 <my_putstr2@plt>
xor    %ebp,%ebp
mov    %ebx,%edi
call   1030 <close@plt>
mov    %ebp,%eax
add    $0x1010,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@O_RDONLY = global i32 0
@.str = [39 x i8] c"Error : an invalid caracter was found\0A\00"
define i32 @check_chars(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [4097 x i8]
store i8* %0, i8** %3
%8 = load i8*, i8** %3
%9 = icmp eq i8* %8, null
br i1 %9, label %15, label %10
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = load i32, i32* @O_RDONLY
%13 = call i32 @open(i8* %11, i32 %12)
store i32 %13, i32* %4
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %10, %1
store i32 0, i32* %2
br label %90
16: ; preds = %10
br label %17
17: ; preds = %29, %16
%18 = load i32, i32* %4
%19 = getelementptr inbounds [4097 x i8], [4097 x i8]* %7, i64 0, i64 0
%20 = call i32 @read(i32 %18, i8* %19, i32 1)
%21 = icmp sgt i32 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %17
%23 = getelementptr inbounds [4097 x i8], [4097 x i8]* %7, i64 0, i64 0
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp ne i32 %25, 10
br label %27
27: ; preds = %22, %17
%28 = phi i1 [ false, %17 ], [ %26, %22 ]
br i1 %28, label %29, label %30
29: ; preds = %27
br label %17
30: ; preds = %27
br label %31
31: ; preds = %86, %30
%32 = load i32, i32* %4
%33 = getelementptr inbounds [4097 x i8], [4097 x i8]* %7, i64 0, i64 0
%34 = call i32 @read(i32 %32, i8* %33, i32 4096)
store i32 %34, i32* %6
%35 = icmp sgt i32 %34, 0
br i1 %35, label %36, label %87
36: ; preds = %31
store i32 -1, i32* %5
%37 = load i32, i32* %6
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [4097 x i8], [4097 x i8]* %7, i64 0, i64 %38
store i8 0, i8* %39
br label %40
40: ; preds = %85, %36
%41 = load i32, i32* %5
%42 = add nsw i32 %41, 1
store i32 %42, i32* %5
%43 = icmp slt i32 %42, 4096
br i1 %43, label %44, label %51
44: ; preds = %40
%45 = load i32, i32* %5
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [4097 x i8], [4097 x i8]* %7, i64 0, i64 %46
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = icmp ne i32 %49, 0
br label %51
51: ; preds = %44, %40
%52 = phi i1 [ false, %40 ], [ %50, %44 ]
br i1 %52, label %53, label %86
53: ; preds = %51
%54 = load i32, i32* %5
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [4097 x i8], [4097 x i8]* %7, i64 0, i64 %55
%57 = load i8, i8* %56
%58 = sext i8 %57 to i32
%59 = icmp ne i32 %58, 46
br i1 %59, label %60, label %85
60: ; preds = %53
%61 = load i32, i32* %5
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds [4097 x i8], [4097 x i8]* %7, i64 0, i64 %62
%64 = load i8, i8* %63
%65 = sext i8 %64 to i32
%66 = icmp ne i32 %65, 111
br i1 %66, label %67, label %85
67: ; preds = %60
%68 = load i32, i32* %5
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds [4097 x i8], [4097 x i8]* %7, i64 0, i64 %69
%71 = load i8, i8* %70
%72 = sext i8 %71 to i32
%73 = icmp ne i32 %72, 10
br i1 %73, label %74, label %85
74: ; preds = %67
%75 = load i32, i32* %5
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds [4097 x i8], [4097 x i8]* %7, i64 0, i64 %76
%78 = load i8, i8* %77
%79 = sext i8 %78 to i32
%80 = icmp ne i32 %79, 0
br i1 %80, label %81, label %85
81: ; preds = %74
%82 = call i32 @my_putstr2(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%83 = load i32, i32* %4
%84 = call i32 @close(i32 %83)
store i32 0, i32* %2
br label %90
85: ; preds = %74, %67, %60, %53
br label %40
86: ; preds = %51
br label %31
87: ; preds = %31
%88 = load i32, i32* %4
%89 = call i32 @close(i32 %88)
store i32 1, i32* %2
br label %90
90: ; preds = %87, %81, %15
%91 = load i32, i32* %2
ret i32 %91
}

LLVM IR (-O2):
@O_RDONLY = global i32 0
@.str = [39 x i8] c"Error : an invalid caracter was found\0A\00"
define i32 @check_chars(i8* %0) {
%2 = alloca [4097 x i8]
%3 = getelementptr inbounds [4097 x i8], [4097 x i8]* %2, i64 0, i64 0
%4 = icmp eq i8* %0, null
br i1 %4, label %65, label %5
5: ; preds = %1
%6 = load i32, i32* @O_RDONLY
%7 = tail call i32 @open(i8* %0, i32 %6)
%8 = icmp slt i32 %7, 0
br i1 %8, label %65, label %9
9: ; preds = %5, %9
%10 = call i32 @read(i32 %7, i8* %3, i32 1)
%11 = icmp sgt i32 %10, 0
%12 = load i8, i8* %3
%13 = icmp ne i8 %12, 10
%14 = select i1 %11, i1 %13, i1 false
br i1 %14, label %9, label %15
15: ; preds = %9
%16 = call i32 @read(i32 %7, i8* %3, i32 4096)
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %62
18: ; preds = %15, %59
%19 = phi i32 [ %60, %59 ], [ %16, %15 ]
%20 = zext i32 %19 to i64
%21 = getelementptr inbounds [4097 x i8], [4097 x i8]* %2, i64 0, i64 %20
store i8 0, i8* %21
br label %22
22: ; preds = %56, %18
%23 = phi i64 [ 0, %18 ], [ %57, %56 ]
%24 = getelementptr inbounds [4097 x i8], [4097 x i8]* %2, i64 0, i64 %23
%25 = load i8, i8* %24
switch i8 %25, label %26 [
i8 0, label %59
i8 46, label %28
i8 111, label %28
i8 10, label %28
]
26: ; preds = %52, %48, %44, %40, %36, %32, %28, %22
%27 = tail call i32 @my_putstr2(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
br label %62
28: ; preds = %22, %22, %22
%29 = or i64 %23, 1
%30 = getelementptr inbounds [4097 x i8], [4097 x i8]* %2, i64 0, i64 %29
%31 = load i8, i8* %30
switch i8 %31, label %26 [
i8 0, label %59
i8 46, label %32
i8 111, label %32
i8 10, label %32
]
32: ; preds = %28, %28, %28
%33 = or i64 %23, 2
%34 = getelementptr inbounds [4097 x i8], [4097 x i8]* %2, i64 0, i64 %33
%35 = load i8, i8* %34
switch i8 %35, label %26 [
i8 0, label %59
i8 46, label %36
i8 111, label %36
i8 10, label %36
]
36: ; preds = %32, %32, %32
%37 = or i64 %23, 3
%38 = getelementptr inbounds [4097 x i8], [4097 x i8]* %2, i64 0, i64 %37
%39 = load i8, i8* %38
switch i8 %39, label %26 [
i8 0, label %59
i8 46, label %40
i8 111, label %40
i8 10, label %40
]
40: ; preds = %36, %36, %36
%41 = or i64 %23, 4
%42 = getelementptr inbounds [4097 x i8], [4097 x i8]* %2, i64 0, i64 %41
%43 = load i8, i8* %42
switch i8 %43, label %26 [
i8 0, label %59
i8 46, label %44
i8 111, label %44
i8 10, label %44
]
44: ; preds = %40, %40, %40
%45 = or i64 %23, 5
%46 = getelementptr inbounds [4097 x i8], [4097 x i8]* %2, i64 0, i64 %45
%47 = load i8, i8* %46
switch i8 %47, label %26 [
i8 0, label %59
i8 46, label %48
i8 111, label %48
i8 10, label %48
]
48: ; preds = %44, %44, %44
%49 = or i64 %23, 6
%50 = getelementptr inbounds [4097 x i8], [4097 x i8]* %2, i64 0, i64 %49
%51 = load i8, i8* %50
switch i8 %51, label %26 [
i8 0, label %59
i8 46, label %52
i8 111, label %52
i8 10, label %52
]
52: ; preds = %48, %48, %48
%53 = or i64 %23, 7
%54 = getelementptr inbounds [4097 x i8], [4097 x i8]* %2, i64 0, i64 %53
%55 = load i8, i8* %54
switch i8 %55, label %26 [
i8 0, label %59
i8 46, label %56
i8 111, label %56
i8 10, label %56
]
56: ; preds = %52, %52, %52
%57 = add nuw nsw i64 %23, 8
%58 = icmp eq i64 %57, 4096
br i1 %58, label %59, label %22
59: ; preds = %56, %52, %48, %44, %40, %36, %32, %28, %22
%60 = call i32 @read(i32 %7, i8* %3, i32 4096)
%61 = icmp sgt i32 %60, 0
br i1 %61, label %18, label %62
62: ; preds = %59, %15, %26
%63 = phi i32 [ 0, %26 ], [ 1, %15 ], [ 1, %59 ]
%64 = tail call i32 @close(i32 %7)
br label %65
65: ; preds = %62, %1, %5
%66 = phi i32 [ 0, %5 ], [ 0, %1 ], [ %63, %62 ]
ret i32 %66
}