#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 int32_t;
typedef int /*<<< orphan*/ addr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ MSG_WAITALL;
int /*<<< orphan*/ SOCK_STREAM;
scalar_t__ connect(int, struct sockaddr *, int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
scalar_t__ floor(int);
int /*<<< orphan*/ fwrite(float *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ inet_addr(char *);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ recv(int, int *, int, int /*<<< orphan*/);
int /*<<< orphan*/ send(int, char *, int, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
int main(int argc, char **argv) {
  int sock;
  struct sockaddr_in addr;
  int32_t bufferIn[256];
  float bufferOut[256];
  int32_t freq, corr, rate;
  int i;
  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.4");
  addr.sin_port = htons(1001);
  if (connect(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
    perror("connect");
    return 1;
  }
  rate = 1;
  rate |= 1 << 31;
  send(sock, (char *)&rate, 4, 0);
  freq = 5000000;
  corr = 25;
  freq = (int)floor(freq * (1.0 + corr * 1.0e-6) + 0.5);
  send(sock, (char *)&freq, 4, 0);
  while (1) {
    recv(sock, bufferIn, 1024, MSG_WAITALL);
    for (i = 0; i < 256; ++i) {
      bufferOut[i] = ((float)bufferIn[i]) / 2147483647.0;
    }
    fwrite(bufferOut, 1, 1024, stdout);
    fflush(stdout);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x830,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e18(%rip),%rax
mov    (%rax),%edi
mov    0x2dff(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10d0 <socket@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    1206 <main+0x56>
lea    0xe2b(%rip),%rdi
call   1090 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    13c4 <main+0x214>
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1060 <memset@plt>
mov    0x2dcb(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
lea    0xdfe(%rip),%rdi
call   1070 <inet_addr@plt>
mov    %eax,-0x1c(%rbp)
mov    $0x3e9,%edi
call   1040 <htons@plt>
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0xc,%edx
call   10a0 <connect@plt>
cmp    $0x0,%rax
jge    1271 <main+0xc1>
lea    0xdd3(%rip),%rdi
call   1090 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    13c4 <main+0x214>
movl   $0x1,-0x82c(%rbp)
mov    -0x82c(%rbp),%eax
or     $0x80000000,%eax
mov    %eax,-0x82c(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x82c(%rbp),%rsi
mov    $0x4,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
movl   $0x4c4b40,-0x824(%rbp)
movl   $0x19,-0x828(%rbp)
cvtsi2sdl -0x824(%rbp),%xmm0
ff
cvtsi2sdl -0x828(%rbp),%xmm1
ff
movsd  0xd3a(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xd36(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd16(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   10c0 <floor@plt>
mov    %eax,-0x824(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x824(%rbp),%rsi
mov    $0x4,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
mov    -0x14(%rbp),%edi
lea    -0x420(%rbp),%rsi
mov    0x2c9c(%rip),%rax
mov    (%rax),%ecx
mov    $0x400,%edx
call   1030 <recv@plt>
movl   $0x0,-0x830(%rbp)
cmpl   $0x100,-0x830(%rbp)
jge    1392 <main+0x1e2>
movslq -0x830(%rbp),%rax
cvtsi2ssl -0x420(%rbp,%rax,4),%xmm0
ff ff
cvtss2sd %xmm0,%xmm0
movsd  0xcb2(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movslq -0x830(%rbp),%rax
movss  %xmm0,-0x820(%rbp,%rax,4)
ff ff
mov    -0x830(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x830(%rbp)
jmp    133a <main+0x18a>
lea    -0x820(%rbp),%rdi
mov    0x2c30(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
mov    $0x400,%edx
call   10b0 <fwrite@plt>
mov    0x2c18(%rip),%rax
mov    (%rax),%edi
call   1080 <fflush@plt>
jmp    1313 <main+0x163>
mov    -0x4(%rbp),%eax
add    $0x830,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x820,%rsp
mov    0x2e22(%rip),%rbx
mov    (%rbx),%edi
mov    0x2e09(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10d0 <socket@plt>
test   %eax,%eax
js     1332 <main+0x182>
mov    %eax,%ebp
lea    0x10(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1060 <memset@plt>
mov    (%rbx),%eax
mov    %eax,0x18(%rsp)
lea    0xe14(%rip),%rdi
call   1070 <inet_addr@plt>
mov    %eax,0x14(%rsp)
mov    $0x3e9,%edi
call   1040 <htons@plt>
mov    %eax,0x10(%rsp)
mov    %ebp,%edi
mov    %r14,%rsi
mov    $0xc,%edx
call   10a0 <connect@plt>
test   %rax,%rax
js     133b <main+0x18b>
movl   $0x80000001,0x8(%rsp)
80
lea    0x8(%rsp),%rsi
mov    %ebp,%edi
mov    $0x4,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
mov    $0x4c4bbd,%edi
call   10c0 <floor@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rsi
mov    %ebp,%edi
mov    $0x4,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
mov    0x2d4b(%rip),%r12
lea    0x420(%rsp),%r14
mov    0x2d4c(%rip),%rbx
lea    0x20(%rsp),%r15
nopl   0x0(%rax)
mov    (%r12),%ecx
mov    %ebp,%edi
mov    %r14,%rsi
mov    $0x400,%edx
call   1030 <recv@plt>
xor    %eax,%eax
movapd 0xd53(%rip),%xmm2
nopl   (%rax)
cvtdq2ps 0x420(%rsp,%rax,4),%xmm0
cvtps2pd %xmm0,%xmm1
movhlps %xmm0,%xmm0
cvtps2pd %xmm0,%xmm0
divpd  %xmm2,%xmm0
divpd  %xmm2,%xmm1
cvtpd2ps %xmm1,%xmm1
cvtpd2ps %xmm0,%xmm0
unpcklpd %xmm0,%xmm1
cvtdq2ps 0x430(%rsp,%rax,4),%xmm0
movapd %xmm1,0x20(%rsp,%rax,4)
cvtps2pd %xmm0,%xmm1
movhlps %xmm0,%xmm0
cvtps2pd %xmm0,%xmm0
divpd  %xmm2,%xmm0
divpd  %xmm2,%xmm1
cvtpd2ps %xmm1,%xmm1
cvtpd2ps %xmm0,%xmm0
unpcklpd %xmm0,%xmm1
movapd %xmm1,0x30(%rsp,%rax,4)
add    $0x8,%rax
cmp    $0x100,%rax
jne    12b0 <main+0x100>
mov    (%rbx),%ecx
mov    %r15,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
call   10b0 <fwrite@plt>
mov    (%rbx),%edi
call   1080 <fflush@plt>
jmp    1290 <main+0xe0>
lea    0xcd7(%rip),%rdi
jmp    1342 <main+0x192>
lea    0xce1(%rip),%rdi
call   1090 <perror@plt>
mov    $0x1,%eax
add    $0x820,%rsp
pop    %rbx
pop    %r12
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 = [12 x i8] c"192.168.1.4\00"
@.str.2 = [8 x i8] c"connect\00"
@MSG_WAITALL = global i32 0
@stdout = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.sockaddr_in
%8 = alloca [256 x i32]
%9 = alloca [256 x float]
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* @AF_INET
%15 = load i32, i32* @SOCK_STREAM
%16 = call i32 @socket(i32 %14, i32 %15, i32 0)
store i32 %16, i32* %6
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %2
%19 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %82
20: ; preds = %2
%21 = call i32 @memset(%struct.sockaddr_in* %7, i32 0, i32 12)
%22 = load i32, i32* @AF_INET
%23 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 2
store i32 %22, i32* %23
%24 = call i32 @inet_addr(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%25 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 1
%26 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %25, i32 0, i32 0
store i32 %24, i32* %26
%27 = call i32 @htons(i32 1001)
%28 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 0
store i32 %27, i32* %28
%29 = load i32, i32* %6
%30 = bitcast %struct.sockaddr_in* %7 to %struct.sockaddr*
%31 = call i64 @connect(i32 %29, %struct.sockaddr* %30, i32 12)
%32 = icmp slt i64 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %20
%34 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %82
35: ; preds = %20
store i32 1, i32* %12
%36 = load i32, i32* %12
%37 = or i32 %36, -2147483648
store i32 %37, i32* %12
%38 = load i32, i32* %6
%39 = bitcast i32* %12 to i8*
%40 = call i32 @send(i32 %38, i8* %39, i32 4, i32 0)
store i32 5000000, i32* %10
store i32 25, i32* %11
%41 = load i32, i32* %10
%42 = sitofp i32 %41 to double
%43 = load i32, i32* %11
%44 = sitofp i32 %43 to double
%45 = call double @llvm.fmuladd.f64(double %44, double 0x3EB0C6F7A0B5ED8D, double 1.000000e+00)
%46 = call double @llvm.fmuladd.f64(double %42, double %45, double 5.000000e-01)
%47 = fptosi double %46 to i32
%48 = call i64 @floor(i32 %47)
%49 = trunc i64 %48 to i32
store i32 %49, i32* %10
%50 = load i32, i32* %6
%51 = bitcast i32* %10 to i8*
%52 = call i32 @send(i32 %50, i8* %51, i32 4, i32 0)
br label %53
53: ; preds = %35, %76
%54 = load i32, i32* %6
%55 = getelementptr inbounds [256 x i32], [256 x i32]* %8, i64 0, i64 0
%56 = load i32, i32* @MSG_WAITALL
%57 = call i32 @recv(i32 %54, i32* %55, i32 1024, i32 %56)
store i32 0, i32* %13
br label %58
58: ; preds = %73, %53
%59 = load i32, i32* %13
%60 = icmp slt i32 %59, 256
br i1 %60, label %61, label %76
61: ; preds = %58
%62 = load i32, i32* %13
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [256 x i32], [256 x i32]* %8, i64 0, i64 %63
%65 = load i32, i32* %64
%66 = sitofp i32 %65 to float
%67 = fpext float %66 to double
%68 = fdiv double %67, 0x41DFFFFFFFC00000
%69 = fptrunc double %68 to float
%70 = load i32, i32* %13
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds [256 x float], [256 x float]* %9, i64 0, i64 %71
store float %69, float* %72
br label %73
73: ; preds = %61
%74 = load i32, i32* %13
%75 = add nsw i32 %74, 1
store i32 %75, i32* %13
br label %58
76: ; preds = %58
%77 = getelementptr inbounds [256 x float], [256 x float]* %9, i64 0, i64 0
%78 = load i32, i32* @stdout
%79 = call i32 @fwrite(float* %77, i32 1, i32 1024, i32 %78)
%80 = load i32, i32* @stdout
%81 = call i32 @fflush(i32 %80)
br label %53
82: ; preds = %33, %18
%83 = load i32, i32* %3
ret i32 %83
}

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 = [12 x i8] c"192.168.1.4\00"
@.str.2 = [8 x i8] c"connect\00"
@MSG_WAITALL = global i32 0
@stdout = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca [256 x i32]
%5 = alloca [256 x float]
%6 = alloca i32
%7 = alloca i32
%8 = bitcast %struct.sockaddr_in* %3 to i8*
%9 = bitcast [256 x i32]* %4 to i8*
%10 = bitcast [256 x float]* %5 to i8*
%11 = bitcast i32* %6 to i8*
%12 = bitcast i32* %7 to i8*
%13 = load i32, i32* @AF_INET
%14 = load i32, i32* @SOCK_STREAM
%15 = tail call i32 @socket(i32 %13, i32 %14, i32 0)
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %2
%18 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %70
19: ; preds = %2
%20 = call i32 @memset(%struct.sockaddr_in* %3, i32 0, i32 12)
%21 = load i32, i32* @AF_INET
%22 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %21, i32* %22
%23 = call i32 @inet_addr(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%24 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1, i32 0
store i32 %23, i32* %24
%25 = call i32 @htons(i32 1001)
%26 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
store i32 %25, i32* %26
%27 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%28 = call i64 @connect(i32 %15, %struct.sockaddr* %27, i32 12)
%29 = icmp slt i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %19
%31 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
br label %70
32: ; preds = %19
store i32 -2147483647, i32* %7
%33 = call i32 @send(i32 %15, i8* %12, i32 4, i32 0)
%34 = call i64 @floor(i32 5000125)
%35 = trunc i64 %34 to i32
store i32 %35, i32* %6
%36 = call i32 @send(i32 %15, i8* %11, i32 4, i32 0)
%37 = getelementptr inbounds [256 x i32], [256 x i32]* %4, i64 0, i64 0
%38 = getelementptr inbounds [256 x float], [256 x float]* %5, i64 0, i64 0
br label %39
39: ; preds = %65, %32
%40 = load i32, i32* @MSG_WAITALL
%41 = call i32 @recv(i32 %15, i32* %37, i32 1024, i32 %40)
br label %42
42: ; preds = %42, %39
%43 = phi i64 [ 0, %39 ], [ %63, %42 ]
%44 = getelementptr inbounds [256 x i32], [256 x i32]* %4, i64 0, i64 %43
%45 = bitcast i32* %44 to <4 x i32>*
%46 = load <4 x i32>, <4 x i32>* %45
%47 = sitofp <4 x i32> %46 to <4 x float>
%48 = fpext <4 x float> %47 to <4 x double>
%49 = fdiv <4 x double> %48, <double 0x41DFFFFFFFC00000, double 0x41DFFFFFFFC00000, double 0x41DFFFFFFFC00000, double 0x41DFFFFFFFC00000>
%50 = fptrunc <4 x double> %49 to <4 x float>
%51 = getelementptr inbounds [256 x float], [256 x float]* %5, i64 0, i64 %43
%52 = bitcast float* %51 to <4 x float>*
store <4 x float> %50, <4 x float>* %52
%53 = or i64 %43, 4
%54 = getelementptr inbounds [256 x i32], [256 x i32]* %4, i64 0, i64 %53
%55 = bitcast i32* %54 to <4 x i32>*
%56 = load <4 x i32>, <4 x i32>* %55
%57 = sitofp <4 x i32> %56 to <4 x float>
%58 = fpext <4 x float> %57 to <4 x double>
%59 = fdiv <4 x double> %58, <double 0x41DFFFFFFFC00000, double 0x41DFFFFFFFC00000, double 0x41DFFFFFFFC00000, double 0x41DFFFFFFFC00000>
%60 = fptrunc <4 x double> %59 to <4 x float>
%61 = getelementptr inbounds [256 x float], [256 x float]* %5, i64 0, i64 %53
%62 = bitcast float* %61 to <4 x float>*
store <4 x float> %60, <4 x float>* %62
%63 = add nuw nsw i64 %43, 8
%64 = icmp eq i64 %63, 256
br i1 %64, label %65, label %42
65: ; preds = %42
%66 = load i32, i32* @stdout
%67 = call i32 @fwrite(float* %38, i32 1, i32 1024, i32 %66)
%68 = load i32, i32* @stdout
%69 = call i32 @fflush(i32 %68)
br label %39
70: ; preds = %30, %17
ret i32 1
}