#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 EXIT_SUCCESS;
int my_strlen(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ swap(char *, char *);
int main(int argc, char *argv[]) {
  char string[100];
  scanf("%99s", string);
  int length = 0;
  length = my_strlen(string);
  int i = 0;
  while (i < length / 2) {
    swap(&string[i], &string[length - i - 1]);
    i++;
  }
  printf("my string is: %s\n", string);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x80(%rbp),%rsi
lea    0xe9c(%rip),%rdi
call   1050 <scanf@plt>
movl   $0x0,-0x84(%rbp)
lea    -0x80(%rbp),%rdi
call   1030 <my_strlen@plt>
mov    %eax,-0x84(%rbp)
movl   $0x0,-0x88(%rbp)
mov    -0x88(%rbp),%eax
mov    %eax,-0x8c(%rbp)
mov    -0x84(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x8c(%rbp),%eax
cmp    %ecx,%eax
jge    11f5 <main+0xb5>
movslq -0x88(%rbp),%rax
lea    -0x80(%rbp),%rdi
add    %rax,%rdi
mov    -0x84(%rbp),%eax
sub    -0x88(%rbp),%eax
sub    $0x1,%eax
cltq
lea    -0x80(%rbp),%rsi
add    %rax,%rsi
call   1060 <swap@plt>
mov    -0x88(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
jmp    118c <main+0x4c>
lea    -0x80(%rbp),%rsi
lea    0xe05(%rip),%rdi
call   1040 <printf@plt>
mov    0x2dd4(%rip),%rax
mov    (%rax),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x70,%rsp
lea    0xeb0(%rip),%rdi
mov    %rsp,%r14
mov    %r14,%rsi
call   1050 <scanf@plt>
mov    %r14,%rdi
call   1030 <my_strlen@plt>
cmp    $0x2,%eax
jl     119c <main+0x5c>
mov    %eax,%ebx
mov    %eax,%r15d
shr    %r15d
add    $0xffffffff,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movslq %ebx,%rbx
lea    (%rsp,%rbx,1),%rsi
mov    %r14,%rdi
call   1060 <swap@plt>
add    $0xffffffff,%ebx
add    $0x1,%r14
add    $0xffffffffffffffff,%r15
jne    1180 <main+0x40>
lea    0xe62(%rip),%rdi
mov    %rsp,%rsi
call   1040 <printf@plt>
mov    0x2e2e(%rip),%rax
mov    (%rax),%eax
add    $0x70,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%99s\00"
@.str.1 = [18 x i8] c"my string is: %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [100 x i8]
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%10 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %9)
store i32 0, i32* %7
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%12 = call i32 @my_strlen(i8* %11)
store i32 %12, i32* %7
store i32 0, i32* %8
br label %13
13: ; preds = %18, %2
%14 = load i32, i32* %8
%15 = load i32, i32* %7
%16 = sdiv i32 %15, 2
%17 = icmp slt i32 %14, %16
br i1 %17, label %18, label %31
18: ; preds = %13
%19 = load i32, i32* %8
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 %20
%22 = load i32, i32* %7
%23 = load i32, i32* %8
%24 = sub nsw i32 %22, %23
%25 = sub nsw i32 %24, 1
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 %26
%28 = call i32 @swap(i8* %21, i8* %27)
%29 = load i32, i32* %8
%30 = add nsw i32 %29, 1
store i32 %30, i32* %8
br label %13
31: ; preds = %13
%32 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%33 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %32)
%34 = load i32, i32* @EXIT_SUCCESS
ret i32 %34
}

LLVM IR (-O2):
@.str = [5 x i8] c"%99s\00"
@.str.1 = [18 x i8] c"my string is: %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%5 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = call i32 @my_strlen(i8* %4)
%7 = icmp sgt i32 %6, 1
br i1 %7, label %8, label %22
8: ; preds = %2
%9 = lshr i32 %6, 1
%10 = zext i32 %9 to i64
br label %11
11: ; preds = %8, %11
%12 = phi i64 [ 0, %8 ], [ %20, %11 ]
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %12
%14 = trunc i64 %12 to i32
%15 = xor i32 %14, -1
%16 = add i32 %6, %15
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %17
%19 = call i32 @swap(i8* %13, i8* %18)
%20 = add nuw nsw i64 %12, 1
%21 = icmp eq i64 %20, %10
br i1 %21, label %22, label %11
22: ; preds = %11, %2
%23 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%24 = load i32, i32* @EXIT_SUCCESS
ret i32 %24
}