#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*/ free(char *);
char *invers(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int strlen(char *);
int main() {
  char prop[100] = {'\0'};
  int x = 0;
  char *sentence = prop;
  printf("prop initializata cu null character says _%s_\n", sentence);
  printf("Say something %c\n\t", 31);
  fgets(prop, 100, stdin);
  x = strlen(prop) - 1;
  prop[x] = '\0';
  printf("prop orig - _%s_, si lungimea originala este %d\n", sentence, x);
  char *result = invers(prop, x);
  printf("prop invers este %s", result);
  free(result);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1060 <memset@plt>
movl   $0x0,-0x74(%rbp)
lea    -0x70(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x80(%rbp),%rsi
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe85(%rip),%rdi
mov    $0x1f,%esi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x70(%rbp),%rdi
mov    0x2e27(%rip),%rax
mov    (%rax),%edx
mov    $0x64,%esi
call   1070 <fgets@plt>
lea    -0x70(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x74(%rbp)
movslq -0x74(%rbp),%rax
movb   $0x0,-0x70(%rbp,%rax,1)
mov    -0x80(%rbp),%rsi
mov    -0x74(%rbp),%edx
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x70(%rbp),%rdi
mov    -0x74(%rbp),%esi
call   1080 <invers@plt>
mov    %rax,-0x88(%rbp)
mov    -0x88(%rbp),%rsi
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x88(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x68,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movl   $0x0,0x60(%rsp)
lea    0xe7a(%rip),%rdi
mov    %rsp,%r14
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe95(%rip),%rdi
mov    $0x1f,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2e3b(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
mov    $0x64,%esi
call   1060 <fgets@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
movslq %eax,%rbx
movb   $0x0,-0x1(%rsp,%rbx,1)
add    $0xffffffffffffffff,%rbx
lea    0xe6b(%rip),%rdi
mov    %r14,%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
mov    %ebx,%esi
call   1070 <invers@plt>
mov    %rax,%rbx
lea    0xe7c(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [47 x i8] c"prop initializata cu null character says _%s_\0A\00"
@.str.1 = [19 x i8] c"Say something %c\0A\09\00"
@stdin = global i32 0
@.str.2 = [49 x i8] c"prop orig - _%s_, si lungimea originala este %d\0A\00"
@.str.3 = [20 x i8] c"prop invers este %s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
store i32 0, i32* %1
%6 = bitcast [100 x i8]* %2 to i8*
store i32 0, i32* %3
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
store i8* %7, i8** %4
%8 = load i8*, i8** %4
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 31)
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%12 = load i32, i32* @stdin
%13 = call i32 @fgets(i8* %11, i32 100, i32 %12)
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%15 = call i32 @strlen(i8* %14)
%16 = sub nsw i32 %15, 1
store i32 %16, i32* %3
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %18
store i8 0, i8* %19
%20 = load i8*, i8** %4
%21 = load i32, i32* %3
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0), i8* %20, i32 %21)
%23 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%24 = load i32, i32* %3
%25 = call i8* @invers(i8* %23, i32 %24)
store i8* %25, i8** %5
%26 = load i8*, i8** %5
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i8* %26)
%28 = load i8*, i8** %5
%29 = call i32 @free(i8* %28)
ret i32 0
}

LLVM IR (-O2):
@.str = [47 x i8] c"prop initializata cu null character says _%s_\0A\00"
@.str.1 = [19 x i8] c"Say something %c\0A\09\00"
@stdin = global i32 0
@.str.2 = [49 x i8] c"prop orig - _%s_, si lungimea originala este %d\0A\00"
@.str.3 = [20 x i8] c"prop invers este %s\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i8* %2)
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 31)
%5 = load i32, i32* @stdin
%6 = call i32 @fgets(i8* %2, i32 100, i32 %5)
%7 = call i32 @strlen(i8* %2)
%8 = add nsw i32 %7, -1
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %9
store i8 0, i8* %10
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0), i8* %2, i32 %8)
%12 = call i8* @invers(i8* %2, i32 %8)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i8* %12)
%14 = call i32 @free(i8* %12)
ret i32 0
}