#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);
scalar_t__ memcmp(char *, char const *, size_t);
size_t strlen(char const *);
int str_begins_with_ss(char *str, const char *pref, char **p) {
  size_t len = strlen(pref);
  while (isspace(*str))
    str++;
  if (memcmp(str, pref, len) == 0) {
    if (p)
      *p = str + len;
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<str_begins_with_ss>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
je     1178 <str_begins_with_ss+0x48>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1151 <str_begins_with_ss+0x21>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
jne    11b9 <str_begins_with_ss+0x89>
cmpq   $0x0,-0x20(%rbp)
je     11ad <str_begins_with_ss+0x7d>
mov    -0x10(%rbp),%rcx
add    -0x28(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    11c0 <str_begins_with_ss+0x90>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_begins_with_ss>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r12
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1030 <strlen@plt>
mov    %rax,%r15
add    $0xffffffffffffffff,%rbx
movsbl 0x1(%rbx),%edi
add    $0x1,%rbx
call   1040 <isspace@plt>
test   %rax,%rax
jne    1150 <str_begins_with_ss+0x20>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
call   1050 <memcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jne    118a <str_begins_with_ss+0x5a>
mov    $0x1,%eax
test   %r14,%r14
je     118a <str_begins_with_ss+0x5a>
add    %r15,%rbx
mov    %rbx,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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