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

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ IPPROTO_UDP;
int /*<<< orphan*/ PF_INET;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ inet_addr(char *);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
int /*<<< orphan*/ sendto(int, char *, int, int /*<<< orphan*/,
                          struct sockaddr *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  int client;
  struct sockaddr_in address;
  char data;
  client = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
  memset(&address, 0, sizeof(address));
  address.sin_family = AF_INET;
  address.sin_addr.s_addr = inet_addr("127.0.0.1");
  address.sin_port = htons(9998);
  data = 2;
  sendto(client, &data, 1, 0, (struct sockaddr *)&address, sizeof(address));
  close(client);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e53(%rip),%rax
mov    (%rax),%edi
mov    0x2e5a(%rip),%rax
mov    (%rax),%esi
mov    0x2e31(%rip),%rax
mov    (%rax),%edx
call   1080 <socket@plt>
mov    %eax,-0x14(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1040 <memset@plt>
mov    0x2e38(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
lea    0xe44(%rip),%rdi
call   1070 <inet_addr@plt>
mov    %eax,-0x1c(%rbp)
mov    $0x270e,%edi
call   1030 <htons@plt>
mov    %eax,-0x20(%rbp)
movb   $0x2,-0x21(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x20(%rbp),%r8
lea    -0x21(%rbp),%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
mov    $0xc,%r9d
call   1050 <sendto@plt>
mov    -0x14(%rbp),%edi
call   1060 <close@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    0x2e62(%rip),%rax
mov    (%rax),%edi
mov    0x2e69(%rip),%rax
mov    (%rax),%esi
mov    0x2e40(%rip),%rax
mov    (%rax),%edx
call   1080 <socket@plt>
mov    %eax,%ebx
lea    0x8(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1040 <memset@plt>
mov    0x2e44(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x10(%rsp)
lea    0xe4f(%rip),%rdi
call   1070 <inet_addr@plt>
mov    %eax,0xc(%rsp)
mov    $0x270e,%edi
call   1030 <htons@plt>
mov    %eax,0x8(%rsp)
movb   $0x2,0x7(%rsp)
lea    0x7(%rsp),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
xor    %ecx,%ecx
mov    %r14,%r8
mov    $0xc,%r9d
call   1050 <sendto@plt>
mov    %ebx,%edi
call   1060 <close@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@PF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@IPPROTO_UDP = global i32 0
@AF_INET = global i32 0
@.str = [10 x i8] c"127.0.0.1\00"
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 i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* @PF_INET
%10 = load i32, i32* @SOCK_DGRAM
%11 = load i32, i32* @IPPROTO_UDP
%12 = call i32 @socket(i32 %9, i32 %10, i32 %11)
store i32 %12, i32* %6
%13 = call i32 @memset(%struct.sockaddr_in* %7, i32 0, i32 12)
%14 = load i32, i32* @AF_INET
%15 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 2
store i32 %14, i32* %15
%16 = call i32 @inet_addr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%17 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 1
%18 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %17, i32 0, i32 0
store i32 %16, i32* %18
%19 = call i32 @htons(i32 9998)
%20 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 0
store i32 %19, i32* %20
store i8 2, i8* %8
%21 = load i32, i32* %6
%22 = bitcast %struct.sockaddr_in* %7 to %struct.sockaddr*
%23 = call i32 @sendto(i32 %21, i8* %8, i32 1, i32 0, %struct.sockaddr* %22, i32 12)
%24 = load i32, i32* %6
%25 = call i32 @close(i32 %24)
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@PF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@IPPROTO_UDP = global i32 0
@AF_INET = global i32 0
@.str = [10 x i8] c"127.0.0.1\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca i8
%5 = bitcast %struct.sockaddr_in* %3 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 = call i32 @memset(%struct.sockaddr_in* %3, i32 0, i32 12)
%11 = load i32, i32* @AF_INET
%12 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %11, i32* %12
%13 = call i32 @inet_addr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%14 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1, i32 0
store i32 %13, i32* %14
%15 = call i32 @htons(i32 9998)
%16 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
store i32 %15, i32* %16
store i8 2, i8* %4
%17 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%18 = call i32 @sendto(i32 %9, i8* %4, i32 1, i32 0, %struct.sockaddr* %17, i32 12)
%19 = call i32 @close(i32 %9)
ret i32 0
}