#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 mygetline(char *, int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ reverse(char *);
int /*<<< orphan*/ trim(char *);
int main(int argc, char *argv[]) {
  int len;
  char line[1000];
  while ((len = mygetline(line, 1000)) > 0) {
    trim(line);
    reverse(line);
    printf("%s\n", line);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x400(%rbp),%rdi
mov    $0x3e8,%esi
call   1060 <mygetline@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jle    11a6 <main+0x66>
lea    -0x400(%rbp),%rdi
call   1050 <trim@plt>
lea    -0x400(%rbp),%rdi
call   1030 <reverse@plt>
lea    -0x400(%rbp),%rsi
lea    0xe64(%rip),%rdi
call   1040 <printf@plt>
jmp    1159 <main+0x19>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x3e8,%rsp
mov    %rsp,%rdi
mov    $0x3e8,%esi
call   1060 <mygetline@plt>
test   %eax,%eax
jle    119c <main+0x5c>
mov    %rsp,%rbx
lea    0xe9b(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
call   1050 <trim@plt>
mov    %rbx,%rdi
call   1030 <reverse@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x3e8,%esi
call   1060 <mygetline@plt>
test   %eax,%eax
jg     1170 <main+0x30>
xor    %eax,%eax
add    $0x3e8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [1000 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %8
8: ; preds = %12, %2
%9 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%10 = call i32 @mygetline(i8* %9, i32 1000)
store i32 %10, i32* %6
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %19
12: ; preds = %8
%13 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%14 = call i32 @trim(i8* %13)
%15 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%16 = call i32 @reverse(i8* %15)
%17 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%18 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %17)
br label %8
19: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1000 x i8]
%4 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%5 = call i32 @mygetline(i8* %4, i32 1000)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %13
7: ; preds = %2, %7
%8 = call i32 @trim(i8* %4)
%9 = call i32 @reverse(i8* %4)
%10 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %4)
%11 = call i32 @mygetline(i8* %4, i32 1000)
%12 = icmp sgt i32 %11, 0
br i1 %12, label %7, label %13
13: ; preds = %7, %2
ret i32 0
}