#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 */
char EOF;
int /*<<< orphan*/ fatal(int, char *, int);
char getchar();
int readl(char *line) {
  char c;
  int i = 0;
  while ((c = getchar()) != EOF) {
    if (c == '\n') {
      line[i] = '\0';
      return i;
    } else if (i >= 81) {
      fatal(i >= 81, "La ligne est > MAXLINE (voir mcu_macros.h)", 2);
    } else {
      line[i++] = c;
    }
  }
  line[i] = '\0';
  return (i == 0 ? EOF : i);
}


x86 assembly (clang, -O0):
<readl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %al,-0x11(%rbp)
movsbl %al,%eax
mov    0x2ea1(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11c4 <readl+0xa4>
movsbl -0x11(%rbp),%eax
cmp    $0xa,%eax
jne    1176 <readl+0x56>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11f8 <readl+0xd8>
cmpl   $0x51,-0x18(%rbp)
jl     11a2 <readl+0x82>
cmpl   $0x51,-0x18(%rbp)
setge  %al
and    $0x1,%al
movzbl %al,%edi
lea    0xe6d(%rip),%rsi
mov    $0x2,%edx
call   1040 <fatal@plt>
jmp    11ba <readl+0x9a>
mov    -0x11(%rbp),%dl
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x18(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
jmp    11bf <readl+0x9f>
jmp    1133 <readl+0x13>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
cmpl   $0x0,-0x18(%rbp)
jne    11ec <readl+0xcc>
mov    0x2e07(%rip),%rax
movsbl (%rax),%eax
mov    %eax,-0x1c(%rbp)
jmp    11f2 <readl+0xd2>
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readl>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
xor    %eax,%eax
call   1030 <getchar@plt>
mov    0x2eb0(%rip),%r15
cmp    (%r15),%al
jne    1146 <readl+0x26>
movb   $0x0,(%rbx)
movsbl (%r15),%ebp
jmp    11a6 <readl+0x86>
lea    0xeb3(%rip),%r14
xor    %ebp,%ebp
jmp    1175 <readl+0x55>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movslq %ebp,%rcx
add    $0x1,%ebp
mov    %al,(%rbx,%rcx,1)
xor    %eax,%eax
call   1030 <getchar@plt>
cmp    (%r15),%al
je     1192 <readl+0x72>
cmp    $0xa,%al
je     119f <readl+0x7f>
cmp    $0x51,%ebp
jl     1160 <readl+0x40>
mov    $0x1,%edi
mov    %r14,%rsi
mov    $0x2,%edx
call   1040 <fatal@plt>
jmp    1169 <readl+0x49>
movslq %ebp,%rax
movb   $0x0,(%rbx,%rax,1)
test   %eax,%eax
jne    11a6 <readl+0x86>
jmp    1140 <readl+0x20>
movslq %ebp,%rax
movb   $0x0,(%rbx,%rax,1)
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i8 0
@.str = [43 x i8] c"La ligne est > MAXLINE (voir mcu_macros.h)\00"
define i32 @readl(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8
%5 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %5
br label %6
6: ; preds = %38, %1
%7 = call signext i8 (...) @getchar()
store i8 %7, i8* %4
%8 = sext i8 %7 to i32
%9 = load i8, i8* @EOF
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %8, %10
br i1 %11, label %12, label %39
12: ; preds = %6
%13 = load i8, i8* %4
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 10
br i1 %15, label %16, label %22
16: ; preds = %12
%17 = load i8*, i8** %3
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
store i8 0, i8* %20
%21 = load i32, i32* %5
store i32 %21, i32* %2
br label %53
22: ; preds = %12
%23 = load i32, i32* %5
%24 = icmp sge i32 %23, 81
br i1 %24, label %25, label %30
25: ; preds = %22
%26 = load i32, i32* %5
%27 = icmp sge i32 %26, 81
%28 = zext i1 %27 to i32
%29 = call i32 @fatal(i32 %28, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 2)
br label %37
30: ; preds = %22
%31 = load i8, i8* %4
%32 = load i8*, i8** %3
%33 = load i32, i32* %5
%34 = add nsw i32 %33, 1
store i32 %34, i32* %5
%35 = sext i32 %33 to i64
%36 = getelementptr inbounds i8, i8* %32, i64 %35
store i8 %31, i8* %36
br label %37
37: ; preds = %30, %25
br label %38
38: ; preds = %37
br label %6
39: ; preds = %6
%40 = load i8*, i8** %3
%41 = load i32, i32* %5
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %40, i64 %42
store i8 0, i8* %43
%44 = load i32, i32* %5
%45 = icmp eq i32 %44, 0
br i1 %45, label %46, label %49
46: ; preds = %39
%47 = load i8, i8* @EOF
%48 = sext i8 %47 to i32
br label %51
49: ; preds = %39
%50 = load i32, i32* %5
br label %51
51: ; preds = %49, %46
%52 = phi i32 [ %48, %46 ], [ %50, %49 ]
store i32 %52, i32* %2
br label %53
53: ; preds = %51, %16
%54 = load i32, i32* %2
ret i32 %54
}

LLVM IR (-O2):
@EOF = global i8 0
@.str = [43 x i8] c"La ligne est > MAXLINE (voir mcu_macros.h)\00"
define i32 @readl(i8* nocapture writeonly %0) {
%2 = tail call signext i8 (...) @getchar()
%3 = load i8, i8* @EOF
%4 = icmp eq i8 %2, %3
br i1 %4, label %5, label %6
5: ; preds = %1
store i8 0, i8* %0
br label %30
6: ; preds = %1, %21
%7 = phi i8 [ %23, %21 ], [ %2, %1 ]
%8 = phi i32 [ %22, %21 ], [ 0, %1 ]
%9 = icmp eq i8 %7, 10
br i1 %9, label %10, label %13
10: ; preds = %6
%11 = sext i32 %8 to i64
%12 = getelementptr inbounds i8, i8* %0, i64 %11
store i8 0, i8* %12
br label %33
13: ; preds = %6
%14 = icmp sgt i32 %8, 80
br i1 %14, label %15, label %17
15: ; preds = %13
%16 = tail call i32 @fatal(i32 1, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 2)
br label %21
17: ; preds = %13
%18 = add nsw i32 %8, 1
%19 = sext i32 %8 to i64
%20 = getelementptr inbounds i8, i8* %0, i64 %19
store i8 %7, i8* %20
br label %21
21: ; preds = %15, %17
%22 = phi i32 [ %8, %15 ], [ %18, %17 ]
%23 = tail call signext i8 (...) @getchar()
%24 = load i8, i8* @EOF
%25 = icmp eq i8 %23, %24
br i1 %25, label %26, label %6
26: ; preds = %21
%27 = sext i32 %22 to i64
%28 = getelementptr inbounds i8, i8* %0, i64 %27
store i8 0, i8* %28
%29 = icmp eq i32 %22, 0
br i1 %29, label %30, label %33
30: ; preds = %5, %26
%31 = load i8, i8* @EOF
%32 = sext i8 %31 to i32
br label %33
33: ; preds = %30, %26, %10
%34 = phi i32 [ %8, %10 ], [ %32, %30 ], [ %22, %26 ]
ret i32 %34
}