#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_VASSALS_DIR=", 18) &&
        strncmp(*uenvs, "UWSGI_EMPEROR_FD=", 17) &&
        strncmp(*uenvs, "UWSGI_BROODLORD_NUM=", 20) &&
        strncmp(*uenvs, "UWSGI_EMPEROR_FD_CONFIG=", 24) &&
        strncmp(*uenvs, "UWSGI_EMPEROR_PROXY=", 20) &&
        strncmp(*uenvs, "UWSGI_JAIL_PID=", 15) &&
        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     1335 <parse_sys_envs+0x1d5>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe70(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1324 <parse_sys_envs+0x1c4>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe55(%rip),%rsi
mov    $0xe,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1324 <parse_sys_envs+0x1c4>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe42(%rip),%rsi
mov    $0x12,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1324 <parse_sys_envs+0x1c4>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe33(%rip),%rsi
mov    $0x11,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1324 <parse_sys_envs+0x1c4>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe23(%rip),%rsi
mov    $0x14,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1324 <parse_sys_envs+0x1c4>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe16(%rip),%rsi
mov    $0x18,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1324 <parse_sys_envs+0x1c4>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe0d(%rip),%rsi
mov    $0x14,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1324 <parse_sys_envs+0x1c4>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe00(%rip),%rsi
mov    $0xf,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1324 <parse_sys_envs+0x1c4>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xdee(%rip),%rsi
mov    $0x19,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1324 <parse_sys_envs+0x1c4>
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    130a <parse_sys_envs+0x1aa>
jmp    1335 <parse_sys_envs+0x1d5>
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   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    (%rdi),%rdi
test   %rdi,%rdi
je     12dc <parse_sys_envs+0x17c>
lea    0xe7f(%rip),%r14
lea    0xe7f(%rip),%r15
lea    0xe87(%rip),%r12
lea    0xe93(%rip),%r13
jmp    11c1 <parse_sys_envs+0x61>
movb   $0x0,(%rax)
add    $0x1,%rax
mov    %rbp,%rdi
mov    %rax,%rsi
xor    %edx,%edx
call   1060 <add_exported_option@plt>
nopl   0x0(%rax)
mov    0x8(%rbx),%rdi
add    $0x8,%rbx
test   %rdi,%rdi
je     12dc <parse_sys_envs+0x17c>
mov    %r14,%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    11b0 <parse_sys_envs+0x50>
mov    (%rbx),%rdi
mov    %r15,%rsi
mov    $0xe,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11b0 <parse_sys_envs+0x50>
mov    (%rbx),%rdi
mov    %r12,%rsi
mov    $0x12,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11b0 <parse_sys_envs+0x50>
mov    (%rbx),%rdi
mov    %r13,%rsi
mov    $0x11,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11b0 <parse_sys_envs+0x50>
mov    (%rbx),%rdi
lea    0xe1f(%rip),%rsi
mov    $0x14,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11b0 <parse_sys_envs+0x50>
mov    (%rbx),%rdi
lea    0xe1b(%rip),%rsi
mov    $0x18,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11b0 <parse_sys_envs+0x50>
mov    (%rbx),%rdi
lea    0xe17(%rip),%rsi
mov    $0x14,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11b0 <parse_sys_envs+0x50>
mov    (%rbx),%rdi
lea    0xe0f(%rip),%rsi
mov    $0xf,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11b0 <parse_sys_envs+0x50>
mov    (%rbx),%rdi
lea    0xe02(%rip),%rsi
mov    $0x19,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11b0 <parse_sys_envs+0x50>
mov    (%rbx),%rdi
add    $0x6,%rdi
call   1040 <strlen@plt>
lea    0x1(%rax),%rdi
call   1070 <uwsgi_malloc@plt>
mov    %rax,%rbp
mov    (%rbx),%rdi
add    $0x6,%rdi
mov    %rax,%rsi
call   1080 <env_to_arg@plt>
mov    %rbp,%rdi
mov    $0x3d,%esi
call   1050 <strchr@plt>
test   %rax,%rax
jne    1198 <parse_sys_envs+0x38>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"UWSGI_\00"
@.str.1 = [15 x i8] c"UWSGI_RELOADS=\00"
@.str.2 = [19 x i8] c"UWSGI_VASSALS_DIR=\00"
@.str.3 = [18 x i8] c"UWSGI_EMPEROR_FD=\00"
@.str.4 = [21 x i8] c"UWSGI_BROODLORD_NUM=\00"
@.str.5 = [25 x i8] c"UWSGI_EMPEROR_FD_CONFIG=\00"
@.str.6 = [21 x i8] c"UWSGI_EMPEROR_PROXY=\00"
@.str.7 = [16 x i8] c"UWSGI_JAIL_PID=\00"
@.str.8 = [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 = %80, %1
%8 = load i8**, i8*** %3
%9 = load i8*, i8** %8
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %83
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 %80, 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 %80
21: ; preds = %16
%22 = load i8**, i8*** %3
%23 = load i8*, i8** %22
%24 = call i64 @strncmp(i8* %23, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 18)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %80
26: ; preds = %21
%27 = load i8**, i8*** %3
%28 = load i8*, i8** %27
%29 = call i64 @strncmp(i8* %28, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 17)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %80
31: ; preds = %26
%32 = load i8**, i8*** %3
%33 = load i8*, i8** %32
%34 = call i64 @strncmp(i8* %33, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 20)
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %80
36: ; preds = %31
%37 = load i8**, i8*** %3
%38 = load i8*, i8** %37
%39 = call i64 @strncmp(i8* %38, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i32 24)
%40 = icmp ne i64 %39, 0
br i1 %40, label %41, label %80
41: ; preds = %36
%42 = load i8**, i8*** %3
%43 = load i8*, i8** %42
%44 = call i64 @strncmp(i8* %43, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i32 20)
%45 = icmp ne i64 %44, 0
br i1 %45, label %46, label %80
46: ; preds = %41
%47 = load i8**, i8*** %3
%48 = load i8*, i8** %47
%49 = call i64 @strncmp(i8* %48, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i32 15)
%50 = icmp ne i64 %49, 0
br i1 %50, label %51, label %80
51: ; preds = %46
%52 = load i8**, i8*** %3
%53 = load i8*, i8** %52
%54 = call i64 @strncmp(i8* %53, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i32 25)
%55 = icmp ne i64 %54, 0
br i1 %55, label %56, label %80
56: ; preds = %51
%57 = load i8**, i8*** %3
%58 = load i8*, i8** %57
%59 = getelementptr inbounds i8, i8* %58, i64 6
%60 = call i64 @strlen(i8* %59)
%61 = add nsw i64 %60, 1
%62 = call i8* @uwsgi_malloc(i64 %61)
store i8* %62, i8** %4
%63 = load i8**, i8*** %3
%64 = load i8*, i8** %63
%65 = getelementptr inbounds i8, i8* %64, i64 6
%66 = load i8*, i8** %4
%67 = call i32 @env_to_arg(i8* %65, i8* %66)
%68 = load i8*, i8** %4
%69 = call i8* @strchr(i8* %68, i8 signext 61)
store i8* %69, i8** %5
%70 = load i8*, i8** %5
%71 = icmp ne i8* %70, null
br i1 %71, label %73, label %72
72: ; preds = %56
br label %83
73: ; preds = %56
%74 = load i8*, i8** %5
%75 = getelementptr inbounds i8, i8* %74, i64 0
store i8 0, i8* %75
%76 = load i8*, i8** %4
%77 = load i8*, i8** %5
%78 = getelementptr inbounds i8, i8* %77, i64 1
%79 = call i32 @add_exported_option(i8* %76, i8* %78, i32 0)
br label %80
80: ; preds = %73, %51, %46, %41, %36, %31, %26, %21, %16, %11
%81 = load i8**, i8*** %3
%82 = getelementptr inbounds i8*, i8** %81, i32 1
store i8** %82, i8*** %3
br label %7
83: ; preds = %72, %7
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"UWSGI_\00"
@.str.1 = [15 x i8] c"UWSGI_RELOADS=\00"
@.str.2 = [19 x i8] c"UWSGI_VASSALS_DIR=\00"
@.str.3 = [18 x i8] c"UWSGI_EMPEROR_FD=\00"
@.str.4 = [21 x i8] c"UWSGI_BROODLORD_NUM=\00"
@.str.5 = [25 x i8] c"UWSGI_EMPEROR_FD_CONFIG=\00"
@.str.6 = [21 x i8] c"UWSGI_EMPEROR_PROXY=\00"
@.str.7 = [16 x i8] c"UWSGI_JAIL_PID=\00"
@.str.8 = [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 %59, label %4
4: ; preds = %1, %55
%5 = phi i8* [ %57, %55 ], [ %2, %1 ]
%6 = phi i8** [ %56, %55 ], [ %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 %55
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 %55, label %13
13: ; preds = %9
%14 = load i8*, i8** %6
%15 = tail call i64 @strncmp(i8* %14, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 18)
%16 = icmp eq i64 %15, 0
br i1 %16, label %55, label %17
17: ; preds = %13
%18 = load i8*, i8** %6
%19 = tail call i64 @strncmp(i8* %18, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 17)
%20 = icmp eq i64 %19, 0
br i1 %20, label %55, label %21
21: ; preds = %17
%22 = load i8*, i8** %6
%23 = tail call i64 @strncmp(i8* %22, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 20)
%24 = icmp eq i64 %23, 0
br i1 %24, label %55, label %25
25: ; preds = %21
%26 = load i8*, i8** %6
%27 = tail call i64 @strncmp(i8* %26, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i32 24)
%28 = icmp eq i64 %27, 0
br i1 %28, label %55, label %29
29: ; preds = %25
%30 = load i8*, i8** %6
%31 = tail call i64 @strncmp(i8* %30, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i32 20)
%32 = icmp eq i64 %31, 0
br i1 %32, label %55, label %33
33: ; preds = %29
%34 = load i8*, i8** %6
%35 = tail call i64 @strncmp(i8* %34, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i32 15)
%36 = icmp eq i64 %35, 0
br i1 %36, label %55, label %37
37: ; preds = %33
%38 = load i8*, i8** %6
%39 = tail call i64 @strncmp(i8* %38, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i32 25)
%40 = icmp eq i64 %39, 0
br i1 %40, label %55, label %41
41: ; preds = %37
%42 = load i8*, i8** %6
%43 = getelementptr inbounds i8, i8* %42, i64 6
%44 = tail call i64 @strlen(i8* %43)
%45 = add nsw i64 %44, 1
%46 = tail call i8* @uwsgi_malloc(i64 %45)
%47 = load i8*, i8** %6
%48 = getelementptr inbounds i8, i8* %47, i64 6
%49 = tail call i32 @env_to_arg(i8* %48, i8* %46)
%50 = tail call i8* @strchr(i8* dereferenceable(1) %46, i8 signext 61)
%51 = icmp eq i8* %50, null
br i1 %51, label %59, label %52
52: ; preds = %41
store i8 0, i8* %50
%53 = getelementptr inbounds i8, i8* %50, i64 1
%54 = tail call i32 @add_exported_option(i8* %46, i8* %53, i32 0)
br label %55
55: ; preds = %52, %37, %33, %29, %25, %21, %17, %13, %9, %4
%56 = getelementptr inbounds i8*, i8** %6, i64 1
%57 = load i8*, i8** %56
%58 = icmp eq i8* %57, null
br i1 %58, label %59, label %4
59: ; preds = %55, %41, %1
ret void
}