#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 */
void reverseString(char *buffer, size_t start, size_t end) {
  char temp;
  while (start < end) {
    end--;
    temp = buffer[start];
    buffer[start] = buffer[end];
    buffer[end] = temp;
    start++;
  }
  return;
}


x86 assembly (clang, -O0):
<reverseString>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    116d <reverseString+0x6d>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x19(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x19(%rbp),%dl
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1110 <reverseString+0x10>
pop    %rbp
ret

x86 assembly (clang, -O2):
<reverseString>:
cmp    %rdx,%rsi
jae    112e <reverseString+0x2e>
add    $0xffffffffffffffff,%rdx
nopl   0x0(%rax)
movzbl (%rdi,%rsi,1),%eax
movzbl (%rdi,%rdx,1),%ecx
mov    %cl,(%rdi,%rsi,1)
mov    %al,(%rdi,%rdx,1)
add    $0x1,%rsi
lea    -0x1(%rdx),%rax
cmp    %rdx,%rsi
mov    %rax,%rdx
jb     1110 <reverseString+0x10>
ret

LLVM IR (-O0):
define void @reverseString(i8* %0, i64 %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
%7 = alloca i8
store i8* %0, i8** %4
store i64 %1, i64* %5
store i64 %2, i64* %6
br label %8
8: ; preds = %12, %3
%9 = load i64, i64* %5
%10 = load i64, i64* %6
%11 = icmp ult i64 %9, %10
br i1 %11, label %12, label %32
12: ; preds = %8
%13 = load i64, i64* %6
%14 = add i64 %13, -1
store i64 %14, i64* %6
%15 = load i8*, i8** %4
%16 = load i64, i64* %5
%17 = getelementptr inbounds i8, i8* %15, i64 %16
%18 = load i8, i8* %17
store i8 %18, i8* %7
%19 = load i8*, i8** %4
%20 = load i64, i64* %6
%21 = getelementptr inbounds i8, i8* %19, i64 %20
%22 = load i8, i8* %21
%23 = load i8*, i8** %4
%24 = load i64, i64* %5
%25 = getelementptr inbounds i8, i8* %23, i64 %24
store i8 %22, i8* %25
%26 = load i8, i8* %7
%27 = load i8*, i8** %4
%28 = load i64, i64* %6
%29 = getelementptr inbounds i8, i8* %27, i64 %28
store i8 %26, i8* %29
%30 = load i64, i64* %5
%31 = add i64 %30, 1
store i64 %31, i64* %5
br label %8
32: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @reverseString(i8* nocapture %0, i64 %1, i64 %2) {
%4 = icmp ult i64 %1, %2
br i1 %4, label %5, label %15
5: ; preds = %3, %5
%6 = phi i64 [ %13, %5 ], [ %1, %3 ]
%7 = phi i64 [ %8, %5 ], [ %2, %3 ]
%8 = add i64 %7, -1
%9 = getelementptr inbounds i8, i8* %0, i64 %6
%10 = load i8, i8* %9
%11 = getelementptr inbounds i8, i8* %0, i64 %8
%12 = load i8, i8* %11
store i8 %12, i8* %9
store i8 %10, i8* %11
%13 = add nuw i64 %6, 1
%14 = icmp ult i64 %13, %8
br i1 %14, label %5, label %15
15: ; preds = %5, %3
ret void
}