#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*/ strcpy(char *, char *);
int strlen(char *);
scalar_t__ strn_casecmp(char *, char *, int);
int has_sessionID(char *inp, char *sessionID) {
  int l;
  char *p;
  l = strlen(inp);
  if (l < 9)
    return 0;
  if (strn_casecmp(inp, "session", 7) != 0)
    return 0;
  p = strchr(inp, ':');
  p++;
  while (*p && (*p == ' '))
    p++;
  if (p) {
    strcpy(sessionID, p);
    return 1;
  } else
    return 0;
}


x86 assembly (clang, -O0):
<has_sessionID>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x9,-0x1c(%rbp)
jge    1172 <has_sessionID+0x32>
movl   $0x0,-0x4(%rbp)
jmp    122c <has_sessionID+0xec>
mov    -0x10(%rbp),%rdi
lea    0xe83(%rip),%rsi
mov    $0x7,%edx
call   1040 <strn_casecmp@plt>
cmp    $0x0,%rax
je     119d <has_sessionID+0x5d>
movl   $0x0,-0x4(%rbp)
jmp    122c <has_sessionID+0xec>
mov    -0x10(%rbp),%rdi
mov    $0x3a,%esi
call   1060 <strchr@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x29(%rbp)
je     11e0 <has_sessionID+0xa0>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
sete   %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    11f0 <has_sessionID+0xb0>
jmp    1201 <has_sessionID+0xc1>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    11bb <has_sessionID+0x7b>
cmpq   $0x0,-0x28(%rbp)
je     1225 <has_sessionID+0xe5>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <strcpy@plt>
movl   $0x1,-0x4(%rbp)
jmp    122c <has_sessionID+0xec>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<has_sessionID>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
call   1050 <strlen@plt>
xor    %ebp,%ebp
cmp    $0x9,%eax
jl     119a <has_sessionID+0x5a>
lea    0xea3(%rip),%rsi
mov    %rbx,%rdi
mov    $0x7,%edx
call   1040 <strn_casecmp@plt>
test   %rax,%rax
jne    119a <has_sessionID+0x5a>
mov    %rbx,%rdi
mov    $0x3a,%esi
call   1060 <strchr@plt>
nopl   0x0(%rax)
cmpb   $0x20,0x1(%rax)
lea    0x1(%rax),%rax
je     1180 <has_sessionID+0x40>
mov    %r14,%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"session\00"
define i32 @has_sessionID(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %4
%9 = call i32 @strlen(i8* %8)
store i32 %9, i32* %6
%10 = load i32, i32* %6
%11 = icmp slt i32 %10, 9
br i1 %11, label %12, label %13
12: ; preds = %2
store i32 0, i32* %3
br label %46
13: ; preds = %2
%14 = load i8*, i8** %4
%15 = call i64 @strn_casecmp(i8* %14, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 7)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %13
store i32 0, i32* %3
br label %46
18: ; preds = %13
%19 = load i8*, i8** %4
%20 = call i8* @strchr(i8* %19, i8 signext 58)
store i8* %20, i8** %7
%21 = load i8*, i8** %7
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %7
br label %23
23: ; preds = %35, %18
%24 = load i8*, i8** %7
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %33
28: ; preds = %23
%29 = load i8*, i8** %7
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 32
br label %33
33: ; preds = %28, %23
%34 = phi i1 [ false, %23 ], [ %32, %28 ]
br i1 %34, label %35, label %38
35: ; preds = %33
%36 = load i8*, i8** %7
%37 = getelementptr inbounds i8, i8* %36, i32 1
store i8* %37, i8** %7
br label %23
38: ; preds = %33
%39 = load i8*, i8** %7
%40 = icmp ne i8* %39, null
br i1 %40, label %41, label %45
41: ; preds = %38
%42 = load i8*, i8** %5
%43 = load i8*, i8** %7
%44 = call i32 @strcpy(i8* %42, i8* %43)
store i32 1, i32* %3
br label %46
45: ; preds = %38
store i32 0, i32* %3
br label %46
46: ; preds = %45, %41, %17, %12
%47 = load i32, i32* %3
ret i32 %47
}

LLVM IR (-O2):
@.str = [8 x i8] c"session\00"
define i32 @has_sessionID(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = icmp slt i32 %3, 9
br i1 %4, label %17, label %5
5: ; preds = %2
%6 = tail call i64 @strn_casecmp(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 7)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %17
8: ; preds = %5
%9 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 58)
br label %10
10: ; preds = %10, %8
%11 = phi i8* [ %9, %8 ], [ %12, %10 ]
%12 = getelementptr inbounds i8, i8* %11, i64 1
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 32
br i1 %14, label %10, label %15
15: ; preds = %10
%16 = tail call i32 @strcpy(i8* %1, i8* %12)
br label %17
17: ; preds = %5, %2, %15
%18 = phi i32 [ 1, %15 ], [ 0, %2 ], [ 0, %5 ]
ret i32 %18
}