#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 my_strlen(char *);
char *my_rev_getstrcpy(char *str) {
  int i;
  int endstring;
  char c;
  i = 0;
  if (str[i] == '-')
    i++;
  endstring = my_strlen(str) - 1;
  while (endstring >= i) {
    c = str[endstring];
    str[endstring] = str[i];
    str[i] = c;
    endstring--;
    i++;
  }
  return (str);
}


x86 assembly (clang, -O0):
<my_rev_getstrcpy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2d,%eax
jne    1141 <my_rev_getstrcpy+0x31>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <my_strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jl     11a5 <my_rev_getstrcpy+0x95>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x11(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x11(%rbp),%dl
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1150 <my_rev_getstrcpy+0x40>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_rev_getstrcpy>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbp
mov    (%rdi),%r14b
xor    %ebx,%ebx
cmp    $0x2d,%r14b
sete   %bl
call   1030 <my_strlen@plt>
cmp    %ebx,%eax
jle    1162 <my_rev_getstrcpy+0x52>
xor    %ecx,%ecx
cmp    $0x2d,%r14b
sete   %cl
cltq
add    $0xffffffffffffffff,%rax
nopl   0x0(%rax,%rax,1)
movzbl 0x0(%rbp,%rax,1),%edx
movzbl 0x0(%rbp,%rcx,1),%ebx
mov    %bl,0x0(%rbp,%rax,1)
mov    %dl,0x0(%rbp,%rcx,1)
add    $0x1,%rcx
lea    -0x1(%rax),%rdx
cmp    %rcx,%rax
mov    %rdx,%rax
jg     1140 <my_rev_getstrcpy+0x30>
mov    %rbp,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i8* @my_rev_getstrcpy(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8
store i8* %0, i8** %2
store i32 0, i32* %3
%6 = load i8*, i8** %2
%7 = load i32, i32* %3
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %6, i64 %8
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %11, 45
br i1 %12, label %13, label %16
13: ; preds = %1
%14 = load i32, i32* %3
%15 = add nsw i32 %14, 1
store i32 %15, i32* %3
br label %16
16: ; preds = %13, %1
%17 = load i8*, i8** %2
%18 = call i32 @my_strlen(i8* %17)
%19 = sub nsw i32 %18, 1
store i32 %19, i32* %4
br label %20
20: ; preds = %24, %16
%21 = load i32, i32* %4
%22 = load i32, i32* %3
%23 = icmp sge i32 %21, %22
br i1 %23, label %24, label %48
24: ; preds = %20
%25 = load i8*, i8** %2
%26 = load i32, i32* %4
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
%29 = load i8, i8* %28
store i8 %29, i8* %5
%30 = load i8*, i8** %2
%31 = load i32, i32* %3
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
%34 = load i8, i8* %33
%35 = load i8*, i8** %2
%36 = load i32, i32* %4
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
store i8 %34, i8* %38
%39 = load i8, i8* %5
%40 = load i8*, i8** %2
%41 = load i32, i32* %3
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %40, i64 %42
store i8 %39, i8* %43
%44 = load i32, i32* %4
%45 = add nsw i32 %44, -1
store i32 %45, i32* %4
%46 = load i32, i32* %3
%47 = add nsw i32 %46, 1
store i32 %47, i32* %3
br label %20
48: ; preds = %20
%49 = load i8*, i8** %2
ret i8* %49
}

LLVM IR (-O2):
define i8* @my_rev_getstrcpy(i8* returned %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 45
%4 = zext i1 %3 to i32
%5 = tail call i32 @my_strlen(i8* %0)
%6 = icmp sgt i32 %5, %4
br i1 %6, label %7, label %20
7: ; preds = %1
%8 = sext i32 %5 to i64
%9 = zext i1 %3 to i64
br label %10
10: ; preds = %7, %10
%11 = phi i64 [ %9, %7 ], [ %18, %10 ]
%12 = phi i64 [ %8, %7 ], [ %13, %10 ]
%13 = add nsw i64 %12, -1
%14 = getelementptr inbounds i8, i8* %0, i64 %13
%15 = load i8, i8* %14
%16 = getelementptr inbounds i8, i8* %0, i64 %11
%17 = load i8, i8* %16
store i8 %17, i8* %14
store i8 %15, i8* %16
%18 = add nuw nsw i64 %11, 1
%19 = icmp sgt i64 %13, %18
br i1 %19, label %10, label %20
20: ; preds = %10, %1
ret i8* %0
}