#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 fxscanner(char *string) {
  int i = 0, j = 0, cntr = 0;
  int length = 0;
  length = strlen(string) - 1;
  printf("\nfx scan two %s", string);
  while (1) {
    for (j = i; j <= length; j++) {
      stringxy(string, i, j);
      cntr++;
    }
    j = 0;
    i++;
    if (i > length)
      break;
  }
  printf("\n");
  printf("count = %d\n", cntr);
  return (0);
}


x86 assembly (clang, -O0):
<fxscanner>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     11b1 <fxscanner+0x81>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1050 <stringxy@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    117f <fxscanner+0x4f>
movl   $0x0,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x18(%rbp),%eax
jle    11d2 <fxscanner+0xa2>
jmp    11d7 <fxscanner+0xa7>
jmp    1179 <fxscanner+0x49>
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fxscanner>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
call   1040 <strlen@plt>
mov    %eax,%r12d
lea    -0x1(%r12),%ebx
lea    0xe9e(%rip),%rdi
xor    %ebp,%ebp
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
test   %ebx,%ebx
cmovle %ebp,%ebx
mov    %r12d,%r15d
xor    %r13d,%r13d
mov    %ebx,0x4(%rsp)
jmp    118d <fxscanner+0x4d>
nop
lea    0x1(%rbp),%eax
add    $0xffffffff,%r15d
cmp    %ebx,%ebp
mov    %eax,%ebp
je     11bd <fxscanner+0x7d>
cmp    %r12d,%ebp
jge    1180 <fxscanner+0x40>
mov    %ebp,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
call   1060 <stringxy@plt>
add    $0x1,%ebx
cmp    %ebx,%r12d
jne    11a0 <fxscanner+0x60>
add    %r15d,%r13d
mov    0x4(%rsp),%ebx
jmp    1180 <fxscanner+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe42(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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