int main() {
  char str[100], p, (*ptr) = &str[100];
  int i, j, n, k;
  printf("Enter the string\n");
  scanf("%s", str);
  i = 0;
  while (i < 100 && (ptr + i) != '\0') {
    i += 1;
  }
  n = i;
  printf("The reversed string is \n");
  for (j = 0; j <= n / 2; j++) {
    p = *(ptr + j);
    *(ptr + j) = *(ptr + (n - j));
    *(ptr + (n - j)) = p;
  }
  printf("%s", str);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x70(%rbp),%rax
add    $0x64,%rax
mov    %rax,-0x80(%rbp)
lea    0xebb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x70(%rbp),%rsi
lea    0xebb(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x0,-0x84(%rbp)
xor    %eax,%eax
cmpl   $0x64,-0x84(%rbp)
mov    %al,-0x91(%rbp)
jge    1198 <main+0x78>
mov    -0x80(%rbp),%rax
movslq -0x84(%rbp),%rcx
add    %rcx,%rax
cmp    $0x0,%rax
setne  %al
mov    %al,-0x91(%rbp)
mov    -0x91(%rbp),%al
test   $0x1,%al
jne    11ab <main+0x8b>
jmp    11bf <main+0x9f>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    1168 <main+0x48>
mov    -0x84(%rbp),%eax
mov    %eax,-0x8c(%rbp)
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x88(%rbp)
mov    -0x88(%rbp),%eax
mov    %eax,-0x98(%rbp)
mov    -0x8c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x98(%rbp),%eax
cmp    %ecx,%eax
jg     126f <main+0x14f>
mov    -0x80(%rbp),%rax
movslq -0x88(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x71(%rbp)
mov    -0x80(%rbp),%rax
mov    -0x8c(%rbp),%ecx
sub    -0x88(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x80(%rbp),%rax
movslq -0x88(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x71(%rbp),%dl
mov    -0x80(%rbp),%rax
mov    -0x8c(%rbp),%ecx
sub    -0x88(%rbp),%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x88(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
jmp    11e3 <main+0xc3>
lea    -0x70(%rbp),%rsi
lea    0xd98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x70,%rsp
lea    0xec7(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb8(%rip),%rdi
xor    %ebx,%ebx
mov    %rsp,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xeb9(%rip),%rdi
call   1030 <puts@plt>
lea    0xc8(%rsp),%rax
nopl   0x0(%rax,%rax,1)
movzbl 0x64(%rsp,%rbx,1),%ecx
movzbl (%rax),%edx
mov    %dl,0x64(%rsp,%rbx,1)
mov    %cl,(%rax)
movzbl 0x65(%rsp,%rbx,1),%ecx
movzbl -0x1(%rax),%edx
mov    %dl,0x65(%rsp,%rbx,1)
mov    %cl,-0x1(%rax)
movzbl 0x66(%rsp,%rbx,1),%ecx
movzbl -0x2(%rax),%edx
mov    %dl,0x66(%rsp,%rbx,1)
mov    %cl,-0x2(%rax)
add    $0x3,%rbx
add    $0xfffffffffffffffd,%rax
cmp    $0x33,%rbx
jne    1170 <main+0x40>
lea    0xe4d(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Enter the string\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [25 x i8] c"The reversed string is \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca i8
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 100
store i8* %9, i8** %4
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %11)
store i32 0, i32* %5
br label %13
13: ; preds = %24, %0
%14 = load i32, i32* %5
%15 = icmp slt i32 %14, 100
br i1 %15, label %16, label %22
16: ; preds = %13
%17 = load i8*, i8** %4
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = icmp ne i8* %20, null
br label %22
22: ; preds = %16, %13
%23 = phi i1 [ false, %13 ], [ %21, %16 ]
br i1 %23, label %24, label %27
24: ; preds = %22
%25 = load i32, i32* %5
%26 = add nsw i32 %25, 1
store i32 %26, i32* %5
br label %13
27: ; preds = %22
%28 = load i32, i32* %5
store i32 %28, i32* %7
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %6
br label %30
30: ; preds = %59, %27
%31 = load i32, i32* %6
%32 = load i32, i32* %7
%33 = sdiv i32 %32, 2
%34 = icmp sle i32 %31, %33
br i1 %34, label %35, label %62
35: ; preds = %30
%36 = load i8*, i8** %4
%37 = load i32, i32* %6
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %36, i64 %38
%40 = load i8, i8* %39
store i8 %40, i8* %3
%41 = load i8*, i8** %4
%42 = load i32, i32* %7
%43 = load i32, i32* %6
%44 = sub nsw i32 %42, %43
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* %41, i64 %45
%47 = load i8, i8* %46
%48 = load i8*, i8** %4
%49 = load i32, i32* %6
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %48, i64 %50
store i8 %47, i8* %51
%52 = load i8, i8* %3
%53 = load i8*, i8** %4
%54 = load i32, i32* %7
%55 = load i32, i32* %6
%56 = sub nsw i32 %54, %55
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8, i8* %53, i64 %57
store i8 %52, i8* %58
br label %59
59: ; preds = %35
%60 = load i32, i32* %6
%61 = add nsw i32 %60, 1
store i32 %61, i32* %6
br label %30
62: ; preds = %30
%63 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %63)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%s\00"
@str = [17 x i8] c"Enter the string\00"
@str.3 = [24 x i8] c"The reversed string is \00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%4 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 100
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.3, i64 0, i64 0))
br label %7
7: ; preds = %7, %0
%8 = phi i64 [ 0, %0 ], [ %26, %7 ]
%9 = getelementptr inbounds i8, i8* %5, i64 %8
%10 = load i8, i8* %9
%11 = sub nuw nsw i64 100, %8
%12 = getelementptr inbounds i8, i8* %5, i64 %11
%13 = load i8, i8* %12
store i8 %13, i8* %9
store i8 %10, i8* %12
%14 = add nuw nsw i64 %8, 1
%15 = getelementptr inbounds i8, i8* %5, i64 %14
%16 = load i8, i8* %15
%17 = sub nsw i64 99, %8
%18 = getelementptr inbounds i8, i8* %5, i64 %17
%19 = load i8, i8* %18
store i8 %19, i8* %15
store i8 %16, i8* %18
%20 = add nuw nsw i64 %8, 2
%21 = getelementptr inbounds i8, i8* %5, i64 %20
%22 = load i8, i8* %21
%23 = sub nsw i64 98, %8
%24 = getelementptr inbounds i8, i8* %5, i64 %23
%25 = load i8, i8* %24
store i8 %25, i8* %21
store i8 %22, i8* %24
%26 = add nuw nsw i64 %8, 3
%27 = icmp eq i64 %26, 51
br i1 %27, label %28, label %7
28: ; preds = %7
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
ret i32 0
}