#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*/ isspace(char);
char *walk_space(char *p, int *line_no) {
  char c;
  for (;;) {
    c = *p;
    if (!isspace(c)) {
      return p;
    } else if (c == '\n') {
      ++(*line_no);
    }
    ++p;
  }
}


x86 assembly (clang, -O0):
<walk_space>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%edi
call   1030 <isspace@plt>
cmp    $0x0,%eax
jne    1145 <walk_space+0x35>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret
movsbl -0x11(%rbp),%eax
cmp    $0xa,%eax
jne    115d <walk_space+0x4d>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
jmp    1162 <walk_space+0x52>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1120 <walk_space+0x10>

x86 assembly (clang, -O2):
<walk_space>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
mov    (%rdi),%bpl
jmp    1128 <walk_space+0x18>
nop
movzbl 0x1(%rbx),%ebp
add    $0x1,%rbx
movsbl %bpl,%edi
call   1030 <isspace@plt>
test   %eax,%eax
je     1141 <walk_space+0x31>
cmp    $0xa,%bpl
jne    1120 <walk_space+0x10>
addl   $0x1,(%r14)
jmp    1120 <walk_space+0x10>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i8* @walk_space(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i8
store i8* %0, i8** %3
store i32* %1, i32** %4
br label %6
6: ; preds = %23, %2
%7 = load i8*, i8** %3
%8 = load i8, i8* %7
store i8 %8, i8* %5
%9 = load i8, i8* %5
%10 = call i32 @isspace(i8 signext %9)
%11 = icmp ne i32 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %6
%13 = load i8*, i8** %3
ret i8* %13
14: ; preds = %6
%15 = load i8, i8* %5
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 10
br i1 %17, label %18, label %22
18: ; preds = %14
%19 = load i32*, i32** %4
%20 = load i32, i32* %19
%21 = add nsw i32 %20, 1
store i32 %21, i32* %19
br label %22
22: ; preds = %18, %14
br label %23
23: ; preds = %22
%24 = load i8*, i8** %3
%25 = getelementptr inbounds i8, i8* %24, i32 1
store i8* %25, i8** %3
br label %6
}

LLVM IR (-O2):
define i8* @walk_space(i8* %0, i32* nocapture %1) {
%3 = load i8, i8* %0
%4 = tail call i32 @isspace(i8 signext %3)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %15, %2
%7 = phi i8* [ %0, %2 ], [ %16, %15 ]
ret i8* %7
8: ; preds = %2, %15
%9 = phi i8 [ %17, %15 ], [ %3, %2 ]
%10 = phi i8* [ %16, %15 ], [ %0, %2 ]
%11 = icmp eq i8 %9, 10
br i1 %11, label %12, label %15
12: ; preds = %8
%13 = load i32, i32* %1
%14 = add nsw i32 %13, 1
store i32 %14, i32* %1
br label %15
15: ; preds = %8, %12
%16 = getelementptr inbounds i8, i8* %10, i64 1
%17 = load i8, i8* %16
%18 = tail call i32 @isspace(i8 signext %17)
%19 = icmp eq i32 %18, 0
br i1 %19, label %6, label %8
}