#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_port;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int int16_t;
typedef int /*<<< orphan*/ addr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ MSG_WAITALL;
int /*<<< orphan*/ SOCK_STREAM;
int abs(int);
scalar_t__ connect(int, struct sockaddr *, int);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ inet_addr(char *);
int *malloc(int);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ recv(int, int *, int, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int main() {
  int i, sock;
  struct sockaddr_in addr;
  int16_t *data, d, dmax;
  data = malloc(2 * 4194304);
  if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
    perror("socket");
    return 1;
  }
  memset(&addr, 0, sizeof(addr));
  addr.sin_family = AF_INET;
  addr.sin_addr.s_addr = inet_addr("192.168.1.100");
  addr.sin_port = htons(1001);
  if (connect(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
    perror("connect");
    return 1;
  }
  while (1) {
    recv(sock, data, 2 * 4194304, MSG_WAITALL);
    dmax = 0;
    for (i = 1; i < 4194304; ++i) {
      d = abs(data[i] - data[i - 1]);
      if (dmax < d)
        dmax = d;
    }
    if (dmax > 10)
      printf("%d\n", dmax);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x800000,%edi
call   1090 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    0x2e24(%rip),%rax
mov    (%rax),%edi
mov    0x2e0b(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10c0 <socket@plt>
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
jge    11fa <main+0x5a>
lea    0xe17(%rip),%rdi
call   10a0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1305 <main+0x165>
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1070 <memset@plt>
mov    0x2dd7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
lea    0xdea(%rip),%rdi
call   1080 <inet_addr@plt>
mov    %eax,-0x14(%rbp)
mov    $0x3e9,%edi
call   1050 <htons@plt>
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%edi
lea    -0x18(%rbp),%rsi
mov    $0xc,%edx
call   10b0 <connect@plt>
cmp    $0x0,%rax
jge    1265 <main+0xc5>
lea    0xdc1(%rip),%rdi
call   10a0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1305 <main+0x165>
jmp    126a <main+0xca>
mov    -0xc(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    0x2d50(%rip),%rax
mov    (%rax),%ecx
mov    $0x800000,%edx
call   1030 <recv@plt>
movl   $0x0,-0x28(%rbp)
movl   $0x1,-0x8(%rbp)
cmpl   $0x400000,-0x8(%rbp)
jge    12e7 <main+0x147>
mov    -0x20(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    -0x20(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
sub    (%rax,%rcx,4),%edi
call   1040 <abs@plt>
mov    %eax,-0x24(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    12d4 <main+0x134>
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
jmp    12d9 <main+0x139>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1292 <main+0xf2>
cmpl   $0xa,-0x28(%rbp)
jle    1300 <main+0x160>
mov    -0x28(%rbp),%esi
lea    0xd22(%rip),%rdi
call   1060 <printf@plt>
jmp    126a <main+0xca>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    $0x800000,%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
mov    0x2e3a(%rip),%r15
mov    (%r15),%edi
mov    0x2e20(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10b0 <socket@plt>
test   %eax,%eax
js     13de <main+0x24e>
mov    %eax,%ebp
lea    0x8(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1060 <memset@plt>
mov    (%r15),%eax
mov    %eax,0x10(%rsp)
lea    0xe1a(%rip),%rdi
call   1070 <inet_addr@plt>
mov    %eax,0xc(%rsp)
mov    $0x3e9,%edi
call   1040 <htons@plt>
mov    %eax,0x8(%rsp)
mov    %ebp,%edi
mov    %r14,%rsi
mov    $0xc,%edx
call   10a0 <connect@plt>
test   %rax,%rax
js     13e7 <main+0x257>
mov    0x2da5(%rip),%r15
lea    0xdf3(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    (%r15),%ecx
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x800000,%edx
call   1030 <recv@plt>
movd   (%rbx),%xmm0
pshufd $0x0,%xmm0,%xmm0
pxor   %xmm1,%xmm1
mov    $0x5,%eax
pxor   %xmm2,%xmm2
nopl   0x0(%rax,%rax,1)
movups -0x10(%rbx,%rax,4),%xmm3
shufps $0x3,%xmm3,%xmm0
shufps $0x98,%xmm3,%xmm0
movaps %xmm3,%xmm4
psubd  %xmm0,%xmm3
movups (%rbx,%rax,4),%xmm0
shufps $0x3,%xmm0,%xmm4
shufps $0x98,%xmm0,%xmm4
movaps %xmm0,%xmm5
psubd  %xmm4,%xmm5
movdqa %xmm3,%xmm4
psrad  $0x1f,%xmm4
paddd  %xmm4,%xmm3
pxor   %xmm4,%xmm3
movdqa %xmm5,%xmm4
psrad  $0x1f,%xmm4
paddd  %xmm4,%xmm5
pxor   %xmm4,%xmm5
movdqa %xmm1,%xmm4
pcmpgtd %xmm3,%xmm1
pand   %xmm1,%xmm4
pandn  %xmm3,%xmm1
por    %xmm4,%xmm1
movdqa %xmm2,%xmm3
pcmpgtd %xmm5,%xmm2
pand   %xmm2,%xmm3
pandn  %xmm5,%xmm2
por    %xmm3,%xmm2
add    $0x8,%rax
cmp    $0x3ffffd,%rax
jne    1260 <main+0xd0>
movdqa %xmm1,%xmm3
pcmpgtd %xmm2,%xmm3
pand   %xmm3,%xmm1
pandn  %xmm2,%xmm3
por    %xmm1,%xmm3
pshufd $0xee,%xmm3,%xmm1
movdqa %xmm3,%xmm2
pcmpgtd %xmm1,%xmm2
pand   %xmm2,%xmm3
pandn  %xmm1,%xmm2
por    %xmm3,%xmm2
pshufd $0x55,%xmm2,%xmm1
movdqa %xmm2,%xmm3
pcmpgtd %xmm1,%xmm3
pand   %xmm3,%xmm2
pandn  %xmm1,%xmm3
por    %xmm2,%xmm3
movd   %xmm3,%eax
pshufd $0xff,%xmm0,%xmm0
movd   %xmm0,%ecx
mov    0xffffe4(%rbx),%edx
mov    %edx,%esi
sub    %ecx,%esi
mov    %esi,%ecx
neg    %ecx
cmovs  %esi,%ecx
mov    0xffffe8(%rbx),%esi
cmp    %ecx,%eax
cmovge %eax,%ecx
mov    %esi,%eax
sub    %edx,%eax
mov    %eax,%edx
neg    %edx
cmovs  %eax,%edx
cmp    %edx,%ecx
cmovge %ecx,%edx
mov    0xffffec(%rbx),%eax
mov    %eax,%ecx
sub    %esi,%ecx
mov    %ecx,%esi
neg    %esi
cmovs  %ecx,%esi
cmp    %esi,%edx
cmovge %edx,%esi
mov    0xfffff0(%rbx),%ecx
mov    %ecx,%edx
sub    %eax,%edx
mov    %edx,%eax
neg    %eax
cmovs  %edx,%eax
cmp    %eax,%esi
cmovge %esi,%eax
mov    0xfffff4(%rbx),%edx
mov    %edx,%esi
sub    %ecx,%esi
mov    %esi,%ecx
neg    %ecx
cmovs  %esi,%ecx
cmp    %ecx,%eax
cmovge %eax,%ecx
mov    0xfffff8(%rbx),%eax
mov    %eax,%esi
sub    %edx,%esi
mov    %esi,%edx
neg    %edx
cmovs  %esi,%edx
cmp    %edx,%ecx
cmovge %ecx,%edx
mov    0xfffffc(%rbx),%ecx
sub    %eax,%ecx
mov    %ecx,%esi
neg    %esi
cmovs  %ecx,%esi
cmp    %esi,%edx
cmovge %edx,%esi
cmp    $0xb,%esi
jb     1230 <main+0xa0>
mov    %r14,%rdi
call   1050 <printf@plt>
jmp    1230 <main+0xa0>
lea    0xc1b(%rip),%rdi
jmp    13ee <main+0x25e>
lea    0xc27(%rip),%rdi
call   1090 <perror@plt>
mov    $0x1,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [7 x i8] c"socket\00"
@.str.1 = [14 x i8] c"192.168.1.100\00"
@.str.2 = [8 x i8] c"connect\00"
@MSG_WAITALL = global i32 0
@.str.3 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca %struct.sockaddr_in
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32* @malloc(i32 8388608)
store i32* %8, i32** %5
%9 = load i32, i32* @AF_INET
%10 = load i32, i32* @SOCK_STREAM
%11 = call i32 @socket(i32 %9, i32 %10, i32 0)
store i32 %11, i32* %3
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %0
%14 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %1
br label %69
15: ; preds = %0
%16 = call i32 @memset(%struct.sockaddr_in* %4, i32 0, i32 12)
%17 = load i32, i32* @AF_INET
%18 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i32 0, i32 2
store i32 %17, i32* %18
%19 = call i32 @inet_addr(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%20 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i32 0, i32 1
%21 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %20, i32 0, i32 0
store i32 %19, i32* %21
%22 = call i32 @htons(i32 1001)
%23 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i32 0, i32 0
store i32 %22, i32* %23
%24 = load i32, i32* %3
%25 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%26 = call i64 @connect(i32 %24, %struct.sockaddr* %25, i32 12)
%27 = icmp slt i64 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %15
%29 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %1
br label %69
30: ; preds = %15
br label %31
31: ; preds = %30, %68
%32 = load i32, i32* %3
%33 = load i32*, i32** %5
%34 = load i32, i32* @MSG_WAITALL
%35 = call i32 @recv(i32 %32, i32* %33, i32 8388608, i32 %34)
store i32 0, i32* %7
store i32 1, i32* %2
br label %36
36: ; preds = %59, %31
%37 = load i32, i32* %2
%38 = icmp slt i32 %37, 4194304
br i1 %38, label %39, label %62
39: ; preds = %36
%40 = load i32*, i32** %5
%41 = load i32, i32* %2
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i32, i32* %40, i64 %42
%44 = load i32, i32* %43
%45 = load i32*, i32** %5
%46 = load i32, i32* %2
%47 = sub nsw i32 %46, 1
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i32, i32* %45, i64 %48
%50 = load i32, i32* %49
%51 = sub nsw i32 %44, %50
%52 = call i32 @abs(i32 %51)
store i32 %52, i32* %6
%53 = load i32, i32* %7
%54 = load i32, i32* %6
%55 = icmp slt i32 %53, %54
br i1 %55, label %56, label %58
56: ; preds = %39
%57 = load i32, i32* %6
store i32 %57, i32* %7
br label %58
58: ; preds = %56, %39
br label %59
59: ; preds = %58
%60 = load i32, i32* %2
%61 = add nsw i32 %60, 1
store i32 %61, i32* %2
br label %36
62: ; preds = %36
%63 = load i32, i32* %7
%64 = icmp sgt i32 %63, 10
br i1 %64, label %65, label %68
65: ; preds = %62
%66 = load i32, i32* %7
%67 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %66)
br label %68
68: ; preds = %65, %62
br label %31
69: ; preds = %28, %13
%70 = load i32, i32* %1
ret i32 %70
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [7 x i8] c"socket\00"
@.str.1 = [14 x i8] c"192.168.1.100\00"
@.str.2 = [8 x i8] c"connect\00"
@MSG_WAITALL = global i32 0
@.str.3 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca %struct.sockaddr_in
%2 = bitcast %struct.sockaddr_in* %1 to i8*
%3 = tail call i32* @malloc(i32 8388608)
%4 = load i32, i32* @AF_INET
%5 = load i32, i32* @SOCK_STREAM
%6 = tail call i32 @socket(i32 %4, i32 %5, i32 0)
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %104
10: ; preds = %0
%11 = call i32 @memset(%struct.sockaddr_in* %1, i32 0, i32 12)
%12 = load i32, i32* @AF_INET
%13 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 2
store i32 %12, i32* %13
%14 = call i32 @inet_addr(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%15 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 1, i32 0
store i32 %14, i32* %15
%16 = call i32 @htons(i32 1001)
%17 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 0
store i32 %16, i32* %17
%18 = bitcast %struct.sockaddr_in* %1 to %struct.sockaddr*
%19 = call i64 @connect(i32 %6, %struct.sockaddr* %18, i32 12)
%20 = icmp slt i64 %19, 0
br i1 %20, label %29, label %21
21: ; preds = %10
%22 = getelementptr inbounds i32, i32* %3, i64 4194297
%23 = getelementptr inbounds i32, i32* %3, i64 4194298
%24 = getelementptr inbounds i32, i32* %3, i64 4194299
%25 = getelementptr inbounds i32, i32* %3, i64 4194300
%26 = getelementptr inbounds i32, i32* %3, i64 4194301
%27 = getelementptr inbounds i32, i32* %3, i64 4194302
%28 = getelementptr inbounds i32, i32* %3, i64 4194303
br label %31
29: ; preds = %10
%30 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
br label %104
31: ; preds = %103, %21
%32 = load i32, i32* @MSG_WAITALL
%33 = call i32 @recv(i32 %6, i32* %3, i32 8388608, i32 %32)
%34 = load i32, i32* %3
%35 = insertelement <4 x i32> poison, i32 %34, i64 3
br label %36
36: ; preds = %36, %31
%37 = phi i64 [ 0, %31 ], [ %58, %36 ]
%38 = phi <4 x i32> [ %35, %31 ], [ %47, %36 ]
%39 = phi <4 x i32> [ zeroinitializer, %31 ], [ %56, %36 ]
%40 = phi <4 x i32> [ zeroinitializer, %31 ], [ %57, %36 ]
%41 = or i64 %37, 1
%42 = getelementptr inbounds i32, i32* %3, i64 %41
%43 = bitcast i32* %42 to <4 x i32>*
%44 = load <4 x i32>, <4 x i32>* %43
%45 = getelementptr inbounds i32, i32* %42, i64 4
%46 = bitcast i32* %45 to <4 x i32>*
%47 = load <4 x i32>, <4 x i32>* %46
%48 = shufflevector <4 x i32> %38, <4 x i32> %44, <4 x i32> <i32 3, i32 4, i32 5, i32 6>
%49 = shufflevector <4 x i32> %44, <4 x i32> %47, <4 x i32> <i32 3, i32 4, i32 5, i32 6>
%50 = sub nsw <4 x i32> %44, %48
%51 = sub nsw <4 x i32> %47, %49
%52 = call <4 x i32> @llvm.abs.v4i32(<4 x i32> %50, i1 true)
%53 = call <4 x i32> @llvm.abs.v4i32(<4 x i32> %51, i1 true)
%54 = icmp slt <4 x i32> %39, %52
%55 = icmp slt <4 x i32> %40, %53
%56 = select <4 x i1> %54, <4 x i32> %52, <4 x i32> %39
%57 = select <4 x i1> %55, <4 x i32> %53, <4 x i32> %40
%58 = add nuw i64 %37, 8
%59 = icmp eq i64 %58, 4194296
br i1 %59, label %60, label %36
60: ; preds = %36
%61 = icmp sgt <4 x i32> %56, %57
%62 = select <4 x i1> %61, <4 x i32> %56, <4 x i32> %57
%63 = call i32 @llvm.vector.reduce.smax.v4i32(<4 x i32> %62)
%64 = extractelement <4 x i32> %47, i64 3
%65 = load i32, i32* %22
%66 = sub nsw i32 %65, %64
%67 = call i32 @llvm.abs.i32(i32 %66, i1 true)
%68 = icmp slt i32 %63, %67
%69 = select i1 %68, i32 %67, i32 %63
%70 = load i32, i32* %23
%71 = sub nsw i32 %70, %65
%72 = call i32 @llvm.abs.i32(i32 %71, i1 true)
%73 = icmp slt i32 %69, %72
%74 = select i1 %73, i32 %72, i32 %69
%75 = load i32, i32* %24
%76 = sub nsw i32 %75, %70
%77 = call i32 @llvm.abs.i32(i32 %76, i1 true)
%78 = icmp slt i32 %74, %77
%79 = select i1 %78, i32 %77, i32 %74
%80 = load i32, i32* %25
%81 = sub nsw i32 %80, %75
%82 = call i32 @llvm.abs.i32(i32 %81, i1 true)
%83 = icmp slt i32 %79, %82
%84 = select i1 %83, i32 %82, i32 %79
%85 = load i32, i32* %26
%86 = sub nsw i32 %85, %80
%87 = call i32 @llvm.abs.i32(i32 %86, i1 true)
%88 = icmp slt i32 %84, %87
%89 = select i1 %88, i32 %87, i32 %84
%90 = load i32, i32* %27
%91 = sub nsw i32 %90, %85
%92 = call i32 @llvm.abs.i32(i32 %91, i1 true)
%93 = icmp slt i32 %89, %92
%94 = select i1 %93, i32 %92, i32 %89
%95 = load i32, i32* %28
%96 = sub nsw i32 %95, %90
%97 = call i32 @llvm.abs.i32(i32 %96, i1 true)
%98 = icmp slt i32 %94, %97
%99 = select i1 %98, i32 %97, i32 %94
%100 = icmp ugt i32 %99, 10
br i1 %100, label %101, label %103
101: ; preds = %60
%102 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %99)
br label %103
103: ; preds = %101, %60
br label %31
104: ; preds = %29, %8
ret i32 1
}