#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_rotation_notification(char *msg, int *length) {
  static char keywd[] = "rotation-transition";
  int kwdlen = sizeof(keywd) - 1;
  int transit = -1;
  char *p;
  *length = 0;
  if (!strncmp(msg, keywd, kwdlen)) {
    for (p = msg + kwdlen; *p && *p == ' '; p++)
      ;
    if (!strncmp(p, "on", 2)) {
      transit = 1;
      *length = ((p + 2) - msg) + (p[2] == '\n' ? 1 : 0);
    } else if (!strncmp(p, "off", 3)) {
      transit = 0;
      *length = ((p + 3) - msg) + (p[3] == '\n' ? 1 : 0);
    }
  }
  return transit;
}


x86 assembly (clang, -O0):
<parse_rotation_notification>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x13,-0x14(%rbp)
movl   $0xffffffff,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0x2eea(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    126b <parse_rotation_notification+0x15b>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x21(%rbp)
je     1188 <parse_rotation_notification+0x78>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
sete   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1198 <parse_rotation_notification+0x88>
jmp    11ae <parse_rotation_notification+0x9e>
jmp    119d <parse_rotation_notification+0x8d>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1163 <parse_rotation_notification+0x53>
mov    -0x20(%rbp),%rdi
lea    0xe47(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    120a <parse_rotation_notification+0xfa>
movl   $0x1,-0x18(%rbp)
mov    -0x20(%rbp),%rax
add    $0x2,%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
mov    -0x20(%rbp),%rcx
movsbl 0x2(%rcx),%esi
xor    %ecx,%ecx
mov    $0x1,%edx
cmp    $0xa,%esi
cmove  %edx,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    1266 <parse_rotation_notification+0x156>
mov    -0x20(%rbp),%rdi
lea    0xdee(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1261 <parse_rotation_notification+0x151>
movl   $0x0,-0x18(%rbp)
mov    -0x20(%rbp),%rax
add    $0x3,%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
mov    -0x20(%rbp),%rcx
movsbl 0x3(%rcx),%esi
xor    %ecx,%ecx
mov    $0x1,%edx
cmp    $0xa,%esi
cmove  %edx,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    1266 <parse_rotation_notification+0x156>
jmp    126b <parse_rotation_notification+0x15b>
mov    -0x18(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_rotation_notification>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
movl   $0x0,(%rsi)
lea    0x2f06(%rip),%rsi
mov    $0x13,%edx
call   1030 <strncmp@plt>
mov    $0xffffffff,%r15d
test   %eax,%eax
jne    11b2 <parse_rotation_notification+0xa2>
add    $0x12,%rbx
mov    $0x12,%ebp
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebp
cmpb   $0x20,0x1(%rbx)
lea    0x1(%rbx),%rbx
je     1150 <parse_rotation_notification+0x40>
lea    0xe9c(%rip),%rsi
mov    %rbx,%rdi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     1197 <parse_rotation_notification+0x87>
lea    0xe87(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
jne    11b2 <parse_rotation_notification+0xa2>
xor    %r15d,%r15d
mov    $0x3,%eax
jmp    11a2 <parse_rotation_notification+0x92>
mov    $0x1,%r15d
mov    $0x2,%eax
xor    %ecx,%ecx
cmpb   $0xa,(%rbx,%rax,1)
sete   %cl
add    %ecx,%eax
add    %ebp,%eax
mov    %eax,(%r14)
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@parse_rotation_notification.keywd = internal global [20 x i8] c"rotation-transition\00"
@.str = [3 x i8] c"on\00"
@.str.1 = [4 x i8] c"off\00"
define i32 @parse_rotation_notification(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
store i8* %0, i8** %3
store i32* %1, i32** %4
store i32 19, i32* %5
store i32 -1, i32* %6
%8 = load i32*, i32** %4
store i32 0, i32* %8
%9 = load i8*, i8** %3
%10 = load i32, i32* %5
%11 = call i32 @strncmp(i8* %9, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @parse_rotation_notification.keywd, i64 0, i64 0), i32 %10)
%12 = icmp ne i32 %11, 0
br i1 %12, label %80, label %13
13: ; preds = %2
%14 = load i8*, i8** %3
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
store i8* %17, i8** %7
br label %18
18: ; preds = %31, %13
%19 = load i8*, i8** %7
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %28
23: ; preds = %18
%24 = load i8*, i8** %7
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 32
br label %28
28: ; preds = %23, %18
%29 = phi i1 [ false, %18 ], [ %27, %23 ]
br i1 %29, label %30, label %34
30: ; preds = %28
br label %31
31: ; preds = %30
%32 = load i8*, i8** %7
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %7
br label %18
34: ; preds = %28
%35 = load i8*, i8** %7
%36 = call i32 @strncmp(i8* %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%37 = icmp ne i32 %36, 0
br i1 %37, label %56, label %38
38: ; preds = %34
store i32 1, i32* %6
%39 = load i8*, i8** %7
%40 = getelementptr inbounds i8, i8* %39, i64 2
%41 = load i8*, i8** %3
%42 = ptrtoint i8* %40 to i64
%43 = ptrtoint i8* %41 to i64
%44 = sub i64 %42, %43
%45 = load i8*, i8** %7
%46 = getelementptr inbounds i8, i8* %45, i64 2
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = icmp eq i32 %48, 10
%50 = zext i1 %49 to i64
%51 = select i1 %49, i32 1, i32 0
%52 = sext i32 %51 to i64
%53 = add nsw i64 %44, %52
%54 = trunc i64 %53 to i32
%55 = load i32*, i32** %4
store i32 %54, i32* %55
br label %79
56: ; preds = %34
%57 = load i8*, i8** %7
%58 = call i32 @strncmp(i8* %57, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3)
%59 = icmp ne i32 %58, 0
br i1 %59, label %78, label %60
60: ; preds = %56
store i32 0, i32* %6
%61 = load i8*, i8** %7
%62 = getelementptr inbounds i8, i8* %61, i64 3
%63 = load i8*, i8** %3
%64 = ptrtoint i8* %62 to i64
%65 = ptrtoint i8* %63 to i64
%66 = sub i64 %64, %65
%67 = load i8*, i8** %7
%68 = getelementptr inbounds i8, i8* %67, i64 3
%69 = load i8, i8* %68
%70 = sext i8 %69 to i32
%71 = icmp eq i32 %70, 10
%72 = zext i1 %71 to i64
%73 = select i1 %71, i32 1, i32 0
%74 = sext i32 %73 to i64
%75 = add nsw i64 %66, %74
%76 = trunc i64 %75 to i32
%77 = load i32*, i32** %4
store i32 %76, i32* %77
br label %78
78: ; preds = %60, %56
br label %79
79: ; preds = %78, %38
br label %80
80: ; preds = %79, %2
%81 = load i32, i32* %6
ret i32 %81
}

LLVM IR (-O2):
@parse_rotation_notification.keywd = internal global [20 x i8] c"rotation-transition\00"
@.str = [3 x i8] c"on\00"
@.str.1 = [4 x i8] c"off\00"
define i32 @parse_rotation_notification(i8* %0, i32* nocapture writeonly %1) {
store i32 0, i32* %1
%3 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @parse_rotation_notification.keywd, i64 0, i64 0), i32 19)
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %30
5: ; preds = %2
%6 = getelementptr inbounds i8, i8* %0, i64 19
br label %7
7: ; preds = %7, %5
%8 = phi i8* [ %6, %5 ], [ %11, %7 ]
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 32
%11 = getelementptr inbounds i8, i8* %8, i64 1
br i1 %10, label %7, label %12
12: ; preds = %7
%13 = tail call i32 @strncmp(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%14 = icmp eq i32 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %12
%16 = tail call i32 @strncmp(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %30
18: ; preds = %15, %12
%19 = phi i64 [ 2, %12 ], [ 3, %15 ]
%20 = phi i32 [ 1, %12 ], [ 0, %15 ]
%21 = getelementptr inbounds i8, i8* %8, i64 %19
%22 = ptrtoint i8* %21 to i64
%23 = ptrtoint i8* %0 to i64
%24 = sub i64 %22, %23
%25 = load i8, i8* %21
%26 = icmp eq i8 %25, 10
%27 = zext i1 %26 to i64
%28 = add nsw i64 %24, %27
%29 = trunc i64 %28 to i32
store i32 %29, i32* %1
br label %30
30: ; preds = %18, %15, %2
%31 = phi i32 [ -1, %2 ], [ -1, %15 ], [ %20, %18 ]
ret i32 %31
}