#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*/ exit(int);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ gets(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putchar(char);
int strlen(char *);
void main(void) {
  char *s;
  register int t;
  s = (char *)malloc(80);
  if (!s) {
    printf("Memory request failed \n");
    exit(1);
  }
  printf("Enter a Sentence: ");
  gets(s);
  printf("The Reverse Sentence is: ");
  for (t = strlen(s) - 1; t >= 0; t--)
    putchar(s[t]);
  printf("\n");
  free(s);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x50,%edi
call   1080 <malloc@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    11a7 <main+0x37>
lea    0xe68(%rip),%rdi
call   1060 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
lea    0xe6a(%rip),%rdi
call   1060 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1070 <gets@plt>
lea    0xe68(%rip),%rdi
call   1060 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jl     1200 <main+0x90>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <putchar@plt>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    11d7 <main+0x67>
lea    0xe0f(%rip),%rdi
call   1060 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x50,%edi
call   1090 <malloc@plt>
test   %rax,%rax
je     1200 <main+0x80>
mov    %rax,%r14
lea    0xe63(%rip),%rdi
call   1070 <printf@plt>
mov    %r14,%rdi
call   1080 <gets@plt>
lea    0xe62(%rip),%rdi
call   1070 <printf@plt>
mov    %r14,%rdi
call   1060 <strlen@plt>
test   %eax,%eax
jle    11e7 <main+0x67>
mov    %eax,%ebx
add    $0x1,%rbx
nopl   0x0(%rax,%rax,1)
lea    -0x2(%rbx),%eax
movsbl (%r14,%rax,1),%edi
call   1040 <putchar@plt>
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
ja     11d0 <main+0x50>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <free@plt>
lea    0xe26(%rip),%rdi
call   1050 <puts@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [24 x i8] c"Memory request failed \0A\00"
@.str.1 = [19 x i8] c"Enter a Sentence: \00"
@.str.2 = [26 x i8] c"The Reverse Sentence is: \00"
@.str.3 = [2 x i8] c"\0A\00"
define void @main() {
%1 = alloca i8*
%2 = alloca i32
%3 = call i64 @malloc(i32 80)
%4 = inttoptr i64 %3 to i8*
store i8* %4, i8** %1
%5 = load i8*, i8** %1
%6 = icmp ne i8* %5, null
br i1 %6, label %10, label %7
7: ; preds = %0
%8 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @exit(i32 1)
unreachable
10: ; preds = %0
%11 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%12 = load i8*, i8** %1
%13 = call i32 @gets(i8* %12)
%14 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%15 = load i8*, i8** %1
%16 = call i32 @strlen(i8* %15)
%17 = sub nsw i32 %16, 1
store i32 %17, i32* %2
br label %18
18: ; preds = %28, %10
%19 = load i32, i32* %2
%20 = icmp sge i32 %19, 0
br i1 %20, label %21, label %31
21: ; preds = %18
%22 = load i8*, i8** %1
%23 = load i32, i32* %2
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
%26 = load i8, i8* %25
%27 = call i32 @putchar(i8 signext %26)
br label %28
28: ; preds = %21
%29 = load i32, i32* %2
%30 = add nsw i32 %29, -1
store i32 %30, i32* %2
br label %18
31: ; preds = %18
%32 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%33 = load i8*, i8** %1
%34 = call i32 @free(i8* %33)
ret void
}

LLVM IR (-O2):
@.str.1 = [19 x i8] c"Enter a Sentence: \00"
@.str.2 = [26 x i8] c"The Reverse Sentence is: \00"
@str = [23 x i8] c"Memory request failed \00"
define void @main() {
%1 = tail call i64 @malloc(i32 80)
%2 = inttoptr i64 %1 to i8*
%3 = icmp eq i64 %1, 0
br i1 %3, label %4, label %7
4: ; preds = %0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @exit(i32 1)
unreachable
7: ; preds = %0
%8 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%9 = tail call i32 @gets(i8* %2)
%10 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%11 = tail call i32 @strlen(i8* %2)
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %23
13: ; preds = %7
%14 = zext i32 %11 to i64
br label %15
15: ; preds = %13, %15
%16 = phi i64 [ %14, %13 ], [ %17, %15 ]
%17 = add nsw i64 %16, -1
%18 = and i64 %17, 4294967295
%19 = getelementptr inbounds i8, i8* %2, i64 %18
%20 = load i8, i8* %19
%21 = tail call i32 @putchar(i8 signext %20)
%22 = icmp ugt i64 %16, 1
br i1 %22, label %15, label %23
23: ; preds = %15, %7
%24 = tail call i32 bitcast (i32 (i8)* @putchar to i32 (i32)*)(i32 10)
%25 = tail call i32 @free(i8* %2)
ret void
}