#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 char uint8_t;
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ strncpy(char *, char *, int);
int parseMSG_in(const uint8_t *msgbody, uint32_t msglen, char *room,
                uint32_t *len) {
  int i;
  memset(room, 0, sizeof(char) * 32);
  for (i = 0; i < msglen; ++i) {
    if (msgbody[i] == '\\') {
      if (i > (32) - 1)
        return -1;
      strncpy(room, (char *)msgbody, i);
      *len = i;
      return 0;
    }
  }
  return -1;
}


x86 assembly (clang, -O0):
<parseMSG_in>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1040 <memset@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11bd <parseMSG_in+0x9d>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5c,%eax
jne    11aa <parseMSG_in+0x8a>
cmpl   $0x1f,-0x2c(%rbp)
jle    1185 <parseMSG_in+0x65>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c4 <parseMSG_in+0xa4>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x2c(%rbp),%edx
call   1030 <strncpy@plt>
mov    -0x2c(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    11c4 <parseMSG_in+0xa4>
jmp    11af <parseMSG_in+0x8f>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    114e <parseMSG_in+0x2e>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parseMSG_in>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r15
mov    %esi,%ebx
mov    %rdi,%r12
mov    %rdx,%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1040 <memset@plt>
mov    $0xffffffff,%eax
test   %ebx,%ebx
jle    1179 <parseMSG_in+0x59>
mov    %ebx,%ecx
xor    %ebx,%ebx
nop
cmpb   $0x5c,(%r12,%rbx,1)
je     1162 <parseMSG_in+0x42>
add    $0x1,%rbx
cmp    %rbx,%rcx
jne    1150 <parseMSG_in+0x30>
jmp    1179 <parseMSG_in+0x59>
cmp    $0x1f,%ebx
ja     1179 <parseMSG_in+0x59>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %ebx,%edx
call   1030 <strncpy@plt>
mov    %ebx,(%r14)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @parseMSG_in(i8* %0, i32 %1, i8* %2, i32* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32*
%10 = alloca i32
store i8* %0, i8** %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i32* %3, i32** %9
%11 = load i8*, i8** %8
%12 = call i32 @memset(i8* %11, i32 0, i32 32)
store i32 0, i32* %10
br label %13
13: ; preds = %37, %4
%14 = load i32, i32* %10
%15 = load i32, i32* %7
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %40
17: ; preds = %13
%18 = load i8*, i8** %6
%19 = load i32, i32* %10
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 92
br i1 %24, label %25, label %36
25: ; preds = %17
%26 = load i32, i32* %10
%27 = icmp sgt i32 %26, 31
br i1 %27, label %28, label %29
28: ; preds = %25
store i32 -1, i32* %5
br label %41
29: ; preds = %25
%30 = load i8*, i8** %8
%31 = load i8*, i8** %6
%32 = load i32, i32* %10
%33 = call i32 @strncpy(i8* %30, i8* %31, i32 %32)
%34 = load i32, i32* %10
%35 = load i32*, i32** %9
store i32 %34, i32* %35
store i32 0, i32* %5
br label %41
36: ; preds = %17
br label %37
37: ; preds = %36
%38 = load i32, i32* %10
%39 = add nsw i32 %38, 1
store i32 %39, i32* %10
br label %13
40: ; preds = %13
store i32 -1, i32* %5
br label %41
41: ; preds = %40, %29, %28
%42 = load i32, i32* %5
ret i32 %42
}

LLVM IR (-O2):
define i32 @parseMSG_in(i8* %0, i32 %1, i8* %2, i32* nocapture writeonly %3) {
%5 = tail call i32 @memset(i8* %2, i32 0, i32 32)
%6 = icmp sgt i32 %1, 0
br i1 %6, label %7, label %22
7: ; preds = %4
%8 = zext i32 %1 to i64
br label %9
9: ; preds = %7, %19
%10 = phi i64 [ 0, %7 ], [ %20, %19 ]
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 92
br i1 %13, label %14, label %19
14: ; preds = %9
%15 = trunc i64 %10 to i32
%16 = icmp ugt i32 %15, 31
br i1 %16, label %22, label %17
17: ; preds = %14
%18 = tail call i32 @strncpy(i8* %2, i8* %0, i32 %15)
store i32 %15, i32* %3
br label %22
19: ; preds = %9
%20 = add nuw nsw i64 %10, 1
%21 = icmp eq i64 %20, %8
br i1 %21, label %22, label %9
22: ; preds = %19, %4, %14, %17
%23 = phi i32 [ 0, %17 ], [ -1, %14 ], [ -1, %4 ], [ -1, %19 ]
ret i32 %23
}