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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
mov    0x2e83(%rip),%rax
mov    (%rax),%edx
lea    -0x20(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1060 <getline@plt>
cmp    $0xffffffff,%eax
jle    119b <main+0x5b>
mov    -0x20(%rbp),%rdi
call   1030 <reverse@plt>
mov    -0x20(%rbp),%rsi
lea    0xe6f(%rip),%rdi
call   1050 <printf@plt>
jmp    115e <main+0x1e>
mov    -0x20(%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    0x10(%rsp),%rsi
call   1060 <getline@plt>
test   %eax,%eax
js     11ba <main+0x7a>
lea    0xe87(%rip),%r14
lea    0x8(%rsp),%r15
lea    0x10(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
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>
test   %eax,%eax
jns    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(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %7
br label %8
8: ; preds = %12, %2
%9 = load i32, i32* @stdin
%10 = call i32 @getline(i8** %7, i64* %6, i32 %9)
%11 = icmp sgt i32 %10, -1
br i1 %11, label %12, label %17
12: ; preds = %8
%13 = load i8*, i8** %7
%14 = call i32 @reverse(i8* %13)
%15 = load i8*, i8** %7
%16 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %15)
br label %8
17: ; preds = %8
%18 = load i8*, i8** %7
%19 = call i32 @free(i8* %18)
ret i32 0
}

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