#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*/ free(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ reverseString(char *);
int /*<<< orphan*/ rot13(char *);
int scanf(char *, char **);
int main() {
  char *msg;
  puts("Enter your message:");
  int readValue = scanf("%ms", &msg);
  if (readValue == 0) {
    puts("oops");
    return 0;
  }
  printf("Initial value: \"%s\"\n", msg);
  reverseString(msg);
  printf("Reversed     : \"%s\"\n", msg);
  reverseString(msg);
  rot13(msg);
  printf("ROT13        : \"%s\"\n", msg);
  free(msg);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
call   1040 <puts@plt>
lea    0xe92(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1070 <scanf@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    11b0 <main+0x50>
lea    0xe79(%rip),%rdi
call   1040 <puts@plt>
movl   $0x0,-0x4(%rbp)
jmp    1204 <main+0xa4>
mov    -0x10(%rbp),%rsi
lea    0xe62(%rip),%rdi
call   1060 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1080 <reverseString@plt>
mov    -0x10(%rbp),%rsi
lea    0xe5e(%rip),%rdi
call   1060 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1080 <reverseString@plt>
mov    -0x10(%rbp),%rdi
call   1050 <rot13@plt>
mov    -0x10(%rbp),%rsi
lea    0xe51(%rip),%rdi
call   1060 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xe98(%rip),%rdi
call   1040 <puts@plt>
lea    0xea0(%rip),%rdi
mov    %rsp,%rsi
call   1070 <scanf@plt>
test   %eax,%eax
je     11d6 <main+0x76>
mov    (%rsp),%rsi
lea    0xe92(%rip),%rdi
call   1060 <printf@plt>
mov    (%rsp),%rdi
call   1080 <reverseString@plt>
mov    (%rsp),%rsi
lea    0xe8e(%rip),%rdi
call   1060 <printf@plt>
mov    (%rsp),%rdi
call   1080 <reverseString@plt>
mov    (%rsp),%rdi
call   1050 <rot13@plt>
mov    (%rsp),%rsi
lea    0xe81(%rip),%rdi
call   1060 <printf@plt>
mov    (%rsp),%rdi
call   1030 <free@plt>
jmp    11e2 <main+0x82>
lea    0xe3b(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Enter your message:\00"
@.str.1 = [4 x i8] c"%ms\00"
@.str.2 = [5 x i8] c"oops\00"
@.str.3 = [21 x i8] c"Initial value: \22%s\22\0A\00"
@.str.4 = [21 x i8] c"Reversed : \22%s\22\0A\00"
@.str.5 = [21 x i8] c"ROT13 : \22%s\22\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @puts(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %2)
store i32 %5, i32* %3
%6 = load i32, i32* %3
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 @puts(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %25
10: ; preds = %0
%11 = load i8*, i8** %2
%12 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %11)
%13 = load i8*, i8** %2
%14 = call i32 @reverseString(i8* %13)
%15 = load i8*, i8** %2
%16 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* %15)
%17 = load i8*, i8** %2
%18 = call i32 @reverseString(i8* %17)
%19 = load i8*, i8** %2
%20 = call i32 @rot13(i8* %19)
%21 = load i8*, i8** %2
%22 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i8* %21)
%23 = load i8*, i8** %2
%24 = call i32 @free(i8* %23)
br label %25
25: ; preds = %10, %8
%26 = load i32, i32* %1
ret i32 %26
}

LLVM IR (-O2):
@.str = [20 x i8] c"Enter your message:\00"
@.str.1 = [4 x i8] c"%ms\00"
@.str.2 = [5 x i8] c"oops\00"
@.str.3 = [21 x i8] c"Initial value: \22%s\22\0A\00"
@.str.4 = [21 x i8] c"Reversed : \22%s\22\0A\00"
@.str.5 = [21 x i8] c"ROT13 : \22%s\22\0A\00"
define i32 @main() {
%1 = alloca i8*
%2 = bitcast i8** %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %1)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %23
8: ; preds = %0
%9 = load i8*, i8** %1
%10 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %9)
%11 = load i8*, i8** %1
%12 = call i32 @reverseString(i8* %11)
%13 = load i8*, i8** %1
%14 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* %13)
%15 = load i8*, i8** %1
%16 = call i32 @reverseString(i8* %15)
%17 = load i8*, i8** %1
%18 = call i32 @rot13(i8* %17)
%19 = load i8*, i8** %1
%20 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i8* %19)
%21 = load i8*, i8** %1
%22 = call i32 @free(i8* %21)
br label %23
23: ; preds = %8, %6
ret i32 0
}