#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 /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int strlen(char *);
void readLine(FILE *input, char *lineFromFile, int maxSize) {
  int stripPointer;
  fgets(lineFromFile, maxSize, input);
  stripPointer = strlen(lineFromFile) - 1;
  while (stripPointer >= 0 && ((lineFromFile[stripPointer] == '\r') ||
                               (lineFromFile[stripPointer] == '\n') ||
                               (lineFromFile[stripPointer] == ' '))) {
    lineFromFile[stripPointer] = 0;
    stripPointer--;
  }
}


x86 assembly (clang, -O0):
<readLine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x8(%rbp),%rdx
call   1040 <fgets@plt>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x18(%rbp)
mov    %al,-0x19(%rbp)
jl     11b0 <readLine+0x90>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
mov    $0x1,%al
cmp    $0xd,%ecx
mov    %al,-0x1a(%rbp)
je     11aa <readLine+0x8a>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
mov    $0x1,%al
cmp    $0xa,%ecx
mov    %al,-0x1a(%rbp)
je     11aa <readLine+0x8a>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
sete   %al
mov    %al,-0x1a(%rbp)
mov    -0x1a(%rbp),%al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    11c0 <readLine+0xa0>
jmp    11da <readLine+0xba>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    1152 <readLine+0x32>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readLine>:
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%rax
mov    %rsi,%rdi
mov    %edx,%esi
mov    %rax,%rdx
call   1040 <fgets@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    1171 <readLine+0x51>
mov    %eax,%eax
add    $0x1,%rax
movabs $0x100002400,%rcx
lea    -0x2(%rax),%edx
movzbl (%rbx,%rdx,1),%esi
cmp    $0x20,%rsi
ja     1171 <readLine+0x51>
bt     %rsi,%rcx
jae    1171 <readLine+0x51>
movb   $0x0,(%rbx,%rdx,1)
add    $0xffffffffffffffff,%rax
cmp    $0x1,%rax
ja     1150 <readLine+0x30>
pop    %rbx
ret

LLVM IR (-O0):
define void @readLine(i32* %0, i8* %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%8 = load i8*, i8** %5
%9 = load i32, i32* %6
%10 = load i32*, i32** %4
%11 = call i32 @fgets(i8* %8, i32 %9, i32* %10)
%12 = load i8*, i8** %5
%13 = call i32 @strlen(i8* %12)
%14 = sub nsw i32 %13, 1
store i32 %14, i32* %7
br label %15
15: ; preds = %46, %3
%16 = load i32, i32* %7
%17 = icmp sge i32 %16, 0
br i1 %17, label %18, label %44
18: ; preds = %15
%19 = load i8*, i8** %5
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 13
br i1 %25, label %42, label %26
26: ; preds = %18
%27 = load i8*, i8** %5
%28 = load i32, i32* %7
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 10
br i1 %33, label %42, label %34
34: ; preds = %26
%35 = load i8*, i8** %5
%36 = load i32, i32* %7
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %40, 32
br label %42
42: ; preds = %34, %26, %18
%43 = phi i1 [ true, %26 ], [ true, %18 ], [ %41, %34 ]
br label %44
44: ; preds = %42, %15
%45 = phi i1 [ false, %15 ], [ %43, %42 ]
br i1 %45, label %46, label %53
46: ; preds = %44
%47 = load i8*, i8** %5
%48 = load i32, i32* %7
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8, i8* %47, i64 %49
store i8 0, i8* %50
%51 = load i32, i32* %7
%52 = add nsw i32 %51, -1
store i32 %52, i32* %7
br label %15
53: ; preds = %44
ret void
}

LLVM IR (-O2):
define void @readLine(i32* nocapture %0, i8* %1, i32 %2) {
%4 = tail call i32 @fgets(i8* %1, i32 %2, i32* %0)
%5 = tail call i32 @strlen(i8* %1)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %17
7: ; preds = %3
%8 = zext i32 %5 to i64
br label %9
9: ; preds = %7, %15
%10 = phi i64 [ %8, %7 ], [ %11, %15 ]
%11 = add nsw i64 %10, -1
%12 = and i64 %11, 4294967295
%13 = getelementptr inbounds i8, i8* %1, i64 %12
%14 = load i8, i8* %13
switch i8 %14, label %17 [
i8 13, label %15
i8 10, label %15
i8 32, label %15
]
15: ; preds = %9, %9, %9
store i8 0, i8* %13
%16 = icmp ugt i64 %10, 1
br i1 %16, label %9, label %17
17: ; preds = %15, %9, %3
ret void
}