#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*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
char *strchr(char *, char);
int /*<<< orphan*/ viderBuffer();
int lire(char *chaine, int longueur) {
  char *positionEntree = NULL;
  if (fgets(chaine, (longueur + 1), stdin) != NULL) {
    positionEntree = strchr(chaine, '\n');
    if (positionEntree != NULL) {
      *positionEntree = '\0';
    } else {
      viderBuffer();
    }
    if (*chaine == ' ') {
      return 0;
    } else {
      return 1;
    }
  } else {
    viderBuffer();
    return 0;
  }
}


x86 assembly (clang, -O0):
<lire>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
add    $0x1,%esi
mov    0x2e90(%rip),%rax
mov    (%rax),%edx
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     11c1 <lire+0x91>
mov    -0x10(%rbp),%rdi
mov    $0xa,%esi
call   1030 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1192 <lire+0x62>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
jmp    1199 <lire+0x69>
mov    $0x0,%al
call   1050 <viderBuffer@plt>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    11b5 <lire+0x85>
movl   $0x0,-0x4(%rbp)
jmp    11cf <lire+0x9f>
movl   $0x1,-0x4(%rbp)
jmp    11cf <lire+0x9f>
mov    $0x0,%al
call   1050 <viderBuffer@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lire>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
add    $0x1,%esi
mov    0x2ea8(%rip),%rax
mov    (%rax),%edx
call   1040 <fgets@plt>
test   %rax,%rax
je     1163 <lire+0x33>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     116e <lire+0x3e>
movb   $0x0,(%rax)
jmp    1175 <lire+0x45>
xor    %ebp,%ebp
xor    %eax,%eax
call   1050 <viderBuffer@plt>
jmp    117e <lire+0x4e>
xor    %eax,%eax
call   1050 <viderBuffer@plt>
xor    %ebp,%ebp
cmpb   $0x20,(%rbx)
setne  %bpl
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32 0
define i32 @lire(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
store i8* %0, i8** %4
store i32 %1, i32* %5
store i8* null, i8** %6
%7 = load i8*, i8** %4
%8 = load i32, i32* %5
%9 = add nsw i32 %8, 1
%10 = load i32, i32* @stdin
%11 = call i32* @fgets(i8* %7, i32 %9, i32 %10)
%12 = icmp ne i32* %11, null
br i1 %12, label %13, label %29
13: ; preds = %2
%14 = load i8*, i8** %4
%15 = call i8* @strchr(i8* %14, i8 signext 10)
store i8* %15, i8** %6
%16 = load i8*, i8** %6
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = load i8*, i8** %6
store i8 0, i8* %19
br label %22
20: ; preds = %13
%21 = call i32 (...) @viderBuffer()
br label %22
22: ; preds = %20, %18
%23 = load i8*, i8** %4
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 32
br i1 %26, label %27, label %28
27: ; preds = %22
store i32 0, i32* %3
br label %31
28: ; preds = %22
store i32 1, i32* %3
br label %31
29: ; preds = %2
%30 = call i32 (...) @viderBuffer()
store i32 0, i32* %3
br label %31
31: ; preds = %29, %28, %27
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
@stdin = global i32 0
define i32 @lire(i8* %0, i32 %1) {
%3 = add nsw i32 %1, 1
%4 = load i32, i32* @stdin
%5 = tail call i32* @fgets(i8* %0, i32 %3, i32 %4)
%6 = icmp eq i32* %5, null
br i1 %6, label %17, label %7
7: ; preds = %2
%8 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 10)
%9 = icmp eq i8* %8, null
br i1 %9, label %11, label %10
10: ; preds = %7
store i8 0, i8* %8
br label %13
11: ; preds = %7
%12 = tail call i32 (...) @viderBuffer()
br label %13
13: ; preds = %11, %10
%14 = load i8, i8* %0
%15 = icmp ne i8 %14, 32
%16 = zext i1 %15 to i32
br label %19
17: ; preds = %2
%18 = tail call i32 (...) @viderBuffer()
br label %19
19: ; preds = %13, %17
%20 = phi i32 [ 0, %17 ], [ %16, %13 ]
ret i32 %20
}