#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 */
int /*<<< orphan*/ assert(char const *);
char *strchr(char const *, char);
scalar_t__ strtol(char const *, int /*<<< orphan*/ *, int);
const char *nextArgument(const char *start, const char **str, size_t *len) {
  const char *p = start;
  if (p[0] != '$') {
    p = strchr(p, '$');
    if (p == NULL)
      return NULL;
  }
  *len = (int)strtol(p + 1, NULL, 10);
  p = strchr(p, '\r');
  assert(p);
  *str = p + 2;
  return p + 2 + (*len) + 2;
}


x86 assembly (clang, -O0):
<nextArgument>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x24,%eax
je     118b <nextArgument+0x5b>
mov    -0x28(%rbp),%rdi
mov    $0x24,%esi
call   1030 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1186 <nextArgument+0x56>
movq   $0x0,-0x8(%rbp)
jmp    11ec <nextArgument+0xbc>
jmp    118b <nextArgument+0x5b>
mov    -0x28(%rbp),%rdi
add    $0x1,%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1050 <strtol@plt>
movslq %eax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rdi
mov    $0xd,%esi
call   1030 <strchr@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <assert@plt>
mov    -0x28(%rbp),%rcx
add    $0x2,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rax
add    $0x2,%rax
mov    -0x20(%rbp),%rcx
add    (%rcx),%rax
add    $0x2,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nextArgument>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
cmpb   $0x24,(%rdi)
je     1158 <nextArgument+0x28>
mov    %rbx,%rdi
mov    $0x24,%esi
call   1030 <strchr@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1198 <nextArgument+0x68>
lea    0x1(%rbx),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1050 <strtol@plt>
cltq
mov    %rax,(%r15)
mov    %rbx,%rdi
mov    $0xd,%esi
call   1030 <strchr@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <assert@plt>
lea    0x2(%rbx),%rax
mov    %rax,(%r14)
mov    (%r15),%rax
add    %rbx,%rax
add    $0x4,%rax
jmp    119a <nextArgument+0x6a>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i8* @nextArgument(i8* %0, i8** nocapture writeonly %1, i64* nocapture %2) {
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 36
br i1 %5, label %9, label %6
6: ; preds = %3
%7 = tail call i8* @strchr(i8* %0, i8 signext 36)
%8 = icmp eq i8* %7, null
br i1 %8, label %21, label %9
9: ; preds = %6, %3
%10 = phi i8* [ %7, %6 ], [ %0, %3 ]
%11 = getelementptr inbounds i8, i8* %10, i64 1
%12 = tail call i64 @strtol(i8* nocapture %11, i32* null, i32 10)
%13 = shl i64 %12, 32
%14 = ashr exact i64 %13, 32
store i64 %14, i64* %2
%15 = tail call i8* @strchr(i8* dereferenceable(1) %10, i8 signext 13)
%16 = tail call i32 @assert(i8* %15)
%17 = getelementptr inbounds i8, i8* %15, i64 2
store i8* %17, i8** %1
%18 = load i64, i64* %2
%19 = getelementptr inbounds i8, i8* %17, i64 %18
%20 = getelementptr inbounds i8, i8* %19, i64 2
br label %21
21: ; preds = %6, %9
%22 = phi i8* [ %20, %9 ], [ null, %6 ]
ret i8* %22
}