#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 strlen(char *);
void inverse(char str[]) {
  char t;
  int i, j;
  for (i = 0, j = strlen(str); i < strlen(str) / 2; i++, j--) {
    t = str[i];
    str[i] = str[j - 1];
    str[j - 1] = t;
  }
}


x86 assembly (clang, -O0):
<inverse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jge    11a6 <inverse+0x96>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x9(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x9(%rbp),%dl
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    112f <inverse+0x1f>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inverse>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    $0x2,%eax
jl     1173 <inverse+0x63>
movslq %ebp,%rbp
add    $0xffffffffffffffff,%rbp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl (%r14,%rbx,1),%eax
movzbl (%r14,%rbp,1),%ecx
mov    %cl,(%r14,%rbx,1)
mov    %al,(%r14,%rbp,1)
add    $0x1,%rbx
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
sar    %ecx
movslq %ecx,%rax
add    $0xffffffffffffffff,%rbp
cmp    %rax,%rbx
jl     1140 <inverse+0x30>
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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