#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 */
char *strpbrk(char const *, char *);
int /*<<< orphan*/ strspn(char const *, char *);
int httpHeaderIsValidValue(const char *value) {
  const char *p = value;
  while ((p = strpbrk(p, "\r\n")) != NULL) {
    p += strspn(p, "\r\n");
    if (*p != ' ' && *p != '\t')
      return (0);
  }
  return (1);
}


x86 assembly (clang, -O0):
<httpHeaderIsValidValue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xec1(%rip),%rsi
call   1040 <strpbrk@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11a3 <httpHeaderIsValidValue+0x83>
mov    -0x18(%rbp),%rdi
lea    0xea3(%rip),%rsi
call   1030 <strspn@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
je     119e <httpHeaderIsValidValue+0x7e>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
je     119e <httpHeaderIsValidValue+0x7e>
movl   $0x0,-0x4(%rbp)
jmp    11aa <httpHeaderIsValidValue+0x8a>
jmp    1134 <httpHeaderIsValidValue+0x14>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<httpHeaderIsValidValue>:
push   %rbp
push   %r14
push   %rbx
lea    0xed5(%rip),%rsi
call   1040 <strpbrk@plt>
mov    $0x1,%r14d
test   %rax,%rax
je     1184 <httpHeaderIsValidValue+0x64>
mov    %rax,%rbx
lea    0xebb(%rip),%rbp
jmp    1166 <httpHeaderIsValidValue+0x46>
nopw   0x0(%rax,%rax,1)
add    %rax,%rbx
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1040 <strpbrk@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1184 <httpHeaderIsValidValue+0x64>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1030 <strspn@plt>
cltq
movzbl (%rbx,%rax,1),%ecx
cmp    $0x20,%cl
je     1150 <httpHeaderIsValidValue+0x30>
cmp    $0x9,%cl
je     1150 <httpHeaderIsValidValue+0x30>
xor    %r14d,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"\0D\0A\00"
define i32 @httpHeaderIsValidValue(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
store i8* %5, i8** %4
br label %6
6: ; preds = %26, %1
%7 = load i8*, i8** %4
%8 = call i8* @strpbrk(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %8, i8** %4
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %27
10: ; preds = %6
%11 = load i8*, i8** %4
%12 = call i32 @strspn(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%13 = load i8*, i8** %4
%14 = sext i32 %12 to i64
%15 = getelementptr inbounds i8, i8* %13, i64 %14
store i8* %15, i8** %4
%16 = load i8*, i8** %4
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 32
br i1 %19, label %20, label %26
20: ; preds = %10
%21 = load i8*, i8** %4
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp ne i32 %23, 9
br i1 %24, label %25, label %26
25: ; preds = %20
store i32 0, i32* %2
br label %28
26: ; preds = %20, %10
br label %6
27: ; preds = %6
store i32 1, i32* %2
br label %28
28: ; preds = %27, %25
%29 = load i32, i32* %2
ret i32 %29
}

LLVM IR (-O2):
@.str = [3 x i8] c"\0D\0A\00"
define i32 @httpHeaderIsValidValue(i8* %0) {
%2 = tail call i8* @strpbrk(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i8* %2, null
br i1 %3, label %13, label %4
4: ; preds = %1, %10
%5 = phi i8* [ %11, %10 ], [ %2, %1 ]
%6 = tail call i32 @strspn(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i8, i8* %5, i64 %7
%9 = load i8, i8* %8
switch i8 %9, label %13 [
i8 32, label %10
i8 9, label %10
]
10: ; preds = %4, %4
%11 = tail call i8* @strpbrk(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %4
13: ; preds = %4, %10, %1
%14 = phi i32 [ 1, %1 ], [ 1, %10 ], [ 0, %4 ]
ret i32 %14
}