#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 */
char *strtok_r(char *, char *, char **);
int next_arg(char **saveptr, char **arg, char **value) {
  char *saveptr_local;
  char *token = strtok_r(NULL, " \t\r\n\v\f", saveptr);
  if (!token) {
    return 0;
  }
  *arg = strtok_r(token, "=", &saveptr_local);
  if (!*arg) {
    *value = NULL;
    return (-3);
  }
  *value = strtok_r(NULL, "", &saveptr_local);
  if (!*value) {
    return (-3);
  }
  return 1;
}


x86 assembly (clang, -O0):
<next_arg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%edi
lea    0xecd(%rip),%rsi
call   1030 <strtok_r@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1153 <next_arg+0x43>
movl   $0x0,-0x4(%rbp)
jmp    11d5 <next_arg+0xc5>
mov    -0x30(%rbp),%rdi
lea    0xea9(%rip),%rsi
lea    -0x28(%rbp),%rdx
call   1030 <strtok_r@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1196 <next_arg+0x86>
mov    -0x20(%rbp),%rax
movq   $0x0,(%rax)
movl   $0xfffffffd,-0x4(%rbp)
jmp    11d5 <next_arg+0xc5>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe65(%rip),%rsi
lea    -0x28(%rbp),%rdx
call   1030 <strtok_r@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
jne    11ce <next_arg+0xbe>
movl   $0xfffffffd,-0x4(%rbp)
jmp    11d5 <next_arg+0xc5>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<next_arg>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rdx
lea    0xed7(%rip),%rsi
xor    %ebx,%ebx
xor    %edi,%edi
call   1030 <strtok_r@plt>
test   %rax,%rax
je     1186 <next_arg+0x76>
lea    0xec9(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %rax,%rdi
call   1030 <strtok_r@plt>
mov    %rax,(%r15)
test   %rax,%rax
je     117a <next_arg+0x6a>
lea    0xeac(%rip),%rsi
lea    0x8(%rsp),%rdx
xor    %edi,%edi
call   1030 <strtok_r@plt>
mov    %rax,(%r14)
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
lea    -0x3(,%rcx,4),%ebx
jmp    1186 <next_arg+0x76>
movq   $0x0,(%r14)
mov    $0xfffffffd,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [7 x i8] c" \09\0D\0A\0B\0C\00"
@.str.1 = [2 x i8] c"=\00"
@.str.2 = [1 x i8] zeroinitializer
define i32 @next_arg(i8** %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i8*
%9 = alloca i8*
store i8** %0, i8*** %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
%10 = load i8**, i8*** %5
%11 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8** %10)
store i8* %11, i8** %9
%12 = load i8*, i8** %9
%13 = icmp ne i8* %12, null
br i1 %13, label %15, label %14
14: ; preds = %3
store i32 0, i32* %4
br label %32
15: ; preds = %3
%16 = load i8*, i8** %9
%17 = call i8* @strtok_r(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8** %8)
%18 = load i8**, i8*** %6
store i8* %17, i8** %18
%19 = load i8**, i8*** %6
%20 = load i8*, i8** %19
%21 = icmp ne i8* %20, null
br i1 %21, label %24, label %22
22: ; preds = %15
%23 = load i8**, i8*** %7
store i8* null, i8** %23
store i32 -3, i32* %4
br label %32
24: ; preds = %15
%25 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8** %8)
%26 = load i8**, i8*** %7
store i8* %25, i8** %26
%27 = load i8**, i8*** %7
%28 = load i8*, i8** %27
%29 = icmp ne i8* %28, null
br i1 %29, label %31, label %30
30: ; preds = %24
store i32 -3, i32* %4
br label %32
31: ; preds = %24
store i32 1, i32* %4
br label %32
32: ; preds = %31, %30, %22, %14
%33 = load i32, i32* %4
ret i32 %33
}

LLVM IR (-O2):
@.str = [7 x i8] c" \09\0D\0A\0B\0C\00"
@.str.1 = [2 x i8] c"=\00"
@.str.2 = [1 x i8] zeroinitializer
define i32 @next_arg(i8** %0, i8** nocapture writeonly %1, i8** nocapture writeonly %2) {
%4 = alloca i8*
%5 = bitcast i8** %4 to i8*
%6 = tail call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8** %0)
%7 = icmp eq i8* %6, null
br i1 %7, label %16, label %8
8: ; preds = %3
%9 = call i8* @strtok_r(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8** %4)
store i8* %9, i8** %1
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %12
11: ; preds = %8
store i8* null, i8** %2
br label %16
12: ; preds = %8
%13 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8** %4)
store i8* %13, i8** %2
%14 = icmp eq i8* %13, null
%15 = select i1 %14, i32 -3, i32 1
br label %16
16: ; preds = %12, %3, %11
%17 = phi i32 [ -3, %11 ], [ 0, %3 ], [ %15, %12 ]
ret i32 %17
}