#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_with2_ss(char *str, const char *pref1, const char *pref2,
                        char **p) {
  size_t len1, len2;
  len1 = strlen(pref1);
  len2 = strlen(pref2);
  while (isspace(*str))
    str++;
  if ((memcmp(str, pref1, len1) == 0) &&
      (memcmp(str + len1, pref2, len2) == 0)) {
    if (p)
      *p = str + len1 + len2;
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<str_begins_with2_ss>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
je     1189 <str_begins_with2_ss+0x59>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1162 <str_begins_with2_ss+0x32>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
jne    11ed <str_begins_with2_ss+0xbd>
mov    -0x10(%rbp),%rdi
add    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x38(%rbp),%rdx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
jne    11ed <str_begins_with2_ss+0xbd>
cmpq   $0x0,-0x28(%rbp)
je     11e1 <str_begins_with2_ss+0xb1>
mov    -0x10(%rbp),%rcx
add    -0x30(%rbp),%rcx
add    -0x38(%rbp),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    11f4 <str_begins_with2_ss+0xc4>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_begins_with2_ss>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r13
mov    %rsi,%rbp
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1030 <strlen@plt>
mov    %rax,%r15
mov    %r13,%rdi
call   1030 <strlen@plt>
mov    %rax,%r12
add    $0xffffffffffffffff,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl 0x1(%rbx),%edi
add    $0x1,%rbx
call   1040 <isspace@plt>
test   %rax,%rax
jne    1170 <str_begins_with2_ss+0x40>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r15,%rdx
call   1050 <memcmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
jne    11be <str_begins_with2_ss+0x8e>
lea    (%rbx,%r15,1),%rdi
mov    %r13,%rsi
mov    %r12,%rdx
call   1050 <memcmp@plt>
test   %rax,%rax
jne    11be <str_begins_with2_ss+0x8e>
mov    $0x1,%ebp
test   %r14,%r14
je     11be <str_begins_with2_ss+0x8e>
add    %r15,%r12
add    %r12,%rbx
mov    %rbx,(%r14)
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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