#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*/ config_handle_arg(char *, char *);
int /*<<< orphan*/ str_starts(char *, char *);
void configstdin_pipe(int argc, char *argv[]) {
  if (argc <= 1)
    return;
  char *cursor;
  char *next;
  char *arg;
  char *val;
  for (int i = 1; i < argc; i++) {
    arg = NULL;
    val = NULL;
    cursor = argv[i];
    next = argv[i + 1];
    if (!str_starts(cursor, "-"))
      continue;
    if (!str_starts(next, "-")) {
      val = next;
      i++;
    }
    arg = cursor;
    config_handle_arg(arg, val);
  }
}


x86 assembly (clang, -O0):
<configstdin_pipe>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x4(%rbp)
jg     113e <configstdin_pipe+0x1e>
jmp    11f1 <configstdin_pipe+0xd1>
movl   $0x1,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11f1 <configstdin_pipe+0xd1>
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x34(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe6f(%rip),%rsi
call   1030 <str_starts@plt>
cmp    $0x0,%eax
jne    11a4 <configstdin_pipe+0x84>
jmp    11e3 <configstdin_pipe+0xc3>
mov    -0x20(%rbp),%rdi
lea    0xe51(%rip),%rsi
call   1030 <str_starts@plt>
cmp    $0x0,%eax
jne    11ce <configstdin_pipe+0xae>
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1040 <config_handle_arg@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1145 <configstdin_pipe+0x25>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<configstdin_pipe>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,0x10(%rsp)
mov    %edi,0xc(%rsp)
cmp    $0x2,%edi
jl     11a6 <configstdin_pipe+0x86>
mov    $0x1,%r14d
lea    0xeb7(%rip),%r15
jmp    116a <configstdin_pipe+0x4a>
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %rbx,%rsi
call   1040 <config_handle_arg@plt>
add    $0x1,%ebp
mov    %r12,%r15
mov    %ebp,%r14d
cmp    0xc(%rsp),%ebp
jge    11a6 <configstdin_pipe+0x86>
movslq %r14d,%rbp
mov    0x10(%rsp),%rax
mov    (%rax,%rbp,8),%r13
mov    0x8(%rax,%rbp,8),%rbx
add    $0x1,%ebp
mov    %r13,%rdi
mov    %r15,%rsi
call   1030 <str_starts@plt>
test   %eax,%eax
je     1161 <configstdin_pipe+0x41>
mov    %rbx,%rdi
mov    %r15,%r12
mov    %r15,%rsi
call   1030 <str_starts@plt>
test   %eax,%eax
je     1150 <configstdin_pipe+0x30>
xor    %ebx,%ebx
mov    %r14d,%ebp
jmp    1150 <configstdin_pipe+0x30>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"-\00"
define void @configstdin_pipe(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
%10 = load i32, i32* %3
%11 = icmp sle i32 %10, 1
br i1 %11, label %12, label %13
12: ; preds = %2
br label %50
13: ; preds = %2
store i32 1, i32* %9
br label %14
14: ; preds = %47, %13
%15 = load i32, i32* %9
%16 = load i32, i32* %3
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %50
18: ; preds = %14
store i8* null, i8** %7
store i8* null, i8** %8
%19 = load i8**, i8*** %4
%20 = load i32, i32* %9
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8*, i8** %19, i64 %21
%23 = load i8*, i8** %22
store i8* %23, i8** %5
%24 = load i8**, i8*** %4
%25 = load i32, i32* %9
%26 = add nsw i32 %25, 1
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8*, i8** %24, i64 %27
%29 = load i8*, i8** %28
store i8* %29, i8** %6
%30 = load i8*, i8** %5
%31 = call i32 @str_starts(i8* %30, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%32 = icmp ne i32 %31, 0
br i1 %32, label %34, label %33
33: ; preds = %18
br label %47
34: ; preds = %18
%35 = load i8*, i8** %6
%36 = call i32 @str_starts(i8* %35, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%37 = icmp ne i32 %36, 0
br i1 %37, label %42, label %38
38: ; preds = %34
%39 = load i8*, i8** %6
store i8* %39, i8** %8
%40 = load i32, i32* %9
%41 = add nsw i32 %40, 1
store i32 %41, i32* %9
br label %42
42: ; preds = %38, %34
%43 = load i8*, i8** %5
store i8* %43, i8** %7
%44 = load i8*, i8** %7
%45 = load i8*, i8** %8
%46 = call i32 @config_handle_arg(i8* %44, i8* %45)
br label %47
47: ; preds = %42, %33
%48 = load i32, i32* %9
%49 = add nsw i32 %48, 1
store i32 %49, i32* %9
br label %14
50: ; preds = %12, %14
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"-\00"
define void @configstdin_pipe(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %25
4: ; preds = %2, %22
%5 = phi i32 [ %23, %22 ], [ 1, %2 ]
%6 = sext i32 %5 to i64
%7 = getelementptr inbounds i8*, i8** %1, i64 %6
%8 = load i8*, i8** %7
%9 = add nsw i32 %5, 1
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8*, i8** %1, i64 %10
%12 = load i8*, i8** %11
%13 = tail call i32 @str_starts(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i32 %13, 0
br i1 %14, label %22, label %15
15: ; preds = %4
%16 = tail call i32 @str_starts(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%17 = icmp eq i32 %16, 0
%18 = select i1 %17, i8* %12, i8* null
%19 = select i1 %17, i32 %9, i32 %5
%20 = tail call i32 @config_handle_arg(i8* %8, i8* %18)
%21 = add nsw i32 %19, 1
br label %22
22: ; preds = %4, %15
%23 = phi i32 [ %9, %4 ], [ %21, %15 ]
%24 = icmp slt i32 %23, %0
br i1 %24, label %4, label %25
25: ; preds = %22, %2
ret void
}