#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 */
scalar_t__ gets(char *);
int /*<<< orphan*/ printf(char *, char, char, char, char);
int main() {
  char s[5];
  while (gets(s)) {
    printf("%c%c%c%c\n", s[3], s[2], s[1], s[0]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x9(%rbp),%rdi
call   1040 <gets@plt>
cmp    $0x0,%rax
je     116a <main+0x4a>
mov    -0x6(%rbp),%dl
mov    -0x7(%rbp),%cl
mov    -0x8(%rbp),%al
lea    0xeae(%rip),%rdi
movsbl %dl,%esi
movsbl %cl,%edx
movsbl %al,%ecx
movsbl -0x9(%rbp),%r8d
call   1030 <printf@plt>
jmp    112f <main+0xf>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0x3(%rsp),%rdi
call   1040 <gets@plt>
test   %rax,%rax
je     116a <main+0x4a>
lea    0xec6(%rip),%r14
lea    0x3(%rsp),%rbx
nop
movsbl 0x6(%rsp),%esi
movsbl 0x5(%rsp),%edx
movsbl 0x4(%rsp),%ecx
movsbl 0x3(%rsp),%r8d
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1040 <gets@plt>
test   %rax,%rax
jne    1140 <main+0x20>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [10 x i8] c"%c%c%c%c\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x i8]
store i32 0, i32* %1
br label %3
3: ; preds = %7, %0
%4 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%5 = call i64 @gets(i8* %4)
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %17
7: ; preds = %3
%8 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 3
%9 = load i8, i8* %8
%10 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 2
%11 = load i8, i8* %10
%12 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 1
%13 = load i8, i8* %12
%14 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%15 = load i8, i8* %14
%16 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8 signext %9, i8 signext %11, i8 signext %13, i8 signext %15)
br label %3
17: ; preds = %3
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"%c%c%c%c\0A\00"
define i32 @main() {
%1 = alloca [5 x i8]
%2 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%3 = call i64 @gets(i8* %2)
%4 = icmp eq i64 %3, 0
br i1 %4, label %17, label %5
5: ; preds = %0
%6 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 3
%7 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 2
%8 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 1
br label %9
9: ; preds = %5, %9
%10 = load i8, i8* %6
%11 = load i8, i8* %7
%12 = load i8, i8* %8
%13 = load i8, i8* %2
%14 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8 signext %10, i8 signext %11, i8 signext %12, i8 signext %13)
%15 = call i64 @gets(i8* %2)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %9
17: ; preds = %9, %0
ret i32 0
}