#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*/ bzero(char *, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ retlinelogin(char *);
int /*<<< orphan*/ retlineuid(char *);
int /*<<< orphan*/ strlen(int /*<<< orphan*/);
int write(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ writeback(int /*<<< orphan*/, char *, char *);
void analyze(char *received, int socket) {
  int i = 7;
  int j = 0;
  char match[100];
  bzero(match, 100);
  while (received[i] != '^') {
    if (received[i] == '*') {
      if (received[6] == 'l') {
        int n = write(socket, writeback(retlinelogin(match), received, match),
                      strlen(writeback(retlinelogin(match), received, match)));
        if (n < 0) {
          perror("ERROR writing to socket");
          exit(1);
        }
      } else if (received[6] == 'u') {
        int n = write(socket, writeback(retlineuid(match), received, match),
                      strlen(writeback(retlineuid(match), received, match)));
        if (n < 0) {
          perror("ERROR writing to socket");
          exit(1);
        }
      }
      bzero(match, 100);
      j = 0;
      i++;
    } else {
      match[j] = received[i];
      j++;
      i++;
    }
  }
}


x86 assembly (clang, -O0):
<analyze>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x7,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    -0x80(%rbp),%rdi
mov    $0x64,%esi
call   1080 <bzero@plt>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5e,%eax
je     135a <analyze+0x1da>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2a,%eax
jne    1330 <analyze+0x1b0>
mov    -0x8(%rbp),%rax
movsbl 0x6(%rax),%eax
cmp    $0x6c,%eax
jne    1270 <analyze+0xf0>
mov    -0xc(%rbp),%eax
mov    %eax,-0x90(%rbp)
lea    -0x80(%rbp),%rdi
call   1060 <retlinelogin@plt>
mov    %eax,%edi
mov    -0x8(%rbp),%rsi
lea    -0x80(%rbp),%rdx
call   1050 <writeback@plt>
mov    %eax,-0x8c(%rbp)
lea    -0x80(%rbp),%rdi
call   1060 <retlinelogin@plt>
mov    %eax,%edi
mov    -0x8(%rbp),%rsi
lea    -0x80(%rbp),%rdx
call   1050 <writeback@plt>
mov    %eax,%edi
call   1040 <strlen@plt>
mov    -0x90(%rbp),%edi
mov    -0x8c(%rbp),%esi
mov    %eax,%edx
call   1030 <write@plt>
mov    %eax,-0x84(%rbp)
cmpl   $0x0,-0x84(%rbp)
jge    126b <analyze+0xeb>
lea    0xda4(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
jmp    130d <analyze+0x18d>
mov    -0x8(%rbp),%rax
movsbl 0x6(%rax),%eax
cmp    $0x75,%eax
jne    1308 <analyze+0x188>
mov    -0xc(%rbp),%eax
mov    %eax,-0x98(%rbp)
lea    -0x80(%rbp),%rdi
call   1090 <retlineuid@plt>
mov    %eax,%edi
mov    -0x8(%rbp),%rsi
lea    -0x80(%rbp),%rdx
call   1050 <writeback@plt>
mov    %eax,-0x94(%rbp)
lea    -0x80(%rbp),%rdi
call   1090 <retlineuid@plt>
mov    %eax,%edi
mov    -0x8(%rbp),%rsi
lea    -0x80(%rbp),%rdx
call   1050 <writeback@plt>
mov    %eax,%edi
call   1040 <strlen@plt>
mov    -0x98(%rbp),%edi
mov    -0x94(%rbp),%esi
mov    %eax,%edx
call   1030 <write@plt>
mov    %eax,-0x88(%rbp)
cmpl   $0x0,-0x88(%rbp)
jge    1303 <analyze+0x183>
lea    0xd0c(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
jmp    1308 <analyze+0x188>
jmp    130d <analyze+0x18d>
lea    -0x80(%rbp),%rdi
mov    $0x64,%esi
call   1080 <bzero@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1355 <analyze+0x1d5>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
movslq -0x14(%rbp),%rax
mov    %cl,-0x80(%rbp,%rax,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11ae <analyze+0x2e>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<analyze>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x70,%rsp
mov    %esi,%r14d
mov    %rdi,%rbx
mov    %rsp,%r15
mov    %r15,%rdi
mov    $0x64,%esi
call   1080 <bzero@plt>
lea    0x7(%rbx),%rbp
jmp    1206 <analyze+0x86>
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1090 <retlineuid@plt>
mov    %eax,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1050 <writeback@plt>
mov    %eax,%r12d
mov    %r15,%rdi
call   1090 <retlineuid@plt>
mov    %eax,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1050 <writeback@plt>
mov    %eax,%edi
call   1040 <strlen@plt>
mov    %r14d,%edi
mov    %r12d,%esi
mov    %eax,%edx
call   1030 <write@plt>
test   %eax,%eax
js     1271 <analyze+0xf1>
mov    %r15,%rdi
mov    $0x64,%esi
call   1080 <bzero@plt>
add    $0x1,%rbp
xor    %eax,%eax
movzbl 0x0(%rbp),%ecx
cmp    $0x2a,%cl
je     1230 <analyze+0xb0>
cmp    $0x5e,%cl
je     1264 <analyze+0xe4>
cltq
mov    %cl,(%rsp,%rax,1)
add    $0x1,%eax
add    $0x1,%rbp
jmp    1208 <analyze+0x88>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x6(%rbx),%al
cmp    $0x75,%al
je     11b0 <analyze+0x30>
cmp    $0x6c,%al
jne    11f5 <analyze+0x75>
mov    %r15,%rdi
call   1060 <retlinelogin@plt>
mov    %eax,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1050 <writeback@plt>
mov    %eax,%r12d
mov    %r15,%rdi
call   1060 <retlinelogin@plt>
jmp    11d0 <analyze+0x50>
add    $0x70,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd88(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [24 x i8] c"ERROR writing to socket\00"
define void @analyze(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [100 x i8]
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 7, i32* %5
store i32 0, i32* %6
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%11 = call i32 @bzero(i8* %10, i32 100)
br label %12
12: ; preds = %99, %2
%13 = load i8*, i8** %3
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %13, i64 %15
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 94
br i1 %19, label %20, label %100
20: ; preds = %12
%21 = load i8*, i8** %3
%22 = load i32, i32* %5
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 42
br i1 %27, label %28, label %86
28: ; preds = %20
%29 = load i8*, i8** %3
%30 = getelementptr inbounds i8, i8* %29, i64 6
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 108
br i1 %33, label %34, label %54
34: ; preds = %28
%35 = load i32, i32* %4
%36 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%37 = call i32 @retlinelogin(i8* %36)
%38 = load i8*, i8** %3
%39 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%40 = call i32 @writeback(i32 %37, i8* %38, i8* %39)
%41 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%42 = call i32 @retlinelogin(i8* %41)
%43 = load i8*, i8** %3
%44 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%45 = call i32 @writeback(i32 %42, i8* %43, i8* %44)
%46 = call i32 @strlen(i32 %45)
%47 = call i32 @write(i32 %35, i32 %40, i32 %46)
store i32 %47, i32* %8
%48 = load i32, i32* %8
%49 = icmp slt i32 %48, 0
br i1 %49, label %50, label %53
50: ; preds = %34
%51 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%52 = call i32 @exit(i32 1)
unreachable
53: ; preds = %34
br label %81
54: ; preds = %28
%55 = load i8*, i8** %3
%56 = getelementptr inbounds i8, i8* %55, i64 6
%57 = load i8, i8* %56
%58 = sext i8 %57 to i32
%59 = icmp eq i32 %58, 117
br i1 %59, label %60, label %80
60: ; preds = %54
%61 = load i32, i32* %4
%62 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%63 = call i32 @retlineuid(i8* %62)
%64 = load i8*, i8** %3
%65 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%66 = call i32 @writeback(i32 %63, i8* %64, i8* %65)
%67 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%68 = call i32 @retlineuid(i8* %67)
%69 = load i8*, i8** %3
%70 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%71 = call i32 @writeback(i32 %68, i8* %69, i8* %70)
%72 = call i32 @strlen(i32 %71)
%73 = call i32 @write(i32 %61, i32 %66, i32 %72)
store i32 %73, i32* %9
%74 = load i32, i32* %9
%75 = icmp slt i32 %74, 0
br i1 %75, label %76, label %79
76: ; preds = %60
%77 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%78 = call i32 @exit(i32 1)
unreachable
79: ; preds = %60
br label %80
80: ; preds = %79, %54
br label %81
81: ; preds = %80, %53
%82 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%83 = call i32 @bzero(i8* %82, i32 100)
store i32 0, i32* %6
%84 = load i32, i32* %5
%85 = add nsw i32 %84, 1
store i32 %85, i32* %5
br label %99
86: ; preds = %20
%87 = load i8*, i8** %3
%88 = load i32, i32* %5
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds i8, i8* %87, i64 %89
%91 = load i8, i8* %90
%92 = load i32, i32* %6
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 %93
store i8 %91, i8* %94
%95 = load i32, i32* %6
%96 = add nsw i32 %95, 1
store i32 %96, i32* %6
%97 = load i32, i32* %5
%98 = add nsw i32 %97, 1
store i32 %98, i32* %5
br label %99
99: ; preds = %86, %81
br label %12
100: ; preds = %12
ret void
}

LLVM IR (-O2):
@.str = [24 x i8] c"ERROR writing to socket\00"
define void @analyze(i8* %0, i32 %1) {
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%5 = call i32 @bzero(i8* %4, i32 100)
%6 = getelementptr inbounds i8, i8* %0, i64 6
br label %7
7: ; preds = %42, %2
%8 = phi i64 [ %44, %42 ], [ 7, %2 ]
%9 = phi i32 [ %43, %42 ], [ 0, %2 ]
%10 = getelementptr inbounds i8, i8* %0, i64 %8
%11 = load i8, i8* %10
switch i8 %11, label %38 [
i8 94, label %45
i8 42, label %12
]
12: ; preds = %7
%13 = load i8, i8* %6
switch i8 %13, label %36 [
i8 108, label %14
i8 117, label %25
]
14: ; preds = %12
%15 = call i32 @retlinelogin(i8* %4)
%16 = call i32 @writeback(i32 %15, i8* %0, i8* %4)
%17 = call i32 @retlinelogin(i8* %4)
%18 = call i32 @writeback(i32 %17, i8* %0, i8* %4)
%19 = call i32 @strlen(i32 %18)
%20 = call i32 @write(i32 %1, i32 %16, i32 %19)
%21 = icmp slt i32 %20, 0
br i1 %21, label %22, label %36
22: ; preds = %14
%23 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %12
%26 = call i32 @retlineuid(i8* %4)
%27 = call i32 @writeback(i32 %26, i8* %0, i8* %4)
%28 = call i32 @retlineuid(i8* %4)
%29 = call i32 @writeback(i32 %28, i8* %0, i8* %4)
%30 = call i32 @strlen(i32 %29)
%31 = call i32 @write(i32 %1, i32 %27, i32 %30)
%32 = icmp slt i32 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %25
%34 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%35 = call i32 @exit(i32 1)
unreachable
36: ; preds = %25, %12, %14
%37 = call i32 @bzero(i8* %4, i32 100)
br label %42
38: ; preds = %7
%39 = sext i32 %9 to i64
%40 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %39
store i8 %11, i8* %40
%41 = add nsw i32 %9, 1
br label %42
42: ; preds = %38, %36
%43 = phi i32 [ 0, %36 ], [ %41, %38 ]
%44 = add nuw i64 %8, 1
br label %7
45: ; preds = %7
ret void
}