#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 /*<<< orphan*/ 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;
  my_strlen(string);
  int i = 0;
  while (i <= length) {
    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>
movl   $0x0,-0x88(%rbp)
mov    -0x88(%rbp),%eax
cmp    -0x84(%rbp),%eax
jg     11d5 <main+0x95>
movslq -0x88(%rbp),%rax
mov    -0x80(%rbp,%rax,1),%cl
mov    -0x84(%rbp),%eax
sub    -0x88(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl %cl,%edi
movsbl -0x80(%rbp,%rax,1),%esi
call   1060 <swap@plt>
mov    -0x88(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
jmp    1186 <main+0x46>
lea    -0x80(%rbp),%rsi
lea    0xe25(%rip),%rdi
call   1040 <printf@plt>
mov    0x2df4(%rip),%rax
mov    (%rax),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x70,%rsp
lea    0xeb4(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    %rbx,%rdi
call   1030 <my_strlen@plt>
movsbl (%rsp),%edi
movsbl -0x1(%rsp),%esi
call   1060 <swap@plt>
lea    0xe91(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    0x2e5d(%rip),%rax
mov    (%rax),%eax
add    $0x70,%rsp
pop    %rbx
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 0, i32* %8
br label %13
13: ; preds = %17, %2
%14 = load i32, i32* %8
%15 = load i32, i32* %7
%16 = icmp sle i32 %14, %15
br i1 %16, label %17, label %32
17: ; preds = %13
%18 = load i32, i32* %8
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 %19
%21 = load i8, i8* %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 = load i8, i8* %27
%29 = call i32 @swap(i8 signext %21, i8 signext %28)
%30 = load i32, i32* %8
%31 = add nsw i32 %30, 1
store i32 %31, i32* %8
br label %13
32: ; preds = %13
%33 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%34 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %33)
%35 = load i32, i32* @EXIT_SUCCESS
ret i32 %35
}

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 = load i8, i8* %4
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 -1
%9 = load i8, i8* %8
%10 = call i32 @swap(i8 signext %7, i8 signext %9)
%11 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%12 = load i32, i32* @EXIT_SUCCESS
ret i32 %12
}