#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*/ free(char *);
int getline(char **, int *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ reverse(char *);
int /*<<< orphan*/ stdin;
int main() {
  char *str = NULL;
  int len;
  while (getline(&str, &len, stdin) != -1) {
    reverse(str);
    printf("%s", str);
  }
  free(str);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
mov    0x2e8a(%rip),%rax
mov    (%rax),%edx
lea    -0x10(%rbp),%rdi
lea    -0x14(%rbp),%rsi
call   1060 <getline@plt>
cmp    $0xffffffff,%eax
je     1194 <main+0x54>
mov    -0x10(%rbp),%rdi
call   1030 <reverse@plt>
mov    -0x10(%rbp),%rsi
lea    0xe76(%rip),%rdi
call   1050 <printf@plt>
jmp    1157 <main+0x17>
mov    -0x10(%rbp),%rdi
call   1040 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
movq   $0x0,0x8(%rsp)
mov    0x2e8d(%rip),%r12
mov    (%r12),%edx
lea    0x8(%rsp),%rdi
lea    0x14(%rsp),%rsi
call   1060 <getline@plt>
cmp    $0xffffffff,%eax
je     11bb <main+0x7b>
lea    0xe86(%rip),%r14
lea    0x8(%rsp),%r15
lea    0x14(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x8(%rsp),%rdi
call   1030 <reverse@plt>
mov    0x8(%rsp),%rsi
mov    %r14,%rdi
call   1050 <printf@plt>
mov    (%r12),%edx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <getline@plt>
cmp    $0xffffffff,%eax
jne    1190 <main+0x50>
mov    0x8(%rsp),%rdi
call   1040 <free@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
store i32 0, i32* %1
store i8* null, i8** %2
br label %4
4: ; preds = %8, %0
%5 = load i32, i32* @stdin
%6 = call i32 @getline(i8** %2, i32* %3, i32 %5)
%7 = icmp ne i32 %6, -1
br i1 %7, label %8, label %13
8: ; preds = %4
%9 = load i8*, i8** %2
%10 = call i32 @reverse(i8* %9)
%11 = load i8*, i8** %2
%12 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %11)
br label %4
13: ; preds = %4
%14 = load i8*, i8** %2
%15 = call i32 @free(i8* %14)
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i8*
%2 = alloca i32
%3 = bitcast i8** %1 to i8*
store i8* null, i8** %1
%4 = bitcast i32* %2 to i8*
%5 = load i32, i32* @stdin
%6 = call i32 @getline(i8** %1, i32* %2, i32 %5)
%7 = icmp eq i32 %6, -1
br i1 %7, label %16, label %8
8: ; preds = %0, %8
%9 = load i8*, i8** %1
%10 = call i32 @reverse(i8* %9)
%11 = load i8*, i8** %1
%12 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = load i32, i32* @stdin
%14 = call i32 @getline(i8** %1, i32* %2, i32 %13)
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %8
16: ; preds = %8, %0
%17 = load i8*, i8** %1
%18 = call i32 @free(i8* %17)
ret i32 0
}