#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 *);
int sizeofstring(char *);
void reverse_string(char s[]) {
  int i, j;
  char s2[1000];
  copy(s2, s);
  for (i = 0, j = sizeofstring(s) - 2; j >= 0; j--, i++)
    s[i] = s2[j];
}


x86 assembly (clang, -O0):
<reverse_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x400(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <copy@plt>
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <sizeofstring@plt>
sub    $0x2,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jl     118c <reverse_string+0x6c>
movslq -0x10(%rbp),%rax
mov    -0x400(%rbp,%rax,1),%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    1155 <reverse_string+0x35>
add    $0x400,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reverse_string>:
push   %r15
push   %r14
push   %rbx
sub    $0x3f0,%rsp
mov    %rdi,%r15
mov    %rsp,%r14
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <copy@plt>
mov    %r15,%rdi
call   1040 <sizeofstring@plt>
cmp    $0x2,%eax
jl     1294 <reverse_string+0x174>
lea    -0x2(%rax),%r8d
add    $0xffffffff,%eax
cmp    $0x8,%eax
jae    1161 <reverse_string+0x41>
xor    %edx,%edx
jmp    1277 <reverse_string+0x157>
cmp    $0x20,%eax
jae    116d <reverse_string+0x4d>
xor    %edx,%edx
jmp    121a <reverse_string+0xfa>
mov    %eax,%edx
and    $0xffffffe0,%edx
lea    0x10(%r15),%rsi
mov    %rdx,%r9
neg    %r9
lea    (%r8,%r14,1),%rcx
add    $0xfffffffffffffff1,%rcx
xor    %edi,%edi
pxor   %xmm0,%xmm0
nopw   0x0(%rax,%rax,1)
movdqu -0x10(%rcx,%rdi,1),%xmm1
movdqu (%rcx,%rdi,1),%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,-0x10(%rsi)
movdqu %xmm1,(%rsi)
add    $0x20,%rsi
add    $0xffffffffffffffe0,%rdi
cmp    %rdi,%r9
jne    1190 <reverse_string+0x70>
cmp    %rax,%rdx
je     1294 <reverse_string+0x174>
test   $0x18,%al
je     1274 <reverse_string+0x154>
mov    %rdx,%rcx
mov    %eax,%edx
and    $0xfffffff8,%edx
lea    (%r15,%rcx,1),%rsi
mov    %rdx,%rdi
neg    %rdi
neg    %rcx
lea    (%r8,%r14,1),%rbx
add    $0xfffffffffffffff9,%rbx
sub    %rdx,%r8
pxor   %xmm0,%xmm0
xchg   %ax,%ax
movq   (%rbx,%rcx,1),%xmm1
punpcklbw %xmm0,%xmm1
pshufd $0x4e,%xmm1,%xmm1
pshuflw $0x1b,%xmm1,%xmm1
pshufhw $0x1b,%xmm1,%xmm1
packuswb %xmm1,%xmm1
movq   %xmm1,(%rsi)
add    $0x8,%rsi
add    $0xfffffffffffffff8,%rcx
cmp    %rcx,%rdi
jne    1240 <reverse_string+0x120>
cmp    %rax,%rdx
jne    1277 <reverse_string+0x157>
jmp    1294 <reverse_string+0x174>
sub    %rdx,%r8
lea    (%rsp,%r8,1),%rcx
nopl   0x0(%rax,%rax,1)
movzbl (%rcx),%ebx
mov    %bl,(%r15,%rdx,1)
add    $0x1,%rdx
add    $0xffffffffffffffff,%rcx
cmp    %rdx,%rax
jne    1280 <reverse_string+0x160>
add    $0x3f0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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