#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 {
  int /*<<< orphan*/ sun_path;
  int /*<<< orphan*/ sun_family;
};

/* Variables and functions */
int /*<<< orphan*/ AF_UNIX;
int /*<<< orphan*/ bzero(struct sockaddr_un *, int);
int getuid();
int /*<<< orphan*/ snprintf(int /*<<< orphan*/, int, char *, int);
void setaddr(struct sockaddr_un *address) {
  bzero(address, sizeof(*address));
  address->sun_family = AF_UNIX;
  snprintf(address->sun_path,
           sizeof(address->sun_path) / sizeof(char) - sizeof(char),
           "/tmp/minstrel.%d", getuid());
}


x86 assembly (clang, -O0):
<setaddr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x8,%esi
call   1050 <bzero@plt>
mov    0x2e97(%rip),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1030 <getuid@plt>
mov    -0xc(%rbp),%edi
mov    %eax,%ecx
mov    $0x3,%esi
lea    0xe85(%rip),%rdx
call   1040 <snprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setaddr>:
push   %rbx
mov    %rdi,%rbx
mov    $0x8,%esi
call   1050 <bzero@plt>
mov    0x2ea3(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x4(%rbx)
mov    (%rbx),%ebx
xor    %eax,%eax
call   1030 <getuid@plt>
lea    0xea6(%rip),%rdx
mov    %ebx,%edi
mov    $0x3,%esi
mov    %eax,%ecx
pop    %rbx
jmp    1040 <snprintf@plt>

LLVM IR (-O0):
%struct.sockaddr_un = type { i32, i32 }
@AF_UNIX = global i32 0
@.str = [17 x i8] c"/tmp/minstrel.%d\00"
define void @setaddr(%struct.sockaddr_un* %0) {
%2 = alloca %struct.sockaddr_un*
store %struct.sockaddr_un* %0, %struct.sockaddr_un** %2
%3 = load %struct.sockaddr_un*, %struct.sockaddr_un** %2
%4 = call i32 @bzero(%struct.sockaddr_un* %3, i32 8)
%5 = load i32, i32* @AF_UNIX
%6 = load %struct.sockaddr_un*, %struct.sockaddr_un** %2
%7 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %6, i32 0, i32 1
store i32 %5, i32* %7
%8 = load %struct.sockaddr_un*, %struct.sockaddr_un** %2
%9 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %8, i32 0, i32 0
%10 = load i32, i32* %9
%11 = call i32 (...) @getuid()
%12 = call i32 @snprintf(i32 %10, i32 3, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %11)
ret void
}

LLVM IR (-O2):
%struct.sockaddr_un = type { i32, i32 }
@AF_UNIX = global i32 0
@.str = [17 x i8] c"/tmp/minstrel.%d\00"
define void @setaddr(%struct.sockaddr_un* nocapture %0) {
%2 = tail call i32 @bzero(%struct.sockaddr_un* %0, i32 8)
%3 = load i32, i32* @AF_UNIX
%4 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %0, i64 0, i32 1
store i32 %3, i32* %4
%5 = getelementptr inbounds %struct.sockaddr_un, %struct.sockaddr_un* %0, i64 0, i32 0
%6 = load i32, i32* %5
%7 = tail call i32 (...) @getuid()
%8 = tail call i32 @snprintf(i32 %6, i32 3, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %7)
ret void
}