#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 */
typedef int /*<<< orphan*/ keywd;

/* Variables and functions */
int /*<<< orphan*/ strncmp(char *, char *, int);
int parse_callui_notification(char *msg, int *length) {
  static char keywd[] = "callui ";
  int kwdlen = sizeof(keywd) - 1;
  int popup = -1;
  *length = 0;
  if (!strncmp(msg, keywd, kwdlen)) {
    msg += kwdlen;
    if (!strncmp(msg, "popup", 5)) {
      popup = 1;
      *length = kwdlen + 5 + (msg[5] == '\n' ? 1 : 0);
    } else if (!strncmp(msg, "popdown", 7)) {
      popup = 0;
      *length = kwdlen + 7 + (msg[7] == '\n' ? 1 : 0);
    }
  }
  return popup;
}


x86 assembly (clang, -O0):
<parse_callui_notification>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x7,-0x14(%rbp)
movl   $0xffffffff,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0x2ee2(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1204 <parse_callui_notification+0xf4>
mov    -0x14(%rbp),%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe90(%rip),%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    11b2 <parse_callui_notification+0xa2>
movl   $0x1,-0x18(%rbp)
mov    -0x14(%rbp),%ecx
add    $0x5,%ecx
mov    -0x8(%rbp),%rax
movsbl 0x5(%rax),%esi
xor    %eax,%eax
mov    $0x1,%edx
cmp    $0xa,%esi
cmove  %edx,%eax
add    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    11ff <parse_callui_notification+0xef>
mov    -0x8(%rbp),%rdi
lea    0xe49(%rip),%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    11fa <parse_callui_notification+0xea>
movl   $0x0,-0x18(%rbp)
mov    -0x14(%rbp),%ecx
add    $0x7,%ecx
mov    -0x8(%rbp),%rax
movsbl 0x7(%rax),%esi
xor    %eax,%eax
mov    $0x1,%edx
cmp    $0xa,%esi
cmove  %edx,%eax
add    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    11ff <parse_callui_notification+0xef>
jmp    1204 <parse_callui_notification+0xf4>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_callui_notification>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
movl   $0x0,(%rsi)
lea    0x2efe(%rip),%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
mov    $0xffffffff,%ebp
test   %eax,%eax
jne    1195 <parse_callui_notification+0x85>
lea    0x7(%rbx),%r15
lea    0xeb8(%rip),%rsi
mov    %r15,%rdi
mov    $0x5,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     1181 <parse_callui_notification+0x71>
lea    0xea6(%rip),%rsi
mov    %r15,%rdi
mov    $0x7,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
jne    1195 <parse_callui_notification+0x85>
xor    %eax,%eax
cmpb   $0xa,0xe(%rbx)
sete   %al
or     $0xe,%eax
xor    %ebp,%ebp
jmp    1192 <parse_callui_notification+0x82>
xor    %eax,%eax
cmpb   $0xa,0xc(%rbx)
sete   %al
or     $0xc,%eax
mov    $0x1,%ebp
mov    %eax,(%r14)
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@parse_callui_notification.keywd = internal global [8 x i8] c"callui \00"
@.str = [6 x i8] c"popup\00"
@.str.1 = [8 x i8] c"popdown\00"
define i32 @parse_callui_notification(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
store i32* %1, i32** %4
store i32 7, i32* %5
store i32 -1, i32* %6
%7 = load i32*, i32** %4
store i32 0, i32* %7
%8 = load i8*, i8** %3
%9 = load i32, i32* %5
%10 = call i32 @strncmp(i8* %8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @parse_callui_notification.keywd, i64 0, i64 0), i32 %9)
%11 = icmp ne i32 %10, 0
br i1 %11, label %50, label %12
12: ; preds = %2
%13 = load i32, i32* %5
%14 = load i8*, i8** %3
%15 = sext i32 %13 to i64
%16 = getelementptr inbounds i8, i8* %14, i64 %15
store i8* %16, i8** %3
%17 = load i8*, i8** %3
%18 = call i32 @strncmp(i8* %17, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 5)
%19 = icmp ne i32 %18, 0
br i1 %19, label %32, label %20
20: ; preds = %12
store i32 1, i32* %6
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 5
%23 = load i8*, i8** %3
%24 = getelementptr inbounds i8, i8* %23, i64 5
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 10
%28 = zext i1 %27 to i64
%29 = select i1 %27, i32 1, i32 0
%30 = add nsw i32 %22, %29
%31 = load i32*, i32** %4
store i32 %30, i32* %31
br label %49
32: ; preds = %12
%33 = load i8*, i8** %3
%34 = call i32 @strncmp(i8* %33, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 7)
%35 = icmp ne i32 %34, 0
br i1 %35, label %48, label %36
36: ; preds = %32
store i32 0, i32* %6
%37 = load i32, i32* %5
%38 = add nsw i32 %37, 7
%39 = load i8*, i8** %3
%40 = getelementptr inbounds i8, i8* %39, i64 7
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = icmp eq i32 %42, 10
%44 = zext i1 %43 to i64
%45 = select i1 %43, i32 1, i32 0
%46 = add nsw i32 %38, %45
%47 = load i32*, i32** %4
store i32 %46, i32* %47
br label %48
48: ; preds = %36, %32
br label %49
49: ; preds = %48, %20
br label %50
50: ; preds = %49, %2
%51 = load i32, i32* %6
ret i32 %51
}

LLVM IR (-O2):
@parse_callui_notification.keywd = internal global [8 x i8] c"callui \00"
@.str = [6 x i8] c"popup\00"
@.str.1 = [8 x i8] c"popdown\00"
define i32 @parse_callui_notification(i8* %0, i32* nocapture writeonly %1) {
store i32 0, i32* %1
%3 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @parse_callui_notification.keywd, i64 0, i64 0), i32 7)
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %25
5: ; preds = %2
%6 = getelementptr inbounds i8, i8* %0, i64 7
%7 = tail call i32 @strncmp(i8* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 5)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %14
9: ; preds = %5
%10 = getelementptr inbounds i8, i8* %0, i64 12
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 10
%13 = select i1 %12, i32 13, i32 12
br label %22
14: ; preds = %5
%15 = tail call i32 @strncmp(i8* %6, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 7)
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %25
17: ; preds = %14
%18 = getelementptr inbounds i8, i8* %0, i64 14
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 10
%21 = select i1 %20, i32 15, i32 14
br label %22
22: ; preds = %17, %9
%23 = phi i32 [ %13, %9 ], [ %21, %17 ]
%24 = phi i32 [ 1, %9 ], [ 0, %17 ]
store i32 %23, i32* %1
br label %25
25: ; preds = %22, %14, %2
%26 = phi i32 [ -1, %2 ], [ -1, %14 ], [ %24, %22 ]
ret i32 %26
}