#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 *, char *);
void reverse1(char *str) {
  char *start, *end;
  start = end = str;
  while (*end != '\0')
    end++;
  end--;
  while (start != end) {
    char temp;
    temp = *start;
    *start = *end;
    *end = temp;
    start++;
    end--;
  }
  printf("%s", str);
}


x86 assembly (clang, -O0):
<reverse1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1149 <reverse1+0x39>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1128 <reverse1+0x18>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
je     119e <reverse1+0x8e>
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x19(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x19(%rbp),%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    1155 <reverse1+0x45>
mov    -0x8(%rbp),%rsi
lea    0xe57(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reverse1>:
mov    %rdi,%rsi
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nop
cmpb   $0x0,(%rsi,%rax,1)
lea    0x1(%rax),%rax
jne    1120 <reverse1+0x10>
cmp    $0x2,%rax
je     115d <reverse1+0x4d>
add    %rsi,%rax
add    $0xfffffffffffffffe,%rax
lea    0x1(%rsi),%rcx
nopl   0x0(%rax,%rax,1)
movzbl -0x1(%rcx),%edi
movzbl (%rax),%edx
mov    %dl,-0x1(%rcx)
mov    %dil,(%rax)
add    $0xffffffffffffffff,%rax
lea    0x1(%rcx),%rdx
cmp    %rax,%rcx
mov    %rdx,%rcx
jne    1140 <reverse1+0x30>
lea    0xe9c(%rip),%rdi
jmp    1030 <printf@plt>

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

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define void @reverse1(i8* %0) {
br label %2
2: ; preds = %2, %1
%3 = phi i8* [ %0, %1 ], [ %6, %2 ]
%4 = load i8, i8* %3
%5 = icmp eq i8 %4, 0
%6 = getelementptr inbounds i8, i8* %3, i64 1
br i1 %5, label %7, label %2
7: ; preds = %2
%8 = getelementptr inbounds i8, i8* %3, i64 -1
%9 = icmp eq i8* %8, %0
br i1 %9, label %18, label %10
10: ; preds = %7, %10
%11 = phi i8* [ %16, %10 ], [ %8, %7 ]
%12 = phi i8* [ %15, %10 ], [ %0, %7 ]
%13 = load i8, i8* %12
%14 = load i8, i8* %11
store i8 %14, i8* %12
store i8 %13, i8* %11
%15 = getelementptr inbounds i8, i8* %12, i64 1
%16 = getelementptr inbounds i8, i8* %11, i64 -1
%17 = icmp eq i8* %15, %16
br i1 %17, label %18, label %10
18: ; preds = %10, %7
%19 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %0)
ret void
}