#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__ {
  unsigned int s_addr;
};
struct sockaddr_in {
  unsigned short sin_port;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ client;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ IPPROTO_UDP;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ close(int);
char *createResponse();
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ sendto(int, char *, int /*<<< orphan*/, int /*<<< orphan*/,
                          struct sockaddr *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char *);
void replySSDP(unsigned int client_ip, unsigned short client_port) {
  char *ssdp_response = createResponse();
  int dgram_socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
  struct sockaddr_in client;
  client.sin_family = AF_INET;
  client.sin_addr.s_addr = client_ip;
  client.sin_port = client_port;
  sendto(dgram_socket, ssdp_response, strlen(ssdp_response), 0,
         (struct sockaddr *)&client, sizeof(client));
  close(dgram_socket);
  free(ssdp_response);
}


x86 assembly (clang, -O0):
<replySSDP>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %si,%ax
mov    %edi,-0x4(%rbp)
mov    %ax,-0x6(%rbp)
mov    $0x0,%al
call   1070 <createResponse@plt>
mov    %rax,-0x10(%rbp)
mov    0x2e64(%rip),%rax
mov    (%rax),%edi
mov    0x2e53(%rip),%rax
mov    (%rax),%esi
mov    0x2e32(%rip),%rax
mov    (%rax),%edx
call   1080 <socket@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e41(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x6(%rbp),%ax
mov    %ax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
lea    -0x20(%rbp),%r8
xor    %ecx,%ecx
mov    $0xc,%r9d
call   1050 <sendto@plt>
mov    -0x14(%rbp),%edi
call   1060 <close@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<replySSDP>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %esi,%r14d
mov    %edi,%r15d
xor    %eax,%eax
call   1070 <createResponse@plt>
mov    %rax,%rbx
mov    0x2e65(%rip),%r12
mov    (%r12),%edi
mov    0x2e52(%rip),%rax
mov    (%rax),%esi
mov    0x2e31(%rip),%rax
mov    (%rax),%edx
call   1080 <socket@plt>
mov    %eax,%ebp
mov    (%r12),%eax
mov    %eax,0x8(%rsp)
mov    %r15d,0x4(%rsp)
mov    %r14w,(%rsp)
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rsp,%r8
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
mov    $0xc,%r9d
call   1050 <sendto@plt>
mov    %ebp,%edi
call   1060 <close@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i16, %struct.TYPE_2__, 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
define void @replySSDP(i32 %0, i16 zeroext %1) {
%3 = alloca i32
%4 = alloca i16
%5 = alloca i8*
%6 = alloca i32
%7 = alloca %struct.sockaddr_in
store i32 %0, i32* %3
store i16 %1, i16* %4
%8 = call i8* (...) @createResponse()
store i8* %8, i8** %5
%9 = load i32, i32* @AF_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 = load i32, i32* @AF_INET
%14 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 2
store i32 %13, i32* %14
%15 = load i32, i32* %3
%16 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 1
%17 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %16, i32 0, i32 0
store i32 %15, i32* %17
%18 = load i16, i16* %4
%19 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 0
store i16 %18, i16* %19
%20 = load i32, i32* %6
%21 = load i8*, i8** %5
%22 = load i8*, i8** %5
%23 = call i32 @strlen(i8* %22)
%24 = bitcast %struct.sockaddr_in* %7 to %struct.sockaddr*
%25 = call i32 @sendto(i32 %20, i8* %21, i32 %23, i32 0, %struct.sockaddr* %24, i32 12)
%26 = load i32, i32* %6
%27 = call i32 @close(i32 %26)
%28 = load i8*, i8** %5
%29 = call i32 @free(i8* %28)
ret void
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i16, %struct.TYPE_2__, 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
define void @replySSDP(i32 %0, i16 zeroext %1) {
%3 = alloca %struct.sockaddr_in
%4 = tail call i8* (...) @createResponse()
%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 = bitcast %struct.sockaddr_in* %3 to i8*
%10 = load i32, i32* @AF_INET
%11 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %10, i32* %11
%12 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1, i32 0
store i32 %0, i32* %12
%13 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
store i16 %1, i16* %13
%14 = tail call i32 @strlen(i8* %4)
%15 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%16 = call i32 @sendto(i32 %8, i8* %4, i32 %14, i32 0, %struct.sockaddr* %15, i32 12)
%17 = call i32 @close(i32 %8)
%18 = call i32 @free(i8* %4)
ret void
}