#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*/ stringxy(char *, int, int);
int strlen(char *);
int bdiranner(char *string) {
  int i = 0, j, k, ctr = 0;
  int length = 0;
  length = strlen(string) - 1;
  printf("\nbackward scan two %s", string);
  for (i = length; i >= 0; i--)
    for (j = 0; j <= length; j++) {
      if (j >= i)
        stringxy(string, i, j);
    }
  printf("\n");
  return (0);
}


x86 assembly (clang, -O0):
<bdiranner>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jl     11d6 <bdiranner+0xa6>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jg     11c3 <bdiranner+0x93>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jl     11b0 <bdiranner+0x80>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1050 <stringxy@plt>
jmp    11b5 <bdiranner+0x85>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1189 <bdiranner+0x59>
jmp    11c8 <bdiranner+0x98>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1178 <bdiranner+0x48>
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bdiranner>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r14
call   1040 <strlen@plt>
mov    %eax,%r15d
lea    0xea6(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
test   %r15d,%r15d
jle    11aa <bdiranner+0x6a>
mov    %r15d,%ebp
jmp    1176 <bdiranner+0x36>
xchg   %ax,%ax
cmp    $0x2,%r12d
jl     11aa <bdiranner+0x6a>
mov    %ebp,%r12d
lea    -0x1(%r12),%ebp
xor    %ebx,%ebx
jmp    1198 <bdiranner+0x58>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%ebx
cmp    %ebx,%r15d
je     1170 <bdiranner+0x30>
cmp    %ebp,%ebx
jl     1190 <bdiranner+0x50>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
call   1060 <stringxy@plt>
jmp    1190 <bdiranner+0x50>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"\0Abackward scan two %s\00"
@.str.1 = [2 x i8] c"\0A\00"
define i32 @bdiranner(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
store i32 0, i32* %6
store i32 0, i32* %7
%8 = load i8*, i8** %2
%9 = call i32 @strlen(i8* %8)
%10 = sub nsw i32 %9, 1
store i32 %10, i32* %7
%11 = load i8*, i8** %2
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = load i32, i32* %7
store i32 %13, i32* %3
br label %14
14: ; preds = %36, %1
%15 = load i32, i32* %3
%16 = icmp sge i32 %15, 0
br i1 %16, label %17, label %39
17: ; preds = %14
store i32 0, i32* %4
br label %18
18: ; preds = %32, %17
%19 = load i32, i32* %4
%20 = load i32, i32* %7
%21 = icmp sle i32 %19, %20
br i1 %21, label %22, label %35
22: ; preds = %18
%23 = load i32, i32* %4
%24 = load i32, i32* %3
%25 = icmp sge i32 %23, %24
br i1 %25, label %26, label %31
26: ; preds = %22
%27 = load i8*, i8** %2
%28 = load i32, i32* %3
%29 = load i32, i32* %4
%30 = call i32 @stringxy(i8* %27, i32 %28, i32 %29)
br label %31
31: ; preds = %26, %22
br label %32
32: ; preds = %31
%33 = load i32, i32* %4
%34 = add nsw i32 %33, 1
store i32 %34, i32* %4
br label %18
35: ; preds = %18
br label %36
36: ; preds = %35
%37 = load i32, i32* %3
%38 = add nsw i32 %37, -1
store i32 %38, i32* %3
br label %14
39: ; preds = %14
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [22 x i8] c"\0Abackward scan two %s\00"
define i32 @bdiranner(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %0)
%4 = icmp sgt i32 %2, 0
br i1 %4, label %7, label %18
5: ; preds = %15
%6 = icmp sgt i32 %8, 1
br i1 %6, label %7, label %18
7: ; preds = %1, %5
%8 = phi i32 [ %9, %5 ], [ %2, %1 ]
%9 = add nsw i32 %8, -1
br label %10
10: ; preds = %7, %15
%11 = phi i32 [ %16, %15 ], [ 0, %7 ]
%12 = icmp slt i32 %11, %9
br i1 %12, label %15, label %13
13: ; preds = %10
%14 = tail call i32 @stringxy(i8* %0, i32 %9, i32 %11)
br label %15
15: ; preds = %10, %13
%16 = add nuw nsw i32 %11, 1
%17 = icmp eq i32 %16, %2
br i1 %17, label %5, label %10
18: ; preds = %5, %1
%19 = tail call i32 @putchar(i32 10)
ret i32 0
}