#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 */
size_t strlen(char const *);
scalar_t__ strncmp(char const *, char const *, size_t);
int kwargs_match(char const *s, char const *key, char const **val) {
  size_t len = strlen(key);
  if (strncmp(s, key, len)) {
    return 0;
  }
  s += len;
  while (*s == ' ' || *s == '\t')
    ++s;
  if (*s == '\0' || *s == ',') {
    if (val)
      *val = NULL;
    return 1;
  }
  if (*s == '=') {
    if (val)
      *val = s + 1;
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<kwargs_match>:
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   1040 <strlen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1168 <kwargs_match+0x48>
movl   $0x0,-0x4(%rbp)
jmp    1239 <kwargs_match+0x119>
mov    -0x28(%rbp),%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x29(%rbp)
je     1199 <kwargs_match+0x79>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
sete   %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    11a9 <kwargs_match+0x89>
jmp    11ba <kwargs_match+0x9a>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1174 <kwargs_match+0x54>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11da <kwargs_match+0xba>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2c,%eax
jne    11fc <kwargs_match+0xdc>
cmpq   $0x0,-0x20(%rbp)
je     11f0 <kwargs_match+0xd0>
mov    -0x20(%rbp),%rax
movq   $0x0,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    1239 <kwargs_match+0x119>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3d,%eax
jne    1232 <kwargs_match+0x112>
cmpq   $0x0,-0x20(%rbp)
je     1226 <kwargs_match+0x106>
mov    -0x10(%rbp),%rcx
add    $0x1,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    1239 <kwargs_match+0x119>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kwargs_match>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
mov    %rsi,%rdi
call   1040 <strlen@plt>
mov    %rax,%r12
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1030 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jne    119b <kwargs_match+0x7b>
lea    (%r12,%r15,1),%rcx
add    $0x1,%rcx
jmp    1169 <kwargs_match+0x49>
xchg   %ax,%ax
cmp    $0x9,%dl
jne    1188 <kwargs_match+0x68>
add    $0x1,%rcx
movzbl -0x1(%rcx),%edx
cmp    $0x1f,%dl
jle    1160 <kwargs_match+0x40>
cmp    $0x20,%dl
je     1165 <kwargs_match+0x45>
cmp    $0x2c,%dl
je     118c <kwargs_match+0x6c>
cmp    $0x3d,%dl
jne    119b <kwargs_match+0x7b>
test   %r14,%r14
jne    1193 <kwargs_match+0x73>
jmp    1196 <kwargs_match+0x76>
test   %dl,%dl
jne    119b <kwargs_match+0x7b>
test   %r14,%r14
je     1196 <kwargs_match+0x76>
xor    %ecx,%ecx
mov    %rcx,(%r14)
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @kwargs_match(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
%11 = load i8*, i8** %5
%12 = load i8*, i8** %6
%13 = load i64, i64* %8
%14 = call i64 @strncmp(i8* %11, i8* %12, i64 %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %3
store i32 0, i32* %4
br label %66
17: ; preds = %3
%18 = load i64, i64* %8
%19 = load i8*, i8** %5
%20 = getelementptr inbounds i8, i8* %19, i64 %18
store i8* %20, i8** %5
br label %21
21: ; preds = %33, %17
%22 = load i8*, i8** %5
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 32
br i1 %25, label %31, label %26
26: ; preds = %21
%27 = load i8*, i8** %5
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 9
br label %31
31: ; preds = %26, %21
%32 = phi i1 [ true, %21 ], [ %30, %26 ]
br i1 %32, label %33, label %36
33: ; preds = %31
%34 = load i8*, i8** %5
%35 = getelementptr inbounds i8, i8* %34, i32 1
store i8* %35, i8** %5
br label %21
36: ; preds = %31
%37 = load i8*, i8** %5
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %39, 0
br i1 %40, label %46, label %41
41: ; preds = %36
%42 = load i8*, i8** %5
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 44
br i1 %45, label %46, label %52
46: ; preds = %41, %36
%47 = load i8**, i8*** %7
%48 = icmp ne i8** %47, null
br i1 %48, label %49, label %51
49: ; preds = %46
%50 = load i8**, i8*** %7
store i8* null, i8** %50
br label %51
51: ; preds = %49, %46
store i32 1, i32* %4
br label %66
52: ; preds = %41
%53 = load i8*, i8** %5
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
%56 = icmp eq i32 %55, 61
br i1 %56, label %57, label %65
57: ; preds = %52
%58 = load i8**, i8*** %7
%59 = icmp ne i8** %58, null
br i1 %59, label %60, label %64
60: ; preds = %57
%61 = load i8*, i8** %5
%62 = getelementptr inbounds i8, i8* %61, i64 1
%63 = load i8**, i8*** %7
store i8* %62, i8** %63
br label %64
64: ; preds = %60, %57
store i32 1, i32* %4
br label %66
65: ; preds = %52
store i32 0, i32* %4
br label %66
66: ; preds = %65, %64, %51, %16
%67 = load i32, i32* %4
ret i32 %67
}

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