#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);
char *sskip(char *);
int strlen(char const *);
scalar_t__ strncasecmp(char *, char const *, int);
int check_token(char **p_, const char *token) {
  char *p = *p_;
  int tlen = strlen(token);
  int ret = strncasecmp(p, token, tlen) == 0 && isspace(p[tlen]);
  if (ret)
    *p_ = sskip(p + tlen + 1);
  return ret;
}


x86 assembly (clang, -O0):
<check_token>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1050 <strncasecmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x21(%rbp)
jne    11a4 <check_token+0x64>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     11d7 <check_token+0x97>
mov    -0x18(%rbp),%rdi
movslq -0x1c(%rbp),%rax
add    %rax,%rdi
add    $0x1,%rdi
call   1060 <sskip@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_token>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
mov    (%rdi),%r12
mov    %rsi,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1050 <strncasecmp@plt>
xor    %r15d,%r15d
test   %rax,%rax
jne    119a <check_token+0x5a>
movslq %ebp,%rbx
movsbl (%r12,%rbx,1),%edi
call   1040 <isspace@plt>
test   %rax,%rax
je     119a <check_token+0x5a>
add    %rbx,%r12
add    $0x1,%r12
mov    %r12,%rdi
call   1060 <sskip@plt>
mov    %rax,(%r14)
mov    $0x1,%r15d
mov    %r15d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @check_token(i8** %0, i8* %1) {
%3 = alloca i8**
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i8** %0, i8*** %3
store i8* %1, i8** %4
%8 = load i8**, i8*** %3
%9 = load i8*, i8** %8
store i8* %9, i8** %5
%10 = load i8*, i8** %4
%11 = call i32 @strlen(i8* %10)
store i32 %11, i32* %6
%12 = load i8*, i8** %5
%13 = load i8*, i8** %4
%14 = load i32, i32* %6
%15 = call i64 @strncasecmp(i8* %12, i8* %13, i32 %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %25
17: ; preds = %2
%18 = load i8*, i8** %5
%19 = load i32, i32* %6
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
%22 = load i8, i8* %21
%23 = call i64 @isspace(i8 signext %22)
%24 = icmp ne i64 %23, 0
br label %25
25: ; preds = %17, %2
%26 = phi i1 [ false, %2 ], [ %24, %17 ]
%27 = zext i1 %26 to i32
store i32 %27, i32* %7
%28 = load i32, i32* %7
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %38
30: ; preds = %25
%31 = load i8*, i8** %5
%32 = load i32, i32* %6
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %31, i64 %33
%35 = getelementptr inbounds i8, i8* %34, i64 1
%36 = call i8* @sskip(i8* %35)
%37 = load i8**, i8*** %3
store i8* %36, i8** %37
br label %38
38: ; preds = %30, %25
%39 = load i32, i32* %7
ret i32 %39
}

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