#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 getline(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ reverse(char *, int);
int main(void) {
  char line[1000];
  int len;
  int count;
  count = 1;
  printf("%d) ", count);
  while ((len = getline(line, 1000)) > 0) {
    if (len > 1) {
      reverse(line, len);
      printf("-\n%s-\n", line);
    }
    printf("%d) ", ++count);
  }
  printf("\nDone!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x3f8(%rbp)
mov    -0x3f8(%rbp),%esi
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x3f0(%rbp),%rdi
mov    $0x3e8,%esi
call   1050 <getline@plt>
mov    %eax,-0x3f4(%rbp)
cmp    $0x0,%eax
jle    11d6 <main+0xa6>
cmpl   $0x1,-0x3f4(%rbp)
jle    11b4 <main+0x84>
lea    -0x3f0(%rbp),%rdi
mov    -0x3f4(%rbp),%esi
call   1030 <reverse@plt>
lea    -0x3f0(%rbp),%rsi
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x3f8(%rbp),%esi
add    $0x1,%esi
mov    %esi,-0x3f8(%rbp)
lea    0xe36(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1160 <main+0x30>
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x3e8,%rsp
lea    0xeab(%rip),%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rsp,%rdi
mov    $0x3e8,%esi
call   1060 <getline@plt>
test   %eax,%eax
jle    11ce <main+0x8e>
mov    $0x2,%ebx
lea    0xe82(%rip),%r14
mov    %rsp,%r15
lea    0xe7d(%rip),%r12
jmp    11b0 <main+0x70>
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
mov    $0x3e8,%esi
call   1060 <getline@plt>
add    $0x1,%ebx
test   %eax,%eax
jle    11ce <main+0x8e>
cmp    $0x1,%eax
je     1190 <main+0x50>
mov    %r15,%rdi
mov    %eax,%esi
call   1030 <reverse@plt>
mov    %r12,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1190 <main+0x50>
lea    0xe37(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x3e8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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