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

/* Type definitions */
struct sockaddr_un {
  char *sun_path;
};
struct in_addr {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
char *inet_ntoa(struct in_addr);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ unlink(char *);
void close_unixsock(int fd, struct in_addr inetaddr) {
  struct sockaddr_un where;
  close(fd);
  snprintf(where.sun_path, sizeof(where.sun_path),
           "/var/run/pptp/"
           "%s",
           inet_ntoa(inetaddr));
  unlink(where.sun_path);
  fprintf(stderr, "*** UNLINK %s ***\n", where.sun_path);
}


x86 assembly (clang, -O0):
<close_unixsock>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %esi,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%edi
call   1060 <close@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <inet_ntoa@plt>
mov    -0x20(%rbp),%rdi
mov    %rax,%rcx
mov    $0x8,%esi
lea    0xe77(%rip),%rdx
call   1050 <snprintf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <unlink@plt>
mov    0x2e42(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe66(%rip),%rsi
call   1070 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<close_unixsock>:
push   %rbx
mov    %esi,%ebx
call   1060 <close@plt>
mov    %ebx,%edi
call   1040 <inet_ntoa@plt>
lea    0xe9a(%rip),%rdx
mov    $0x8,%esi
mov    %rax,%rcx
call   1050 <snprintf@plt>
call   1030 <unlink@plt>
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
lea    0xe89(%rip),%rsi
pop    %rbx
jmp    1070 <fprintf@plt>

LLVM IR (-O0):
%struct.in_addr = type { i32 }
%struct.sockaddr_un = type { i8* }
@.str = [17 x i8] c"/var/run/pptp/%s\00"
@stderr = global i32 0
@.str.1 = [19 x i8] c"*** UNLINK %s ***\0A\00"
define void @close_unixsock(i32 %0, i32 %1) {
%3 = alloca %struct.in_addr
%4 = alloca i32
%5 = alloca %struct.sockaddr_un
%6 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %3, i32 0, i32 0
store i32 %1, i32* %6
store i32 %0, i32* %4
%7 = load i32, i32* %4
%8 = call i32 @close(i32 %7)
%9 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %5, i32 0, i32 0
%10 = load i8*, i8** %9
%11 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %3, i32 0, i32 0
%12 = load i32, i32* %11
%13 = call i8* @inet_ntoa(i32 %12)
%14 = call i32 @snprintf(i8* %10, i32 8, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %5, i32 0, i32 0
%16 = load i8*, i8** %15
%17 = call i32 @unlink(i8* %16)
%18 = load i32, i32* @stderr
%19 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %5, i32 0, i32 0
%20 = load i8*, i8** %19
%21 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %20)
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"/var/run/pptp/%s\00"
@stderr = global i32 0
@.str.1 = [19 x i8] c"*** UNLINK %s ***\0A\00"
define void @close_unixsock(i32 %0, i32 %1) {
%3 = tail call i32 @close(i32 %0)
%4 = tail call i8* @inet_ntoa(i32 %1)
%5 = tail call i32 @snprintf(i8* undef, i32 8, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = tail call i32 @unlink(i8* undef)
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* undef)
ret void
}