#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 */
scalar_t__ is_html(char *, int *, int);
int length(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ toNextChar(char *, int *);
int html_count(char *html) {
  printf("html_count recupere: %s\n", html);
  int min, index, max, compte;
  compte = min = index = 0;
  do {
    min++;
  } while (html[min] != '>');
  min++;
  printf("min: %d\n", min);
  max = length(html);
  do {
    max--;
  } while (html[max] != '<');
  printf("max: %d\n", max);
  int minStripSpace = min;
  do {
    minStripSpace++;
  } while (html[minStripSpace] == ' ');
  printf("minStripSpace: %d => %c\n", minStripSpace, html[minStripSpace]);
  int maxStripSpace = max;
  do {
    maxStripSpace--;
  } while (html[maxStripSpace] == ' ');
  printf("maxStripSpace: %d => %c\n", maxStripSpace, html[maxStripSpace]);
  for (index = minStripSpace; index < maxStripSpace + 1; index++) {
    printf("%c, index=%d\n", html[index], index);
    if (html[index] == '&') {
      compte += is_html(html, &index, maxStripSpace);
    } else if (html[index] == ' ') {
      printf("espace\n");
      compte++;
      toNextChar(html, &index);
    } else {
      compte++;
    }
  }
  return compte;
}


x86 assembly (clang, -O0):
<html_count>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3e,%eax
jne    1173 <html_count+0x33>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <length@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3c,%eax
jne    11b7 <html_count+0x77>
mov    -0x14(%rbp),%esi
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
je     11ec <html_count+0xac>
mov    -0x1c(%rbp),%esi
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edx
lea    0xe0b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
je     122d <html_count+0xed>
mov    -0x20(%rbp),%esi
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%edx
lea    0xde3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    1332 <html_count+0x1f2>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
mov    -0x10(%rbp),%edx
lea    0xdc8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x26,%eax
jne    12d3 <html_count+0x193>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%edx
lea    -0x10(%rbp),%rsi
call   1050 <is_html@plt>
mov    %rax,%rcx
movslq -0x18(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x18(%rbp)
jmp    131f <html_count+0x1df>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    1311 <html_count+0x1d1>
lea    0xd7c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1060 <toNextChar@plt>
jmp    131a <html_count+0x1da>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    131f <html_count+0x1df>
jmp    1324 <html_count+0x1e4>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    126e <html_count+0x12e>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<html_count>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xe9b(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%ebx
mov    $0xffffffff,%ebp
nopl   0x0(%rax)
add    $0x1,%ebp
cmpb   $0x3e,(%r14,%rbx,1)
lea    0x1(%rbx),%rbx
jne    1180 <html_count+0x30>
lea    0xe84(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
call   1030 <length@plt>
mov    %eax,%r15d
cltq
add    %r14,%rax
add    $0xffffffffffffffff,%rax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0xffffffff,%r15d
cmpb   $0x3c,(%rax)
lea    -0x1(%rax),%rax
jne    11c0 <html_count+0x70>
lea    0xe4e(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebp,%eax
add    %r14,%rax
add    $0x3,%rax
nopw   0x0(%rax,%rax,1)
movsbl (%rax),%edx
add    $0x1,%ebx
add    $0x1,%rax
cmp    $0x20,%edx
je     11f0 <html_count+0xa0>
lea    0xe25(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movslq %r15d,%rax
add    %r14,%rax
add    $0xffffffffffffffff,%rax
nopl   0x0(%rax)
movsbl (%rax),%edx
add    $0xffffffff,%r15d
add    $0xffffffffffffffff,%rax
cmp    $0x20,%edx
je     1220 <html_count+0xd0>
lea    0x1(%r15),%r13d
lea    0xe09(%rip),%rdi
xor    %ebp,%ebp
mov    %r15d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebx,0x4(%rsp)
cmp    %r13d,%ebx
jge    12c9 <html_count+0x179>
lea    0xe06(%rip),%r12
xor    %ebp,%ebp
jmp    128b <html_count+0x13b>
nopl   0x0(%rax,%rax,1)
lea    0xe04(%rip),%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
lea    0x4(%rsp),%rsi
call   1070 <toNextChar@plt>
add    %ebx,%ebp
mov    0x4(%rsp),%ebx
add    $0x1,%ebx
mov    %ebx,0x4(%rsp)
cmp    %r13d,%ebx
jge    12c9 <html_count+0x179>
movslq %ebx,%rdx
movsbl (%r14,%rdx,1),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movslq 0x4(%rsp),%rax
movzbl (%r14,%rax,1),%eax
mov    $0x1,%ebx
cmp    $0x20,%al
je     1260 <html_count+0x110>
cmp    $0x26,%al
jne    1279 <html_count+0x129>
mov    %r14,%rdi
lea    0x4(%rsp),%rsi
mov    %r15d,%edx
call   1060 <is_html@plt>
mov    %rax,%rbx
jmp    1279 <html_count+0x129>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"html_count recupere: %s\0A\00"
@.str.1 = [9 x i8] c"min: %d\0A\00"
@.str.2 = [9 x i8] c"max: %d\0A\00"
@.str.3 = [25 x i8] c"minStripSpace: %d => %c\0A\00"
@.str.4 = [25 x i8] c"maxStripSpace: %d => %c\0A\00"
@.str.5 = [14 x i8] c"%c, index=%d\0A\00"
@.str.6 = [8 x i8] c"espace\0A\00"
define i32 @html_count(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %2
%9 = load i8*, i8** %2
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %9)
store i32 0, i32* %4
store i32 0, i32* %3
store i32 0, i32* %6
br label %11
11: ; preds = %14, %1
%12 = load i32, i32* %3
%13 = add nsw i32 %12, 1
store i32 %13, i32* %3
br label %14
14: ; preds = %11
%15 = load i8*, i8** %2
%16 = load i32, i32* %3
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 62
br i1 %21, label %11, label %22
22: ; preds = %14
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
%25 = load i32, i32* %3
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %25)
%27 = load i8*, i8** %2
%28 = call i32 @length(i8* %27)
store i32 %28, i32* %5
br label %29
29: ; preds = %32, %22
%30 = load i32, i32* %5
%31 = add nsw i32 %30, -1
store i32 %31, i32* %5
br label %32
32: ; preds = %29
%33 = load i8*, i8** %2
%34 = load i32, i32* %5
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp ne i32 %38, 60
br i1 %39, label %29, label %40
40: ; preds = %32
%41 = load i32, i32* %5
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %41)
%43 = load i32, i32* %3
store i32 %43, i32* %7
br label %44
44: ; preds = %47, %40
%45 = load i32, i32* %7
%46 = add nsw i32 %45, 1
store i32 %46, i32* %7
br label %47
47: ; preds = %44
%48 = load i8*, i8** %2
%49 = load i32, i32* %7
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %48, i64 %50
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = icmp eq i32 %53, 32
br i1 %54, label %44, label %55
55: ; preds = %47
%56 = load i32, i32* %7
%57 = load i8*, i8** %2
%58 = load i32, i32* %7
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i8, i8* %57, i64 %59
%61 = load i8, i8* %60
%62 = sext i8 %61 to i32
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 %56, i32 %62)
%64 = load i32, i32* %5
store i32 %64, i32* %8
br label %65
65: ; preds = %68, %55
%66 = load i32, i32* %8
%67 = add nsw i32 %66, -1
store i32 %67, i32* %8
br label %68
68: ; preds = %65
%69 = load i8*, i8** %2
%70 = load i32, i32* %8
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds i8, i8* %69, i64 %71
%73 = load i8, i8* %72
%74 = sext i8 %73 to i32
%75 = icmp eq i32 %74, 32
br i1 %75, label %65, label %76
76: ; preds = %68
%77 = load i32, i32* %8
%78 = load i8*, i8** %2
%79 = load i32, i32* %8
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds i8, i8* %78, i64 %80
%82 = load i8, i8* %81
%83 = sext i8 %82 to i32
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %77, i32 %83)
%85 = load i32, i32* %7
store i32 %85, i32* %4
br label %86
86: ; preds = %134, %76
%87 = load i32, i32* %4
%88 = load i32, i32* %8
%89 = add nsw i32 %88, 1
%90 = icmp slt i32 %87, %89
br i1 %90, label %91, label %137
91: ; preds = %86
%92 = load i8*, i8** %2
%93 = load i32, i32* %4
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds i8, i8* %92, i64 %94
%96 = load i8, i8* %95
%97 = sext i8 %96 to i32
%98 = load i32, i32* %4
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 %97, i32 %98)
%100 = load i8*, i8** %2
%101 = load i32, i32* %4
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds i8, i8* %100, i64 %102
%104 = load i8, i8* %103
%105 = sext i8 %104 to i32
%106 = icmp eq i32 %105, 38
br i1 %106, label %107, label %115
107: ; preds = %91
%108 = load i8*, i8** %2
%109 = load i32, i32* %8
%110 = call i64 @is_html(i8* %108, i32* %4, i32 %109)
%111 = load i32, i32* %6
%112 = sext i32 %111 to i64
%113 = add nsw i64 %112, %110
%114 = trunc i64 %113 to i32
store i32 %114, i32* %6
br label %133
115: ; preds = %91
%116 = load i8*, i8** %2
%117 = load i32, i32* %4
%118 = sext i32 %117 to i64
%119 = getelementptr inbounds i8, i8* %116, i64 %118
%120 = load i8, i8* %119
%121 = sext i8 %120 to i32
%122 = icmp eq i32 %121, 32
br i1 %122, label %123, label %129
123: ; preds = %115
%124 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%125 = load i32, i32* %6
%126 = add nsw i32 %125, 1
store i32 %126, i32* %6
%127 = load i8*, i8** %2
%128 = call i32 @toNextChar(i8* %127, i32* %4)
br label %132
129: ; preds = %115
%130 = load i32, i32* %6
%131 = add nsw i32 %130, 1
store i32 %131, i32* %6
br label %132
132: ; preds = %129, %123
br label %133
133: ; preds = %132, %107
br label %134
134: ; preds = %133
%135 = load i32, i32* %4
%136 = add nsw i32 %135, 1
store i32 %136, i32* %4
br label %86
137: ; preds = %86
%138 = load i32, i32* %6
ret i32 %138
}

