#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int main() {
  char st[40], stInv[40];
  int i, j, tam = 0;
  printf("Digite a string :");
  scanf("%s", st);
  while (st[tam] != '\0' && tam < 40) {
    tam++;
  }
  stInv[tam] = '\0';
  j = tam - 1;
  i = 0;
  while (i < tam) {
    stInv[j] = st[i];
    i++;
    j--;
  }
  printf("Inversa : %s\n", stInv);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x6c(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x30(%rbp),%rsi
lea    0xec3(%rip),%rdi
call   1040 <scanf@plt>
movslq -0x6c(%rbp),%rax
movsbl -0x30(%rbp,%rax,1),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x6d(%rbp)
je     1175 <main+0x55>
cmpl   $0x28,-0x6c(%rbp)
setl   %al
mov    %al,-0x6d(%rbp)
mov    -0x6d(%rbp),%al
test   $0x1,%al
jne    1185 <main+0x65>
jmp    1193 <main+0x73>
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
jmp    1154 <main+0x34>
movslq -0x6c(%rbp),%rax
movb   $0x0,-0x60(%rbp,%rax,1)
mov    -0x6c(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x68(%rbp)
movl   $0x0,-0x64(%rbp)
mov    -0x64(%rbp),%eax
cmp    -0x6c(%rbp),%eax
jge    11df <main+0xbf>
movslq -0x64(%rbp),%rax
mov    -0x30(%rbp,%rax,1),%cl
movslq -0x68(%rbp),%rax
mov    %cl,-0x60(%rbp,%rax,1)
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
mov    -0x68(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x68(%rbp)
jmp    11ac <main+0x8c>
lea    -0x60(%rbp),%rsi
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x60,%rsp
lea    0xed4(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed6(%rip),%rdi
mov    %rsp,%rsi
call   1040 <scanf@plt>
lea    0x27(%rsp),%rcx
nopl   0x0(%rax)
lea    0x1(%rbx),%rax
add    $0x1,%rcx
cmpb   $0x0,(%rsp,%rbx,1)
je     1167 <main+0x47>
cmp    $0x28,%rbx
mov    %rax,%rbx
jb     1150 <main+0x30>
movb   $0x0,0x8(%rcx)
cmp    $0x1,%eax
je     12b3 <main+0x193>
add    $0xffffffffffffffff,%rax
cmp    $0x8,%rax
jae    1188 <main+0x68>
xor    %edx,%edx
mov    %rax,%rsi
jmp    1292 <main+0x172>
movabs $0x7ffffffffffffff0,%rsi
ff ff 7f
cmp    $0x10,%rax
jae    119f <main+0x7f>
xor    %edx,%edx
jmp    1234 <main+0x114>
mov    %rax,%rdx
and    %rsi,%rdx
movdqa (%rsp),%xmm1
pxor   %xmm0,%xmm0
movdqa %xmm1,%xmm2
punpcklbw %xmm0,%xmm2
pshufd $0x4e,%xmm2,%xmm2
pshuflw $0x1b,%xmm2,%xmm2
pshufhw $0x1b,%xmm2,%xmm2
punpckhbw %xmm0,%xmm1
pshufd $0x4e,%xmm1,%xmm1
pshuflw $0x1b,%xmm1,%xmm1
pshufhw $0x1b,%xmm1,%xmm1
packuswb %xmm2,%xmm1
movdqu %xmm1,-0x8(%rcx)
cmp    $0x10,%rdx
je     1220 <main+0x100>
movdqa 0x10(%rsp),%xmm1
movdqa %xmm1,%xmm2
punpcklbw %xmm0,%xmm2
pshufd $0x4e,%xmm2,%xmm2
pshuflw $0x1b,%xmm2,%xmm2
pshufhw $0x1b,%xmm2,%xmm2
punpckhbw %xmm0,%xmm1
pshufd $0x4e,%xmm1,%xmm0
pshuflw $0x1b,%xmm0,%xmm0
pshufhw $0x1b,%xmm0,%xmm0
packuswb %xmm2,%xmm0
movdqu %xmm0,-0x18(%rcx)
cmp    %rdx,%rax
je     12b3 <main+0x193>
test   $0x8,%al
jne    1234 <main+0x114>
mov    %eax,%esi
and    $0xf,%esi
jmp    1292 <main+0x172>
mov    %rdx,%rdi
add    $0x8,%rsi
mov    %rsi,%rdx
and    %rax,%rdx
mov    %eax,%esi
and    $0x7,%esi
sub    %rdi,%rcx
mov    %rax,%rbx
and    $0xfffffffffffffff8,%rbx
pxor   %xmm0,%xmm0
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movq   (%rsp,%rdi,1),%xmm1
punpcklbw %xmm0,%xmm1
pshufd $0x4e,%xmm1,%xmm1
pshuflw $0x1b,%xmm1,%xmm1
pshufhw $0x1b,%xmm1,%xmm1
packuswb %xmm1,%xmm1
movq   %xmm1,(%rcx)
add    $0x8,%rdi
add    $0xfffffffffffffff8,%rcx
cmp    %rdi,%rbx
jne    1260 <main+0x140>
cmp    %rdx,%rax
je     12b3 <main+0x193>
lea    0x30(%rsp),%rcx
add    %rsi,%rcx
add    $0xffffffffffffffff,%rcx
xchg   %ax,%ax
movzbl (%rsp,%rdx,1),%ebx
mov    %bl,(%rcx)
add    $0x1,%rdx
add    $0xffffffffffffffff,%rcx
cmp    %rdx,%rax
jne    12a0 <main+0x180>
lea    0xd5b(%rip),%rdi
lea    0x30(%rsp),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [18 x i8] c"Digite a string :\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [14 x i8] c"Inversa : %s\0A\00"
define i32 @main() {
%1 = alloca [40 x i8]
%2 = alloca [40 x i8]
%3 = getelementptr inbounds [40 x i8], [40 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
br label %7
7: ; preds = %7, %0
%8 = phi i64 [ %14, %7 ], [ 0, %0 ]
%9 = getelementptr inbounds [40 x i8], [40 x i8]* %1, i64 0, i64 %8
%10 = load i8, i8* %9
%11 = icmp ne i8 %10, 0
%12 = icmp ult i64 %8, 40
%13 = select i1 %11, i1 %12, i1 false
%14 = add nuw nsw i64 %8, 1
br i1 %13, label %7, label %15
15: ; preds = %7
%16 = trunc i64 %8 to i32
%17 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 %8
store i8 0, i8* %17
%18 = icmp eq i32 %16, 0
br i1 %18, label %79, label %19
19: ; preds = %15
%20 = icmp ult i64 %8, 8
br i1 %20, label %67, label %21
21: ; preds = %19
%22 = icmp ult i64 %8, 16
br i1 %22, label %48, label %23
23: ; preds = %21
%24 = and i64 %8, 9223372036854775792
%25 = add nsw i64 %8, -1
%26 = bitcast [40 x i8]* %1 to <16 x i8>*
%27 = load <16 x i8>, <16 x i8>* %26
%28 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 %25
%29 = 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>
%30 = getelementptr inbounds i8, i8* %28, i64 -15
%31 = bitcast i8* %30 to <16 x i8>*
store <16 x i8> %29, <16 x i8>* %31
%32 = icmp eq i64 %24, 16
br i1 %32, label %42, label %33
33: ; preds = %23
%34 = add nsw i64 %8, -17
%35 = getelementptr inbounds [40 x i8], [40 x i8]* %1, i64 0, i64 16
%36 = bitcast i8* %35 to <16 x i8>*
%37 = load <16 x i8>, <16 x i8>* %36
%38 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 %34
%39 = shufflevector <16 x i8> %37, <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>
%40 = getelementptr inbounds i8, i8* %38, i64 -15
%41 = bitcast i8* %40 to <16 x i8>*
store <16 x i8> %39, <16 x i8>* %41
br label %42
42: ; preds = %33, %23
%43 = icmp eq i64 %8, %24
br i1 %43, label %79, label %44
44: ; preds = %42
%45 = and i64 %8, 15
%46 = and i64 %8, 8
%47 = icmp eq i64 %46, 0
br i1 %47, label %67, label %48
48: ; preds = %21, %44
%49 = phi i64 [ %24, %44 ], [ 0, %21 ]
%50 = and i64 %8, 9223372036854775800
%51 = and i64 %8, 7
br label %52
52: ; preds = %52, %48
%53 = phi i64 [ %49, %48 ], [ %63, %52 ]
%54 = xor i64 %53, -1
%55 = add i64 %8, %54
%56 = getelementptr inbounds [40 x i8], [40 x i8]* %1, i64 0, i64 %53
%57 = bitcast i8* %56 to <8 x i8>*
%58 = load <8 x i8>, <8 x i8>* %57
%59 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 %55
%60 = shufflevector <8 x i8> %58, <8 x i8> poison, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
%61 = getelementptr inbounds i8, i8* %59, i64 -7
%62 = bitcast i8* %61 to <8 x i8>*
store <8 x i8> %60, <8 x i8>* %62
%63 = add nuw i64 %53, 8
%64 = icmp eq i64 %63, %50
br i1 %64, label %65, label %52
65: ; preds = %52
%66 = icmp eq i64 %8, %50
br i1 %66, label %79, label %67
67: ; preds = %19, %44, %65
%68 = phi i64 [ 0, %19 ], [ %24, %44 ], [ %50, %65 ]
%69 = phi i64 [ %8, %19 ], [ %45, %44 ], [ %51, %65 ]
br label %70
70: ; preds = %67, %70
%71 = phi i64 [ %77, %70 ], [ %68, %67 ]
%72 = phi i64 [ %73, %70 ], [ %69, %67 ]
%73 = add nsw i64 %72, -1
%74 = getelementptr inbounds [40 x i8], [40 x i8]* %1, i64 0, i64 %71
%75 = load i8, i8* %74
%76 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 %73
store i8 %75, i8* %76
%77 = add nuw nsw i64 %71, 1
%78 = icmp eq i64 %77, %8
br i1 %78, label %79, label %70
79: ; preds = %70, %42, %65, %15
%80 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %4)
ret i32 0
}