#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 EOF;
int getchar();
int strlen(char *);
void clearInputStream(char *in) {
  int c, len;
  len = strlen(in);
  if (in[len - 1] != '\n')
    while ((c = getchar()) != '\n' && c != EOF)
      ;
}


x86 assembly (clang, -O0):
<clearInputStream>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
je     119d <clearInputStream+0x7d>
jmp    1157 <clearInputStream+0x37>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,%ecx
mov    %ecx,-0xc(%rbp)
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x11(%rbp)
je     1183 <clearInputStream+0x63>
mov    -0xc(%rbp),%eax
mov    0x2e6d(%rip),%rcx
cmp    (%rcx),%eax
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1193 <clearInputStream+0x73>
jmp    1198 <clearInputStream+0x78>
jmp    1157 <clearInputStream+0x37>
jmp    119d <clearInputStream+0x7d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clearInputStream>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%rbx,1)
je     1150 <clearInputStream+0x30>
mov    0x2eaf(%rip),%rbx
nopl   0x0(%rax)
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%eax
je     1150 <clearInputStream+0x30>
cmp    (%rbx),%eax
jne    1140 <clearInputStream+0x20>
pop    %rbx
ret

LLVM IR (-O0):
@EOF = global i32 0
define void @clearInputStream(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i32 @strlen(i8* %5)
store i32 %6, i32* %4
%7 = load i8*, i8** %2
%8 = load i32, i32* %4
%9 = sub nsw i32 %8, 1
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %7, i64 %10
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 10
br i1 %14, label %15, label %27
15: ; preds = %1
br label %16
16: ; preds = %25, %15
%17 = call i32 (...) @getchar()
store i32 %17, i32* %3
%18 = icmp ne i32 %17, 10
br i1 %18, label %19, label %23
19: ; preds = %16
%20 = load i32, i32* %3
%21 = load i32, i32* @EOF
%22 = icmp ne i32 %20, %21
br label %23
23: ; preds = %19, %16
%24 = phi i1 [ false, %16 ], [ %22, %19 ]
br i1 %24, label %25, label %26
25: ; preds = %23
br label %16
26: ; preds = %23
br label %27
27: ; preds = %26, %1
ret void
}

LLVM IR (-O2):
@EOF = global i32 0
define void @clearInputStream(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = add nsw i32 %2, -1
%4 = sext i32 %3 to i64
%5 = getelementptr inbounds i8, i8* %0, i64 %4
%6 = load i8, i8* %5
%7 = icmp eq i8 %6, 10
br i1 %7, label %14, label %8
8: ; preds = %1, %8
%9 = tail call i32 (...) @getchar()
%10 = icmp ne i32 %9, 10
%11 = load i32, i32* @EOF
%12 = icmp ne i32 %9, %11
%13 = select i1 %10, i1 %12, i1 false
br i1 %13, label %8, label %14
14: ; preds = %8, %1
ret void
}