#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*/ printf(char *);
void Reversed(char *in) {
  char temp;
  char *end;
  if (in == NULL) {
    printf("NULL input\n");
    return;
  }
  if (*in == 0) {
    printf("Empty string input\n");
    return;
  }
  end = in;
  while (*end) {
    end++;
  }
  --end;
  while (end > in) {
    temp = *in;
    *in = *end;
    *end = temp;
    in++;
    end--;
  }
}


x86 assembly (clang, -O0):
<Reversed>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1138 <Reversed+0x28>
lea    0xed2(%rip),%rdi
call   1030 <printf@plt>
jmp    11d4 <Reversed+0xc4>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1159 <Reversed+0x49>
lea    0xebd(%rip),%rdi
call   1030 <printf@plt>
jmp    11d4 <Reversed+0xc4>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     117f <Reversed+0x6f>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1161 <Reversed+0x51>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x8(%rbp),%rax
jbe    11d4 <Reversed+0xc4>
mov    -0x8(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x9(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
mov    -0x9(%rbp),%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    118b <Reversed+0x7b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Reversed>:
test   %rdi,%rdi
je     117d <Reversed+0x6d>
mov    (%rdi),%sil
test   %sil,%sil
je     1189 <Reversed+0x79>
mov    $0xffffffffffffffff,%rdx
mov    $0x2,%eax
nopl   0x0(%rax)
add    $0xffffffffffffffff,%rax
cmpb   $0x0,0x2(%rdi,%rdx,1)
lea    0x1(%rdx),%rdx
jne    1130 <Reversed+0x20>
test   %rdx,%rdx
je     117c <Reversed+0x6c>
mov    (%rdi,%rdx,1),%cl
mov    %cl,(%rdi)
mov    %sil,(%rdi,%rdx,1)
cmp    $0x3,%rdx
jb     117c <Reversed+0x6c>
mov    %rdi,%rcx
sub    %rax,%rcx
add    $0x2,%rdi
nopl   (%rax)
movzbl -0x1(%rdi),%eax
movzbl (%rcx),%edx
mov    %dl,-0x1(%rdi)
mov    %al,(%rcx)
add    $0xffffffffffffffff,%rcx
lea    0x1(%rdi),%rax
cmp    %rdi,%rcx
mov    %rax,%rdi
ja     1160 <Reversed+0x50>
ret
lea    0xe8f(%rip),%rdi
jmp    1030 <puts@plt>
lea    0xe70(%rip),%rdi
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"NULL input\0A\00"
@.str.1 = [20 x i8] c"Empty string input\0A\00"
define void @Reversed(i8* %0) {
%2 = alloca i8*
%3 = alloca i8
%4 = alloca i8*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %44
9: ; preds = %1
%10 = load i8*, i8** %2
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %9
%15 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %44
16: ; preds = %9
%17 = load i8*, i8** %2
store i8* %17, i8** %4
br label %18
18: ; preds = %22, %16
%19 = load i8*, i8** %4
%20 = load i8, i8* %19
%21 = icmp ne i8 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %18
%23 = load i8*, i8** %4
%24 = getelementptr inbounds i8, i8* %23, i32 1
store i8* %24, i8** %4
br label %18
25: ; preds = %18
%26 = load i8*, i8** %4
%27 = getelementptr inbounds i8, i8* %26, i32 -1
store i8* %27, i8** %4
br label %28
28: ; preds = %32, %25
%29 = load i8*, i8** %4
%30 = load i8*, i8** %2
%31 = icmp ugt i8* %29, %30
br i1 %31, label %32, label %44
32: ; preds = %28
%33 = load i8*, i8** %2
%34 = load i8, i8* %33
store i8 %34, i8* %3
%35 = load i8*, i8** %4
%36 = load i8, i8* %35
%37 = load i8*, i8** %2
store i8 %36, i8* %37
%38 = load i8, i8* %3
%39 = load i8*, i8** %4
store i8 %38, i8* %39
%40 = load i8*, i8** %2
%41 = getelementptr inbounds i8, i8* %40, i32 1
store i8* %41, i8** %2
%42 = load i8*, i8** %4
%43 = getelementptr inbounds i8, i8* %42, i32 -1
store i8* %43, i8** %4
br label %28
44: ; preds = %7, %14, %28
ret void
}

LLVM IR (-O2):
@str = [19 x i8] c"Empty string input\00"
@str.2 = [11 x i8] c"NULL input\00"
define void @Reversed(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %30, label %3
3: ; preds = %1
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %30, label %16
6: ; preds = %16
%7 = getelementptr inbounds i8, i8* %0, i64 %17
%8 = icmp eq i64 %17, 0
br i1 %8, label %33, label %9
9: ; preds = %6
%10 = load i8, i8* %7
store i8 %10, i8* %0
store i8 %4, i8* %7
%11 = icmp ugt i64 %17, 2
br i1 %11, label %12, label %33
12: ; preds = %9
%13 = add nsw i64 %17, -1
%14 = getelementptr inbounds i8, i8* %0, i64 1
%15 = getelementptr inbounds i8, i8* %0, i64 %13
br label %22
16: ; preds = %3, %16
%17 = phi i64 [ %18, %16 ], [ 0, %3 ]
%18 = add nuw nsw i64 %17, 1
%19 = getelementptr inbounds i8, i8* %0, i64 %18
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 0
br i1 %21, label %6, label %16
22: ; preds = %12, %22
%23 = phi i8* [ %15, %12 ], [ %28, %22 ]
%24 = phi i8* [ %14, %12 ], [ %27, %22 ]
%25 = load i8, i8* %24
%26 = load i8, i8* %23
store i8 %26, i8* %24
store i8 %25, i8* %23
%27 = getelementptr inbounds i8, i8* %24, i64 1
%28 = getelementptr inbounds i8, i8* %23, i64 -1
%29 = icmp ugt i8* %28, %27
br i1 %29, label %22, label %33
30: ; preds = %3, %1
%31 = phi i8* [ getelementptr inbounds ([11 x i8], [11 x i8]* @str.2, i64 0, i64 0), %1 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0), %3 ]
%32 = tail call i32 @puts(i8* dereferenceable(1) %31)
br label %33
33: ; preds = %22, %9, %30, %6
ret void
}