#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*/ copy(char *, char *);
size_t strlen(char *);
void reverse(char s[]) {
  size_t len = strlen(s);
  char temp[len];
  int j;
  copy(temp, s);
  j = 0;
  while (len > 0) {
    s[j] = temp[len - 1];
    --len;
    ++j;
  }
}


x86 assembly (clang, -O0):
<reverse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x30(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rsi
call   1040 <copy@plt>
movl   $0x0,-0x24(%rbp)
cmpq   $0x0,-0x10(%rbp)
jbe    11af <reverse+0x8f>
mov    -0x30(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    $0x1,%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1170 <reverse+0x50>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reverse>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    %rax,%r15
mov    %rsp,%r14
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <copy@plt>
test   %r15,%r15
je     12a2 <reverse+0x182>
cmp    $0x8,%r15
jae    116a <reverse+0x4a>
xor    %eax,%eax
mov    %r15,%rcx
jmp    1282 <reverse+0x162>
cmp    $0x20,%r15
jae    1177 <reverse+0x57>
xor    %eax,%eax
jmp    1220 <reverse+0x100>
mov    %r15,%rax
and    $0xffffffffffffffe0,%rax
lea    (%r15,%r14,1),%rcx
add    $0xfffffffffffffff0,%rcx
xor    %edx,%edx
pxor   %xmm0,%xmm0
nopl   0x0(%rax)
movdqu -0x10(%rcx),%xmm1
movdqu (%rcx),%xmm2
movdqa %xmm2,%xmm3
punpcklbw %xmm0,%xmm3
pshufd $0x4e,%xmm3,%xmm3
pshuflw $0x1b,%xmm3,%xmm3
pshufhw $0x1b,%xmm3,%xmm3
punpckhbw %xmm0,%xmm2
pshufd $0x4e,%xmm2,%xmm2
pshuflw $0x1b,%xmm2,%xmm2
pshufhw $0x1b,%xmm2,%xmm2
packuswb %xmm3,%xmm2
movdqa %xmm1,%xmm3
punpcklbw %xmm0,%xmm3
pshufd $0x4e,%xmm3,%xmm3
pshuflw $0x1b,%xmm3,%xmm3
pshufhw $0x1b,%xmm3,%xmm3
punpckhbw %xmm0,%xmm1
pshufd $0x4e,%xmm1,%xmm1
pshuflw $0x1b,%xmm1,%xmm1
pshufhw $0x1b,%xmm1,%xmm1
packuswb %xmm3,%xmm1
movdqu %xmm2,(%rbx,%rdx,1)
movdqu %xmm1,0x10(%rbx,%rdx,1)
add    $0x20,%rdx
add    $0xffffffffffffffe0,%rcx
cmp    %rdx,%rax
jne    1190 <reverse+0x70>
cmp    %rax,%r15
je     12a2 <reverse+0x182>
test   $0x18,%r15b
je     12ad <reverse+0x18d>
mov    %rax,%rdx
mov    %r15,%rax
and    $0xfffffffffffffff8,%rax
mov    %r15d,%ecx
and    $0x7,%ecx
mov    %r15,%rsi
sub    %rdx,%rsi
add    %r14,%rsi
add    $0xfffffffffffffff8,%rsi
pxor   %xmm0,%xmm0
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movq   (%rsi),%xmm1
punpcklbw %xmm0,%xmm1
pshufd $0x4e,%xmm1,%xmm1
pshuflw $0x1b,%xmm1,%xmm1
pshufhw $0x1b,%xmm1,%xmm1
packuswb %xmm1,%xmm1
movq   %xmm1,(%rbx,%rdx,1)
add    $0x8,%rdx
add    $0xfffffffffffffff8,%rsi
cmp    %rdx,%rax
jne    1250 <reverse+0x130>
cmp    %rax,%r15
je     12a2 <reverse+0x182>
add    %rax,%rbx
cs nopw 0x0(%rax,%rax,1)
nop
movzbl -0x1(%r14,%rcx,1),%eax
mov    %al,(%rbx)
add    $0x1,%rbx
add    $0xffffffffffffffff,%rcx
jne    1290 <reverse+0x170>
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
and    $0x1f,%r15d
jmp    1162 <reverse+0x42>

LLVM IR (-O0):
define void @reverse(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i32
store i8* %0, i8** %2
%7 = load i8*, i8** %2
%8 = call i64 @strlen(i8* %7)
store i64 %8, i64* %3
%9 = load i64, i64* %3
%10 = call i8* @llvm.stacksave()
store i8* %10, i8** %4
%11 = alloca i8, i64 %9
store i64 %9, i64* %5
%12 = load i8*, i8** %2
%13 = call i32 @copy(i8* %11, i8* %12)
store i32 0, i32* %6
br label %14
14: ; preds = %17, %1
%15 = load i64, i64* %3
%16 = icmp ugt i64 %15, 0
br i1 %16, label %17, label %30
17: ; preds = %14
%18 = load i64, i64* %3
%19 = sub i64 %18, 1
%20 = getelementptr inbounds i8, i8* %11, i64 %19
%21 = load i8, i8* %20
%22 = load i8*, i8** %2
%23 = load i32, i32* %6
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
store i8 %21, i8* %25
%26 = load i64, i64* %3
%27 = add i64 %26, -1
store i64 %27, i64* %3
%28 = load i32, i32* %6
%29 = add nsw i32 %28, 1
store i32 %29, i32* %6
br label %14
30: ; preds = %14
%31 = load i8*, i8** %4
ret void
}

LLVM IR (-O2):
define void @reverse(i8* %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = alloca i8, i64 %2
%4 = call i32 @copy(i8* %3, i8* %0)
%5 = icmp eq i64 %2, 0
br i1 %5, label %69, label %6
6: ; preds = %1
%7 = icmp ult i64 %2, 8
br i1 %7, label %57, label %8
8: ; preds = %6
%9 = icmp ult i64 %2, 32
br i1 %9, label %38, label %10
10: ; preds = %8
%11 = and i64 %2, -32
br label %12
12: ; preds = %12, %10
%13 = phi i64 [ 0, %10 ], [ %30, %12 ]
%14 = xor i64 %13, -1
%15 = add i64 %2, %14
%16 = getelementptr inbounds i8, i8* %3, i64 %15
%17 = getelementptr inbounds i8, i8* %16, i64 -15
%18 = bitcast i8* %17 to <16 x i8>*
%19 = load <16 x i8>, <16 x i8>* %18
%20 = shufflevector <16 x i8> %19, <16 x i8> poison, <16 x i32> <i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
%21 = getelementptr inbounds i8, i8* %16, i64 -16
%22 = getelementptr inbounds i8, i8* %21, i64 -15
%23 = bitcast i8* %22 to <16 x i8>*
%24 = load <16 x i8>, <16 x i8>* %23
%25 = shufflevector <16 x i8> %24, <16 x i8> poison, <16 x i32> <i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
%26 = getelementptr inbounds i8, i8* %0, i64 %13
%27 = bitcast i8* %26 to <16 x i8>*
store <16 x i8> %20, <16 x i8>* %27
%28 = getelementptr inbounds i8, i8* %26, i64 16
%29 = bitcast i8* %28 to <16 x i8>*
store <16 x i8> %25, <16 x i8>* %29
%30 = add nuw i64 %13, 32
%31 = icmp eq i64 %30, %11
br i1 %31, label %32, label %12
32: ; preds = %12
%33 = icmp eq i64 %2, %11
br i1 %33, label %69, label %34
34: ; preds = %32
%35 = and i64 %2, 31
%36 = and i64 %2, 24
%37 = icmp eq i64 %36, 0
br i1 %37, label %57, label %38
38: ; preds = %8, %34
%39 = phi i64 [ %11, %34 ], [ 0, %8 ]
%40 = and i64 %2, -8
%41 = and i64 %2, 7
%42 = getelementptr inbounds i8, i8* %3, i64 -7
br label %43
43: ; preds = %43, %38
%44 = phi i64 [ %39, %38 ], [ %53, %43 ]
%45 = xor i64 %44, -1
%46 = add i64 %2, %45
%47 = getelementptr inbounds i8, i8* %42, i64 %46
%48 = bitcast i8* %47 to <8 x i8>*
%49 = load <8 x i8>, <8 x i8>* %48
%50 = shufflevector <8 x i8> %49, <8 x i8> poison, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
%51 = getelementptr inbounds i8, i8* %0, i64 %44
%52 = bitcast i8* %51 to <8 x i8>*
store <8 x i8> %50, <8 x i8>* %52
%53 = add nuw i64 %44, 8
%54 = icmp eq i64 %53, %40
br i1 %54, label %55, label %43
55: ; preds = %43
%56 = icmp eq i64 %2, %40
br i1 %56, label %69, label %57
57: ; preds = %6, %34, %55
%58 = phi i64 [ 0, %6 ], [ %11, %34 ], [ %40, %55 ]
%59 = phi i64 [ %2, %6 ], [ %35, %34 ], [ %41, %55 ]
br label %60
60: ; preds = %57, %60
%61 = phi i64 [ %67, %60 ], [ %58, %57 ]
%62 = phi i64 [ %63, %60 ], [ %59, %57 ]
%63 = add i64 %62, -1
%64 = getelementptr inbounds i8, i8* %3, i64 %63
%65 = load i8, i8* %64
%66 = getelementptr inbounds i8, i8* %0, i64 %61
store i8 %65, i8* %66
%67 = add nuw i64 %61, 1
%68 = icmp eq i64 %63, 0
br i1 %68, label %69, label %60
69: ; preds = %60, %32, %55, %1
ret void
}