#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 strcspn(char *, char *);
int /*<<< orphan*/ strspn(char *, char *);
char *consume_until_whitespace(char **str) {
  char *tok = *str;
  if (tok) {
    tok += strspn(tok, " \t");
    if (*tok == '\0') {
      *str = NULL;
      tok = NULL;
    } else {
      char *eot = tok + strcspn(tok, " \t");
      if (*eot == '\0') {
        *str = NULL;
      } else {
        *eot = '\0';
        *str = eot + 1;
      }
    }
  }
  return tok;
}


x86 assembly (clang, -O0):
<consume_until_whitespace>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11f2 <consume_until_whitespace+0xd2>
mov    -0x10(%rbp),%rdi
lea    0xeb3(%rip),%rsi
call   1030 <strspn@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    118a <consume_until_whitespace+0x6a>
mov    -0x8(%rbp),%rax
movq   $0x0,(%rax)
movq   $0x0,-0x10(%rbp)
jmp    11ed <consume_until_whitespace+0xcd>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe63(%rip),%rsi
call   1040 <strcspn@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11d2 <consume_until_whitespace+0xb2>
mov    -0x8(%rbp),%rax
movq   $0x0,(%rax)
jmp    11e8 <consume_until_whitespace+0xc8>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rcx
add    $0x1,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
jmp    11ed <consume_until_whitespace+0xcd>
jmp    11f2 <consume_until_whitespace+0xd2>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<consume_until_whitespace>:
push   %r14
push   %rbx
push   %rax
mov    (%rdi),%rbx
test   %rbx,%rbx
je     116c <consume_until_whitespace+0x4c>
mov    %rdi,%r14
lea    0xeca(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strspn@plt>
cltq
cmpb   $0x0,(%rbx,%rax,1)
je     1170 <consume_until_whitespace+0x50>
add    %rax,%rbx
lea    0xeb0(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcspn@plt>
cltq
cmpb   $0x0,(%rbx,%rax,1)
je     1176 <consume_until_whitespace+0x56>
add    %rbx,%rax
movb   $0x0,(%rax)
add    $0x1,%rax
jmp    1178 <consume_until_whitespace+0x58>
xor    %ebx,%ebx
jmp    117b <consume_until_whitespace+0x5b>
xor    %eax,%eax
xor    %ebx,%ebx
jmp    1178 <consume_until_whitespace+0x58>
xor    %eax,%eax
mov    %rax,(%r14)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c" \09\00"
define i8* @consume_until_whitespace(i8** nocapture %0) {
%2 = load i8*, i8** %0
%3 = icmp eq i8* %2, null
br i1 %3, label %21, label %4
4: ; preds = %1
%5 = tail call i32 @strspn(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%6 = sext i32 %5 to i64
%7 = getelementptr inbounds i8, i8* %2, i64 %6
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 0
br i1 %9, label %18, label %10
10: ; preds = %4
%11 = tail call i32 @strcspn(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %7, i64 %12
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %10
store i8 0, i8* %13
%17 = getelementptr inbounds i8, i8* %13, i64 1
br label %18
18: ; preds = %16, %10, %4
%19 = phi i8* [ null, %4 ], [ %17, %16 ], [ null, %10 ]
%20 = phi i8* [ null, %4 ], [ %7, %16 ], [ %7, %10 ]
store i8* %19, i8** %0
br label %21
21: ; preds = %18, %1
%22 = phi i8* [ null, %1 ], [ %20, %18 ]
ret i8* %22
}