#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 */
typedef int /*<<< orphan*/ temp;
struct timeval {
  scalar_t__ tv_usec;
  scalar_t__ tv_sec;
};
typedef int /*<<< orphan*/ hostname;

/* Variables and functions */
int /*<<< orphan*/ gethostname(char *, int);
int getpid();
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/);
int /*<<< orphan*/ memcpy(char *, char *, int);
scalar_t__ rand();
int /*<<< orphan*/ snprintf(char *, int, char *, char *, unsigned long,
                            unsigned long, unsigned long, unsigned long,
                            char *);
int /*<<< orphan*/ srand(int);
scalar_t__ time(int /*<<< orphan*/);
void make_cookie(char *cookie) {
  static int randomized = 0;
  char hostname[500];
  struct timeval tv;
  char temp[1000];
  if (!randomized) {
    srand((int)time(0) ^ getpid());
  }
  (void)gethostname(hostname, sizeof(hostname));
  (void)gettimeofday(&tv, 0);
  (void)snprintf(temp, sizeof(temp), "%s.%ld.%06ld.%08lx%08lx.%s", hostname,
                 (unsigned long int)tv.tv_sec, (unsigned long int)tv.tv_usec,
                 (unsigned long int)rand(), (unsigned long int)rand(),
                 "1234567890123456789012345678901234567890");
  memcpy(cookie, temp, 36);
  cookie[36] = '\0';
}


x86 assembly (clang, -O0):
<make_cookie>:
push   %rbp
mov    %rsp,%rbp
sub    $0x650,%rsp
mov    %rdi,-0x8(%rbp)
cmpl   $0x0,0x2ece(%rip)
jne    11bd <make_cookie+0x3d>
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,-0x604(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    -0x604(%rbp),%edi
xor    %eax,%edi
call   1060 <srand@plt>
lea    -0x200(%rbp),%rdi
mov    $0x1f4,%esi
call   1090 <gethostname@plt>
lea    -0x210(%rbp),%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
lea    -0x600(%rbp),%rax
mov    %rax,-0x630(%rbp)
lea    -0x200(%rbp),%rax
mov    %rax,-0x628(%rbp)
mov    -0x208(%rbp),%rax
mov    %rax,-0x620(%rbp)
mov    -0x210(%rbp),%rax
mov    %rax,-0x618(%rbp)
mov    $0x0,%al
call   10a0 <rand@plt>
mov    %rax,-0x610(%rbp)
mov    $0x0,%al
call   10a0 <rand@plt>
mov    -0x630(%rbp),%rdi
mov    -0x628(%rbp),%rcx
mov    -0x620(%rbp),%r8
mov    -0x618(%rbp),%r9
mov    -0x610(%rbp),%r11
mov    %rax,%r10
mov    $0x3e8,%esi
lea    0xda5(%rip),%rdx
lea    0xdb9(%rip),%rax
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1040 <snprintf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x600(%rbp),%rsi
mov    $0x24,%edx
call   1070 <memcpy@plt>
mov    -0x8(%rbp),%rax
movb   $0x0,0x24(%rax)
add    $0x650,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_cookie>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x5f8,%rsp
mov    %rdi,%r15
xor    %edi,%edi
call   1080 <time@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1030 <getpid@plt>
xor    %eax,%ebx
mov    %ebx,%edi
call   1060 <srand@plt>
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    $0x1f4,%esi
call   1090 <gethostname@plt>
mov    %rsp,%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
mov    (%rsp),%r12
mov    0x8(%rsp),%rbx
xor    %eax,%eax
call   10a0 <rand@plt>
mov    %rax,%r13
xor    %eax,%eax
call   10a0 <rand@plt>
sub    $0x8,%rsp
lea    0xe2c(%rip),%r10
lea    0xe0a(%rip),%rdx
lea    0x218(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x3e8,%esi
mov    %r14,%rcx
mov    %rbx,%r8
mov    %r12,%r9
push   %r10
push   %rax
push   %r13
call   1040 <snprintf@plt>
add    $0x20,%rsp
mov    %r15,%rdi
mov    %rbp,%rsi
mov    $0x24,%edx
call   1070 <memcpy@plt>
movb   $0x0,0x24(%r15)
add    $0x5f8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.timeval = type { i64, i64 }
@make_cookie.randomized = internal global i32 0
@.str = [27 x i8] c"%s.%ld.%06ld.%08lx%08lx.%s\00"
@.str.1 = [41 x i8] c"1234567890123456789012345678901234567890\00"
define void @make_cookie(i8* %0) {
%2 = alloca i8*
%3 = alloca [500 x i8]
%4 = alloca %struct.timeval
%5 = alloca [1000 x i8]
store i8* %0, i8** %2
%6 = load i32, i32* @make_cookie.randomized
%7 = icmp ne i32 %6, 0
br i1 %7, label %14, label %8
8: ; preds = %1
%9 = call i64 @time(i32 0)
%10 = trunc i64 %9 to i32
%11 = call i32 (...) @getpid()
%12 = xor i32 %10, %11
%13 = call i32 @srand(i32 %12)
br label %14
14: ; preds = %8, %1
%15 = getelementptr inbounds [500 x i8], [500 x i8]* %3, i64 0, i64 0
%16 = call i32 @gethostname(i8* %15, i32 500)
%17 = call i32 @gettimeofday(%struct.timeval* %4, i32 0)
%18 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%19 = getelementptr inbounds [500 x i8], [500 x i8]* %3, i64 0, i64 0
%20 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 1
%21 = load i64, i64* %20
%22 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 0
%23 = load i64, i64* %22
%24 = call i64 (...) @rand()
%25 = call i64 (...) @rand()
%26 = call i32 @snprintf(i8* %18, i32 1000, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %19, i64 %21, i64 %23, i64 %24, i64 %25, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
%27 = load i8*, i8** %2
%28 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%29 = call i32 @memcpy(i8* %27, i8* %28, i32 36)
%30 = load i8*, i8** %2
%31 = getelementptr inbounds i8, i8* %30, i64 36
store i8 0, i8* %31
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i64, i64 }
@.str = [27 x i8] c"%s.%ld.%06ld.%08lx%08lx.%s\00"
@.str.1 = [41 x i8] c"1234567890123456789012345678901234567890\00"
define void @make_cookie(i8* %0) {
%2 = alloca [500 x i8]
%3 = alloca %struct.timeval
%4 = alloca [1000 x i8]
%5 = getelementptr inbounds [500 x i8], [500 x i8]* %2, i64 0, i64 0
%6 = bitcast %struct.timeval* %3 to i8*
%7 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%8 = tail call i64 @time(i32 0)
%9 = trunc i64 %8 to i32
%10 = tail call i32 (...) @getpid()
%11 = xor i32 %10, %9
%12 = tail call i32 @srand(i32 %11)
%13 = call i32 @gethostname(i8* %5, i32 500)
%14 = call i32 @gettimeofday(%struct.timeval* %3, i32 0)
%15 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
%16 = load i64, i64* %15
%17 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%18 = load i64, i64* %17
%19 = call i64 (...) @rand()
%20 = call i64 (...) @rand()
%21 = call i32 @snprintf(i8* %7, i32 1000, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %5, i64 %16, i64 %18, i64 %19, i64 %20, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
%22 = call i32 @memcpy(i8* %0, i8* %7, i32 36)
%23 = getelementptr inbounds i8, i8* %0, i64 36
store i8 0, i8* %23
ret void
}