#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*/ add_exported_option(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ env_to_arg(char *, char *);
char *strchr(char *, char);
scalar_t__ strlen(char *);
scalar_t__ strncmp(char *, char *, int);
char *uwsgi_malloc(scalar_t__);
void parse_sys_envs(char **envs) {
  char **uenvs = envs;
  char *earg, *eq_pos;
  while (*uenvs) {
    if (!strncmp(*uenvs, "UWSGI_", 6) &&
        strncmp(*uenvs, "UWSGI_RELOADS=", 14) &&
        strncmp(*uenvs, "UWSGI_ORIGINAL_PROC_NAME=", 25)) {
      earg = uwsgi_malloc(strlen(*uenvs + 6) + 1);
      env_to_arg(*uenvs + 6, earg);
      eq_pos = strchr(earg, '=');
      if (!eq_pos) {
        break;
      }
      eq_pos[0] = 0;
      add_exported_option(earg, eq_pos + 1, 0);
    }
    uenvs++;
  }
}


x86 assembly (clang, -O0):
<parse_sys_envs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     1269 <parse_sys_envs+0x109>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe70(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1258 <parse_sys_envs+0xf8>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe55(%rip),%rsi
mov    $0xe,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1258 <parse_sys_envs+0xf8>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe42(%rip),%rsi
mov    $0x19,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1258 <parse_sys_envs+0xf8>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
add    $0x6,%rdi
call   1040 <strlen@plt>
mov    %rax,%rdi
add    $0x1,%rdi
call   1070 <uwsgi_malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
add    $0x6,%rdi
mov    -0x18(%rbp),%rsi
call   1080 <env_to_arg@plt>
mov    -0x18(%rbp),%rdi
mov    $0x3d,%esi
call   1050 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    123e <parse_sys_envs+0xde>
jmp    1269 <parse_sys_envs+0x109>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
add    $0x1,%rsi
xor    %edx,%edx
call   1060 <add_exported_option@plt>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    1174 <parse_sys_envs+0x14>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_sys_envs>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdi,%rbx
mov    (%rdi),%rdi
test   %rdi,%rdi
je     122f <parse_sys_envs+0xcf>
lea    0xe81(%rip),%r14
lea    0xe81(%rip),%r15
lea    0xe89(%rip),%r12
jmp    11a1 <parse_sys_envs+0x41>
nop
mov    0x8(%rbx),%rdi
add    $0x8,%rbx
test   %rdi,%rdi
je     122f <parse_sys_envs+0xcf>
mov    %r14,%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    1190 <parse_sys_envs+0x30>
mov    (%rbx),%rdi
mov    %r15,%rsi
mov    $0xe,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1190 <parse_sys_envs+0x30>
mov    (%rbx),%rdi
mov    %r12,%rsi
mov    $0x19,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1190 <parse_sys_envs+0x30>
mov    (%rbx),%rdi
add    $0x6,%rdi
call   1040 <strlen@plt>
lea    0x1(%rax),%rdi
call   1070 <uwsgi_malloc@plt>
mov    %rax,%r13
mov    (%rbx),%rdi
add    $0x6,%rdi
mov    %rax,%rsi
call   1080 <env_to_arg@plt>
mov    %r13,%rdi
mov    $0x3d,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     122f <parse_sys_envs+0xcf>
movb   $0x0,(%rax)
add    $0x1,%rax
mov    %r13,%rdi
mov    %rax,%rsi
xor    %edx,%edx
call   1060 <add_exported_option@plt>
jmp    1190 <parse_sys_envs+0x30>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [7 x i8] c"UWSGI_\00"
@.str.1 = [15 x i8] c"UWSGI_RELOADS=\00"
@.str.2 = [26 x i8] c"UWSGI_ORIGINAL_PROC_NAME=\00"
define void @parse_sys_envs(i8** nocapture %0) {
%2 = load i8*, i8** %0
%3 = icmp eq i8* %2, null
br i1 %3, label %35, label %4
4: ; preds = %1, %31
%5 = phi i8* [ %33, %31 ], [ %2, %1 ]
%6 = phi i8** [ %32, %31 ], [ %0, %1 ]
%7 = tail call i64 @strncmp(i8* %5, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %31
9: ; preds = %4
%10 = load i8*, i8** %6
%11 = tail call i64 @strncmp(i8* %10, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 14)
%12 = icmp eq i64 %11, 0
br i1 %12, label %31, label %13
13: ; preds = %9
%14 = load i8*, i8** %6
%15 = tail call i64 @strncmp(i8* %14, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 25)
%16 = icmp eq i64 %15, 0
br i1 %16, label %31, label %17
17: ; preds = %13
%18 = load i8*, i8** %6
%19 = getelementptr inbounds i8, i8* %18, i64 6
%20 = tail call i64 @strlen(i8* %19)
%21 = add nsw i64 %20, 1
%22 = tail call i8* @uwsgi_malloc(i64 %21)
%23 = load i8*, i8** %6
%24 = getelementptr inbounds i8, i8* %23, i64 6
%25 = tail call i32 @env_to_arg(i8* %24, i8* %22)
%26 = tail call i8* @strchr(i8* dereferenceable(1) %22, i8 signext 61)
%27 = icmp eq i8* %26, null
br i1 %27, label %35, label %28
28: ; preds = %17
store i8 0, i8* %26
%29 = getelementptr inbounds i8, i8* %26, i64 1
%30 = tail call i32 @add_exported_option(i8* %22, i8* %29, i32 0)
br label %31
31: ; preds = %28, %13, %9, %4
%32 = getelementptr inbounds i8*, i8** %6, i64 1
%33 = load i8*, i8** %32
%34 = icmp eq i8* %33, null
br i1 %34, label %35, label %4
35: ; preds = %31, %17, %1
ret void
}