#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 */
struct sockaddr_un {
  int /*<<< orphan*/ sun_path;
  int /*<<< orphan*/ sun_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ remote;

/* Variables and functions */
int /*<<< orphan*/ AF_UNIX;
int /*<<< orphan*/ SOCK_STREAM;
int accept(int, struct sockaddr *, int *);
int bind(int, struct sockaddr *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int listen(int, int);
int /*<<< orphan*/ perror(char *);
int recv(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ send(int, char *, int, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ strcpy(int /*<<< orphan*/, char *);
int strlen(int /*<<< orphan*/);
int /*<<< orphan*/ *strstr(char *, char *);
int /*<<< orphan*/ unlink(char *);
int main(void) {
  int s, s2, t, len;
  struct sockaddr_un local, remote;
  char str[1024];
  if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
    perror("socket");
    exit(1);
  }
  local.sun_family = AF_UNIX;
  strcpy(local.sun_path, "/tmp/weborf_auth.socket");
  unlink("/tmp/weborf_auth.socket");
  len = strlen(local.sun_path) + sizeof(local.sun_family);
  if (bind(s, (struct sockaddr *)&local, len) == -1) {
    perror("bind");
    exit(1);
  }
  if (listen(s, 5) == -1) {
    perror("listen");
    exit(1);
  }
  for (;;) {
    t = sizeof(remote);
    if ((s2 = accept(s, (struct sockaddr *)&remote, &t)) == -1) {
      perror("accept");
      exit(1);
    }
    t = recv(s2, str, 1024, 0);
    str[t] = '\0';
    if (str[1] == 'f' && str[2] == 'i' && str[3] == 'l' && str[4] == 'm') {
      if (strstr(str, "::ffff:10.0.") == NULL) {
        send(s2, "c", 1, 0);
      }
    }
    close(s2);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2dff(%rip),%rax
mov    (%rax),%edi
mov    0x2de6(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10f0 <socket@plt>
mov    %eax,-0x8(%rbp)
cmp    $0xffffffff,%eax
jne    121d <main+0x4d>
lea    0xe03(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    0x2dc4(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%edi
lea    0xdcd(%rip),%rsi
call   1050 <strcpy@plt>
lea    0xdc1(%rip),%rdi
call   1040 <unlink@plt>
mov    -0x20(%rbp),%edi
call   1060 <strlen@plt>
cltq
add    $0x4,%rax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   10a0 <bind@plt>
cmp    $0xffffffff,%eax
jne    1283 <main+0xb3>
lea    0xda4(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x8(%rbp),%edi
mov    $0x5,%esi
call   1090 <listen@plt>
cmp    $0xffffffff,%eax
jne    12af <main+0xdf>
lea    0xd7d(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
jmp    12b4 <main+0xe4>
movl   $0x8,-0x10(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x28(%rbp),%rsi
lea    -0x10(%rbp),%rdx
call   10c0 <accept@plt>
mov    %eax,-0xc(%rbp)
cmp    $0xffffffff,%eax
jne    12ed <main+0x11d>
lea    0xd46(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0xc(%rbp),%edi
lea    -0x430(%rbp),%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0x10(%rbp)
movslq -0x10(%rbp),%rax
movb   $0x0,-0x430(%rbp,%rax,1)
movsbl -0x42f(%rbp),%eax
cmp    $0x66,%eax
jne    138a <main+0x1ba>
movsbl -0x42e(%rbp),%eax
cmp    $0x69,%eax
jne    138a <main+0x1ba>
movsbl -0x42d(%rbp),%eax
cmp    $0x6c,%eax
jne    138a <main+0x1ba>
movsbl -0x42c(%rbp),%eax
cmp    $0x6d,%eax
jne    138a <main+0x1ba>
lea    -0x430(%rbp),%rdi
lea    0xccb(%rip),%rsi
call   10e0 <strstr@plt>
cmp    $0x0,%rax
jne    1385 <main+0x1b5>
mov    -0xc(%rbp),%edi
lea    0xcbf(%rip),%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1070 <send@plt>
jmp    138a <main+0x1ba>
mov    -0xc(%rbp),%edi
call   1080 <close@plt>
jmp    12b4 <main+0xe4>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x428,%rsp
mov    0x2e00(%rip),%rbx
mov    (%rbx),%edi
mov    0x2de7(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10f0 <socket@plt>
cmp    $0xffffffff,%eax
jne    120b <main+0x3b>
lea    0xe0b(%rip),%rdi
jmp    128f <main+0xbf>
mov    %eax,%r12d
mov    (%rbx),%eax
mov    %eax,0x1c(%rsp)
lea    0xde5(%rip),%rbx
mov    %rbx,%rsi
call   1050 <strcpy@plt>
mov    %rbx,%rdi
call   1040 <unlink@plt>
call   1060 <strlen@plt>
lea    0x4(%rax),%edx
lea    0x18(%rsp),%rsi
mov    %r12d,%edi
call   10a0 <bind@plt>
cmp    $0xffffffff,%eax
jne    124e <main+0x7e>
lea    0xdcc(%rip),%rdi
jmp    128f <main+0xbf>
mov    %r12d,%edi
mov    $0x5,%esi
call   1090 <listen@plt>
cmp    $0xffffffff,%eax
jne    1269 <main+0x99>
lea    0xdb6(%rip),%rdi
jmp    128f <main+0xbf>
movl   $0x8,0xc(%rsp)
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
mov    %r12d,%edi
call   10c0 <accept@plt>
cmp    $0xffffffff,%eax
jne    129e <main+0xce>
lea    0xd95(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    %eax,%ebp
lea    0x20(%rsp),%rbx
lea    0xd7f(%rip),%r14
lea    0x10(%rsp),%r13
lea    0xc(%rsp),%r15
jmp    12e4 <main+0x114>
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
call   1080 <close@plt>
movl   $0x8,0xc(%rsp)
mov    %r12d,%edi
mov    %r13,%rsi
mov    %r15,%rdx
call   10c0 <accept@plt>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
je     1288 <main+0xb8>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,0xc(%rsp)
cltq
movb   $0x0,0x20(%rsp,%rax,1)
movd   0x21(%rsp),%xmm0
movd   %xmm0,%eax
cmp    $0x6d6c6966,%eax
jne    12c0 <main+0xf0>
mov    %rbx,%rdi
mov    %r14,%rsi
call   10e0 <strstr@plt>
test   %rax,%rax
jne    12c0 <main+0xf0>
mov    %ebp,%edi
lea    0xd0e(%rip),%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1070 <send@plt>
jmp    12c0 <main+0xf0>

LLVM IR (-O0):
%struct.sockaddr_un = type { i32, i32 }
%struct.sockaddr = type { i32 }
@AF_UNIX = global i32 0
@SOCK_STREAM = global i32 0
@.str = [7 x i8] c"socket\00"
@.str.1 = [24 x i8] c"/tmp/weborf_auth.socket\00"
@.str.2 = [5 x i8] c"bind\00"
@.str.3 = [7 x i8] c"listen\00"
@.str.4 = [7 x i8] c"accept\00"
@.str.5 = [13 x i8] c"::ffff:10.0.\00"
@.str.6 = [2 x i8] c"c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca %struct.sockaddr_un
%7 = alloca %struct.sockaddr_un
%8 = alloca [1024 x i8]
store i32 0, i32* %1
%9 = load i32, i32* @AF_UNIX
%10 = load i32, i32* @SOCK_STREAM
%11 = call i32 @socket(i32 %9, i32 %10, i32 0)
store i32 %11, i32* %2
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %16
13: ; preds = %0
%14 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %0
%17 = load i32, i32* @AF_UNIX
%18 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %6, i32 0, i32 1
store i32 %17, i32* %18
%19 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %6, i32 0, i32 0
%20 = load i32, i32* %19
%21 = call i32 @strcpy(i32 %20, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%22 = call i32 @unlink(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%23 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %6, i32 0, i32 0
%24 = load i32, i32* %23
%25 = call i32 @strlen(i32 %24)
%26 = sext i32 %25 to i64
%27 = add i64 %26, 4
%28 = trunc i64 %27 to i32
store i32 %28, i32* %5
%29 = load i32, i32* %2
%30 = bitcast %struct.sockaddr_un* %6 to %struct.sockaddr*
%31 = load i32, i32* %5
%32 = call i32 @bind(i32 %29, %struct.sockaddr* %30, i32 %31)
%33 = icmp eq i32 %32, -1
br i1 %33, label %34, label %37
34: ; preds = %16
%35 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%36 = call i32 @exit(i32 1)
unreachable
37: ; preds = %16
%38 = load i32, i32* %2
%39 = call i32 @listen(i32 %38, i32 5)
%40 = icmp eq i32 %39, -1
br i1 %40, label %41, label %44
41: ; preds = %37
%42 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%43 = call i32 @exit(i32 1)
unreachable
44: ; preds = %37
br label %45
45: ; preds = %87, %44
store i32 8, i32* %4
%46 = load i32, i32* %2
%47 = bitcast %struct.sockaddr_un* %7 to %struct.sockaddr*
%48 = call i32 @accept(i32 %46, %struct.sockaddr* %47, i32* %4)
store i32 %48, i32* %3
%49 = icmp eq i32 %48, -1
br i1 %49, label %50, label %53
50: ; preds = %45
%51 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%52 = call i32 @exit(i32 1)
unreachable
53: ; preds = %45
%54 = load i32, i32* %3
%55 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%56 = call i32 @recv(i32 %54, i8* %55, i32 1024, i32 0)
store i32 %56, i32* %4
%57 = load i32, i32* %4
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 %58
store i8 0, i8* %59
%60 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 1
%61 = load i8, i8* %60
%62 = sext i8 %61 to i32
%63 = icmp eq i32 %62, 102
br i1 %63, label %64, label %87
64: ; preds = %53
%65 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 2
%66 = load i8, i8* %65
%67 = sext i8 %66 to i32
%68 = icmp eq i32 %67, 105
br i1 %68, label %69, label %87
69: ; preds = %64
%70 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 3
%71 = load i8, i8* %70
%72 = sext i8 %71 to i32
%73 = icmp eq i32 %72, 108
br i1 %73, label %74, label %87
74: ; preds = %69
%75 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 4
%76 = load i8, i8* %75
%77 = sext i8 %76 to i32
%78 = icmp eq i32 %77, 109
br i1 %78, label %79, label %87
79: ; preds = %74
%80 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%81 = call i32* @strstr(i8* %80, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%82 = icmp eq i32* %81, null
br i1 %82, label %83, label %86
83: ; preds = %79
%84 = load i32, i32* %3
%85 = call i32 @send(i32 %84, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i32 1, i32 0)
br label %86
86: ; preds = %83, %79
br label %87
87: ; preds = %86, %74, %69, %64, %53
%88 = load i32, i32* %3
%89 = call i32 @close(i32 %88)
br label %45
}

LLVM IR (-O2):
%struct.sockaddr_un = type { i32, i32 }
%struct.sockaddr = type { i32 }
@AF_UNIX = global i32 0
@SOCK_STREAM = global i32 0
@.str = [7 x i8] c"socket\00"
@.str.1 = [24 x i8] c"/tmp/weborf_auth.socket\00"
@.str.2 = [5 x i8] c"bind\00"
@.str.3 = [7 x i8] c"listen\00"
@.str.4 = [7 x i8] c"accept\00"
@.str.5 = [13 x i8] c"::ffff:10.0.\00"
@.str.6 = [2 x i8] c"c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.sockaddr_un
%3 = alloca %struct.sockaddr_un
%4 = alloca [1024 x i8]
%5 = bitcast i32* %1 to i8*
%6 = bitcast %struct.sockaddr_un* %2 to i8*
%7 = bitcast %struct.sockaddr_un* %3 to i8*
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%9 = load i32, i32* @AF_UNIX
%10 = load i32, i32* @SOCK_STREAM
%11 = tail call i32 @socket(i32 %9, i32 %10, i32 0)
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %16
13: ; preds = %0
%14 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%15 = tail call i32 @exit(i32 1)
unreachable
16: ; preds = %0
%17 = load i32, i32* @AF_UNIX
%18 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %2, i64 0, i32 1
store i32 %17, i32* %18
%19 = tail call i32 @strcpy(i32 undef, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%20 = tail call i32 @unlink(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%21 = tail call i32 @strlen(i32 undef)
%22 = add i32 %21, 4
%23 = bitcast %struct.sockaddr_un* %2 to %struct.sockaddr*
%24 = call i32 @bind(i32 %11, %struct.sockaddr* %23, i32 %22)
%25 = icmp eq i32 %24, -1
br i1 %25, label %26, label %29
26: ; preds = %16
%27 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%28 = call i32 @exit(i32 1)
unreachable
29: ; preds = %16
%30 = call i32 @listen(i32 %11, i32 5)
%31 = icmp eq i32 %30, -1
br i1 %31, label %39, label %32
32: ; preds = %29
%33 = bitcast %struct.sockaddr_un* %3 to %struct.sockaddr*
store i32 8, i32* %1
%34 = call i32 @accept(i32 %11, %struct.sockaddr* %33, i32* %1)
%35 = icmp eq i32 %34, -1
br i1 %35, label %42, label %36
36: ; preds = %32
%37 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 1
%38 = bitcast i8* %37 to <4 x i8>*
br label %45
39: ; preds = %29
%40 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%41 = call i32 @exit(i32 1)
unreachable
42: ; preds = %59, %32
%43 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%44 = call i32 @exit(i32 1)
unreachable
45: ; preds = %36, %59
%46 = phi i32 [ %34, %36 ], [ %61, %59 ]
%47 = call i32 @recv(i32 %46, i8* %8, i32 1024, i32 0)
store i32 %47, i32* %1
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %48
store i8 0, i8* %49
%50 = load <4 x i8>, <4 x i8>* %38
%51 = freeze <4 x i8> %50
%52 = bitcast <4 x i8> %51 to i32
%53 = icmp eq i32 %52, 1835821414
br i1 %53, label %54, label %59
54: ; preds = %45
%55 = call i32* @strstr(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%56 = icmp eq i32* %55, null
br i1 %56, label %57, label %59
57: ; preds = %54
%58 = call i32 @send(i32 %46, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i32 1, i32 0)
br label %59
59: ; preds = %54, %57, %45
%60 = call i32 @close(i32 %46)
store i32 8, i32* %1
%61 = call i32 @accept(i32 %11, %struct.sockaddr* %33, i32* %1)
%62 = icmp eq i32 %61, -1
br i1 %62, label %42, label %45
}