#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__ strchr(char *, char);
int strspn(char *, char *);
char *skip_lws(char *str) {
  str += strspn(str, " \t");
  for (;;) {
    if (*str && strchr("\r\n", *str)) {
      char *p = str;
      if (*p == '\r')
        p++;
      if (*p == '\n')
        p++;
      if (*p && strchr(" \t", *p)) {
        str = p + strspn(p, " \t");
        continue;
      }
    }
    break;
  }
  return str;
}


x86 assembly (clang, -O0):
<skip_lws>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xec9(%rip),%rsi
call   1040 <strspn@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1218 <skip_lws+0xf8>
mov    -0x8(%rbp),%rax
lea    0xe9c(%rip),%rdi
movsbl (%rax),%esi
call   1030 <strchr@plt>
cmp    $0x0,%rax
je     1218 <skip_lws+0xf8>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xd,%eax
jne    119d <skip_lws+0x7d>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    11b9 <skip_lws+0x99>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1213 <skip_lws+0xf3>
mov    -0x10(%rbp),%rax
lea    0xe2c(%rip),%rdi
movsbl (%rax),%esi
call   1030 <strchr@plt>
cmp    $0x0,%rax
je     1213 <skip_lws+0xf3>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe07(%rip),%rsi
call   1040 <strspn@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
jmp    114c <skip_lws+0x2c>
jmp    1218 <skip_lws+0xf8>
jmp    121d <skip_lws+0xfd>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<skip_lws>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdi,%rbx
lea    0xecd(%rip),%rsi
call   1040 <strspn@plt>
cltq
lea    (%rbx,%rax,1),%r12
mov    (%rbx,%rax,1),%al
test   %al,%al
je     11bf <skip_lws+0x9f>
lea    0xeb7(%rip),%r14
lea    0xead(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl %al,%esi
mov    %r14,%rdi
call   1030 <strchr@plt>
test   %rax,%rax
je     11bf <skip_lws+0x9f>
xor    %eax,%eax
cmpb   $0xd,(%r12)
sete   %al
xor    %ebx,%ebx
cmpb   $0xa,(%r12,%rax,1)
lea    (%r12,%rax,1),%r13
sete   %bl
movzbl (%rbx,%r13,1),%eax
test   %al,%al
je     11bf <skip_lws+0x9f>
movsbl %al,%esi
mov    %r15,%rdi
call   1030 <strchr@plt>
test   %rax,%rax
je     11bf <skip_lws+0x9f>
add    %rbx,%r13
mov    %r13,%rdi
mov    %r15,%rsi
call   1040 <strspn@plt>
cltq
lea    (%rax,%r13,1),%r12
movzbl 0x0(%r13,%rax,1),%eax
test   %al,%al
jne    1160 <skip_lws+0x40>
mov    %r12,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c" \09\00"
@.str.1 = [3 x i8] c"\0D\0A\00"
define i8* @skip_lws(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i32 @strspn(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%6 = load i8*, i8** %2
%7 = sext i32 %5 to i64
%8 = getelementptr inbounds i8, i8* %6, i64 %7
store i8* %8, i8** %2
br label %9
9: ; preds = %46, %1
%10 = load i8*, i8** %2
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %53
14: ; preds = %9
%15 = load i8*, i8** %2
%16 = load i8, i8* %15
%17 = call i64 @strchr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 signext %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %53
19: ; preds = %14
%20 = load i8*, i8** %2
store i8* %20, i8** %3
%21 = load i8*, i8** %3
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 13
br i1 %24, label %25, label %28
25: ; preds = %19
%26 = load i8*, i8** %3
%27 = getelementptr inbounds i8, i8* %26, i32 1
store i8* %27, i8** %3
br label %28
28: ; preds = %25, %19
%29 = load i8*, i8** %3
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 10
br i1 %32, label %33, label %36
33: ; preds = %28
%34 = load i8*, i8** %3
%35 = getelementptr inbounds i8, i8* %34, i32 1
store i8* %35, i8** %3
br label %36
36: ; preds = %33, %28
%37 = load i8*, i8** %3
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %52
41: ; preds = %36
%42 = load i8*, i8** %3
%43 = load i8, i8* %42
%44 = call i64 @strchr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %43)
%45 = icmp ne i64 %44, 0
br i1 %45, label %46, label %52
46: ; preds = %41
%47 = load i8*, i8** %3
%48 = load i8*, i8** %3
%49 = call i32 @strspn(i8* %48, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %47, i64 %50
store i8* %51, i8** %2
br label %9
52: ; preds = %41, %36
br label %53
53: ; preds = %52, %14, %9
br label %54
54: ; preds = %53
%55 = load i8*, i8** %2
ret i8* %55
}

LLVM IR (-O2):
@.str = [3 x i8] c" \09\00"
@.str.1 = [3 x i8] c"\0D\0A\00"
define i8* @skip_lws(i8* %0) {
%2 = tail call i32 @strspn(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%3 = sext i32 %2 to i64
%4 = getelementptr inbounds i8, i8* %0, i64 %3
%5 = load i8, i8* %4
%6 = icmp eq i8 %5, 0
br i1 %6, label %32, label %7
7: ; preds = %1, %26
%8 = phi i8 [ %30, %26 ], [ %5, %1 ]
%9 = phi i8* [ %29, %26 ], [ %4, %1 ]
%10 = tail call i64 @strchr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 signext %8)
%11 = icmp eq i64 %10, 0
br i1 %11, label %32, label %12
12: ; preds = %7
%13 = load i8, i8* %9
%14 = icmp eq i8 %13, 13
%15 = zext i1 %14 to i64
%16 = getelementptr i8, i8* %9, i64 %15
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 10
%19 = zext i1 %18 to i64
%20 = getelementptr i8, i8* %16, i64 %19
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 0
br i1 %22, label %32, label %23
23: ; preds = %12
%24 = tail call i64 @strchr(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %21)
%25 = icmp eq i64 %24, 0
br i1 %25, label %32, label %26
26: ; preds = %23
%27 = tail call i32 @strspn(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %20, i64 %28
%30 = load i8, i8* %29
%31 = icmp eq i8 %30, 0
br i1 %31, label %32, label %7
32: ; preds = %7, %26, %23, %12, %1
%33 = phi i8* [ %4, %1 ], [ %9, %12 ], [ %9, %23 ], [ %29, %26 ], [ %9, %7 ]
ret i8* %33
}