#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 getcharline(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ reverse(char *, int, char *);
int main() {
  for (int i = 0; i < 300; i++) {
    char line[1000];
    int len = getcharline(line);
    if (len < 1)
      break;
    char reversed[1000];
    reverse(line, len, reversed);
    printf("%s", reversed);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x7e0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x12c,-0x8(%rbp)
jge    11b4 <main+0x84>
lea    -0x3f0(%rbp),%rdi
call   1050 <getcharline@plt>
mov    %eax,-0x3f4(%rbp)
cmpl   $0x1,-0x3f4(%rbp)
jge    117a <main+0x4a>
jmp    11b4 <main+0x84>
lea    -0x3f0(%rbp),%rdi
mov    -0x3f4(%rbp),%esi
lea    -0x7e0(%rbp),%rdx
call   1030 <reverse@plt>
lea    -0x7e0(%rbp),%rsi
lea    0xe5f(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1149 <main+0x19>
mov    -0x4(%rbp),%eax
add    $0x7e0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x7d8,%rsp
mov    $0x12c,%ebp
lea    0x3f0(%rsp),%r14
mov    %rsp,%rbx
lea    0xeac(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
call   1050 <getcharline@plt>
test   %eax,%eax
jle    1189 <main+0x59>
mov    %r14,%rdi
mov    %eax,%esi
mov    %rbx,%rdx
call   1030 <reverse@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
add    $0xffffffff,%ebp
jne    1160 <main+0x30>
xor    %eax,%eax
add    $0x7d8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [1000 x i8]
%4 = alloca i32
%5 = alloca [1000 x i8]
store i32 0, i32* %1
store i32 0, i32* %2
br label %6
6: ; preds = %22, %0
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 300
br i1 %8, label %9, label %25
9: ; preds = %6
%10 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%11 = call i32 @getcharline(i8* %10)
store i32 %11, i32* %4
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 1
br i1 %13, label %14, label %15
14: ; preds = %9
br label %25
15: ; preds = %9
%16 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%17 = load i32, i32* %4
%18 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%19 = call i32 @reverse(i8* %16, i32 %17, i8* %18)
%20 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%21 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %20)
br label %22
22: ; preds = %15
%23 = load i32, i32* %2
%24 = add nsw i32 %23, 1
store i32 %24, i32* %2
br label %6
25: ; preds = %14, %6
%26 = load i32, i32* %1
ret i32 %26
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [1000 x i8]
%2 = alloca [1000 x i8]
%3 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
br label %5
5: ; preds = %0, %9
%6 = phi i32 [ 0, %0 ], [ %12, %9 ]
%7 = call i32 @getcharline(i8* %3)
%8 = icmp slt i32 %7, 1
br i1 %8, label %14, label %9
9: ; preds = %5
%10 = call i32 @reverse(i8* %3, i32 %7, i8* %4)
%11 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %4)
%12 = add nuw nsw i32 %6, 1
%13 = icmp eq i32 %12, 300
br i1 %13, label %15, label %5
14: ; preds = %5
br label %15
15: ; preds = %9, %14
ret i32 0
}