#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 */
char *strchr(char *, char);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ uwsgi_alarm_trigger(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ uwsgi_log(char *);
int uwsgi_hook_alarm(char *arg) {
  char *space = strchr(arg, ' ');
  if (!space) {
    uwsgi_log("invalid alarm hook 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):
<uwsgi_hook_alarm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x20,%esi
call   1050 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1181 <uwsgi_hook_alarm+0x41>
lea    0xe90(%rip),%rdi
call   1060 <uwsgi_log@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c6 <uwsgi_hook_alarm+0x86>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
add    $0x1,%rdi
call   1030 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    %eax,%edx
call   1040 <uwsgi_alarm_trigger@plt>
mov    -0x18(%rbp),%rax
movb   $0x20,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uwsgi_hook_alarm>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
mov    $0x20,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     1181 <uwsgi_hook_alarm+0x41>
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    1192 <uwsgi_hook_alarm+0x52>
lea    0xe78(%rip),%rdi
call   1060 <uwsgi_log@plt>
mov    $0xffffffff,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

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