#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 /*<<< orphan*/ memcpy(char *, char *, int);
scalar_t__ string_search(char *, char *);
int get_connection_state(char *line, char *state) {
  if (string_search(line, "ESTABLISHED")) {
    memcpy(state, "ESTABLISHED", 11);
  } else if (string_search(line, "TIME_WAIT")) {
    memcpy(state, "TIME_WAIT", 9);
  } else if (string_search(line, "FIN_WAIT")) {
    memcpy(state, "FIN_WAIT", 8);
  } else if (string_search(line, "SYN_RECV")) {
    memcpy(state, "SYN_RECV", 8);
  } else if (string_search(line, "SYN_SENT")) {
    memcpy(state, "SYN_SENT", 8);
  } else if (string_search(line, "UNREPLIED")) {
    memcpy(state, "UNREPLIED", 9);
  } else if (string_search(line, "CLOSE")) {
    memcpy(state, "CLOSE", 5);
  } else if (string_search(line, "ASSURED")) {
    memcpy(state, "ASSURED", 7);
  } else {
    if (string_search(line, "udp")) {
      memcpy(state, "UNREPLIED", 9);
    } else {
      memcpy(state, " ", 1);
    }
  }
  return (0);
}


x86 assembly (clang, -O0):
<get_connection_state>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xec5(%rip),%rsi
call   1030 <string_search@plt>
cmp    $0x0,%rax
je     1164 <get_connection_state+0x44>
mov    -0x10(%rbp),%rdi
lea    0xeab(%rip),%rsi
mov    $0xb,%edx
call   1040 <memcpy@plt>
jmp    1341 <get_connection_state+0x221>
mov    -0x8(%rbp),%rdi
lea    0xe9d(%rip),%rsi
call   1030 <string_search@plt>
cmp    $0x0,%rax
je     1198 <get_connection_state+0x78>
mov    -0x10(%rbp),%rdi
lea    0xe83(%rip),%rsi
mov    $0x9,%edx
call   1040 <memcpy@plt>
jmp    133c <get_connection_state+0x21c>
mov    -0x8(%rbp),%rdi
lea    0xe73(%rip),%rsi
call   1030 <string_search@plt>
cmp    $0x0,%rax
je     11cc <get_connection_state+0xac>
mov    -0x10(%rbp),%rdi
lea    0xe59(%rip),%rsi
mov    $0x8,%edx
call   1040 <memcpy@plt>
jmp    1337 <get_connection_state+0x217>
mov    -0x8(%rbp),%rdi
lea    0xe48(%rip),%rsi
call   1030 <string_search@plt>
cmp    $0x0,%rax
je     1200 <get_connection_state+0xe0>
mov    -0x10(%rbp),%rdi
lea    0xe2e(%rip),%rsi
mov    $0x8,%edx
call   1040 <memcpy@plt>
jmp    1332 <get_connection_state+0x212>
mov    -0x8(%rbp),%rdi
lea    0xe1d(%rip),%rsi
call   1030 <string_search@plt>
cmp    $0x0,%rax
je     1234 <get_connection_state+0x114>
mov    -0x10(%rbp),%rdi
lea    0xe03(%rip),%rsi
mov    $0x8,%edx
call   1040 <memcpy@plt>
jmp    132d <get_connection_state+0x20d>
mov    -0x8(%rbp),%rdi
lea    0xdf2(%rip),%rsi
call   1030 <string_search@plt>
cmp    $0x0,%rax
je     1268 <get_connection_state+0x148>
mov    -0x10(%rbp),%rdi
lea    0xdd8(%rip),%rsi
mov    $0x9,%edx
call   1040 <memcpy@plt>
jmp    1328 <get_connection_state+0x208>
mov    -0x8(%rbp),%rdi
lea    0xdc8(%rip),%rsi
call   1030 <string_search@plt>
cmp    $0x0,%rax
je     129c <get_connection_state+0x17c>
mov    -0x10(%rbp),%rdi
lea    0xdae(%rip),%rsi
mov    $0x5,%edx
call   1040 <memcpy@plt>
jmp    1323 <get_connection_state+0x203>
mov    -0x8(%rbp),%rdi
lea    0xd9a(%rip),%rsi
call   1030 <string_search@plt>
cmp    $0x0,%rax
je     12d0 <get_connection_state+0x1b0>
mov    -0x10(%rbp),%rdi
lea    0xd80(%rip),%rsi
mov    $0x7,%edx
call   1040 <memcpy@plt>
jmp    131e <get_connection_state+0x1fe>
mov    -0x8(%rbp),%rdi
lea    0xd6e(%rip),%rsi
call   1030 <string_search@plt>
cmp    $0x0,%rax
je     1304 <get_connection_state+0x1e4>
mov    -0x10(%rbp),%rdi
lea    0xd3c(%rip),%rsi
mov    $0x9,%edx
call   1040 <memcpy@plt>
jmp    1319 <get_connection_state+0x1f9>
mov    -0x10(%rbp),%rdi
lea    0xd3e(%rip),%rsi
mov    $0x1,%edx
call   1040 <memcpy@plt>
jmp    131e <get_connection_state+0x1fe>
jmp    1323 <get_connection_state+0x203>
jmp    1328 <get_connection_state+0x208>
jmp    132d <get_connection_state+0x20d>
jmp    1332 <get_connection_state+0x212>
jmp    1337 <get_connection_state+0x217>
jmp    133c <get_connection_state+0x21c>
jmp    1341 <get_connection_state+0x221>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_connection_state>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xecf(%rip),%rsi
call   1030 <string_search@plt>
test   %rax,%rax
je     114f <get_connection_state+0x2f>
lea    0xebe(%rip),%rsi
mov    %r14,%rdi
mov    $0xb,%edx
jmp    11d1 <get_connection_state+0xb1>
lea    0xeb6(%rip),%rsi
mov    %rbx,%rdi
call   1030 <string_search@plt>
test   %rax,%rax
je     1174 <get_connection_state+0x54>
lea    0xea2(%rip),%rsi
mov    %r14,%rdi
mov    $0x9,%edx
jmp    11d1 <get_connection_state+0xb1>
lea    0xe9b(%rip),%rsi
mov    %rbx,%rdi
call   1030 <string_search@plt>
test   %rax,%rax
je     1191 <get_connection_state+0x71>
lea    0xe87(%rip),%rsi
jmp    11c9 <get_connection_state+0xa9>
lea    0xe87(%rip),%rsi
mov    %rbx,%rdi
call   1030 <string_search@plt>
test   %rax,%rax
je     11ae <get_connection_state+0x8e>
lea    0xe73(%rip),%rsi
jmp    11c9 <get_connection_state+0xa9>
lea    0xe73(%rip),%rsi
mov    %rbx,%rdi
call   1030 <string_search@plt>
test   %rax,%rax
je     11e0 <get_connection_state+0xc0>
lea    0xe5f(%rip),%rsi
mov    %r14,%rdi
mov    $0x8,%edx
call   1040 <memcpy@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe4a(%rip),%rsi
mov    %rbx,%rdi
call   1030 <string_search@plt>
test   %rax,%rax
je     1200 <get_connection_state+0xe0>
lea    0xe36(%rip),%rsi
jmp    116a <get_connection_state+0x4a>
lea    0xe34(%rip),%rsi
mov    %rbx,%rdi
call   1030 <string_search@plt>
test   %rax,%rax
je     1225 <get_connection_state+0x105>
lea    0xe20(%rip),%rsi
mov    %r14,%rdi
mov    $0x5,%edx
jmp    11d1 <get_connection_state+0xb1>
lea    0xe15(%rip),%rsi
mov    %rbx,%rdi
call   1030 <string_search@plt>
test   %rax,%rax
je     124a <get_connection_state+0x12a>
lea    0xe01(%rip),%rsi
mov    %r14,%rdi
mov    $0x7,%edx
jmp    11d1 <get_connection_state+0xb1>
lea    0xdf8(%rip),%rsi
mov    %rbx,%rdi
call   1030 <string_search@plt>
test   %rax,%rax
jne    11f4 <get_connection_state+0xd4>
lea    0xde8(%rip),%rsi
mov    %r14,%rdi
mov    $0x1,%edx
jmp    11d1 <get_connection_state+0xb1>

