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

/* Variables and functions */
int /*<<< orphan*/ getpid();
int /*<<< orphan*/ random();
int /*<<< orphan*/ snprintf(char *, int, char *, char *, int /*<<< orphan*/,
                            int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ srandom(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
char *gen_unix_sockname(void) {
  static char scratch[80];
  srandom(time(NULL));
  snprintf(scratch, 80, "%s-%lu%d%ld", "isock", time(NULL), getpid(), random());
  return scratch;
}


x86 assembly (clang, -O0):
<gen_unix_sockname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1030 <srandom@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %eax,-0x4(%rbp)
mov    $0x0,%al
call   1070 <random@plt>
mov    -0x8(%rbp),%r8d
mov    -0x4(%rbp),%r9d
lea    0x2ecc(%rip),%rdi
mov    $0x50,%esi
lea    0xe60(%rip),%rdx
lea    0xe65(%rip),%rcx
mov    %eax,(%rsp)
call   1050 <snprintf@plt>
lea    0x2eaa(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gen_unix_sockname>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1030 <srandom@plt>
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1040 <getpid@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1070 <random@plt>
mov    %eax,(%rsp)
lea    0x2ed7(%rip),%r14
lea    0xe70(%rip),%rdx
lea    0xe75(%rip),%rcx
mov    %r14,%rdi
mov    $0x50,%esi
mov    %ebx,%r8d
mov    %ebp,%r9d
call   1050 <snprintf@plt>
mov    %r14,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@gen_unix_sockname.scratch = internal global [80 x i8] zeroinitializer
@.str = [12 x i8] c"%s-%lu%d%ld\00"
@.str.1 = [6 x i8] c"isock\00"
define i8* @gen_unix_sockname() {
%1 = call i32 @time(i32* null)
%2 = call i32 @srandom(i32 %1)
%3 = call i32 @time(i32* null)
%4 = call i32 (...) @getpid()
%5 = call i32 (...) @random()
%6 = call i32 @snprintf(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @gen_unix_sockname.scratch, i64 0, i64 0), i32 80, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %3, i32 %4, i32 %5)
ret i8* getelementptr inbounds ([80 x i8], [80 x i8]* @gen_unix_sockname.scratch, i64 0, i64 0)
}

LLVM IR (-O2):
@gen_unix_sockname.scratch = internal global [80 x i8] zeroinitializer
@.str = [12 x i8] c"%s-%lu%d%ld\00"
@.str.1 = [6 x i8] c"isock\00"
define i8* @gen_unix_sockname() {
%1 = tail call i32 @time(i32* null)
%2 = tail call i32 @srandom(i32 %1)
%3 = tail call i32 @time(i32* null)
%4 = tail call i32 (...) @getpid()
%5 = tail call i32 (...) @random()
%6 = tail call i32 @snprintf(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @gen_unix_sockname.scratch, i64 0, i64 0), i32 80, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %3, i32 %4, i32 %5)
ret i8* getelementptr inbounds ([80 x i8], [80 x i8]* @gen_unix_sockname.scratch, i64 0, i64 0)
}