#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ free(char *);
char *getln(int /*<<< orphan*/ *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ strrev(char *);
int rev(FILE *in) {
  char *line = NULL;
  if (!in)
    return -1;
  while ((line = getln(in))) {
    strrev(line);
    puts(line);
    free(line);
  }
  free(line);
  return 0;
}


x86 assembly (clang, -O0):
<rev>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    116b <rev+0x2b>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b7 <rev+0x77>
jmp    1170 <rev+0x30>
mov    -0x10(%rbp),%rdi
call   1050 <getln@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11a7 <rev+0x67>
mov    -0x18(%rbp),%rdi
call   1060 <strrev@plt>
mov    -0x18(%rbp),%rdi
call   1040 <puts@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
jmp    1170 <rev+0x30>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rev>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     1193 <rev+0x53>
mov    %rdi,%r14
call   1050 <getln@plt>
test   %rax,%rax
je     1188 <rev+0x48>
mov    %rax,%rbx
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1060 <strrev@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1050 <getln@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1160 <rev+0x20>
xor    %ebx,%ebx
xor    %edi,%edi
call   1030 <free@plt>
jmp    1198 <rev+0x58>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @rev(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i8*
store i32* %0, i32** %3
store i8* null, i8** %4
%5 = load i32*, i32** %3
%6 = icmp ne i32* %5, null
br i1 %6, label %8, label %7
7: ; preds = %1
store i32 -1, i32* %2
br label %23
8: ; preds = %1
br label %9
9: ; preds = %13, %8
%10 = load i32*, i32** %3
%11 = call i8* @getln(i32* %10)
store i8* %11, i8** %4
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %20
13: ; preds = %9
%14 = load i8*, i8** %4
%15 = call i32 @strrev(i8* %14)
%16 = load i8*, i8** %4
%17 = call i32 @puts(i8* %16)
%18 = load i8*, i8** %4
%19 = call i32 @free(i8* %18)
br label %9
20: ; preds = %9
%21 = load i8*, i8** %4
%22 = call i32 @free(i8* %21)
store i32 0, i32* %2
br label %23
23: ; preds = %20, %7
%24 = load i32, i32* %2
ret i32 %24
}

LLVM IR (-O2):
define i32 @rev(i32* %0) {
%2 = icmp eq i32* %0, null
br i1 %2, label %15, label %3
3: ; preds = %1
%4 = tail call i8* @getln(i32* %0)
%5 = icmp eq i8* %4, null
br i1 %5, label %13, label %6
6: ; preds = %3, %6
%7 = phi i8* [ %11, %6 ], [ %4, %3 ]
%8 = tail call i32 @strrev(i8* %7)
%9 = tail call i32 @puts(i8* %7)
%10 = tail call i32 @free(i8* %7)
%11 = tail call i8* @getln(i32* %0)
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %6
13: ; preds = %6, %3
%14 = tail call i32 @free(i8* null)
br label %15
15: ; preds = %1, %13
%16 = phi i32 [ 0, %13 ], [ -1, %1 ]
ret i32 %16
}