#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 /*<<< orphan*/ dst;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int EXIT_FAILURE;
int /*<<< orphan*/ IPPROTO_UDP;
int /*<<< orphan*/ PF_INET;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ inet_addr(char *);
int /*<<< orphan*/ printf(char *, int);
int sendto(int, char *, int, int /*<<< orphan*/, struct sockaddr *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int main(int argc, char **argv, char **envp) {
  char *buffer = "stress:1|c";
  struct sockaddr_in dst;
  int s, ret, i;
  s = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
  if (s < 0) {
    printf("socket() returned=%d\n", s);
    return EXIT_FAILURE;
  }
  dst.sin_family = AF_INET;
  dst.sin_addr.s_addr = inet_addr("127.0.0.1");
  dst.sin_port = htons(8125);
  for (;;) {
    ret = sendto(s, buffer, 10, 0, (struct sockaddr *)&dst, sizeof(dst));
    if (ret < 0) {
      printf("sendto() returned=%d\n", ret);
      return EXIT_FAILURE;
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    0xe8f(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2e54(%rip),%rax
mov    (%rax),%edi
mov    0x2e5b(%rip),%rax
mov    (%rax),%esi
mov    0x2e2a(%rip),%rax
mov    (%rax),%edx
call   1070 <socket@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jge    11c2 <main+0x72>
mov    -0x34(%rbp),%esi
lea    0xe5f(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e10(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1239 <main+0xe9>
mov    0x2e1f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
lea    0xe4c(%rip),%rdi
call   1060 <inet_addr@plt>
mov    %eax,-0x2c(%rbp)
mov    $0x1fbd,%edi
call   1030 <htons@plt>
mov    %eax,-0x30(%rbp)
mov    -0x34(%rbp),%edi
mov    -0x20(%rbp),%rsi
lea    -0x30(%rbp),%r8
mov    $0xa,%edx
xor    %ecx,%ecx
mov    $0xc,%r9d
call   1050 <sendto@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x0,-0x38(%rbp)
jge    1234 <main+0xe4>
mov    -0x38(%rbp),%esi
lea    0xe0d(%rip),%rdi
call   1040 <printf@plt>
mov    0x2d9e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1239 <main+0xe9>
jmp    11ea <main+0x9a>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    0x2e70(%rip),%rax
mov    (%rax),%edi
mov    0x2e77(%rip),%rax
mov    (%rax),%esi
mov    0x2e46(%rip),%rax
mov    (%rax),%edx
call   1070 <socket@plt>
mov    %eax,%ebx
test   %eax,%eax
js     11e9 <main+0x99>
mov    0x2e62(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x8(%rsp)
lea    0xe8e(%rip),%rdi
call   1060 <inet_addr@plt>
mov    %eax,0x4(%rsp)
mov    $0x1fbd,%edi
call   1030 <htons@plt>
mov    %eax,(%rsp)
lea    0xe50(%rip),%r14
mov    %rsp,%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0xa,%edx
xor    %ecx,%ecx
mov    %r15,%r8
mov    $0xc,%r9d
call   1050 <sendto@plt>
test   %eax,%eax
jns    11c0 <main+0x70>
lea    0xe46(%rip),%rdi
mov    %eax,%esi
jmp    11f2 <main+0xa2>
lea    0xe1b(%rip),%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
mov    0x2dca(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [11 x i8] c"stress:1|c\00"
@PF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@IPPROTO_UDP = global i32 0
@.str.1 = [22 x i8] c"socket() returned=%d\0A\00"
@EXIT_FAILURE = global i32 0
@AF_INET = global i32 0
@.str.2 = [10 x i8] c"127.0.0.1\00"
@.str.3 = [22 x i8] c"sendto() returned=%d\0A\00"
define i32 @main(i32 %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i8*
%9 = alloca %struct.sockaddr_in
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %4
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8** %8
%13 = load i32, i32* @PF_INET
%14 = load i32, i32* @SOCK_DGRAM
%15 = load i32, i32* @IPPROTO_UDP
%16 = call i32 @socket(i32 %13, i32 %14, i32 %15)
store i32 %16, i32* %10
%17 = load i32, i32* %10
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %3
%20 = load i32, i32* %10
%21 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %20)
%22 = load i32, i32* @EXIT_FAILURE
store i32 %22, i32* %4
br label %43
23: ; preds = %3
%24 = load i32, i32* @AF_INET
%25 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 2
store i32 %24, i32* %25
%26 = call i32 @inet_addr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%27 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 1
%28 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %27, i32 0, i32 0
store i32 %26, i32* %28
%29 = call i32 @htons(i32 8125)
%30 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 0
store i32 %29, i32* %30
br label %31
31: ; preds = %42, %23
%32 = load i32, i32* %10
%33 = load i8*, i8** %8
%34 = bitcast %struct.sockaddr_in* %9 to %struct.sockaddr*
%35 = call i32 @sendto(i32 %32, i8* %33, i32 10, i32 0, %struct.sockaddr* %34, i32 12)
store i32 %35, i32* %11
%36 = load i32, i32* %11
%37 = icmp slt i32 %36, 0
br i1 %37, label %38, label %42
38: ; preds = %31
%39 = load i32, i32* %11
%40 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %39)
%41 = load i32, i32* @EXIT_FAILURE
store i32 %41, i32* %4
br label %43
42: ; preds = %31
br label %31
43: ; preds = %38, %19
%44 = load i32, i32* %4
ret i32 %44
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [11 x i8] c"stress:1|c\00"
@PF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@IPPROTO_UDP = global i32 0
@.str.1 = [22 x i8] c"socket() returned=%d\0A\00"
@EXIT_FAILURE = global i32 0
@AF_INET = global i32 0
@.str.2 = [10 x i8] c"127.0.0.1\00"
@.str.3 = [22 x i8] c"sendto() returned=%d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1, i8** nocapture readnone %2) {
%4 = alloca %struct.sockaddr_in
%5 = bitcast %struct.sockaddr_in* %4 to i8*
%6 = load i32, i32* @PF_INET
%7 = load i32, i32* @SOCK_DGRAM
%8 = load i32, i32* @IPPROTO_UDP
%9 = tail call i32 @socket(i32 %6, i32 %7, i32 %8)
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %3
%12 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %9)
br label %26
13: ; preds = %3
%14 = load i32, i32* @AF_INET
%15 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 2
store i32 %14, i32* %15
%16 = tail call i32 @inet_addr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%17 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1, i32 0
store i32 %16, i32* %17
%18 = tail call i32 @htons(i32 8125)
%19 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0
store i32 %18, i32* %19
%20 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
br label %21
21: ; preds = %21, %13
%22 = call i32 @sendto(i32 %9, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 10, i32 0, %struct.sockaddr* %20, i32 12)
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %21
24: ; preds = %21
%25 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %22)
br label %26
26: ; preds = %24, %11
%27 = load i32, i32* @EXIT_FAILURE
ret i32 %27
}