#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 */
int EOF;
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
int readline(FILE *stream, char *buffer) {
  int c, count;
  for (count = 0; (c = fgetc(stream)) != EOF && count < 100; count++) {
    if (c == '\n') {
      buffer[count] = '\0';
      return 1;
    } else if (c == '\r')
      count--;
    else
      buffer[count] = c;
  }
  if (count < 100) {
    buffer[count] = '\0';
    return 0;
  }
  buffer[100 - 1] = '\0';
  fprintf(stderr, "Le mot commençant par %s est trop long\n", buffer);
  return 1;
}


x86 assembly (clang, -O0):
<readline>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %eax,%ecx
mov    %ecx,-0x1c(%rbp)
xor    %eax,%eax
mov    0x2e9a(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0x21(%rbp)
je     1163 <readline+0x43>
cmpl   $0x64,-0x20(%rbp)
setl   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1173 <readline+0x53>
jmp    11d5 <readline+0xb5>
cmpl   $0xa,-0x1c(%rbp)
jne    1195 <readline+0x75>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
movl   $0x1,-0x4(%rbp)
jmp    121f <readline+0xff>
cmpl   $0xd,-0x1c(%rbp)
jne    11ad <readline+0x8d>
mov    -0x20(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x20(%rbp)
jmp    11bd <readline+0x9d>
mov    -0x1c(%rbp),%eax
mov    %al,%dl
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    11c2 <readline+0xa2>
jmp    11c7 <readline+0xa7>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1137 <readline+0x17>
cmpl   $0x64,-0x20(%rbp)
jge    11f7 <readline+0xd7>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
movl   $0x0,-0x4(%rbp)
jmp    121f <readline+0xff>
mov    -0x18(%rbp),%rax
movb   $0x0,0x63(%rax)
mov    0x2dd2(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xded(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readline>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
call   1030 <fgetc@plt>
mov    0x2ead(%rip),%r12
xor    %ebx,%ebx
cmp    (%r12),%eax
je     1197 <readline+0x77>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmp    $0xd,%eax
je     1170 <readline+0x50>
movslq %ebx,%rcx
cmp    $0xa,%eax
je     11a0 <readline+0x80>
mov    %al,(%r14,%rcx,1)
jmp    1173 <readline+0x53>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0xffffffff,%ebx
mov    %ebx,%r13d
lea    0x1(%r13),%ebx
mov    %r15,%rdi
call   1030 <fgetc@plt>
cmp    (%r12),%eax
je     118e <readline+0x6e>
cmp    $0x63,%r13d
jl     1150 <readline+0x30>
cmp    $0x62,%r13d
jg     11a7 <readline+0x87>
movslq %ebx,%rbx
movb   $0x0,(%r14,%rbx,1)
xor    %eax,%eax
jmp    11c9 <readline+0xa9>
movb   $0x0,(%r14,%rcx,1)
jmp    11c4 <readline+0xa4>
movb   $0x0,0x63(%r14)
mov    0x2e25(%rip),%rax
mov    (%rax),%edi
lea    0xe44(%rip),%rsi
mov    %r14,%rdx
call   1040 <fprintf@plt>
mov    $0x1,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@EOF = global i32 0
@stderr = global i32 0
@.str = [41 x i8] c"Le mot commen\C3\A7ant par %s est trop long\0A\00"
define i32 @readline(i32* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %4
store i8* %1, i8** %5
store i32 0, i32* %7
br label %8
8: ; preds = %41, %2
%9 = load i32*, i32** %4
%10 = call i32 @fgetc(i32* %9)
store i32 %10, i32* %6
%11 = load i32, i32* @EOF
%12 = icmp ne i32 %10, %11
br i1 %12, label %13, label %16
13: ; preds = %8
%14 = load i32, i32* %7
%15 = icmp slt i32 %14, 100
br label %16
16: ; preds = %13, %8
%17 = phi i1 [ false, %8 ], [ %15, %13 ]
br i1 %17, label %18, label %44
18: ; preds = %16
%19 = load i32, i32* %6
%20 = icmp eq i32 %19, 10
br i1 %20, label %21, label %26
21: ; preds = %18
%22 = load i8*, i8** %5
%23 = load i32, i32* %7
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
store i8 0, i8* %25
store i32 1, i32* %3
br label %58
26: ; preds = %18
%27 = load i32, i32* %6
%28 = icmp eq i32 %27, 13
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = load i32, i32* %7
%31 = add nsw i32 %30, -1
store i32 %31, i32* %7
br label %39
32: ; preds = %26
%33 = load i32, i32* %6
%34 = trunc i32 %33 to i8
%35 = load i8*, i8** %5
%36 = load i32, i32* %7
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
store i8 %34, i8* %38
br label %39
39: ; preds = %32, %29
br label %40
40: ; preds = %39
br label %41
41: ; preds = %40
%42 = load i32, i32* %7
%43 = add nsw i32 %42, 1
store i32 %43, i32* %7
br label %8
44: ; preds = %16
%45 = load i32, i32* %7
%46 = icmp slt i32 %45, 100
br i1 %46, label %47, label %52
47: ; preds = %44
%48 = load i8*, i8** %5
%49 = load i32, i32* %7
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %48, i64 %50
store i8 0, i8* %51
store i32 0, i32* %3
br label %58
52: ; preds = %44
%53 = load i8*, i8** %5
%54 = getelementptr inbounds i8, i8* %53, i64 99
store i8 0, i8* %54
%55 = load i32, i32* @stderr
%56 = load i8*, i8** %5
%57 = call i32 @fprintf(i32 %55, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i8* %56)
store i32 1, i32* %3
br label %58
58: ; preds = %52, %47, %21
%59 = load i32, i32* %3
ret i32 %59
}

LLVM IR (-O2):
@EOF = global i32 0
@stderr = global i32 0
@.str = [41 x i8] c"Le mot commen\C3\A7ant par %s est trop long\0A\00"
define i32 @readline(i32* nocapture %0, i8* %1) {
%3 = tail call i32 @fgetc(i32* %0)
%4 = load i32, i32* @EOF
%5 = icmp eq i32 %3, %4
br i1 %5, label %28, label %6
6: ; preds = %2, %18
%7 = phi i32 [ %21, %18 ], [ %3, %2 ]
%8 = phi i32 [ %20, %18 ], [ 0, %2 ]
switch i32 %7, label %14 [
i32 10, label %9
i32 13, label %12
]
9: ; preds = %6
%10 = sext i32 %8 to i64
%11 = getelementptr inbounds i8, i8* %1, i64 %10
store i8 0, i8* %11
br label %35
12: ; preds = %6
%13 = add nsw i32 %8, -1
br label %18
14: ; preds = %6
%15 = trunc i32 %7 to i8
%16 = sext i32 %8 to i64
%17 = getelementptr inbounds i8, i8* %1, i64 %16
store i8 %15, i8* %17
br label %18
18: ; preds = %14, %12
%19 = phi i32 [ %13, %12 ], [ %8, %14 ]
%20 = add nsw i32 %19, 1
%21 = tail call i32 @fgetc(i32* %0)
%22 = load i32, i32* @EOF
%23 = icmp ne i32 %21, %22
%24 = icmp slt i32 %19, 99
%25 = select i1 %23, i1 %24, i1 false
br i1 %25, label %6, label %26
26: ; preds = %18
%27 = sext i32 %20 to i64
br i1 %24, label %28, label %31
28: ; preds = %2, %26
%29 = phi i64 [ %27, %26 ], [ 0, %2 ]
%30 = getelementptr inbounds i8, i8* %1, i64 %29
store i8 0, i8* %30
br label %35
31: ; preds = %26
%32 = getelementptr inbounds i8, i8* %1, i64 99
store i8 0, i8* %32
%33 = load i32, i32* @stderr
%34 = tail call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i8* %1)
br label %35
35: ; preds = %31, %28, %9
%36 = phi i32 [ 1, %9 ], [ 0, %28 ], [ 1, %31 ]
ret i32 %36
}