#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 *idris2_readLine(int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
char *idris2_getStr() {
  char *inp = idris2_readLine(stdin);
  for (char *c = inp; *c != '\0'; ++c) {
    if (*c == '\n' || *c == '\r') {
      *c = '\0';
    }
  }
  return inp;
}


x86 assembly (clang, -O0):
<idris2_getStr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2ec9(%rip),%rax
mov    (%rax),%edi
call   1030 <idris2_readLine@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     117f <idris2_getStr+0x6f>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
je     1162 <idris2_getStr+0x52>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xd,%eax
jne    1169 <idris2_getStr+0x59>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
jmp    116e <idris2_getStr+0x5e>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1132 <idris2_getStr+0x22>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<idris2_getStr>:
push   %rax
mov    0x2ed0(%rip),%rax
mov    (%rax),%edi
call   1030 <idris2_readLine@plt>
mov    %rax,%rcx
jmp    1137 <idris2_getStr+0x27>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movb   $0x0,(%rcx)
add    $0x1,%rcx
movzbl (%rcx),%edx
cmp    $0xa,%dl
je     1130 <idris2_getStr+0x20>
cmp    $0xd,%dl
je     1130 <idris2_getStr+0x20>
test   %dl,%dl
jne    1133 <idris2_getStr+0x23>
pop    %rcx
ret

LLVM IR (-O0):
@stdin = global i32 0
define i8* @idris2_getStr() {
%1 = alloca i8*
%2 = alloca i8*
%3 = load i32, i32* @stdin
%4 = call i8* @idris2_readLine(i32 %3)
store i8* %4, i8** %1
%5 = load i8*, i8** %1
store i8* %5, i8** %2
br label %6
6: ; preds = %24, %0
%7 = load i8*, i8** %2
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %27
11: ; preds = %6
%12 = load i8*, i8** %2
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 10
br i1 %15, label %21, label %16
16: ; preds = %11
%17 = load i8*, i8** %2
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 13
br i1 %20, label %21, label %23
21: ; preds = %16, %11
%22 = load i8*, i8** %2
store i8 0, i8* %22
br label %23
23: ; preds = %21, %16
br label %24
24: ; preds = %23
%25 = load i8*, i8** %2
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %2
br label %6
27: ; preds = %6
%28 = load i8*, i8** %1
ret i8* %28
}

LLVM IR (-O2):
@stdin = global i32 0
define i8* @idris2_getStr() {
%1 = load i32, i32* @stdin
%2 = tail call i8* @idris2_readLine(i32 %1)
br label %3
3: ; preds = %8, %0
%4 = phi i8* [ %2, %0 ], [ %9, %8 ]
%5 = load i8, i8* %4
switch i8 %5, label %8 [
i8 0, label %6
i8 10, label %7
i8 13, label %7
]
6: ; preds = %3
ret i8* %2
7: ; preds = %3, %3
store i8 0, i8* %4
br label %8
8: ; preds = %3, %7
%9 = getelementptr inbounds i8, i8* %4, i64 1
br label %3
}