#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;
};
struct hostent {
  int /*<<< orphan*/ h_addr;
};
typedef int /*<<< orphan*/ server;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ bcopy(int /*<<< orphan*/, int /*<<< orphan*/ *, int);
struct hostent *gethostbyname(char *);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ sendto(int, char *, int, int /*<<< orphan*/,
                          struct sockaddr *, int);
void cs2d_request_ips(int socket_descriptor) {
  struct hostent *usgn = gethostbyname("www.usgn.de");
  struct sockaddr_in server;
  server.sin_family = AF_INET;
  server.sin_port = htons(36963);
  bcopy(usgn->h_addr, &(server.sin_addr.s_addr), 4);
  char iprequest[] = {0x01, 0x00, 0x14, 0x01};
  sendto(socket_descriptor, iprequest, 4, 0, (struct sockaddr *)&server,
         sizeof(server));
}


x86 assembly (clang, -O0):
<cs2d_request_ips>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
lea    0xeae(%rip),%rdi
call   1050 <gethostbyname@plt>
mov    %rax,-0x10(%rbp)
mov    0x2e86(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    $0x9063,%edi
call   1030 <htons@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
lea    -0x20(%rbp),%rsi
mov    $0x4,%edx
call   1060 <bcopy@plt>
mov    0xe7e(%rip),%eax
mov    %eax,-0x24(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x24(%rbp),%rsi
lea    -0x20(%rbp),%r8
mov    $0x4,%edx
xor    %ecx,%ecx
mov    $0xc,%r9d
call   1040 <sendto@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cs2d_request_ips>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %edi,%ebp
lea    0xeb1(%rip),%rdi
call   1050 <gethostbyname@plt>
mov    %rax,%rbx
mov    0x2e8a(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x10(%rsp)
mov    $0x9063,%edi
call   1030 <htons@plt>
mov    %eax,0xc(%rsp)
mov    (%rbx),%edi
lea    0x8(%rsp),%rbx
mov    %rbx,%rsi
mov    $0x4,%edx
call   1060 <bcopy@plt>
movl   $0x1140001,0x4(%rsp)
01
lea    0x4(%rsp),%rsi
mov    %ebp,%edi
mov    $0x4,%edx
xor    %ecx,%ecx
mov    %rbx,%r8
mov    $0xc,%r9d
call   1040 <sendto@plt>
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.hostent = type { i32 }
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [12 x i8] c"www.usgn.de\00"
@AF_INET = global i32 0
@__const.cs2d_request_ips.iprequest = [4 x i8] c"\01\00\14\01"
define void @cs2d_request_ips(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.hostent*
%4 = alloca %struct.sockaddr_in
%5 = alloca [4 x i8]
store i32 %0, i32* %2
%6 = call %struct.hostent* @gethostbyname(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
store %struct.hostent* %6, %struct.hostent** %3
%7 = load i32, i32* @AF_INET
%8 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i32 0, i32 2
store i32 %7, i32* %8
%9 = call i32 @htons(i32 36963)
%10 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i32 0, i32 1
store i32 %9, i32* %10
%11 = load %struct.hostent*, %struct.hostent** %3
%12 = getelementptr inbounds %struct.hostent, %struct.hostent* %11, i32 0, i32 0
%13 = load i32, i32* %12
%14 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i32 0, i32 0
%15 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %14, i32 0, i32 0
%16 = call i32 @bcopy(i32 %13, i32* %15, i32 4)
%17 = bitcast [4 x i8]* %5 to i8*
%18 = load i32, i32* %2
%19 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%20 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%21 = call i32 @sendto(i32 %18, i8* %19, i32 4, i32 0, %struct.sockaddr* %20, i32 12)
ret void
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.hostent = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [12 x i8] c"www.usgn.de\00"
@AF_INET = global i32 0
define void @cs2d_request_ips(i32 %0) {
%2 = alloca %struct.sockaddr_in
%3 = alloca i32
%4 = tail call %struct.hostent* @gethostbyname(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%5 = bitcast %struct.sockaddr_in* %2 to i8*
%6 = load i32, i32* @AF_INET
%7 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 2
store i32 %6, i32* %7
%8 = tail call i32 @htons(i32 36963)
%9 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 1
store i32 %8, i32* %9
%10 = getelementptr inbounds %struct.hostent, %struct.hostent* %4, i64 0, i32 0
%11 = load i32, i32* %10
%12 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 0, i32 0
%13 = call i32 @bcopy(i32 %11, i32* %12, i32 4)
%14 = bitcast i32* %3 to i8*
store i32 18087937, i32* %3
%15 = bitcast %struct.sockaddr_in* %2 to %struct.sockaddr*
%16 = call i32 @sendto(i32 %0, i8* %14, i32 4, i32 0, %struct.sockaddr* %15, i32 12)
ret void
}