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

/* Variables and functions */
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int make_l2psocket();
int /*<<< orphan*/ printf(char *, ...);
int recv(int, char *, int, int /*<<< orphan*/);
int send(int, char *, scalar_t__, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int /*<<< orphan*/ sscanf(char *, char *, float *);
scalar_t__ strlen(char *);
int /*<<< orphan*/ usleep(int);
int main(void) {
  int sockl2p;
  int len;
  int oldflags;
  char l2pSND[256];
  char l2pRECV[256];
  float azim, elev;
  char azims[7], elevs[6];
  sockl2p = make_l2psocket();
  if (sockl2p == -1)
    printf("l2pclient: listen2planes not in operation\n");
  else
    printf("l2pclient: listen2planes socket() established on %d\n", sockl2p);
  sprintf(l2pSND, "telscp: \0");
  len = send(sockl2p, l2pSND, strlen(l2pSND) + 1, 0);
  while (1) {
    sprintf(azims, "220.0");
    sprintf(elevs, "20.0");
    if (sockl2p > 0) {
      len = recv(sockl2p, l2pRECV, sizeof(l2pRECV), 0);
      sscanf(azims, "%f", &azim);
      sscanf(elevs, "%f", &elev);
      sprintf(l2pSND, "telscp:  %6.2f %5.2f\0", azim, elev);
      len = send(sockl2p, l2pSND, strlen(l2pSND) + 1, 0);
      if (len < 0) {
        printf("l2pclient: socket send error, closing...\n");
        close(sockl2p);
        sockl2p = -1;
        len = 0;
        exit(1);
      }
      printf("%s\n", l2pSND);
    }
    usleep(3000);
  }
  close(sockl2p);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x250,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1090 <make_l2psocket@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    11d9 <main+0x39>
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    11ea <main+0x4a>
mov    -0x8(%rbp),%esi
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x110(%rbp),%rdi
lea    0xe9f(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x234(%rbp)
lea    -0x110(%rbp),%rax
mov    %rax,-0x230(%rbp)
lea    -0x110(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x234(%rbp),%edi
mov    -0x230(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
xor    %ecx,%ecx
call   1050 <send@plt>
mov    %eax,-0xc(%rbp)
lea    -0x21f(%rbp),%rdi
lea    0xe12(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x225(%rbp),%rdi
lea    0xdfe(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
cmpl   $0x0,-0x8(%rbp)
jle    137c <main+0x1dc>
mov    -0x8(%rbp),%edi
lea    -0x210(%rbp),%rsi
mov    $0x100,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0xc(%rbp)
lea    -0x21f(%rbp),%rdi
lea    0xdcb(%rip),%rsi
lea    -0x214(%rbp),%rdx
call   1080 <sscanf@plt>
lea    -0x225(%rbp),%rdi
lea    0xdb1(%rip),%rsi
lea    -0x218(%rbp),%rdx
call   1080 <sscanf@plt>
lea    -0x110(%rbp),%rdi
movss  -0x214(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
movss  -0x218(%rbp),%xmm1
ff
cvtss2sd %xmm1,%xmm1
lea    0xdba(%rip),%rsi
mov    $0x2,%al
call   10a0 <sprintf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x244(%rbp)
lea    -0x110(%rbp),%rax
mov    %rax,-0x240(%rbp)
lea    -0x110(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x244(%rbp),%edi
mov    -0x240(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
xor    %ecx,%ecx
call   1050 <send@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    1367 <main+0x1c7>
lea    0xd29(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x8(%rbp),%edi
call   1070 <close@plt>
movl   $0xffffffff,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x1,%edi
call   10b0 <exit@plt>
lea    -0x110(%rbp),%rsi
lea    0xd1e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0xbb8,%edi
call   10c0 <usleep@plt>
jmp    1240 <main+0xa0>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x228,%rsp
xor    %eax,%eax
call   10a0 <make_l2psocket@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
jne    11dd <main+0x2d>
lea    0xe91(%rip),%rdi
call   1040 <puts@plt>
jmp    11ed <main+0x3d>
lea    0xe1c(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1070 <printf@plt>
movabs $0x203a7063736c6574,%rax
70 3a 20
mov    %rax,0x20(%rsp)
movb   $0x0,0x28(%rsp)
lea    0x20(%rsp),%r14
mov    %r14,%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%rdx
mov    %ebx,%edi
mov    %r14,%rsi
xor    %ecx,%ecx
call   1060 <send@plt>
lea    0xe16(%rip),%r12
lea    0x8(%rsp),%r15
lea    0x10(%rsp),%r13
lea    0xe65(%rip),%rbp
jmp    124a <main+0x9a>
nopl   0x0(%rax,%rax,1)
mov    $0xbb8,%edi
call   10d0 <usleep@plt>
movw   $0x30,0x1c(%rsp)
movl   $0x2e303232,0x18(%rsp)
2e
movl   $0x302e3032,0x8(%rsp)
30
movb   $0x0,0xc(%rsp)
test   %ebx,%ebx
jle    1240 <main+0x90>
mov    %ebx,%edi
lea    0x120(%rsp),%rsi
mov    $0x100,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
lea    0x18(%rsp),%rdi
mov    %r12,%rsi
lea    0x14(%rsp),%rdx
call   1090 <sscanf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1090 <sscanf@plt>
movss  0x14(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  0x10(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
mov    %r14,%rdi
mov    %rbp,%rsi
mov    $0x2,%al
call   10b0 <sprintf@plt>
mov    %r14,%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%rdx
mov    %ebx,%edi
mov    %r14,%rsi
xor    %ecx,%ecx
call   1060 <send@plt>
test   %eax,%eax
js     12ea <main+0x13a>
mov    %r14,%rdi
call   1040 <puts@plt>
jmp    1240 <main+0x90>
lea    0xd4d(%rip),%rdi
call   1040 <puts@plt>
mov    %ebx,%edi
call   1080 <close@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [43 x i8] c"l2pclient: listen2planes not in operation\0A\00"
@.str.1 = [53 x i8] c"l2pclient: listen2planes socket() established on %d\0A\00"
@.str.2 = [10 x i8] c"telscp: \00\00"
@.str.3 = [6 x i8] c"220.0\00"
@.str.4 = [5 x i8] c"20.0\00"
@.str.5 = [3 x i8] c"%f\00"
@.str.6 = [22 x i8] c"telscp: %6.2f %5.2f\00\00"
@.str.7 = [42 x i8] c"l2pclient: socket send error, closing...\0A\00"
@.str.8 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [256 x i8]
%6 = alloca [256 x i8]
%7 = alloca float
%8 = alloca float
%9 = alloca [7 x i8]
%10 = alloca [6 x i8]
store i32 0, i32* %1
%11 = call i32 (...) @make_l2psocket()
store i32 %11, i32* %2
%12 = load i32, i32* %2
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %16
14: ; preds = %0
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
br label %19
16: ; preds = %0
%17 = load i32, i32* %2
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0), i32 %17)
br label %19
19: ; preds = %16, %14
%20 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%21 = call i32 (i8*, i8*, ...) @sprintf(i8* %20, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%22 = load i32, i32* %2
%23 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%24 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%25 = call i64 @strlen(i8* %24)
%26 = add nsw i64 %25, 1
%27 = call i32 @send(i32 %22, i8* %23, i64 %26, i32 0)
store i32 %27, i32* %3
br label %28
28: ; preds = %19, %65
%29 = getelementptr inbounds [7 x i8], [7 x i8]* %9, i64 0, i64 0
%30 = call i32 (i8*, i8*, ...) @sprintf(i8* %29, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%31 = getelementptr inbounds [6 x i8], [6 x i8]* %10, i64 0, i64 0
%32 = call i32 (i8*, i8*, ...) @sprintf(i8* %31, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%33 = load i32, i32* %2
%34 = icmp sgt i32 %33, 0
br i1 %34, label %35, label %65
35: ; preds = %28
%36 = load i32, i32* %2
%37 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%38 = call i32 @recv(i32 %36, i8* %37, i32 256, i32 0)
store i32 %38, i32* %3
%39 = getelementptr inbounds [7 x i8], [7 x i8]* %9, i64 0, i64 0
%40 = call i32 @sscanf(i8* %39, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), float* %7)
%41 = getelementptr inbounds [6 x i8], [6 x i8]* %10, i64 0, i64 0
%42 = call i32 @sscanf(i8* %41, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), float* %8)
%43 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%44 = load float, float* %7
%45 = fpext float %44 to double
%46 = load float, float* %8
%47 = fpext float %46 to double
%48 = call i32 (i8*, i8*, ...) @sprintf(i8* %43, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), double %45, double %47)
%49 = load i32, i32* %2
%50 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%51 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%52 = call i64 @strlen(i8* %51)
%53 = add nsw i64 %52, 1
%54 = call i32 @send(i32 %49, i8* %50, i64 %53, i32 0)
store i32 %54, i32* %3
%55 = load i32, i32* %3
%56 = icmp slt i32 %55, 0
br i1 %56, label %57, label %62
57: ; preds = %35
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.7, i64 0, i64 0))
%59 = load i32, i32* %2
%60 = call i32 @close(i32 %59)
store i32 -1, i32* %2
store i32 0, i32* %3
%61 = call i32 @exit(i32 1)
unreachable
62: ; preds = %35
%63 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* %63)
br label %65
65: ; preds = %62, %28
%66 = call i32 @usleep(i32 3000)
br label %28
}

LLVM IR (-O2):
@.str.1 = [53 x i8] c"l2pclient: listen2planes socket() established on %d\0A\00"
@.str.2 = [10 x i8] c"telscp: \00\00"
@.str.3 = [6 x i8] c"220.0\00"
@.str.4 = [5 x i8] c"20.0\00"
@.str.5 = [3 x i8] c"%f\00"
@.str.6 = [22 x i8] c"telscp: %6.2f %5.2f\00\00"
@str = [41 x i8] c"l2pclient: socket send error, closing...\00"
@str.9 = [42 x i8] c"l2pclient: listen2planes not in operation\00"
define i32 @main() {
%1 = alloca [256 x i8]
%2 = alloca [256 x i8]
%3 = alloca float
%4 = alloca float
%5 = alloca [7 x i8]
%6 = alloca [6 x i8]
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%9 = bitcast float* %3 to i8*
%10 = bitcast float* %4 to i8*
%11 = getelementptr inbounds [7 x i8], [7 x i8]* %5, i64 0, i64 0
%12 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 0
%13 = tail call i32 (...) @make_l2psocket()
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %17
15: ; preds = %0
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.9, i64 0, i64 0))
br label %19
17: ; preds = %0
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0), i32 %13)
br label %19
19: ; preds = %17, %15
%20 = call i64 @strlen(i8* %7)
%21 = add nsw i64 %20, 1
%22 = call i32 @send(i32 %13, i8* %7, i64 %21, i32 0)
%23 = icmp sgt i32 %13, 0
br label %24
24: ; preds = %44, %19
br i1 %23, label %25, label %44
25: ; preds = %24
%26 = call i32 @recv(i32 %13, i8* %8, i32 256, i32 0)
%27 = call i32 @sscanf(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), float* %3)
%28 = call i32 @sscanf(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), float* %4)
%29 = load float, float* %3
%30 = fpext float %29 to double
%31 = load float, float* %4
%32 = fpext float %31 to double
%33 = call i32 (i8*, i8*, ...) @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), double %30, double %32)
%34 = call i64 @strlen(i8* %7)
%35 = add nsw i64 %34, 1
%36 = call i32 @send(i32 %13, i8* %7, i64 %35, i32 0)
%37 = icmp slt i32 %36, 0
br i1 %37, label %38, label %42
38: ; preds = %25
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str, i64 0, i64 0))
%40 = call i32 @close(i32 %13)
%41 = call i32 @exit(i32 1)
unreachable
42: ; preds = %25
%43 = call i32 @puts(i8* %7)
br label %44
44: ; preds = %42, %24
%45 = call i32 @usleep(i32 3000)
br label %24
}