#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 */
scalar_t__ fgets(char *, int const, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ reverse(char *);
int /*<<< orphan*/ stdin;
int main(void) {
  const int maxlen = 80;
  char s[maxlen];
  printf("\n_____REVLINE_____\n\n");
  while (fgets(s, maxlen, stdin)) {
    reverse(s);
    printf("%s\n\n", s);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x50,-0x8(%rbp)
mov    %rsp,%rax
mov    %rax,-0x10(%rbp)
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2e86(%rip),%rax
mov    (%rax),%edx
lea    -0x60(%rbp),%rdi
mov    $0x50,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     119c <main+0x6c>
lea    -0x60(%rbp),%rdi
call   1030 <reverse@plt>
lea    0xe89(%rip),%rdi
lea    -0x60(%rbp),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    115b <main+0x2b>
movl   $0x0,-0x4(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x50,%rsp
lea    0xeb5(%rip),%rdi
call   1040 <puts@plt>
mov    0x2e8c(%rip),%r15
mov    (%r15),%edx
mov    %rsp,%rdi
mov    $0x50,%esi
call   1060 <fgets@plt>
test   %rax,%rax
je     11aa <main+0x6a>
mov    %rsp,%rbx
lea    0xe85(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <reverse@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%r15),%edx
mov    %rbx,%rdi
mov    $0x50,%esi
call   1060 <fgets@plt>
test   %rax,%rax
jne    1180 <main+0x40>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@stdin = global i32 0
@.str.1 = [5 x i8] c"%s\0A\0A\00"
@str = [20 x i8] c"\0A_____REVLINE_____\0A\00"
define i32 @main() {
%1 = alloca [80 x i8]
%2 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%4 = load i32, i32* @stdin
%5 = call i64 @fgets(i8* %2, i32 80, i32 %4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %13, label %7
7: ; preds = %0, %7
%8 = call i32 @reverse(i8* %2)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%10 = load i32, i32* @stdin
%11 = call i64 @fgets(i8* %2, i32 80, i32 %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %7
13: ; preds = %7, %0
ret i32 0
}