#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 */
typedef int /*<<< orphan*/ word;

/* Variables and functions */
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int strlen(char *);
int main() {
  char word[50];
  int i;
  fgets(word, sizeof(word), stdin);
  printf("sizeof(word):%d\n", (int)sizeof(word));
  for (i = strlen(word); i >= 0; i--) {
    if (word[i] == '\n')
      word[i] = '\0';
    printf("%c", word[i]);
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x40(%rbp),%rdi
mov    0x2e9e(%rip),%rax
mov    (%rax),%edx
mov    $0x32,%esi
call   1050 <fgets@plt>
lea    0xea3(%rip),%rdi
mov    $0x32,%esi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x40(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
jl     11bf <main+0x8f>
movslq -0x44(%rbp),%rax
movsbl -0x40(%rbp,%rax,1),%eax
cmp    $0xa,%eax
jne    119a <main+0x6a>
movslq -0x44(%rbp),%rax
movb   $0x0,-0x40(%rbp,%rax,1)
movslq -0x44(%rbp),%rax
movsbl -0x40(%rbp,%rax,1),%esi
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x44(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x44(%rbp)
jmp    1175 <main+0x45>
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40,%rsp
mov    0x2e9c(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x32,%esi
call   1060 <fgets@plt>
lea    0xe9b(%rip),%rdi
mov    $0x32,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
js     11b0 <main+0x70>
mov    %eax,%ebx
add    $0x1,%rbx
jmp    119e <main+0x5e>
cs nopw 0x0(%rax,%rax,1)
nop
movsbl %al,%edi
call   1030 <putchar@plt>
add    $0xffffffffffffffff,%rbx
jle    11b0 <main+0x70>
movzbl -0x1(%rsp,%rbx,1),%eax
cmp    $0xa,%al
jne    1190 <main+0x50>
movb   $0x0,-0x1(%rsp,%rbx,1)
xor    %eax,%eax
jmp    1190 <main+0x50>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [17 x i8] c"sizeof(word):%d\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 [50 x i8]
%3 = alloca i32
store i32 0, i32* %1
%4 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%5 = load i32, i32* @stdin
%6 = call i32 @fgets(i8* %4, i32 50, i32 %5)
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 50)
%8 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%9 = call i32 @strlen(i8* %8)
store i32 %9, i32* %3
br label %10
10: ; preds = %31, %0
%11 = load i32, i32* %3
%12 = icmp sge i32 %11, 0
br i1 %12, label %13, label %34
13: ; preds = %10
%14 = load i32, i32* %3
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 10
br i1 %19, label %20, label %24
20: ; preds = %13
%21 = load i32, i32* %3
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 %22
store i8 0, i8* %23
br label %24
24: ; preds = %20, %13
%25 = load i32, i32* %3
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [50 x i8], [50 x i8]* %2, 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.1, i64 0, i64 0), i32 %29)
br label %31
31: ; preds = %24
%32 = load i32, i32* %3
%33 = add nsw i32 %32, -1
store i32 %33, i32* %3
br label %10
34: ; preds = %10
%35 = 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):
@stdin = global i32 0
@.str = [17 x i8] c"sizeof(word):%d\0A\00"
define i32 @main() {
%1 = alloca [50 x i8]
%2 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @stdin
%4 = call i32 @fgets(i8* %2, i32 50, i32 %3)
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 50)
%6 = call i32 @strlen(i8* %2)
%7 = icmp sgt i32 %6, -1
br i1 %7, label %8, label %22
8: ; preds = %0
%9 = zext i32 %6 to i64
br label %10
10: ; preds = %8, %16
%11 = phi i64 [ %9, %8 ], [ %20, %16 ]
%12 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %11
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 10
br i1 %14, label %15, label %16
15: ; preds = %10
store i8 0, i8* %12
br label %16
16: ; preds = %15, %10
%17 = phi i8 [ 0, %15 ], [ %13, %10 ]
%18 = sext i8 %17 to i32
%19 = call i32 @putchar(i32 %18)
%20 = add nsw i64 %11, -1
%21 = icmp sgt i64 %11, 0
br i1 %21, label %10, label %22
22: ; preds = %16, %0
%23 = call i32 @putchar(i32 10)
ret i32 0
}