#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 is_html(char *c, int *index, int max) {
  int i, limit;
  int fakeIndex = *index;
  printf("is_html recupere: %s\n", c);
  limit = ((fakeIndex + 10 - max) > 0 ? max : fakeIndex + 10);
  printf("limite de la recherche a l'index %d\n", limit);
  for (i = fakeIndex; i <= limit; i++) {
    if (c[i] == ';') {
      *index = i;
      printf("saut de %d char\n", i - fakeIndex);
      return 1;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<is_html>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xec9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0xa,%eax
sub    -0x1c(%rbp),%eax
cmp    $0x0,%eax
jle    115b <is_html+0x4b>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
jmp    1164 <is_html+0x54>
mov    -0x28(%rbp),%eax
add    $0xa,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%esi
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x24(%rbp),%eax
jg     11de <is_html+0xce>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3b,%eax
jne    11cb <is_html+0xbb>
mov    -0x20(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%esi
sub    -0x28(%rbp),%esi
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11e5 <is_html+0xd5>
jmp    11d0 <is_html+0xc0>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1181 <is_html+0x71>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_html>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%r15
mov    (%rsi),%r12d
lea    0xed6(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xa(%r12),%ebx
cmp    %ebp,%ebx
cmovg  %ebp,%ebx
lea    0xed1(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
cmp    %ebx,%r12d
jg     1197 <is_html+0x87>
movslq %r12d,%rax
add    %rax,%r15
mov    %r12d,%eax
not    %ebx
add    %rax,%rbx
xor    %esi,%esi
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmpb   $0x3b,(%r15,%rsi,1)
je     1183 <is_html+0x73>
add    $0x1,%rsi
mov    %ebx,%eax
add    %esi,%eax
jne    1170 <is_html+0x60>
jmp    1197 <is_html+0x87>
add    %esi,%r12d
mov    %r12d,(%r14)
lea    0xeab(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"is_html recupere: %s\0A\00"
@.str.1 = [37 x i8] c"limite de la recherche a l'index %d\0A\00"
@.str.2 = [17 x i8] c"saut de %d char\0A\00"
define i32 @is_html(i8* %0, i32* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %5
store i32* %1, i32** %6
store i32 %2, i32* %7
%11 = load i32*, i32** %6
%12 = load i32, i32* %11
store i32 %12, i32* %10
%13 = load i8*, i8** %5
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = load i32, i32* %10
%16 = add nsw i32 %15, 10
%17 = load i32, i32* %7
%18 = sub nsw i32 %16, %17
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %3
%21 = load i32, i32* %7
br label %25
22: ; preds = %3
%23 = load i32, i32* %10
%24 = add nsw i32 %23, 10
br label %25
25: ; preds = %22, %20
%26 = phi i32 [ %21, %20 ], [ %24, %22 ]
store i32 %26, i32* %9
%27 = load i32, i32* %9
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %27)
%29 = load i32, i32* %10
store i32 %29, i32* %8
br label %30
30: ; preds = %50, %25
%31 = load i32, i32* %8
%32 = load i32, i32* %9
%33 = icmp sle i32 %31, %32
br i1 %33, label %34, label %53
34: ; preds = %30
%35 = load i8*, i8** %5
%36 = load i32, i32* %8
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %40, 59
br i1 %41, label %42, label %49
42: ; preds = %34
%43 = load i32, i32* %8
%44 = load i32*, i32** %6
store i32 %43, i32* %44
%45 = load i32, i32* %8
%46 = load i32, i32* %10
%47 = sub nsw i32 %45, %46
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %47)
store i32 1, i32* %4
br label %54
49: ; preds = %34
br label %50
50: ; preds = %49
%51 = load i32, i32* %8
%52 = add nsw i32 %51, 1
store i32 %52, i32* %8
br label %30
53: ; preds = %30
store i32 1, i32* %4
br label %54
54: ; preds = %53, %42
%55 = load i32, i32* %4
ret i32 %55
}

LLVM IR (-O2):
@.str = [22 x i8] c"is_html recupere: %s\0A\00"
@.str.1 = [37 x i8] c"limite de la recherche a l'index %d\0A\00"
@.str.2 = [17 x i8] c"saut de %d char\0A\00"
define i32 @is_html(i8* %0, i32* nocapture %1, i32 %2) {
%4 = load i32, i32* %1
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %0)
%6 = add nsw i32 %4, 10
%7 = icmp sgt i32 %6, %2
%8 = select i1 %7, i32 %2, i32 %6
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = icmp sgt i32 %4, %8
br i1 %10, label %27, label %11
11: ; preds = %3
%12 = sext i32 %4 to i64
%13 = add i32 %8, 1
br label %14
14: ; preds = %11, %23
%15 = phi i64 [ %12, %11 ], [ %24, %23 ]
%16 = getelementptr inbounds i8, i8* %0, i64 %15
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 59
br i1 %18, label %19, label %23
19: ; preds = %14
%20 = trunc i64 %15 to i32
store i32 %20, i32* %1
%21 = sub nsw i32 %20, %4
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %21)
br label %27
23: ; preds = %14
%24 = add nsw i64 %15, 1
%25 = trunc i64 %24 to i32
%26 = icmp eq i32 %13, %25
br i1 %26, label %27, label %14
27: ; preds = %23, %3, %19
ret i32 1
}