LLVM IR (-O0):
@.str = [12 x i8] c"ESTABLISHED\00"
@.str.1 = [10 x i8] c"TIME_WAIT\00"
@.str.2 = [9 x i8] c"FIN_WAIT\00"
@.str.3 = [9 x i8] c"SYN_RECV\00"
@.str.4 = [9 x i8] c"SYN_SENT\00"
@.str.5 = [10 x i8] c"UNREPLIED\00"
@.str.6 = [6 x i8] c"CLOSE\00"
@.str.7 = [8 x i8] c"ASSURED\00"
@.str.8 = [4 x i8] c"udp\00"
@.str.9 = [2 x i8] c" \00"
define i32 @get_connection_state(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%5 = load i8*, i8** %3
%6 = call i64 @string_search(i8* %5, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load i8*, i8** %4
%10 = call i32 @memcpy(i8* %9, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 11)
br label %78
11: ; preds = %2
%12 = load i8*, i8** %3
%13 = call i64 @string_search(i8* %12, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %11
%16 = load i8*, i8** %4
%17 = call i32 @memcpy(i8* %16, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 9)
br label %77
18: ; preds = %11
%19 = load i8*, i8** %3
%20 = call i64 @string_search(i8* %19, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %18
%23 = load i8*, i8** %4
%24 = call i32 @memcpy(i8* %23, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 8)
br label %76
25: ; preds = %18
%26 = load i8*, i8** %3
%27 = call i64 @string_search(i8* %26, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %25
%30 = load i8*, i8** %4
%31 = call i32 @memcpy(i8* %30, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 8)
br label %75
32: ; preds = %25
%33 = load i8*, i8** %3
%34 = call i64 @string_search(i8* %33, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %32
%37 = load i8*, i8** %4
%38 = call i32 @memcpy(i8* %37, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 8)
br label %74
39: ; preds = %32
%40 = load i8*, i8** %3
%41 = call i64 @string_search(i8* %40, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%42 = icmp ne i64 %41, 0
br i1 %42, label %43, label %46
43: ; preds = %39
%44 = load i8*, i8** %4
%45 = call i32 @memcpy(i8* %44, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 9)
br label %73
46: ; preds = %39
%47 = load i8*, i8** %3
%48 = call i64 @string_search(i8* %47, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%49 = icmp ne i64 %48, 0
br i1 %49, label %50, label %53
50: ; preds = %46
%51 = load i8*, i8** %4
%52 = call i32 @memcpy(i8* %51, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 5)
br label %72
53: ; preds = %46
%54 = load i8*, i8** %3
%55 = call i64 @string_search(i8* %54, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
%56 = icmp ne i64 %55, 0
br i1 %56, label %57, label %60
57: ; preds = %53
%58 = load i8*, i8** %4
%59 = call i32 @memcpy(i8* %58, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i32 7)
br label %71
60: ; preds = %53
%61 = load i8*, i8** %3
%62 = call i64 @string_search(i8* %61, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%63 = icmp ne i64 %62, 0
br i1 %63, label %64, label %67
64: ; preds = %60
%65 = load i8*, i8** %4
%66 = call i32 @memcpy(i8* %65, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 9)
br label %70
67: ; preds = %60
%68 = load i8*, i8** %4
%69 = call i32 @memcpy(i8* %68, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i32 1)
br label %70
70: ; preds = %67, %64
br label %71
71: ; preds = %70, %57
br label %72
72: ; preds = %71, %50
br label %73
73: ; preds = %72, %43
br label %74
74: ; preds = %73, %36
br label %75
75: ; preds = %74, %29
br label %76
76: ; preds = %75, %22
br label %77
77: ; preds = %76, %15
br label %78
78: ; preds = %77, %8
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"ESTABLISHED\00"
@.str.1 = [10 x i8] c"TIME_WAIT\00"
@.str.2 = [9 x i8] c"FIN_WAIT\00"
@.str.3 = [9 x i8] c"SYN_RECV\00"
@.str.4 = [9 x i8] c"SYN_SENT\00"
@.str.5 = [10 x i8] c"UNREPLIED\00"
@.str.6 = [6 x i8] c"CLOSE\00"
@.str.7 = [8 x i8] c"ASSURED\00"
@.str.8 = [4 x i8] c"udp\00"
@.str.9 = [2 x i8] c" \00"
define i32 @get_connection_state(i8* %0, i8* %1) {
%3 = tail call i64 @string_search(i8* %0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i64 %3, 0
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = tail call i32 @memcpy(i8* %1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 11)
br label %49
7: ; preds = %2
%8 = tail call i64 @string_search(i8* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %7
%11 = tail call i32 @memcpy(i8* %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 9)
br label %49
12: ; preds = %7
%13 = tail call i64 @string_search(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %12
%16 = tail call i32 @memcpy(i8* %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 8)
br label %49
17: ; preds = %12
%18 = tail call i64 @string_search(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %17
%21 = tail call i32 @memcpy(i8* %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 8)
br label %49
22: ; preds = %17
%23 = tail call i64 @string_search(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %27, label %25
25: ; preds = %22
%26 = tail call i32 @memcpy(i8* %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 8)
br label %49
27: ; preds = %22
%28 = tail call i64 @string_search(i8* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %32, label %30
30: ; preds = %27
%31 = tail call i32 @memcpy(i8* %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 9)
br label %49
32: ; preds = %27
%33 = tail call i64 @string_search(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %37, label %35
35: ; preds = %32
%36 = tail call i32 @memcpy(i8* %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 5)
br label %49
37: ; preds = %32
%38 = tail call i64 @string_search(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
br i1 %39, label %42, label %40
40: ; preds = %37
%41 = tail call i32 @memcpy(i8* %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i32 7)
br label %49
42: ; preds = %37
%43 = tail call i64 @string_search(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%44 = icmp eq i64 %43, 0
br i1 %44, label %47, label %45
45: ; preds = %42
%46 = tail call i32 @memcpy(i8* %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 9)
br label %49
47: ; preds = %42
%48 = tail call i32 @memcpy(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i32 1)
br label %49
49: ; preds = %10, %20, %30, %40, %47, %45, %35, %25, %15, %5
ret i32 0
}