#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 */
typedef int /*<<< orphan*/ to;
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  TYPE_1__ sin_addr;
  void *sin_port;
  void *sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int ssize_t;
typedef int /*<<< orphan*/ from;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
void *AF_INET;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ MSG_CONFIRM;
int /*<<< orphan*/ PF_INET;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ assert(int);
int bind(int, struct sockaddr const *, int);
void *htons(int);
int inet_aton(char *, TYPE_1__ *);
int /*<<< orphan*/ printf(char *, int);
int sendto(int, char *, int, int /*<<< orphan*/, struct sockaddr const *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int main(int argc, char **argv) {
  int sock, status;
  char buf[1] = "A";
  ssize_t s;
  struct sockaddr_in to, from;
  const struct sockaddr *__to = (const struct sockaddr *)&to;
  const struct sockaddr *__from = (const struct sockaddr *)&from;
  sock = socket(PF_INET, SOCK_DGRAM, 0);
  assert(sock != -1);
  from.sin_family = AF_INET;
  from.sin_port = htons(0xdead);
  from.sin_addr.s_addr = INADDR_ANY;
  status = bind(sock, __from, sizeof(from));
  assert(!status);
  to.sin_family = AF_INET;
  to.sin_port = htons(0xbeef);
  status = inet_aton("192.168.222.1", &to.sin_addr);
  assert(status);
  s = sendto(sock, buf, sizeof(buf), MSG_CONFIRM, __to, sizeof(to));
  assert(s == sizeof(buf));
  printf("Successfully sent %zd byte(s)\n", s);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xe74(%rip),%al
mov    %al,-0x19(%rbp)
lea    -0x38(%rbp),%rax
mov    %rax,-0x58(%rbp)
lea    -0x50(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
mov    0x2e29(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1090 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    0x2e15(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x40(%rbp)
mov    $0xdead,%edi
call   1030 <htons@plt>
mov    %rax,-0x48(%rbp)
mov    0x2df1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x50(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x60(%rbp),%rsi
mov    $0x18,%edx
call   1080 <bind@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    0x2dc6(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    $0xbeef,%edi
call   1030 <htons@plt>
mov    %rax,-0x30(%rbp)
lea    -0x38(%rbp),%rsi
lea    0xdbf(%rip),%rdi
call   1070 <inet_aton@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
call   1060 <assert@plt>
mov    -0x14(%rbp),%edi
lea    -0x19(%rbp),%rsi
mov    0x2d70(%rip),%rax
mov    (%rax),%ecx
mov    -0x58(%rbp),%r8
mov    $0x1,%edx
mov    $0x18,%r9d
call   1050 <sendto@plt>
mov    %eax,-0x20(%rbp)
movslq -0x20(%rbp),%rax
cmp    $0x1,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x20(%rbp),%esi
lea    0xd77(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x38,%rsp
movb   $0x41,0x7(%rsp)
mov    0x2e3d(%rip),%rax
mov    (%rax),%edi
mov    0x2e4c(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1090 <socket@plt>
mov    %eax,%ebx
xor    %edi,%edi
cmp    $0xffffffff,%eax
setne  %dil
call   1060 <assert@plt>
mov    0x2e3c(%rip),%r14
mov    (%r14),%rax
mov    %rax,0x18(%rsp)
mov    $0xdead,%edi
call   1030 <htons@plt>
mov    %rax,0x10(%rsp)
mov    0x2e16(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x8(%rsp)
lea    0x8(%rsp),%rsi
mov    %ebx,%edi
mov    $0x18,%edx
call   1080 <bind@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1060 <assert@plt>
mov    (%r14),%rax
mov    %rax,0x30(%rsp)
mov    $0xbeef,%edi
call   1030 <htons@plt>
mov    %rax,0x28(%rsp)
lea    0xdf4(%rip),%rdi
lea    0x20(%rsp),%r14
mov    %r14,%rsi
call   1070 <inet_aton@plt>
mov    %eax,%edi
call   1060 <assert@plt>
mov    0x2da9(%rip),%rax
mov    (%rax),%ecx
lea    0x7(%rsp),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
mov    %r14,%r8
mov    $0x18,%r9d
call   1050 <sendto@plt>
mov    %eax,%ebx
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1060 <assert@plt>
lea    0xdb4(%rip),%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.TYPE_2__, i8*, i8* }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@__const.main.buf = [1 x i8] c"A"
@PF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@AF_INET = global i8* null
@INADDR_ANY = global i32 0
@.str = [14 x i8] c"192.168.222.1\00"
@MSG_CONFIRM = global i32 0
@.str.1 = [31 x i8] c"Successfully sent %zd byte(s)\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca [1 x i8]
%9 = alloca i32
%10 = alloca %struct.sockaddr_in
%11 = alloca %struct.sockaddr_in
%12 = alloca %struct.sockaddr*
%13 = alloca %struct.sockaddr*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = bitcast [1 x i8]* %8 to i8*
%15 = bitcast %struct.sockaddr_in* %10 to %struct.sockaddr*
store %struct.sockaddr* %15, %struct.sockaddr** %12
%16 = bitcast %struct.sockaddr_in* %11 to %struct.sockaddr*
store %struct.sockaddr* %16, %struct.sockaddr** %13
%17 = load i32, i32* @PF_INET
%18 = load i32, i32* @SOCK_DGRAM
%19 = call i32 @socket(i32 %17, i32 %18, i32 0)
store i32 %19, i32* %6
%20 = load i32, i32* %6
%21 = icmp ne i32 %20, -1
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
%24 = load i8*, i8** @AF_INET
%25 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 2
store i8* %24, i8** %25
%26 = call i8* @htons(i32 57005)
%27 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 1
store i8* %26, i8** %27
%28 = load i32, i32* @INADDR_ANY
%29 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 0
%30 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %29, i32 0, i32 0
store i32 %28, i32* %30
%31 = load i32, i32* %6
%32 = load %struct.sockaddr*, %struct.sockaddr** %13
%33 = call i32 @bind(i32 %31, %struct.sockaddr* %32, i32 24)
store i32 %33, i32* %7
%34 = load i32, i32* %7
%35 = icmp ne i32 %34, 0
%36 = xor i1 %35, true
%37 = zext i1 %36 to i32
%38 = call i32 @assert(i32 %37)
%39 = load i8*, i8** @AF_INET
%40 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 2
store i8* %39, i8** %40
%41 = call i8* @htons(i32 48879)
%42 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 1
store i8* %41, i8** %42
%43 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 0
%44 = call i32 @inet_aton(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), %struct.TYPE_2__* %43)
store i32 %44, i32* %7
%45 = load i32, i32* %7
%46 = call i32 @assert(i32 %45)
%47 = load i32, i32* %6
%48 = getelementptr inbounds [1 x i8], [1 x i8]* %8, i64 0, i64 0
%49 = load i32, i32* @MSG_CONFIRM
%50 = load %struct.sockaddr*, %struct.sockaddr** %12
%51 = call i32 @sendto(i32 %47, i8* %48, i32 1, i32 %49, %struct.sockaddr* %50, i32 24)
store i32 %51, i32* %9
%52 = load i32, i32* %9
%53 = sext i32 %52 to i64
%54 = icmp eq i64 %53, 1
%55 = zext i1 %54 to i32
%56 = call i32 @assert(i32 %55)
%57 = load i32, i32* %9
%58 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %57)
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i8*, i8* }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@PF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@AF_INET = global i8* null
@INADDR_ANY = global i32 0
@.str = [14 x i8] c"192.168.222.1\00"
@MSG_CONFIRM = global i32 0
@.str.1 = [31 x i8] c"Successfully sent %zd byte(s)\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1 x i8]
%4 = alloca %struct.sockaddr_in
%5 = alloca %struct.sockaddr_in
%6 = getelementptr inbounds [1 x i8], [1 x i8]* %3, i64 0, i64 0
store i8 65, i8* %6
%7 = bitcast %struct.sockaddr_in* %4 to i8*
%8 = bitcast %struct.sockaddr_in* %5 to i8*
%9 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%10 = bitcast %struct.sockaddr_in* %5 to %struct.sockaddr*
%11 = load i32, i32* @PF_INET
%12 = load i32, i32* @SOCK_DGRAM
%13 = tail call i32 @socket(i32 %11, i32 %12, i32 0)
%14 = icmp ne i32 %13, -1
%15 = zext i1 %14 to i32
%16 = tail call i32 @assert(i32 %15)
%17 = load i8*, i8** @AF_INET
%18 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 2
store i8* %17, i8** %18
%19 = tail call i8* @htons(i32 57005)
%20 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 1
store i8* %19, i8** %20
%21 = load i32, i32* @INADDR_ANY
%22 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 0, i32 0
store i32 %21, i32* %22
%23 = call i32 @bind(i32 %13, %struct.sockaddr* %10, i32 24)
%24 = icmp eq i32 %23, 0
%25 = zext i1 %24 to i32
%26 = call i32 @assert(i32 %25)
%27 = load i8*, i8** @AF_INET
%28 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 2
store i8* %27, i8** %28
%29 = call i8* @htons(i32 48879)
%30 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1
store i8* %29, i8** %30
%31 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0
%32 = call i32 @inet_aton(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), %struct.TYPE_2__* %31)
%33 = call i32 @assert(i32 %32)
%34 = load i32, i32* @MSG_CONFIRM
%35 = call i32 @sendto(i32 %13, i8* %6, i32 1, i32 %34, %struct.sockaddr* %9, i32 24)
%36 = icmp eq i32 %35, 1
%37 = zext i1 %36 to i32
%38 = call i32 @assert(i32 %37)
%39 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %35)
ret i32 0
}