#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__ memcmp(char *, char const *, int);
int strcmp(char *, char const *);
int strlen(char const *);
bool get_next_arg_val(int *acp, char ***avp, const char *s, char **ap) {
  int i = strcmp(**avp, s);
  if (i == 0) {
    (*acp)--;
    (*avp)++;
    *ap = **avp;
    return true;
  }
  if (i == '=') {
    int l = strlen(s);
    if (memcmp(**avp, s, l) == 0 && (**avp)[l] == '=') {
      *ap = (**avp) + l + 1;
      return true;
    }
  }
  return false;
}


x86 assembly (clang, -O0):
<get_next_arg_val>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <strcmp@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jne    119e <get_next_arg_val+0x6e>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0xffffffff,%ecx
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rcx
add    $0x8,%rcx
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    1223 <get_next_arg_val+0xf3>
cmpl   $0x3d,-0x2c(%rbp)
jne    121c <get_next_arg_val+0xec>
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x30(%rbp),%edx
call   1040 <memcmp@plt>
cmp    $0x0,%rax
jne    1217 <get_next_arg_val+0xe7>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%rax
movslq -0x30(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3d,%eax
jne    1217 <get_next_arg_val+0xe7>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%rcx
movslq -0x30(%rbp),%rax
add    %rax,%rcx
add    $0x1,%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    1223 <get_next_arg_val+0xf3>
jmp    121c <get_next_arg_val+0xec>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_next_arg_val>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%rbp
mov    %rsi,%r13
mov    %rdi,%r12
mov    (%rsi),%rbx
mov    (%rbx),%rdi
mov    %rdx,%rsi
call   1050 <strcmp@plt>
xor    %r15d,%r15d
cmp    $0x3d,%eax
je     117d <get_next_arg_val+0x4d>
test   %eax,%eax
jne    11b8 <get_next_arg_val+0x88>
addl   $0xffffffff,(%r12)
lea    0x8(%rbx),%rax
mov    %rax,0x0(%r13)
mov    0x8(%rbx),%rax
mov    %rax,(%r14)
mov    $0x1,%r15d
jmp    11b8 <get_next_arg_val+0x88>
mov    %rbp,%rdi
call   1030 <strlen@plt>
mov    %eax,%r12d
mov    0x0(%r13),%rax
mov    (%rax),%rdi
mov    %rbp,%rsi
mov    %r12d,%edx
call   1040 <memcmp@plt>
test   %rax,%rax
jne    11b8 <get_next_arg_val+0x88>
mov    0x0(%r13),%rax
mov    (%rax),%rax
movslq %r12d,%rcx
cmpb   $0x3d,(%rax,%rcx,1)
jne    11b8 <get_next_arg_val+0x88>
add    %rcx,%rax
add    $0x1,%rax
jmp    1172 <get_next_arg_val+0x42>
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @get_next_arg_val(i32* %0, i8*** %1, i8* %2, i8** %3) {
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i8***
%8 = alloca i8*
%9 = alloca i8**
%10 = alloca i32
%11 = alloca i32
store i32* %0, i32** %6
store i8*** %1, i8**** %7
store i8* %2, i8** %8
store i8** %3, i8*** %9
%12 = load i8***, i8**** %7
%13 = load i8**, i8*** %12
%14 = load i8*, i8** %13
%15 = load i8*, i8** %8
%16 = call i32 @strcmp(i8* %14, i8* %15)
store i32 %16, i32* %10
%17 = load i32, i32* %10
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %30
19: ; preds = %4
%20 = load i32*, i32** %6
%21 = load i32, i32* %20
%22 = add nsw i32 %21, -1
store i32 %22, i32* %20
%23 = load i8***, i8**** %7
%24 = load i8**, i8*** %23
%25 = getelementptr inbounds i8*, i8** %24, i32 1
store i8** %25, i8*** %23
%26 = load i8***, i8**** %7
%27 = load i8**, i8*** %26
%28 = load i8*, i8** %27
%29 = load i8**, i8*** %9
store i8* %28, i8** %29
store i32 1, i32* %5
br label %64
30: ; preds = %4
%31 = load i32, i32* %10
%32 = icmp eq i32 %31, 61
br i1 %32, label %33, label %63
33: ; preds = %30
%34 = load i8*, i8** %8
%35 = call i32 @strlen(i8* %34)
store i32 %35, i32* %11
%36 = load i8***, i8**** %7
%37 = load i8**, i8*** %36
%38 = load i8*, i8** %37
%39 = load i8*, i8** %8
%40 = load i32, i32* %11
%41 = call i64 @memcmp(i8* %38, i8* %39, i32 %40)
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %62
43: ; preds = %33
%44 = load i8***, i8**** %7
%45 = load i8**, i8*** %44
%46 = load i8*, i8** %45
%47 = load i32, i32* %11
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* %46, i64 %48
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = icmp eq i32 %51, 61
br i1 %52, label %53, label %62
53: ; preds = %43
%54 = load i8***, i8**** %7
%55 = load i8**, i8*** %54
%56 = load i8*, i8** %55
%57 = load i32, i32* %11
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8, i8* %56, i64 %58
%60 = getelementptr inbounds i8, i8* %59, i64 1
%61 = load i8**, i8*** %9
store i8* %60, i8** %61
store i32 1, i32* %5
br label %64
62: ; preds = %43, %33
br label %63
63: ; preds = %62, %30
store i32 0, i32* %5
br label %64
64: ; preds = %63, %53, %19
%65 = load i32, i32* %5
ret i32 %65
}

LLVM IR (-O2):
define i32 @get_next_arg_val(i32* nocapture %0, i8*** nocapture %1, i8* %2, i8** nocapture writeonly %3) {
%5 = load i8**, i8*** %1
%6 = load i8*, i8** %5
%7 = tail call i32 @strcmp(i8* dereferenceable(1) %6, i8* dereferenceable(1) %2)
switch i32 %7, label %30 [
i32 0, label %8
i32 61, label %13
]
8: ; preds = %4
%9 = load i32, i32* %0
%10 = add nsw i32 %9, -1
store i32 %10, i32* %0
%11 = getelementptr inbounds i8*, i8** %5, i64 1
store i8** %11, i8*** %1
%12 = load i8*, i8** %11
br label %28
13: ; preds = %4
%14 = tail call i32 @strlen(i8* %2)
%15 = load i8**, i8*** %1
%16 = load i8*, i8** %15
%17 = tail call i64 @memcmp(i8* %16, i8* %2, i32 %14)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %30
19: ; preds = %13
%20 = load i8**, i8*** %1
%21 = load i8*, i8** %20
%22 = sext i32 %14 to i64
%23 = getelementptr inbounds i8, i8* %21, i64 %22
%24 = load i8, i8* %23
%25 = icmp eq i8 %24, 61
br i1 %25, label %26, label %30
26: ; preds = %19
%27 = getelementptr inbounds i8, i8* %23, i64 1
br label %28
28: ; preds = %8, %26
%29 = phi i8* [ %27, %26 ], [ %12, %8 ]
store i8* %29, i8** %3
br label %30
30: ; preds = %28, %4, %13, %19
%31 = phi i32 [ 0, %19 ], [ 0, %13 ], [ 0, %4 ], [ 1, %28 ]
ret i32 %31
}