#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__ isspace(char);
char *memchr(char *, char, int);
int count_cfg_data_lines(char *from, char *to) {
  char *dl = from;
  int count = 0;
  char *eol;
  while (dl < to) {
    while (isspace(*dl))
      dl++;
    count++;
    eol = memchr(dl, '\n', to - dl);
    if (!eol)
      eol = to;
    dl = eol;
  }
  return count - 1;
}


x86 assembly (clang, -O0):
<count_cfg_data_lines>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11c1 <count_cfg_data_lines+0xa1>
jmp    1152 <count_cfg_data_lines+0x32>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isspace@plt>
cmp    $0x0,%rax
je     1179 <count_cfg_data_lines+0x59>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1152 <count_cfg_data_lines+0x32>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
mov    $0xa,%esi
call   1040 <memchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11b4 <count_cfg_data_lines+0x94>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    113f <count_cfg_data_lines+0x1f>
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<count_cfg_data_lines>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0xffffffff,%r15d
cmp    %rsi,%rdi
jae    1197 <count_cfg_data_lines+0x77>
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x1(%rsi),%r12d
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r13d,%r15d
mov    %r12d,%ebp
sub    %ebx,%ebp
add    $0xffffffffffffffff,%rbx
nopl   0x0(%rax)
movsbl 0x1(%rbx),%edi
add    $0x1,%rbx
call   1030 <isspace@plt>
add    $0xffffffff,%ebp
test   %rax,%rax
jne    1160 <count_cfg_data_lines+0x40>
lea    0x1(%r15),%r13d
mov    %rbx,%rdi
mov    $0xa,%esi
mov    %ebp,%edx
call   1040 <memchr@plt>
mov    %rax,%rbx
test   %rax,%rax
cmove  %r14,%rbx
cmp    %r14,%rbx
jb     1150 <count_cfg_data_lines+0x30>
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @count_cfg_data_lines(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = load i8*, i8** %3
store i8* %8, i8** %5
store i32 0, i32* %6
br label %9
9: ; preds = %37, %2
%10 = load i8*, i8** %5
%11 = load i8*, i8** %4
%12 = icmp ult i8* %10, %11
br i1 %12, label %13, label %39
13: ; preds = %9
br label %14
14: ; preds = %19, %13
%15 = load i8*, i8** %5
%16 = load i8, i8* %15
%17 = call i64 @isspace(i8 signext %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %14
%20 = load i8*, i8** %5
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %5
br label %14
22: ; preds = %14
%23 = load i32, i32* %6
%24 = add nsw i32 %23, 1
store i32 %24, i32* %6
%25 = load i8*, i8** %5
%26 = load i8*, i8** %4
%27 = load i8*, i8** %5
%28 = ptrtoint i8* %26 to i64
%29 = ptrtoint i8* %27 to i64
%30 = sub i64 %28, %29
%31 = trunc i64 %30 to i32
%32 = call i8* @memchr(i8* %25, i8 signext 10, i32 %31)
store i8* %32, i8** %7
%33 = load i8*, i8** %7
%34 = icmp ne i8* %33, null
br i1 %34, label %37, label %35
35: ; preds = %22
%36 = load i8*, i8** %4
store i8* %36, i8** %7
br label %37
37: ; preds = %35, %22
%38 = load i8*, i8** %7
store i8* %38, i8** %5
br label %9
39: ; preds = %9
%40 = load i32, i32* %6
%41 = sub nsw i32 %40, 1
ret i32 %41
}

LLVM IR (-O2):
define i32 @count_cfg_data_lines(i8* %0, i8* %1) {
%3 = icmp ult i8* %0, %1
br i1 %3, label %4, label %24
4: ; preds = %2
%5 = ptrtoint i8* %1 to i64
br label %6
6: ; preds = %4, %15
%7 = phi i32 [ 0, %4 ], [ %16, %15 ]
%8 = phi i8* [ %0, %4 ], [ %22, %15 ]
br label %9
9: ; preds = %9, %6
%10 = phi i8* [ %14, %9 ], [ %8, %6 ]
%11 = load i8, i8* %10
%12 = tail call i64 @isspace(i8 signext %11)
%13 = icmp eq i64 %12, 0
%14 = getelementptr inbounds i8, i8* %10, i64 1
br i1 %13, label %15, label %9
15: ; preds = %9
%16 = add nuw nsw i32 %7, 1
%17 = ptrtoint i8* %10 to i64
%18 = sub i64 %5, %17
%19 = trunc i64 %18 to i32
%20 = tail call i8* @memchr(i8* %10, i8 signext 10, i32 %19)
%21 = icmp eq i8* %20, null
%22 = select i1 %21, i8* %1, i8* %20
%23 = icmp ult i8* %22, %1
br i1 %23, label %6, label %24
24: ; preds = %15, %2
%25 = phi i32 [ -1, %2 ], [ %7, %15 ]
ret i32 %25
}