#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 *, ...);
size_t strlen(char *);
void print_reverse_2(char *s) {
  printf("Your word is %lu letters long\n", strlen(s));
  size_t len = strlen(s);
  char reversed_word[len + 1];
  int i = 0;
  char *t = s + len - 1;
  while (t >= s) {
    reversed_word[i] = *t;
    i++;
    t--;
  }
  printf("\n");
  printf("%s", reversed_word);
  printf("\n");
}


x86 assembly (clang, -O0):
<print_reverse_2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rsi
lea    0xec1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdx
mov    %rdx,%rax
add    $0x1,%rax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
add    $0x10,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x8(%rbp),%rax
add    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x8(%rbp),%rax
jb     11ce <print_reverse_2+0xae>
mov    -0x38(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rcx),%dl
movslq -0x24(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x30(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x30(%rbp)
jmp    1195 <print_reverse_2+0x75>
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x38(%rbp),%rsi
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_reverse_2>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
mov    %rdi,%r14
call   1040 <strlen@plt>
lea    0xeba(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %rsp,%rbx
lea    0x10(%rax),%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%rbx
mov    %rbx,%rsp
lea    (%r14,%rax,1),%rcx
add    $0xffffffffffffffff,%rcx
cmp    %r14,%rcx
jb     12e2 <print_reverse_2+0x1b2>
lea    (%rax,%r14,1),%r8
mov    $0x1,%r10d
sub    %r8,%r10
mov    %r14,%r9
neg    %r9
cmp    %r9,%r10
cmovbe %r9,%r10
add    %r8,%r10
cmp    $0x8,%r10
jae    11a4 <print_reverse_2+0x74>
xor    %edx,%edx
jmp    12c7 <print_reverse_2+0x197>
cmp    $0x20,%r10
jae    11b1 <print_reverse_2+0x81>
xor    %edx,%edx
jmp    125c <print_reverse_2+0x12c>
mov    %r10,%rdx
and    $0xffffffffffffffe0,%rdx
lea    (%rax,%r14,1),%rdi
add    $0xfffffffffffffff0,%rdi
xor    %esi,%esi
pxor   %xmm0,%xmm0
cs nopw 0x0(%rax,%rax,1)
movdqu -0x10(%rdi),%xmm1
movdqu (%rdi),%xmm2
movdqa %xmm2,%xmm3
punpcklbw %xmm0,%xmm3
pshufd $0x4e,%xmm3,%xmm3
pshuflw $0x1b,%xmm3,%xmm3
pshufhw $0x1b,%xmm3,%xmm3
punpckhbw %xmm0,%xmm2
pshufd $0x4e,%xmm2,%xmm2
pshuflw $0x1b,%xmm2,%xmm2
pshufhw $0x1b,%xmm2,%xmm2
packuswb %xmm3,%xmm2
movdqa %xmm1,%xmm3
punpcklbw %xmm0,%xmm3
pshufd $0x4e,%xmm3,%xmm3
pshuflw $0x1b,%xmm3,%xmm3
pshufhw $0x1b,%xmm3,%xmm3
punpckhbw %xmm0,%xmm1
pshufd $0x4e,%xmm1,%xmm1
pshuflw $0x1b,%xmm1,%xmm1
pshufhw $0x1b,%xmm1,%xmm1
packuswb %xmm3,%xmm1
movdqa %xmm2,(%rbx,%rsi,1)
movdqa %xmm1,0x10(%rbx,%rsi,1)
add    $0x20,%rsi
add    $0xffffffffffffffe0,%rdi
cmp    %rsi,%rdx
jne    11d0 <print_reverse_2+0xa0>
cmp    %rdx,%r10
je     12e2 <print_reverse_2+0x1b2>
test   $0x18,%r10b
je     12c4 <print_reverse_2+0x194>
mov    $0x1,%esi
sub    %r8,%rsi
cmp    %r9,%rsi
cmovbe %r9,%rsi
mov    %rdx,%rdi
add    %r8,%rsi
mov    %rsi,%rdx
and    $0xfffffffffffffff8,%rdx
sub    %rdx,%rcx
sub    %rdi,%rax
add    %r14,%rax
add    $0xfffffffffffffff8,%rax
pxor   %xmm0,%xmm0
nopl   0x0(%rax)
movq   (%rax),%xmm1
punpcklbw %xmm0,%xmm1
pshufd $0x4e,%xmm1,%xmm1
pshuflw $0x1b,%xmm1,%xmm1
pshufhw $0x1b,%xmm1,%xmm1
packuswb %xmm1,%xmm1
movq   %xmm1,(%rbx,%rdi,1)
add    $0x8,%rdi
add    $0xfffffffffffffff8,%rax
cmp    %rdi,%rdx
jne    1290 <print_reverse_2+0x160>
cmp    %rdx,%rsi
jne    12c7 <print_reverse_2+0x197>
jmp    12e2 <print_reverse_2+0x1b2>
sub    %rdx,%rcx
add    %rbx,%rdx
nopw   0x0(%rax,%rax,1)
movzbl (%rcx),%eax
mov    %al,(%rdx)
add    $0xffffffffffffffff,%rcx
add    $0x1,%rdx
cmp    %r14,%rcx
jae    12d0 <print_reverse_2+0x1a0>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xd2c(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    -0x10(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [31 x i8] c"Your word is %lu letters long\0A\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [3 x i8] c"%s\00"
define void @print_reverse_2(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i32
%7 = alloca i8*
store i8* %0, i8** %2
%8 = load i8*, i8** %2
%9 = call i64 @strlen(i8* %8)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i64 %9)
%11 = load i8*, i8** %2
%12 = call i64 @strlen(i8* %11)
store i64 %12, i64* %3
%13 = load i64, i64* %3
%14 = add i64 %13, 1
%15 = call i8* @llvm.stacksave()
store i8* %15, i8** %4
%16 = alloca i8, i64 %14
store i64 %14, i64* %5
store i32 0, i32* %6
%17 = load i8*, i8** %2
%18 = load i64, i64* %3
%19 = getelementptr inbounds i8, i8* %17, i64 %18
%20 = getelementptr inbounds i8, i8* %19, i64 -1
store i8* %20, i8** %7
br label %21
21: ; preds = %25, %1
%22 = load i8*, i8** %7
%23 = load i8*, i8** %2
%24 = icmp uge i8* %22, %23
br i1 %24, label %25, label %35
25: ; preds = %21
%26 = load i8*, i8** %7
%27 = load i8, i8* %26
%28 = load i32, i32* %6
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %16, i64 %29
store i8 %27, i8* %30
%31 = load i32, i32* %6
%32 = add nsw i32 %31, 1
store i32 %32, i32* %6
%33 = load i8*, i8** %7
%34 = getelementptr inbounds i8, i8* %33, i32 -1
store i8* %34, i8** %7
br label %21
35: ; preds = %21
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %16)
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%39 = load i8*, i8** %4
ret void
}

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