#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 /*<<< orphan*/ RVExtension(char *, int, char *);
int /*<<< orphan*/ free(char *);
int getline(char **, size_t *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
size_t strlen(char *);
int main(void) {
  while (true) {
    char *function = NULL;
    size_t length = 0;
    printf("Enter function name: ");
    if (getline(&function, &length, stdin) == -1)
      return 0;
    for (size_t i = 0; i < length; i++)
      if (function[i] == '\n')
        function[i] = 0;
    length = strlen(function);
    if (length > 0) {
      char output[20000] = {0};
      RVExtension(output, 20000, function);
      printf("%s\n", output);
    }
    free(function);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4e40,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2e51(%rip),%rax
mov    (%rax),%edx
lea    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1080 <getline@plt>
cmp    $0xffffffff,%eax
jne    11ba <main+0x5a>
xor    %eax,%eax
add    $0x4e40,%rsp
pop    %rbp
ret
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1207 <main+0xa7>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    11f1 <main+0x91>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    11f6 <main+0x96>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    11c2 <main+0x62>
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jbe    125c <main+0xfc>
lea    -0x4e40(%rbp),%rdi
xor    %esi,%esi
mov    $0x4e20,%edx
call   1070 <memset@plt>
lea    -0x4e40(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x4e20,%esi
call   1040 <RVExtension@plt>
lea    -0x4e40(%rbp),%rsi
lea    0xdc1(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
jmp    1172 <main+0x12>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x4e38,%rsp
movq   $0x0,0x8(%rsp)
movq   $0x0,(%rsp)
lea    0xe67(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x2e41(%rip),%rbp
mov    0x0(%rbp),%edx
lea    0x8(%rsp),%rdi
mov    %rsp,%rsi
call   1090 <getline@plt>
cmp    $0xffffffff,%eax
je     129b <main+0x12b>
lea    0xe39(%rip),%r14
lea    0x8(%rsp),%r15
mov    %rsp,%r12
lea    0x10(%rsp),%r13
jmp    121a <main+0xaa>
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <free@plt>
movq   $0x0,0x8(%rsp)
movq   $0x0,(%rsp)
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x0(%rbp),%edx
mov    %r15,%rdi
mov    %r12,%rsi
call   1090 <getline@plt>
cmp    $0xffffffff,%eax
je     129b <main+0x12b>
mov    (%rsp),%rax
test   %rax,%rax
je     1250 <main+0xe0>
xor    %ecx,%ecx
jmp    1239 <main+0xc9>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rcx
cmp    %rax,%rcx
jae    1250 <main+0xe0>
mov    0x8(%rsp),%rdx
cmpb   $0xa,(%rdx,%rcx,1)
jne    1230 <main+0xc0>
movb   $0x0,(%rdx,%rcx,1)
mov    (%rsp),%rax
jmp    1230 <main+0xc0>
xchg   %ax,%ax
mov    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %rax,(%rsp)
test   %rax,%rax
je     11e0 <main+0x70>
mov    $0x4e20,%edx
mov    %r13,%rdi
xor    %esi,%esi
call   1080 <memset@plt>
mov    %r13,%rdi
mov    $0x4e20,%esi
mov    %rbx,%rdx
call   1050 <RVExtension@plt>
mov    %r13,%rdi
call   1040 <puts@plt>
mov    0x8(%rsp),%rbx
jmp    11e0 <main+0x70>
xor    %eax,%eax
add    $0x4e38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Enter function name: \00"
@stdin = global i32 0
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i64
%5 = alloca [20000 x i8]
store i32 0, i32* %1
br label %6
6: ; preds = %0, %44
store i8* null, i8** %2
store i64 0, i64* %3
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* @stdin
%9 = call i32 @getline(i8** %2, i64* %3, i32 %8)
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %12
11: ; preds = %6
ret i32 0
12: ; preds = %6
store i64 0, i64* %4
br label %13
13: ; preds = %29, %12
%14 = load i64, i64* %4
%15 = load i64, i64* %3
%16 = icmp ult i64 %14, %15
br i1 %16, label %17, label %32
17: ; preds = %13
%18 = load i8*, i8** %2
%19 = load i64, i64* %4
%20 = getelementptr inbounds i8, i8* %18, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 10
br i1 %23, label %24, label %28
24: ; preds = %17
%25 = load i8*, i8** %2
%26 = load i64, i64* %4
%27 = getelementptr inbounds i8, i8* %25, i64 %26
store i8 0, i8* %27
br label %28
28: ; preds = %24, %17
br label %29
29: ; preds = %28
%30 = load i64, i64* %4
%31 = add i64 %30, 1
store i64 %31, i64* %4
br label %13
32: ; preds = %13
%33 = load i8*, i8** %2
%34 = call i64 @strlen(i8* %33)
store i64 %34, i64* %3
%35 = load i64, i64* %3
%36 = icmp ugt i64 %35, 0
br i1 %36, label %37, label %44
37: ; preds = %32
%38 = bitcast [20000 x i8]* %5 to i8*
%39 = getelementptr inbounds [20000 x i8], [20000 x i8]* %5, i64 0, i64 0
%40 = load i8*, i8** %2
%41 = call i32 @RVExtension(i8* %39, i32 20000, i8* %40)
%42 = getelementptr inbounds [20000 x i8], [20000 x i8]* %5, i64 0, i64 0
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %42)
br label %44
44: ; preds = %37, %32
%45 = load i8*, i8** %2
%46 = call i32 @free(i8* %45)
br label %6
}

LLVM IR (-O2):
@.str = [22 x i8] c"Enter function name: \00"
@stdin = global i32 0
define i32 @main() {
%1 = alloca i8*
%2 = alloca i64
%3 = alloca [20000 x i8]
%4 = bitcast i8** %1 to i8*
%5 = bitcast i64* %2 to i8*
%6 = getelementptr inbounds [20000 x i8], [20000 x i8]* %3, i64 0, i64 0
store i8* null, i8** %1
store i64 0, i64* %2
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* @stdin
%9 = call i32 @getline(i8** %1, i64* %2, i32 %8)
%10 = icmp eq i32 %9, -1
br i1 %10, label %42, label %11
11: ; preds = %0, %35
%12 = load i64, i64* %2
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %27, %11
%15 = load i8*, i8** %1
%16 = call i64 @strlen(i8* dereferenceable(1) %15)
store i64 %16, i64* %2
%17 = icmp eq i64 %16, 0
br i1 %17, label %35, label %31
18: ; preds = %11, %27
%19 = phi i64 [ %28, %27 ], [ %12, %11 ]
%20 = phi i64 [ %29, %27 ], [ 0, %11 ]
%21 = load i8*, i8** %1
%22 = getelementptr inbounds i8, i8* %21, i64 %20
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 10
br i1 %24, label %25, label %27
25: ; preds = %18
store i8 0, i8* %22
%26 = load i64, i64* %2
br label %27
27: ; preds = %18, %25
%28 = phi i64 [ %19, %18 ], [ %26, %25 ]
%29 = add nuw i64 %20, 1
%30 = icmp ult i64 %29, %28
br i1 %30, label %18, label %14
31: ; preds = %14
%32 = call i32 @RVExtension(i8* %6, i32 20000, i8* %15)
%33 = call i32 @puts(i8* %6)
%34 = load i8*, i8** %1
br label %35
35: ; preds = %14, %31
%36 = phi i8* [ %15, %14 ], [ %34, %31 ]
%37 = call i32 @free(i8* %36)
store i8* null, i8** %1
store i64 0, i64* %2
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%39 = load i32, i32* @stdin
%40 = call i32 @getline(i8** %1, i64* %2, i32 %39)
%41 = icmp eq i32 %40, -1
br i1 %41, label %42, label %11
42: ; preds = %35, %0
ret i32 0
}