#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 */
int atoi(char *);
int /*<<< orphan*/ debugPrintStr(char *, char *);
char *strstr(char *, char *);
char *strtok(char *, char *);
int contactCountRecvd(char *line) {
  char *idx = strstr(line, "SYN");
  if (idx == NULL) {
    return -1;
  } else {
    debugPrintStr("INFO msn : contactCountRecvd : contacts recieved ", idx);
    char *token = strtok(idx, " ");
    int cnt = 0;
    char *contactCnt = NULL;
    while (token != NULL) {
      token = strtok(NULL, " ");
      if (cnt == 2) {
        contactCnt = token;
        break;
      }
      cnt++;
    }
    debugPrintStr("INFO msn : contactCountRecvd : Contact Count : ",
                  contactCnt);
    return atoi(contactCnt);
  }
}


x86 assembly (clang, -O0):
<contactCountRecvd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea9(%rip),%rsi
call   1060 <strstr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1177 <contactCountRecvd+0x37>
movl   $0xffffffff,-0x4(%rbp)
jmp    120a <contactCountRecvd+0xca>
mov    -0x18(%rbp),%rsi
lea    0xe82(%rip),%rdi
call   1030 <debugPrintStr@plt>
mov    -0x18(%rbp),%rdi
lea    0xed2(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movq   $0x0,-0x30(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11ee <contactCountRecvd+0xae>
xor    %eax,%eax
mov    %eax,%edi
lea    0xea4(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x20(%rbp)
cmpl   $0x2,-0x24(%rbp)
jne    11e0 <contactCountRecvd+0xa0>
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    11ee <contactCountRecvd+0xae>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11aa <contactCountRecvd+0x6a>
mov    -0x30(%rbp),%rsi
lea    0xe3d(%rip),%rdi
call   1030 <debugPrintStr@plt>
mov    -0x30(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<contactCountRecvd>:
push   %rbx
lea    0xeb8(%rip),%rsi
call   1060 <strstr@plt>
test   %rax,%rax
je     11b5 <contactCountRecvd+0x75>
mov    %rax,%rbx
lea    0xea8(%rip),%rdi
mov    %rax,%rsi
call   1030 <debugPrintStr@plt>
lea    0xef9(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strtok@plt>
test   %rax,%rax
je     11bc <contactCountRecvd+0x7c>
lea    0xee5(%rip),%rsi
xor    %ebx,%ebx
xor    %edi,%edi
call   1040 <strtok@plt>
test   %rax,%rax
je     11be <contactCountRecvd+0x7e>
lea    0xed0(%rip),%rsi
xor    %ebx,%ebx
xor    %edi,%edi
call   1040 <strtok@plt>
test   %rax,%rax
je     11be <contactCountRecvd+0x7e>
lea    0xebb(%rip),%rsi
xor    %edi,%edi
call   1040 <strtok@plt>
mov    %rax,%rbx
jmp    11be <contactCountRecvd+0x7e>
mov    $0xffffffff,%eax
pop    %rbx
ret
xor    %ebx,%ebx
lea    0xe71(%rip),%rdi
mov    %rbx,%rsi
call   1030 <debugPrintStr@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1050 <atoi@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"SYN\00"
@.str.1 = [50 x i8] c"INFO msn : contactCountRecvd : contacts recieved \00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [48 x i8] c"INFO msn : contactCountRecvd : Contact Count : \00"
define i32 @contactCountRecvd(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
store i8* %0, i8** %3
%8 = load i8*, i8** %3
%9 = call i8* @strstr(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i8* %9, i8** %4
%10 = load i8*, i8** %4
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %13
12: ; preds = %1
store i32 -1, i32* %2
br label %35
13: ; preds = %1
%14 = load i8*, i8** %4
%15 = call i32 @debugPrintStr(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = load i8*, i8** %4
%17 = call i8* @strtok(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %17, i8** %5
store i32 0, i32* %6
store i8* null, i8** %7
br label %18
18: ; preds = %27, %13
%19 = load i8*, i8** %5
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %30
21: ; preds = %18
%22 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %22, i8** %5
%23 = load i32, i32* %6
%24 = icmp eq i32 %23, 2
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = load i8*, i8** %5
store i8* %26, i8** %7
br label %30
27: ; preds = %21
%28 = load i32, i32* %6
%29 = add nsw i32 %28, 1
store i32 %29, i32* %6
br label %18
30: ; preds = %25, %18
%31 = load i8*, i8** %7
%32 = call i32 @debugPrintStr(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0), i8* %31)
%33 = load i8*, i8** %7
%34 = call i32 @atoi(i8* %33)
store i32 %34, i32* %2
br label %35
35: ; preds = %30, %12
%36 = load i32, i32* %2
ret i32 %36
}

LLVM IR (-O2):
@.str = [4 x i8] c"SYN\00"
@.str.1 = [50 x i8] c"INFO msn : contactCountRecvd : contacts recieved \00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [48 x i8] c"INFO msn : contactCountRecvd : Contact Count : \00"
define i32 @contactCountRecvd(i8* %0) {
%2 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i8* %2, null
br i1 %3, label %20, label %4
4: ; preds = %1
%5 = tail call i32 @debugPrintStr(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%6 = tail call i8* @strtok(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%7 = icmp eq i8* %6, null
br i1 %7, label %16, label %8
8: ; preds = %4
%9 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%10 = icmp eq i8* %9, null
br i1 %10, label %16, label %11
11: ; preds = %8
%12 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp eq i8* %12, null
br i1 %13, label %16, label %14
14: ; preds = %11
%15 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %16
16: ; preds = %8, %11, %14, %4
%17 = phi i8* [ null, %4 ], [ null, %8 ], [ null, %11 ], [ %15, %14 ]
%18 = tail call i32 @debugPrintStr(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0), i8* %17)
%19 = tail call i32 @atoi(i8* %17)
br label %20
20: ; preds = %1, %16
%21 = phi i32 [ %19, %16 ], [ -1, %1 ]
ret i32 %21
}