#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 */
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int main() {
  char c;
  char w[150];
  int i = 0;
  printf("vuvedi text:\n");
  while ((c = getchar()) != '\n') {
    w[i] = c;
    i++;
  }
  printf("\noburnat text\n");
  while (i > 0) {
    i--;
    printf("%c", w[i]);
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xa4(%rbp)
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
cmp    $0xa,%eax
je     1185 <main+0x65>
mov    -0x5(%rbp),%cl
movslq -0xa4(%rbp),%rax
mov    %cl,-0xa0(%rbp,%rax,1)
mov    -0xa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa4(%rbp)
jmp    114a <main+0x2a>
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0xa4(%rbp)
jle    11d1 <main+0xb1>
mov    -0xa4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xa4(%rbp)
movslq -0xa4(%rbp),%rax
movsbl -0xa0(%rbp,%rax,1),%esi
ff
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1193 <main+0x73>
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0xa0,%rsp
lea    0xec1(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
jne    115d <main+0x2d>
lea    0xeb7(%rip),%rdi
call   1040 <puts@plt>
jmp    11a6 <main+0x76>
xor    %ebx,%ebx
nop
mov    %al,(%rsp,%rbx,1)
add    $0x1,%rbx
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
jne    1160 <main+0x30>
lea    0xe94(%rip),%rdi
call   1040 <puts@plt>
test   %ebx,%ebx
jle    11a6 <main+0x76>
mov    %ebx,%ebx
add    $0x1,%rbx
nopl   0x0(%rax,%rax,1)
lea    -0x2(%rbx),%eax
movsbl (%rsp,%rax,1),%edi
call   1030 <putchar@plt>
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
ja     1190 <main+0x60>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbx
ret

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

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