#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*/ exit(int);
char *strchr(char *, char);
char *uwsgi_concat2(char *, char *);
int /*<<< orphan*/ uwsgi_legion_register(char *, char *, char *, char *,
                                         char *);
int /*<<< orphan*/ uwsgi_log(char *);
void uwsgi_opt_legion(char *opt, char *value, void *foobar) {
  char *legion = uwsgi_concat2(value, (char *)"");
  char *space = strchr(legion, ' ');
  if (!space) {
    uwsgi_log("invalid legion syntax, must be <legion> <addr> <valor> "
              "<algo:secret>\n");
    exit(1);
  }
  *space = 0;
  char *addr = space + 1;
  space = strchr(addr, ' ');
  if (!space) {
    uwsgi_log("invalid legion syntax, must be <legion> <addr> <valor> "
              "<algo:secret>\n");
    exit(1);
  }
  *space = 0;
  char *valor = space + 1;
  space = strchr(valor, ' ');
  if (!space) {
    uwsgi_log("invalid legion syntax, must be <legion> <addr> <valor> "
              "<algo:secret>\n");
    exit(1);
  }
  *space = 0;
  char *algo_secret = space + 1;
  char *colon = strchr(algo_secret, ':');
  if (!colon) {
    uwsgi_log("invalid legion syntax, must be <legion> <addr> <valor> "
              "<algo:secret>\n");
    exit(1);
  }
  *colon = 0;
  char *secret = colon + 1;
  uwsgi_legion_register(legion, addr, valor, algo_secret, secret);
}


