#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 */
scalar_t__ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int, int, int, int);
int sscanf(char *, char *, int *, int *, int *, int *);
int /*<<< orphan*/ stdin;
char *strchr(char *, char);
scalar_t__ strlen(char *);
int /*<<< orphan*/ strncat(char *, char *, scalar_t__);
scalar_t__ strncmp(char *, char *, int);
int main(int argc, char *argv[]) {
  char buff[4096];
  char buff2[4096];
  char *p;
  char *q;
  int a, b, c, d;
  int count = 0;
  while (fgets(buff, 4096, stdin)) {
    if (!strncmp(buff, "Received:", 9)) {
      if (!count) {
        count++;
        continue;
      }
      while (fgets(buff2, 4096, stdin)) {
        if (strncmp(buff2, "Received:", 9))
          strncat(buff, buff2, strlen(buff) - 4096);
        else
          break;
      }
      p = strchr(buff, '(');
      if (!p) {
        return 1;
      }
      if (*(++p) < '0' || *p > '9') {
        q = strchr(p, '(');
        if (!q) {
          q = strchr(p, '@');
          if (!q) {
            return 1;
          }
        }
        p = q + 1;
      }
      q = strchr(p, '@');
      if (q) {
        p = q + 1;
      }
      if (sscanf(p, "%d.%d.%d.%d", &a, &b, &c, &d) != 4) {
        return 1;
      }
      printf("%d.%d.%d.%d\n", a, b, c, d);
      while (fgets(buff, 4096, stdin))
        ;
      return 0;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2050,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x2034(%rbp)
lea    -0x1010(%rbp),%rdi
mov    0x2e47(%rip),%rax
mov    (%rax),%edx
mov    $0x1000,%esi
call   1080 <fgets@plt>
cmp    $0x0,%rax
je     144a <main+0x2da>
lea    -0x1010(%rbp),%rdi
lea    0xe3b(%rip),%rsi
mov    $0x9,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1445 <main+0x2d5>
cmpl   $0x0,-0x2034(%rbp)
jne    11fa <main+0x8a>
mov    -0x2034(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2034(%rbp)
jmp    1193 <main+0x23>
jmp    11ff <main+0x8f>
lea    -0x2010(%rbp),%rdi
mov    0x2ddb(%rip),%rax
mov    (%rax),%edx
mov    $0x1000,%esi
call   1080 <fgets@plt>
cmp    $0x0,%rax
je     1299 <main+0x129>
lea    -0x2010(%rbp),%rdi
lea    0xdcf(%rip),%rsi
mov    $0x9,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     128f <main+0x11f>
lea    -0x1010(%rbp),%rax
mov    %rax,-0x2048(%rbp)
lea    -0x2010(%rbp),%rax
mov    %rax,-0x2040(%rbp)
lea    -0x1010(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x2048(%rbp),%rdi
mov    -0x2040(%rbp),%rsi
mov    %rax,%rdx
sub    $0x1000,%rdx
call   1070 <strncat@plt>
jmp    1294 <main+0x124>
jmp    1299 <main+0x129>
jmp    11ff <main+0x8f>
lea    -0x1010(%rbp),%rdi
mov    $0x28,%esi
call   1050 <strchr@plt>
mov    %rax,-0x2018(%rbp)
cmpq   $0x0,-0x2018(%rbp)
jne    12cb <main+0x15b>
movl   $0x1,-0x4(%rbp)
jmp    1451 <main+0x2e1>
mov    -0x2018(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x2018(%rbp)
movsbl 0x1(%rax),%eax
cmp    $0x30,%eax
jl     1300 <main+0x190>
mov    -0x2018(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x39,%eax
jle    136f <main+0x1ff>
mov    -0x2018(%rbp),%rdi
mov    $0x28,%esi
call   1050 <strchr@plt>
mov    %rax,-0x2020(%rbp)
cmpq   $0x0,-0x2020(%rbp)
jne    135d <main+0x1ed>
mov    -0x2018(%rbp),%rdi
mov    $0x40,%esi
call   1050 <strchr@plt>
mov    %rax,-0x2020(%rbp)
cmpq   $0x0,-0x2020(%rbp)
jne    1358 <main+0x1e8>
movl   $0x1,-0x4(%rbp)
jmp    1451 <main+0x2e1>
jmp    135d <main+0x1ed>
mov    -0x2020(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x2018(%rbp)
mov    -0x2018(%rbp),%rdi
mov    $0x40,%esi
call   1050 <strchr@plt>
mov    %rax,-0x2020(%rbp)
cmpq   $0x0,-0x2020(%rbp)
je     13a7 <main+0x237>
mov    -0x2020(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x2018(%rbp)
mov    -0x2018(%rbp),%rdi
lea    0xc55(%rip),%rsi
lea    -0x2024(%rbp),%rdx
lea    -0x2028(%rbp),%rcx
lea    -0x202c(%rbp),%r8
lea    -0x2030(%rbp),%r9
call   1090 <sscanf@plt>
cmp    $0x4,%eax
je     13eb <main+0x27b>
movl   $0x1,-0x4(%rbp)
jmp    1451 <main+0x2e1>
mov    -0x2024(%rbp),%esi
mov    -0x2028(%rbp),%edx
mov    -0x202c(%rbp),%ecx
mov    -0x2030(%rbp),%r8d
lea    0xc0b(%rip),%rdi
call   1060 <printf@plt>
lea    -0x1010(%rbp),%rdi
mov    0x2bca(%rip),%rax
mov    (%rax),%edx
mov    $0x1000,%esi
call   1080 <fgets@plt>
cmp    $0x0,%rax
je     1439 <main+0x2c9>
jmp    1410 <main+0x2a0>
movl   $0x0,-0x4(%rbp)
jmp    1451 <main+0x2e1>
jmp    1193 <main+0x23>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x2050,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2018,%rsp
mov    0x2e60(%rip),%r13
lea    0x10(%rsp),%rbx
lea    0xe6c(%rip),%r14
mov    $0x1,%ebp
nopl   0x0(%rax)
mov    0x0(%r13),%edx
mov    %rbx,%rdi
mov    $0x1000,%esi
call   1080 <fgets@plt>
test   %rax,%rax
je     1358 <main+0x1e8>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x9,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    11a0 <main+0x30>
lea    0x10(%rsp),%rbx
lea    0xe25(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    0x0(%r13),%edx
mov    %rbx,%rdi
mov    $0x1000,%esi
call   1080 <fgets@plt>
test   %rax,%rax
je     1358 <main+0x1e8>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x9,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    11e0 <main+0x70>
mov    0x0(%r13),%edx
lea    0x1010(%rsp),%rdi
mov    $0x1000,%esi
call   1080 <fgets@plt>
test   %rax,%rax
je     1285 <main+0x115>
lea    0xdcf(%rip),%r14
lea    0x1010(%rsp),%r15
lea    0x10(%rsp),%r12
xchg   %ax,%ax
mov    %r15,%rdi
mov    %r14,%rsi
mov    $0x9,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1285 <main+0x115>
mov    %r12,%rdi
call   1040 <strlen@plt>
lea    -0x1000(%rax),%rdx
mov    %r12,%rdi
mov    %r15,%rsi
call   1070 <strncat@plt>
mov    0x0(%r13),%edx
mov    %r15,%rdi
mov    $0x1000,%esi
call   1080 <fgets@plt>
test   %rax,%rax
jne    1240 <main+0xd0>
lea    0x10(%rsp),%rdi
mov    $0x28,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     1358 <main+0x1e8>
mov    %rax,%r14
add    $0x1,%r14
mov    0x1(%rax),%al
add    $0xc6,%al
cmp    $0xf5,%al
ja     12dc <main+0x16c>
mov    %r14,%rdi
mov    $0x28,%esi
call   1050 <strchr@plt>
test   %rax,%rax
jne    12d5 <main+0x165>
mov    %r14,%rdi
mov    $0x40,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     1358 <main+0x1e8>
add    $0x1,%rax
mov    %rax,%r14
mov    %r14,%rdi
mov    $0x40,%esi
call   1050 <strchr@plt>
lea    0x1(%rax),%rdi
test   %rax,%rax
cmove  %r14,%rdi
lea    0xd0f(%rip),%rsi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
lea    0x4(%rsp),%r8
mov    %rsp,%r9
call   1090 <sscanf@plt>
cmp    $0x4,%eax
jne    1358 <main+0x1e8>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
mov    0x4(%rsp),%ecx
mov    (%rsp),%r8d
lea    0xce8(%rip),%rdi
call   1060 <printf@plt>
lea    0x10(%rsp),%rbx
nopl   0x0(%rax,%rax,1)
mov    0x0(%r13),%edx
mov    %rbx,%rdi
mov    $0x1000,%esi
call   1080 <fgets@plt>
test   %rax,%rax
jne    1340 <main+0x1d0>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x2018,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [10 x i8] c"Received:\00"
@.str.1 = [12 x i8] c"%d.%d.%d.%d\00"
@.str.2 = [13 x i8] c"%d.%d.%d.%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [4096 x i8]
%7 = alloca [4096 x i8]
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %14
br label %15
15: ; preds = %107, %27, %2
%16 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%17 = load i32, i32* @stdin
%18 = call i64 @fgets(i8* %16, i32 4096, i32 %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %108
20: ; preds = %15
%21 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%22 = call i64 @strncmp(i8* %21, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 9)
%23 = icmp ne i64 %22, 0
br i1 %23, label %107, label %24
24: ; preds = %20
%25 = load i32, i32* %14
%26 = icmp ne i32 %25, 0
br i1 %26, label %30, label %27
27: ; preds = %24
%28 = load i32, i32* %14
%29 = add nsw i32 %28, 1
store i32 %29, i32* %14
br label %15
30: ; preds = %24
br label %31
31: ; preds = %48, %30
%32 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%33 = load i32, i32* @stdin
%34 = call i64 @fgets(i8* %32, i32 4096, i32 %33)
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %49
36: ; preds = %31
%37 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%38 = call i64 @strncmp(i8* %37, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 9)
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %47
40: ; preds = %36
%41 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%42 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%43 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%44 = call i64 @strlen(i8* %43)
%45 = sub nsw i64 %44, 4096
%46 = call i32 @strncat(i8* %41, i8* %42, i64 %45)
br label %48
47: ; preds = %36
br label %49
48: ; preds = %40
br label %31
49: ; preds = %47, %31
%50 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%51 = call i8* @strchr(i8* %50, i8 signext 40)
store i8* %51, i8** %8
%52 = load i8*, i8** %8
%53 = icmp ne i8* %52, null
br i1 %53, label %55, label %54
54: ; preds = %49
store i32 1, i32* %3
br label %109
55: ; preds = %49
%56 = load i8*, i8** %8
%57 = getelementptr inbounds i8, i8* %56, i32 1
store i8* %57, i8** %8
%58 = load i8, i8* %57
%59 = sext i8 %58 to i32
%60 = icmp slt i32 %59, 48
br i1 %60, label %66, label %61
61: ; preds = %55
%62 = load i8*, i8** %8
%63 = load i8, i8* %62
%64 = sext i8 %63 to i32
%65 = icmp sgt i32 %64, 57
br i1 %65, label %66, label %81
66: ; preds = %61, %55
%67 = load i8*, i8** %8
%68 = call i8* @strchr(i8* %67, i8 signext 40)
store i8* %68, i8** %9
%69 = load i8*, i8** %9
%70 = icmp ne i8* %69, null
br i1 %70, label %78, label %71
71: ; preds = %66
%72 = load i8*, i8** %8
%73 = call i8* @strchr(i8* %72, i8 signext 64)
store i8* %73, i8** %9
%74 = load i8*, i8** %9
%75 = icmp ne i8* %74, null
br i1 %75, label %77, label %76
76: ; preds = %71
store i32 1, i32* %3
br label %109
77: ; preds = %71
br label %78
78: ; preds = %77, %66
%79 = load i8*, i8** %9
%80 = getelementptr inbounds i8, i8* %79, i64 1
store i8* %80, i8** %8
br label %81
81: ; preds = %78, %61
%82 = load i8*, i8** %8
%83 = call i8* @strchr(i8* %82, i8 signext 64)
store i8* %83, i8** %9
%84 = load i8*, i8** %9
%85 = icmp ne i8* %84, null
br i1 %85, label %86, label %89
86: ; preds = %81
%87 = load i8*, i8** %9
%88 = getelementptr inbounds i8, i8* %87, i64 1
store i8* %88, i8** %8
br label %89
89: ; preds = %86, %81
%90 = load i8*, i8** %8
%91 = call i32 @sscanf(i8* %90, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32* %10, i32* %11, i32* %12, i32* %13)
%92 = icmp ne i32 %91, 4
br i1 %92, label %93, label %94
93: ; preds = %89
store i32 1, i32* %3
br label %109
94: ; preds = %89
%95 = load i32, i32* %10
%96 = load i32, i32* %11
%97 = load i32, i32* %12
%98 = load i32, i32* %13
%99 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %95, i32 %96, i32 %97, i32 %98)
br label %100
100: ; preds = %105, %94
%101 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%102 = load i32, i32* @stdin
%103 = call i64 @fgets(i8* %101, i32 4096, i32 %102)
%104 = icmp ne i64 %103, 0
br i1 %104, label %105, label %106
105: ; preds = %100
br label %100
106: ; preds = %100
store i32 0, i32* %3
br label %109
107: ; preds = %20
br label %15
108: ; preds = %15
store i32 1, i32* %3
br label %109
109: ; preds = %108, %106, %93, %76, %54
%110 = load i32, i32* %3
ret i32 %110
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [10 x i8] c"Received:\00"
@.str.1 = [12 x i8] c"%d.%d.%d.%d\00"
@.str.2 = [13 x i8] c"%d.%d.%d.%d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [4096 x i8]
%4 = alloca [4096 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%10 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%11 = bitcast i32* %5 to i8*
%12 = bitcast i32* %6 to i8*
%13 = bitcast i32* %7 to i8*
%14 = bitcast i32* %8 to i8*
br label %15
15: ; preds = %2, %19
%16 = load i32, i32* @stdin
%17 = call i64 @fgets(i8* %9, i32 4096, i32 %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %78, label %19
19: ; preds = %15
%20 = call i64 @strncmp(i8* %9, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 9)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %15
22: ; preds = %19, %26
%23 = load i32, i32* @stdin
%24 = call i64 @fgets(i8* %9, i32 4096, i32 %23)
%25 = icmp eq i64 %24, 0
br i1 %25, label %78, label %26
26: ; preds = %22
%27 = call i64 @strncmp(i8* %9, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 9)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %22
29: ; preds = %26
%30 = load i32, i32* @stdin
%31 = call i64 @fgets(i8* %10, i32 4096, i32 %30)
%32 = icmp eq i64 %31, 0
br i1 %32, label %43, label %33
33: ; preds = %29, %36
%34 = call i64 @strncmp(i8* %10, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 9)
%35 = icmp eq i64 %34, 0
br i1 %35, label %43, label %36
36: ; preds = %33
%37 = call i64 @strlen(i8* %9)
%38 = add nsw i64 %37, -4096
%39 = call i32 @strncat(i8* %9, i8* %10, i64 %38)
%40 = load i32, i32* @stdin
%41 = call i64 @fgets(i8* %10, i32 4096, i32 %40)
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %33
43: ; preds = %36, %33, %29
%44 = call i8* @strchr(i8* %9, i8 signext 40)
%45 = icmp eq i8* %44, null
br i1 %45, label %78, label %46
46: ; preds = %43
%47 = getelementptr inbounds i8, i8* %44, i64 1
%48 = load i8, i8* %47
%49 = add i8 %48, -58
%50 = icmp ult i8 %49, -10
br i1 %50, label %51, label %60
51: ; preds = %46
%52 = call i8* @strchr(i8* %47, i8 signext 40)
%53 = icmp eq i8* %52, null
br i1 %53, label %54, label %57
54: ; preds = %51
%55 = call i8* @strchr(i8* %47, i8 signext 64)
%56 = icmp eq i8* %55, null
br i1 %56, label %78, label %57
57: ; preds = %54, %51
%58 = phi i8* [ %52, %51 ], [ %55, %54 ]
%59 = getelementptr inbounds i8, i8* %58, i64 1
br label %60
60: ; preds = %46, %57
%61 = phi i8* [ %59, %57 ], [ %47, %46 ]
%62 = call i8* @strchr(i8* %61, i8 signext 64)
%63 = icmp eq i8* %62, null
%64 = getelementptr inbounds i8, i8* %62, i64 1
%65 = select i1 %63, i8* %61, i8* %64
%66 = call i32 @sscanf(i8* %65, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32* %5, i32* %6, i32* %7, i32* %8)
%67 = icmp eq i32 %66, 4
br i1 %67, label %68, label %78
68: ; preds = %60
%69 = load i32, i32* %5
%70 = load i32, i32* %6
%71 = load i32, i32* %7
%72 = load i32, i32* %8
%73 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %69, i32 %70, i32 %71, i32 %72)
br label %74
74: ; preds = %74, %68
%75 = load i32, i32* @stdin
%76 = call i64 @fgets(i8* %9, i32 4096, i32 %75)
%77 = icmp eq i64 %76, 0
br i1 %77, label %78, label %74
78: ; preds = %15, %22, %74, %60, %54, %43
%79 = phi i32 [ 1, %43 ], [ 1, %54 ], [ 1, %60 ], [ 0, %74 ], [ 1, %22 ], [ 1, %15 ]
ret i32 %79
}