#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 /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int main(void) {
  char line[255];
  int i = 0;
  int j;
  printf("Please enter a line of text:\n");
  scanf("%c", &line[i]);
  while (line[i] != '\n' && ++i < 255)
    scanf("%c", &line[i]);
  for (--i; i >= 0; i--)
    printf("%c", line[i]);
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x114(%rbp)
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x114(%rbp),%rax
lea    -0x110(%rbp),%rsi
add    %rax,%rsi
lea    0xebc(%rip),%rdi
call   1040 <scanf@plt>
movslq -0x114(%rbp),%rax
movsbl -0x110(%rbp,%rax,1),%ecx
ff
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x119(%rbp)
je     11a4 <main+0x84>
mov    -0x114(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x114(%rbp)
cmp    $0xff,%eax
setl   %al
mov    %al,-0x119(%rbp)
mov    -0x119(%rbp),%al
test   $0x1,%al
jne    11b7 <main+0x97>
jmp    11d9 <main+0xb9>
movslq -0x114(%rbp),%rax
lea    -0x110(%rbp),%rsi
add    %rax,%rsi
lea    0xe4f(%rip),%rdi
call   1040 <scanf@plt>
jmp    1167 <main+0x47>
mov    -0x114(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x114(%rbp)
cmpl   $0x0,-0x114(%rbp)
jl     1226 <main+0x106>
movslq -0x114(%rbp),%rax
movsbl -0x110(%rbp,%rax,1),%esi
ff
lea    0xe13(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x114(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x114(%rbp)
jmp    11e8 <main+0xc8>
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x108,%rsp
lea    0xebe(%rip),%rdi
call   1040 <puts@plt>
lea    0xeaf(%rip),%rdi
mov    %rsp,%rsi
call   1050 <scanf@plt>
cmpb   $0xa,(%rsp)
je     11c4 <main+0x94>
lea    0x1(%rsp),%r15
xor    %r12d,%r12d
lea    0xe92(%rip),%r14
xchg   %ax,%ax
cmp    $0xfe,%r12
je     119b <main+0x6b>
lea    (%r15,%r12,1),%rsi
mov    %r14,%rdi
call   1050 <scanf@plt>
lea    0x1(%r12),%rbx
cmpb   $0xa,0x1(%rsp,%r12,1)
mov    %rbx,%r12
jne    1170 <main+0x40>
test   %ebx,%ebx
jg     11a0 <main+0x70>
jmp    11c4 <main+0x94>
mov    $0xff,%ebx
add    $0x1,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl -0x2(%rsp,%rbx,1),%edi
call   1030 <putchar@plt>
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
ja     11b0 <main+0x80>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [30 x i8] c"Please enter a line of text:\0A\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [255 x i8]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* %3
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 %7
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %8)
br label %10
10: ; preds = %23, %0
%11 = load i32, i32* %3
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 10
br i1 %16, label %17, label %21
17: ; preds = %10
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 1
store i32 %19, i32* %3
%20 = icmp slt i32 %19, 255
br label %21
21: ; preds = %17, %10
%22 = phi i1 [ false, %10 ], [ %20, %17 ]
br i1 %22, label %23, label %28
23: ; preds = %21
%24 = load i32, i32* %3
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 %25
%27 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %26)
br label %10
28: ; preds = %21
%29 = load i32, i32* %3
%30 = add nsw i32 %29, -1
store i32 %30, i32* %3
br label %31
31: ; preds = %41, %28
%32 = load i32, i32* %3
%33 = icmp sge i32 %32, 0
br i1 %33, label %34, label %44
34: ; preds = %31
%35 = load i32, i32* %3
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 %36
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %39)
br label %41
41: ; preds = %34
%42 = load i32, i32* %3
%43 = add nsw i32 %42, -1
store i32 %43, i32* %3
br label %31
44: ; preds = %31
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%c\00"
@str = [29 x i8] c"Please enter a line of text:\00"
define i32 @main() {
%1 = alloca [255 x i8]
%2 = getelementptr inbounds [255 x i8], [255 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%5 = load i8, i8* %2
%6 = icmp eq i8 %5, 10
br i1 %6, label %30, label %7
7: ; preds = %0, %11
%8 = phi i64 [ %9, %11 ], [ 0, %0 ]
%9 = add nuw nsw i64 %8, 1
%10 = icmp eq i64 %8, 254
br i1 %10, label %19, label %11
11: ; preds = %7
%12 = getelementptr inbounds [255 x i8], [255 x i8]* %1, i64 0, i64 %9
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = load i8, i8* %12
%15 = icmp eq i8 %14, 10
br i1 %15, label %16, label %7
16: ; preds = %11
%17 = trunc i64 %9 to i32
%18 = icmp sgt i32 %17, 0
br i1 %18, label %19, label %30
19: ; preds = %7, %16
%20 = phi i64 [ %9, %16 ], [ 255, %7 ]
%21 = and i64 %20, 4294967295
br label %22
22: ; preds = %19, %22
%23 = phi i64 [ %21, %19 ], [ %24, %22 ]
%24 = add nsw i64 %23, -1
%25 = getelementptr inbounds [255 x i8], [255 x i8]* %1, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = call i32 @putchar(i32 %27)
%29 = icmp ugt i64 %23, 1
br i1 %29, label %22, label %30
30: ; preds = %22, %0, %16
%31 = call i32 @putchar(i32 10)
ret i32 0
}