#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*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ stdin;
int strlen(char *);
int main() {
  printf("Enter input: ");
  char str[100 + 1];
  fgets(str, 100 + 1, stdin);
  for (int i = strlen(str) - 1; i >= 0; i--) {
    if (str[i] == '\n')
      continue;
    else
      putchar(str[i]);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xea7(%rip),%rdi
call   1050 <printf@plt>
lea    -0x70(%rbp),%rdi
mov    0x2e7f(%rip),%rax
mov    (%rax),%edx
mov    $0x65,%esi
call   1060 <fgets@plt>
lea    -0x70(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x74(%rbp)
cmpl   $0x0,-0x74(%rbp)
jl     11c6 <main+0x86>
movslq -0x74(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0xa,%eax
jne    11a5 <main+0x65>
jmp    11b8 <main+0x78>
movslq -0x74(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%edi
call   1030 <putchar@plt>
jmp    11b8 <main+0x78>
mov    -0x74(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x74(%rbp)
jmp    1184 <main+0x44>
lea    0xe41(%rip),%rdi
call   1050 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x70,%rsp
lea    0xeb4(%rip),%rdi
call   1050 <printf@plt>
mov    0x2e90(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x65,%esi
call   1060 <fgets@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    119f <main+0x5f>
mov    %eax,%ebx
add    $0x1,%rbx
jmp    118a <main+0x4a>
xchg   %ax,%ax
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
jbe    119f <main+0x5f>
lea    -0x2(%rbx),%eax
movzbl (%rsp,%rax,1),%eax
cmp    $0xa,%al
je     1180 <main+0x40>
movsbl %al,%edi
call   1030 <putchar@plt>
jmp    1180 <main+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [14 x i8] c"Enter input: \00"
@stdin = global i32 0
@.str.1 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [101 x i8]
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [101 x i8], [101 x i8]* %2, i64 0, i64 0
%6 = load i32, i32* @stdin
%7 = call i32 @fgets(i8* %5, i32 101, i32 %6)
%8 = getelementptr inbounds [101 x i8], [101 x i8]* %2, i64 0, i64 0
%9 = call i32 @strlen(i8* %8)
%10 = sub nsw i32 %9, 1
store i32 %10, i32* %3
br label %11
11: ; preds = %29, %0
%12 = load i32, i32* %3
%13 = icmp sge i32 %12, 0
br i1 %13, label %14, label %32
14: ; preds = %11
%15 = load i32, i32* %3
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [101 x i8], [101 x i8]* %2, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 10
br i1 %20, label %21, label %22
21: ; preds = %14
br label %29
22: ; preds = %14
%23 = load i32, i32* %3
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [101 x i8], [101 x i8]* %2, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = call i32 @putchar(i8 signext %26)
br label %28
28: ; preds = %22
br label %29
29: ; preds = %28, %21
%30 = load i32, i32* %3
%31 = add nsw i32 %30, -1
store i32 %31, i32* %3
br label %11
32: ; preds = %11
%33 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%34 = load i32, i32* %1
ret i32 %34
}

LLVM IR (-O2):
@.str = [14 x i8] c"Enter input: \00"
@stdin = global i32 0
define i32 @main() {
%1 = alloca [101 x i8]
%2 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%3 = getelementptr inbounds [101 x i8], [101 x i8]* %1, i64 0, i64 0
%4 = load i32, i32* @stdin
%5 = call i32 @fgets(i8* %3, i32 101, i32 %4)
%6 = call i32 @strlen(i8* %3)
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = zext i32 %6 to i64
br label %12
10: ; preds = %21, %0
%11 = call i32 bitcast (i32 (i8)* @putchar to i32 (i32)*)(i32 10)
ret i32 0
12: ; preds = %8, %21
%13 = phi i64 [ %9, %8 ], [ %14, %21 ]
%14 = add nsw i64 %13, -1
%15 = and i64 %14, 4294967295
%16 = getelementptr inbounds [101 x i8], [101 x i8]* %1, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 10
br i1 %18, label %21, label %19
19: ; preds = %12
%20 = call i32 @putchar(i8 signext %17)
br label %21
21: ; preds = %12, %19
%22 = icmp ugt i64 %13, 1
br i1 %22, label %12, label %10
}