#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 */
struct uwsgi_legion {
  int dummy;
};

/* Variables and functions */
char *strchr(char *, char);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ uwsgi_alarm_trigger(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ uwsgi_log(char *);
int legion_action_alarm(struct uwsgi_legion *ul, char *arg) {
  char *space = strchr(arg, ' ');
  if (!space) {
    uwsgi_log("invalid alarm action syntax, must be: <alarm> <msg>\n");
    return -1;
  }
  *space = 0;
  uwsgi_alarm_trigger(arg, space + 1, strlen(space + 1));
  *space = ' ';
  return 0;
}


x86 assembly (clang, -O0):
<legion_action_alarm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x20,%esi
call   1050 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1185 <legion_action_alarm+0x45>
lea    0xe8c(%rip),%rdi
call   1060 <uwsgi_log@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ca <legion_action_alarm+0x8a>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
add    $0x1,%rdi
call   1030 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
call   1040 <uwsgi_alarm_trigger@plt>
mov    -0x20(%rbp),%rax
movb   $0x20,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<legion_action_alarm>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rsi,%rdi
mov    $0x20,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     1184 <legion_action_alarm+0x44>
mov    %rax,%r15
movb   $0x0,(%rax)
mov    %rax,%rbx
add    $0x1,%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <uwsgi_alarm_trigger@plt>
movb   $0x20,(%r15)
xor    %eax,%eax
jmp    1195 <legion_action_alarm+0x55>
lea    0xe75(%rip),%rdi
call   1060 <uwsgi_log@plt>
mov    $0xffffffff,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.uwsgi_legion = type { i32 }
@.str = [53 x i8] c"invalid alarm action syntax, must be: <alarm> <msg>\0A\00"
define i32 @legion_action_alarm(%struct.uwsgi_legion* %0, i8* %1) {
%3 = alloca i32
%4 = alloca %struct.uwsgi_legion*
%5 = alloca i8*
%6 = alloca i8*
store %struct.uwsgi_legion* %0, %struct.uwsgi_legion** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %5
%8 = call i8* @strchr(i8* %7, i8 signext 32)
store i8* %8, i8** %6
%9 = load i8*, i8** %6
%10 = icmp ne i8* %9, null
br i1 %10, label %13, label %11
11: ; preds = %2
%12 = call i32 @uwsgi_log(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %23
13: ; preds = %2
%14 = load i8*, i8** %6
store i8 0, i8* %14
%15 = load i8*, i8** %5
%16 = load i8*, i8** %6
%17 = getelementptr inbounds i8, i8* %16, i64 1
%18 = load i8*, i8** %6
%19 = getelementptr inbounds i8, i8* %18, i64 1
%20 = call i32 @strlen(i8* %19)
%21 = call i32 @uwsgi_alarm_trigger(i8* %15, i8* %17, i32 %20)
%22 = load i8*, i8** %6
store i8 32, i8* %22
store i32 0, i32* %3
br label %23
23: ; preds = %13, %11
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
%struct.uwsgi_legion = type { i32 }
@.str = [53 x i8] c"invalid alarm action syntax, must be: <alarm> <msg>\0A\00"
define i32 @legion_action_alarm(%struct.uwsgi_legion* nocapture readnone %0, i8* %1) {
%3 = tail call i8* @strchr(i8* dereferenceable(1) %1, i8 signext 32)
%4 = icmp eq i8* %3, null
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @uwsgi_log(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
br label %11
7: ; preds = %2
store i8 0, i8* %3
%8 = getelementptr inbounds i8, i8* %3, i64 1
%9 = tail call i32 @strlen(i8* %8)
%10 = tail call i32 @uwsgi_alarm_trigger(i8* %1, i8* %8, i32 %9)
store i8 32, i8* %3
br label %11
11: ; preds = %7, %5
%12 = phi i32 [ 0, %7 ], [ -1, %5 ]
ret i32 %12
}