x86 assembly (clang, -O0):
<uwsgi_opt_legion>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xed6(%rip),%rsi
call   1060 <uwsgi_concat2@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x20,%esi
call   1030 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11ab <uwsgi_opt_legion+0x5b>
lea    0xe64(%rip),%rdi
call   1040 <uwsgi_log@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    $0x20,%esi
call   1030 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11f1 <uwsgi_opt_legion+0xa1>
lea    0xe1e(%rip),%rdi
call   1040 <uwsgi_log@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    $0x20,%esi
call   1030 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1237 <uwsgi_opt_legion+0xe7>
lea    0xdd8(%rip),%rdi
call   1040 <uwsgi_log@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
mov    $0x3a,%esi
call   1030 <strchr@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    127d <uwsgi_opt_legion+0x12d>
lea    0xd92(%rip),%rdi
call   1040 <uwsgi_log@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x48(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    -0x40(%rbp),%rcx
mov    -0x50(%rbp),%r8
call   1050 <uwsgi_legion_register@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uwsgi_opt_legion>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rdi
lea    0xee3(%rip),%rsi
call   1060 <uwsgi_concat2@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    $0x20,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     11f6 <uwsgi_opt_legion+0xa6>
mov    %rax,%r15
movb   $0x0,(%rax)
add    $0x1,%r15
mov    %r15,%rdi
mov    $0x20,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     11f6 <uwsgi_opt_legion+0xa6>
mov    %rax,%r12
movb   $0x0,(%rax)
add    $0x1,%r12
mov    %r12,%rdi
mov    $0x20,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     11f6 <uwsgi_opt_legion+0xa6>
mov    %rax,%rbx
movb   $0x0,(%rax)
add    $0x1,%rbx
mov    %rbx,%rdi
mov    $0x3a,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     11f6 <uwsgi_opt_legion+0xa6>
movb   $0x0,(%rax)
add    $0x1,%rax
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %rbx,%rcx
mov    %rax,%r8
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1050 <uwsgi_legion_register@plt>
lea    0xe03(%rip),%rdi
call   1040 <uwsgi_log@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [70 x i8] c"invalid legion syntax, must be <legion> <addr> <valor> <algo:secret>\0A\00"
define void @uwsgi_opt_legion(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%14 = load i8*, i8** %5
%15 = call i8* @uwsgi_concat2(i8* %14, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i8* %15, i8** %7
%16 = load i8*, i8** %7
%17 = call i8* @strchr(i8* %16, i8 signext 32)
store i8* %17, i8** %8
%18 = load i8*, i8** %8
%19 = icmp ne i8* %18, null
br i1 %19, label %23, label %20
20: ; preds = %3
%21 = call i32 @uwsgi_log(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.1, i64 0, i64 0))
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %3
%24 = load i8*, i8** %8
store i8 0, i8* %24
%25 = load i8*, i8** %8
%26 = getelementptr inbounds i8, i8* %25, i64 1
store i8* %26, i8** %9
%27 = load i8*, i8** %9
%28 = call i8* @strchr(i8* %27, i8 signext 32)
store i8* %28, i8** %8
%29 = load i8*, i8** %8
%30 = icmp ne i8* %29, null
br i1 %30, label %34, label %31
31: ; preds = %23
%32 = call i32 @uwsgi_log(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.1, i64 0, i64 0))
%33 = call i32 @exit(i32 1)
unreachable
34: ; preds = %23
%35 = load i8*, i8** %8
store i8 0, i8* %35
%36 = load i8*, i8** %8
%37 = getelementptr inbounds i8, i8* %36, i64 1
store i8* %37, i8** %10
%38 = load i8*, i8** %10
%39 = call i8* @strchr(i8* %38, i8 signext 32)
store i8* %39, i8** %8
%40 = load i8*, i8** %8
%41 = icmp ne i8* %40, null
br i1 %41, label %45, label %42
42: ; preds = %34
%43 = call i32 @uwsgi_log(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.1, i64 0, i64 0))
%44 = call i32 @exit(i32 1)
unreachable
45: ; preds = %34
%46 = load i8*, i8** %8
store i8 0, i8* %46
%47 = load i8*, i8** %8
%48 = getelementptr inbounds i8, i8* %47, i64 1
store i8* %48, i8** %11
%49 = load i8*, i8** %11
%50 = call i8* @strchr(i8* %49, i8 signext 58)
store i8* %50, i8** %12
%51 = load i8*, i8** %12
%52 = icmp ne i8* %51, null
br i1 %52, label %56, label %53
53: ; preds = %45
%54 = call i32 @uwsgi_log(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.1, i64 0, i64 0))
%55 = call i32 @exit(i32 1)
unreachable
56: ; preds = %45
%57 = load i8*, i8** %12
store i8 0, i8* %57
%58 = load i8*, i8** %12
%59 = getelementptr inbounds i8, i8* %58, i64 1
store i8* %59, i8** %13
%60 = load i8*, i8** %7
%61 = load i8*, i8** %9
%62 = load i8*, i8** %10
%63 = load i8*, i8** %11
%64 = load i8*, i8** %13
%65 = call i32 @uwsgi_legion_register(i8* %60, i8* %61, i8* %62, i8* %63, i8* %64)
ret void
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [70 x i8] c"invalid legion syntax, must be <legion> <addr> <valor> <algo:secret>\0A\00"
define void @uwsgi_opt_legion(i8* nocapture readnone %0, i8* %1, i8* nocapture readnone %2) {
%4 = tail call i8* @uwsgi_concat2(i8* %1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%5 = tail call i8* @strchr(i8* dereferenceable(1) %4, i8 signext 32)
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %10
7: ; preds = %3
%8 = tail call i32 @uwsgi_log(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.1, i64 0, i64 0))
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %3
store i8 0, i8* %5
%11 = getelementptr inbounds i8, i8* %5, i64 1
%12 = tail call i8* @strchr(i8* %11, i8 signext 32)
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %17
14: ; preds = %10
%15 = tail call i32 @uwsgi_log(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.1, i64 0, i64 0))
%16 = tail call i32 @exit(i32 1)
unreachable
17: ; preds = %10
store i8 0, i8* %12
%18 = getelementptr inbounds i8, i8* %12, i64 1
%19 = tail call i8* @strchr(i8* %18, i8 signext 32)
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %24
21: ; preds = %17
%22 = tail call i32 @uwsgi_log(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.1, i64 0, i64 0))
%23 = tail call i32 @exit(i32 1)
unreachable
24: ; preds = %17
store i8 0, i8* %19
%25 = getelementptr inbounds i8, i8* %19, i64 1
%26 = tail call i8* @strchr(i8* %25, i8 signext 58)
%27 = icmp eq i8* %26, null
br i1 %27, label %28, label %31
28: ; preds = %24
%29 = tail call i32 @uwsgi_log(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.1, i64 0, i64 0))
%30 = tail call i32 @exit(i32 1)
unreachable
31: ; preds = %24
store i8 0, i8* %26
%32 = getelementptr inbounds i8, i8* %26, i64 1
%33 = tail call i32 @uwsgi_legion_register(i8* %4, i8* %11, i8* %18, i8* %25, i8* %32)
ret void
}