#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 const);
int get_pre_skip(const char *s) {
  int skip = 0;
  while (*s) {
    if (*s == '\n') {
      skip++;
      break;
    } else if (isspace(*s)) {
      skip++;
    }
    s++;
  }
  return skip;
}


x86 assembly (clang, -O0):
<get_pre_skip>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     1183 <get_pre_skip+0x73>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    114e <get_pre_skip+0x3e>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1183 <get_pre_skip+0x73>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isspace@plt>
cmp    $0x0,%rax
je     116d <get_pre_skip+0x5d>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1172 <get_pre_skip+0x62>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1123 <get_pre_skip+0x13>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_pre_skip>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
movzbl (%rbx),%eax
test   %al,%al
je     1143 <get_pre_skip+0x33>
cmp    $0xa,%al
je     1140 <get_pre_skip+0x30>
movsbl %al,%edi
call   1030 <isspace@plt>
cmp    $0x1,%rax
sbb    $0xffffffff,%ebp
add    $0x1,%rbx
jmp    1120 <get_pre_skip+0x10>
add    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

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