LLVM IR (-O2):
@.str = [25 x i8] c"html_count recupere: %s\0A\00"
@.str.1 = [9 x i8] c"min: %d\0A\00"
@.str.2 = [9 x i8] c"max: %d\0A\00"
@.str.3 = [25 x i8] c"minStripSpace: %d => %c\0A\00"
@.str.4 = [25 x i8] c"maxStripSpace: %d => %c\0A\00"
@.str.5 = [14 x i8] c"%c, index=%d\0A\00"
@str = [7 x i8] c"espace\00"
define i32 @html_count(i8* %0) {
%2 = alloca i32
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %0)
%4 = bitcast i32* %2 to i8*
br label %5
5: ; preds = %5, %1
%6 = phi i64 [ %7, %5 ], [ 0, %1 ]
%7 = add nuw nsw i64 %6, 1
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 62
br i1 %10, label %11, label %5
11: ; preds = %5
%12 = trunc i64 %6 to i32
%13 = add nuw nsw i32 %12, 2
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%15 = tail call i32 @length(i8* %0)
%16 = sext i32 %15 to i64
br label %17
17: ; preds = %17, %11
%18 = phi i64 [ %19, %17 ], [ %16, %11 ]
%19 = add i64 %18, -1
%20 = getelementptr inbounds i8, i8* %0, i64 %19
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 60
br i1 %22, label %23, label %17
23: ; preds = %17
%24 = trunc i64 %19 to i32
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %24)
%26 = and i64 %6, 4294967295
%27 = add nuw nsw i64 %26, 2
br label %28
28: ; preds = %28, %23
%29 = phi i64 [ %30, %28 ], [ %27, %23 ]
%30 = add nuw i64 %29, 1
%31 = getelementptr inbounds i8, i8* %0, i64 %30
%32 = load i8, i8* %31
%33 = icmp eq i8 %32, 32
br i1 %33, label %28, label %34
34: ; preds = %28
%35 = trunc i64 %30 to i32
%36 = sext i8 %32 to i32
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 %35, i32 %36)
%38 = shl i64 %19, 32
%39 = ashr exact i64 %38, 32
br label %40
40: ; preds = %40, %34
%41 = phi i64 [ %42, %40 ], [ %39, %34 ]
%42 = add i64 %41, -1
%43 = getelementptr inbounds i8, i8* %0, i64 %42
%44 = load i8, i8* %43
%45 = icmp eq i8 %44, 32
br i1 %45, label %40, label %46
46: ; preds = %40
%47 = trunc i64 %41 to i32
%48 = trunc i64 %42 to i32
%49 = sext i8 %44 to i32
%50 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %48, i32 %49)
store i32 %35, i32* %2
%51 = icmp slt i32 %35, %47
br i1 %51, label %52, label %76
52: ; preds = %46, %70
%53 = phi i32 [ %72, %70 ], [ 0, %46 ]
%54 = phi i32 [ %74, %70 ], [ %35, %46 ]
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8, i8* %0, i64 %55
%57 = load i8, i8* %56
%58 = sext i8 %57 to i32
%59 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 %58, i32 %54)
%60 = load i32, i32* %2
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8, i8* %0, i64 %61
%63 = load i8, i8* %62
switch i8 %63, label %70 [
i8 38, label %64
i8 32, label %67
]
64: ; preds = %52
%65 = call i64 @is_html(i8* %0, i32* %2, i32 %48)
%66 = trunc i64 %65 to i32
br label %70
67: ; preds = %52
%68 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
%69 = call i32 @toNextChar(i8* %0, i32* %2)
br label %70
70: ; preds = %52, %64, %67
%71 = phi i32 [ %66, %64 ], [ 1, %67 ], [ 1, %52 ]
%72 = add i32 %71, %53
%73 = load i32, i32* %2
%74 = add nsw i32 %73, 1
store i32 %74, i32* %2
%75 = icmp slt i32 %74, %47
br i1 %75, label %52, label %76
76: ; preds = %70, %46
%77 = phi i32 [ 0, %46 ], [ %72, %70 ]
ret i32 %77
}