#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 strlen(char const *);
scalar_t__ strncmp(char const *, char const *, int);
bool strhazit(const char *str, const char **p) {
  int len = strlen(str);
  if (strncmp(str, *p, len))
    return false;
  for (*p += len; isspace(**p); ++*p)
    ;
  return true;
}


x86 assembly (clang, -O0):
<strhazit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1175 <strhazit+0x45>
movl   $0x0,-0x4(%rbp)
jmp    11c0 <strhazit+0x90>
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%rax
mov    (%rax),%rcx
movslq %edx,%rdx
add    %rdx,%rcx
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%edi
call   1050 <isspace@plt>
cmp    $0x0,%rax
je     11b9 <strhazit+0x89>
jmp    11a6 <strhazit+0x76>
mov    -0x18(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
jmp    1188 <strhazit+0x58>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strhazit>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%rbp
call   1040 <strlen@plt>
mov    %eax,%r15d
mov    (%rbx),%rsi
mov    %rbp,%rdi
mov    %eax,%edx
call   1030 <strncmp@plt>
xor    %r14d,%r14d
test   %rax,%rax
je     1168 <strhazit+0x38>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%rbx),%rax
movslq %r15d,%rcx
lea    (%rax,%rcx,1),%rdx
mov    %rdx,(%rbx)
movsbl (%rax,%rcx,1),%edi
call   1050 <isspace@plt>
mov    $0x1,%r14d
test   %rax,%rax
je     115a <strhazit+0x2a>
nopl   0x0(%rax)
mov    (%rbx),%rax
lea    0x1(%rax),%rcx
mov    %rcx,(%rbx)
movsbl 0x1(%rax),%edi
call   1050 <isspace@plt>
test   %rax,%rax
jne    1190 <strhazit+0x60>
jmp    115a <strhazit+0x2a>

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

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