#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 {
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ si_other;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ IPPROTO_UDP;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ _kbhit();
int /*<<< orphan*/ changemode(int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ die(char *);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ inet_addr(char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *);
int sendto(int, char const *, int, int /*<<< orphan*/, struct sockaddr *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int main(void) {
  struct sockaddr_in si_other;
  int s, slen = sizeof(si_other);
  unsigned char data[(450)];
  if ((s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) {
    die("socket create error");
  }
  memset((char *)&si_other, 0, sizeof(si_other));
  si_other.sin_family = AF_INET;
  si_other.sin_port = htons((40002));
  si_other.sin_addr.s_addr = inet_addr("192.168.1.230");
  printf("press space to stop\n");
  changemode(1);
  while (!_kbhit()) {
    for (int i = 0; i < (450); i += 3) {
      data[i] = 0;
      data[i + 1] = i >> 1;
      data[i + 2] = 0;
    }
    if (sendto(s, (const char *)data, (450), 0, (struct sockaddr *)&si_other,
               slen) == -1) {
      die("couldn't sendto");
    }
  }
  getchar();
  changemode(0);
  close(s);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1f0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xc,-0x18(%rbp)
mov    0x2e18(%rip),%rax
mov    (%rax),%edi
mov    0x2e07(%rip),%rax
mov    (%rax),%esi
mov    0x2de6(%rip),%rax
mov    (%rax),%edx
call   10d0 <socket@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
jne    1201 <main+0x51>
lea    0xe04(%rip),%rdi
call   10c0 <die@plt>
lea    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1060 <memset@plt>
mov    0x2dd0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    $0x9c42,%edi
call   1040 <htons@plt>
mov    %eax,-0xc(%rbp)
lea    0xde3(%rip),%rdi
call   1090 <inet_addr@plt>
mov    %eax,-0x10(%rbp)
lea    0xde2(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   10b0 <changemode@plt>
mov    $0x0,%al
call   1030 <_kbhit@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    126b <main+0xbb>
jmp    1310 <main+0x160>
movl   $0x0,-0x1e4(%rbp)
cmpl   $0x1c2,-0x1e4(%rbp)
jge    12d8 <main+0x128>
movslq -0x1e4(%rbp),%rax
movb   $0x0,-0x1e0(%rbp,%rax,1)
mov    -0x1e4(%rbp),%eax
sar    $0x1,%eax
mov    %al,%cl
mov    -0x1e4(%rbp),%eax
add    $0x1,%eax
cltq
mov    %cl,-0x1e0(%rbp,%rax,1)
mov    -0x1e4(%rbp),%eax
add    $0x2,%eax
cltq
movb   $0x0,-0x1e0(%rbp,%rax,1)
mov    -0x1e4(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x1e4(%rbp)
jmp    1275 <main+0xc5>
mov    -0x14(%rbp),%edi
lea    -0x1e0(%rbp),%rsi
lea    -0x10(%rbp),%r8
mov    -0x18(%rbp),%r9d
mov    $0x1c2,%edx
xor    %ecx,%ecx
call   1070 <sendto@plt>
cmp    $0xffffffff,%eax
jne    130b <main+0x15b>
lea    0xd31(%rip),%rdi
call   10c0 <die@plt>
jmp    124f <main+0x9f>
mov    $0x0,%al
call   10a0 <getchar@plt>
xor    %edi,%edi
call   10b0 <changemode@plt>
mov    -0x14(%rbp),%edi
call   1080 <close@plt>
xor    %eax,%eax
add    $0x1f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1d8,%rsp
mov    0x2e23(%rip),%r14
mov    (%r14),%edi
mov    0x2e11(%rip),%rax
mov    (%rax),%esi
mov    0x2df0(%rip),%rax
mov    (%rax),%edx
call   10d0 <socket@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
jne    11f2 <main+0x42>
lea    0xe13(%rip),%rdi
call   10c0 <die@plt>
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1060 <memset@plt>
mov    (%r14),%eax
mov    %eax,0x8(%rsp)
mov    $0x9c42,%edi
call   1050 <htons@plt>
mov    %eax,0x4(%rsp)
lea    0xdf7(%rip),%rdi
call   1090 <inet_addr@plt>
mov    %eax,(%rsp)
lea    0xe06(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   10b0 <changemode@plt>
xor    %eax,%eax
call   1040 <_kbhit@plt>
test   %eax,%eax
je     126c <main+0xbc>
xor    %eax,%eax
call   10a0 <getchar@plt>
xor    %edi,%edi
call   10b0 <changemode@plt>
mov    %ebx,%edi
call   1080 <close@plt>
xor    %eax,%eax
add    $0x1d8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0x10(%rsp),%r14
mov    %rsp,%r15
lea    0xda7(%rip),%r12
xor    %ecx,%ecx
jmp    1290 <main+0xe0>
nop
xor    %eax,%eax
call   1040 <_kbhit@plt>
mov    $0x0,%ecx
test   %eax,%eax
jne    1246 <main+0x96>
movb   $0x0,0x10(%rsp,%rcx,1)
mov    %rcx,%rax
shr    %rax
mov    %al,0x11(%rsp,%rcx,1)
movb   $0x0,0x12(%rsp,%rcx,1)
lea    0x3(%rcx),%rax
cmp    $0x1bf,%rcx
mov    %rax,%rcx
jb     1290 <main+0xe0>
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x1c2,%edx
xor    %ecx,%ecx
mov    %r15,%r8
mov    $0xc,%r9d
call   1070 <sendto@plt>
cmp    $0xffffffff,%eax
jne    1280 <main+0xd0>
mov    %r12,%rdi
call   10c0 <die@plt>
jmp    1280 <main+0xd0>

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@IPPROTO_UDP = global i32 0
@.str = [20 x i8] c"socket create error\00"
@.str.1 = [14 x i8] c"192.168.1.230\00"
@.str.2 = [21 x i8] c"press space to stop\0A\00"
@.str.3 = [16 x i8] c"couldn't sendto\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.sockaddr_in
%3 = alloca i32
%4 = alloca i32
%5 = alloca [450 x i8]
%6 = alloca i32
store i32 0, i32* %1
store i32 12, i32* %4
%7 = load i32, i32* @AF_INET
%8 = load i32, i32* @SOCK_DGRAM
%9 = load i32, i32* @IPPROTO_UDP
%10 = call i32 @socket(i32 %7, i32 %8, i32 %9)
store i32 %10, i32* %3
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = call i32 @die(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %12, %0
%15 = bitcast %struct.sockaddr_in* %2 to i8*
%16 = call i32 @memset(i8* %15, i32 0, i32 12)
%17 = load i32, i32* @AF_INET
%18 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i32 0, i32 2
store i32 %17, i32* %18
%19 = call i32 @htons(i32 40002)
%20 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i32 0, i32 1
store i32 %19, i32* %20
%21 = call i32 @inet_addr(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%22 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i32 0, i32 0
%23 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %22, i32 0, i32 0
store i32 %21, i32* %23
%24 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%25 = call i32 @changemode(i32 1)
br label %26
26: ; preds = %61, %14
%27 = call i32 (...) @_kbhit()
%28 = icmp ne i32 %27, 0
%29 = xor i1 %28, true
br i1 %29, label %30, label %62
30: ; preds = %26
store i32 0, i32* %6
br label %31
31: ; preds = %49, %30
%32 = load i32, i32* %6
%33 = icmp slt i32 %32, 450
br i1 %33, label %34, label %52
34: ; preds = %31
%35 = load i32, i32* %6
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [450 x i8], [450 x i8]* %5, i64 0, i64 %36
store i8 0, i8* %37
%38 = load i32, i32* %6
%39 = ashr i32 %38, 1
%40 = trunc i32 %39 to i8
%41 = load i32, i32* %6
%42 = add nsw i32 %41, 1
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [450 x i8], [450 x i8]* %5, i64 0, i64 %43
store i8 %40, i8* %44
%45 = load i32, i32* %6
%46 = add nsw i32 %45, 2
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [450 x i8], [450 x i8]* %5, i64 0, i64 %47
store i8 0, i8* %48
br label %49
49: ; preds = %34
%50 = load i32, i32* %6
%51 = add nsw i32 %50, 3
store i32 %51, i32* %6
br label %31
52: ; preds = %31
%53 = load i32, i32* %3
%54 = getelementptr inbounds [450 x i8], [450 x i8]* %5, i64 0, i64 0
%55 = bitcast %struct.sockaddr_in* %2 to %struct.sockaddr*
%56 = load i32, i32* %4
%57 = call i32 @sendto(i32 %53, i8* %54, i32 450, i32 0, %struct.sockaddr* %55, i32 %56)
%58 = icmp eq i32 %57, -1
br i1 %58, label %59, label %61
59: ; preds = %52
%60 = call i32 @die(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
br label %61
61: ; preds = %59, %52
br label %26
62: ; preds = %26
%63 = call i32 (...) @getchar()
%64 = call i32 @changemode(i32 0)
%65 = load i32, i32* %3
%66 = call i32 @close(i32 %65)
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@IPPROTO_UDP = global i32 0
@.str = [20 x i8] c"socket create error\00"
@.str.1 = [14 x i8] c"192.168.1.230\00"
@.str.3 = [16 x i8] c"couldn't sendto\00"
@str = [20 x i8] c"press space to stop\00"
define i32 @main() {
%1 = alloca %struct.sockaddr_in
%2 = alloca [450 x i8]
%3 = bitcast %struct.sockaddr_in* %1 to i8*
%4 = getelementptr inbounds [450 x i8], [450 x i8]* %2, i64 0, i64 0
%5 = load i32, i32* @AF_INET
%6 = load i32, i32* @SOCK_DGRAM
%7 = load i32, i32* @IPPROTO_UDP
%8 = tail call i32 @socket(i32 %5, i32 %6, i32 %7)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = tail call i32 @die(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %0
%13 = call i32 @memset(i8* %3, i32 0, i32 12)
%14 = load i32, i32* @AF_INET
%15 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 2
store i32 %14, i32* %15
%16 = call i32 @htons(i32 40002)
%17 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 1
store i32 %16, i32* %17
%18 = call i32 @inet_addr(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%19 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 0, i32 0
store i32 %18, i32* %19
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%21 = call i32 @changemode(i32 1)
%22 = call i32 (...) @_kbhit()
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %47
24: ; preds = %12
%25 = bitcast %struct.sockaddr_in* %1 to %struct.sockaddr*
br label %29
26: ; preds = %29
%27 = call i32 @sendto(i32 %8, i8* %4, i32 450, i32 0, %struct.sockaddr* %25, i32 12)
%28 = icmp eq i32 %27, -1
br i1 %28, label %42, label %44
29: ; preds = %40, %24
%30 = phi i64 [ 0, %24 ], [ %41, %40 ]
%31 = getelementptr inbounds [450 x i8], [450 x i8]* %2, i64 0, i64 %30
store i8 0, i8* %31
%32 = lshr i64 %30, 1
%33 = trunc i64 %32 to i8
%34 = add nuw nsw i64 %30, 1
%35 = getelementptr inbounds [450 x i8], [450 x i8]* %2, i64 0, i64 %34
store i8 %33, i8* %35
%36 = add nuw nsw i64 %30, 2
%37 = getelementptr inbounds [450 x i8], [450 x i8]* %2, i64 0, i64 %36
store i8 0, i8* %37
%38 = add nuw nsw i64 %30, 3
%39 = icmp ult i64 %30, 447
br i1 %39, label %40, label %26
40: ; preds = %29, %44
%41 = phi i64 [ %38, %29 ], [ 0, %44 ]
br label %29
42: ; preds = %26
%43 = call i32 @die(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
br label %44
44: ; preds = %42, %26
%45 = call i32 (...) @_kbhit()
%46 = icmp eq i32 %45, 0
br i1 %46, label %40, label %47
47: ; preds = %44, %12
%48 = call i32 (...) @getchar()
%49 = call i32 @changemode(i32 0)
%50 = call i32 @close(i32 %8)
ret i32 0
}