#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 scalar_t__ time_t;

/* Variables and functions */
int /*<<< orphan*/ _remove_char(char *, char);
char *ctime(scalar_t__ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
char *malloc(int);
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ memset(char *, char, int);
int /*<<< orphan*/ stderr;
int strlen(char *);
scalar_t__ time(int /*<<< orphan*/ *);
char *generate_peer_id() {
  time_t current_time;
  char *c_time_string;
  current_time = time(NULL);
  if (current_time == ((time_t)-1))
    (void)fprintf(stderr, "Failure to compute.");
  c_time_string = ctime(&current_time);
  if (c_time_string == NULL)
    (void)fprintf(stderr, "Failure to convert.");
  _remove_char(c_time_string, ' ');
  _remove_char(c_time_string, ':');
  char *result = malloc(21);
  memset(result, '\0', 21);
  memcpy(result, "RRRRRRRRRRRRRRRRRRRR", 20);
  memcpy(result, c_time_string, strlen(c_time_string) - 1);
  return result;
}


x86 assembly (clang, -O0):
<generate_peer_id>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
xor    %eax,%eax
mov    %eax,%edi
call   1080 <time@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0xffffffffffffffff,-0x8(%rbp)
jne    11b5 <generate_peer_id+0x35>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
lea    0xe50(%rip),%rsi
call   1060 <fprintf@plt>
lea    -0x8(%rbp),%rdi
call   1030 <ctime@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11e2 <generate_peer_id+0x62>
mov    0x2e0c(%rip),%rax
mov    (%rax),%edi
lea    0xe37(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x10(%rbp),%rdi
mov    $0x20,%esi
call   1090 <_remove_char@plt>
mov    -0x10(%rbp),%rdi
mov    $0x3a,%esi
call   1090 <_remove_char@plt>
mov    $0x15,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0x15,%edx
call   1050 <memset@plt>
mov    -0x18(%rbp),%rdi
lea    0xe01(%rip),%rsi
mov    $0x14,%edx
call   1070 <memcpy@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    %eax,%edx
sub    $0x1,%edx
call   1070 <memcpy@plt>
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate_peer_id>:
push   %r14
push   %rbx
push   %rax
xor    %edi,%edi
call   1080 <time@plt>
mov    %rax,(%rsp)
cmp    $0xffffffffffffffff,%rax
jne    11aa <generate_peer_id+0x2a>
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
lea    0xe5b(%rip),%rsi
call   1060 <fprintf@plt>
mov    %rsp,%rdi
call   1030 <ctime@plt>
mov    %rax,%r14
test   %rax,%rax
jne    11cf <generate_peer_id+0x4f>
mov    0x2e1f(%rip),%rax
mov    (%rax),%edi
lea    0xe4a(%rip),%rsi
call   1060 <fprintf@plt>
mov    %r14,%rdi
mov    $0x20,%esi
call   1090 <_remove_char@plt>
mov    %r14,%rdi
mov    $0x3a,%esi
call   1090 <_remove_char@plt>
mov    $0x15,%edi
call   10a0 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %esi,%esi
mov    $0x15,%edx
call   1050 <memset@plt>
lea    0xe1c(%rip),%rsi
mov    %rbx,%rdi
mov    $0x14,%edx
call   1070 <memcpy@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
lea    -0x1(%rax),%edx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1070 <memcpy@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [20 x i8] c"Failure to compute.\00"
@.str.1 = [20 x i8] c"Failure to convert.\00"
@.str.2 = [21 x i8] c"RRRRRRRRRRRRRRRRRRRR\00"
define i8* @generate_peer_id() {
%1 = alloca i64
%2 = alloca i8*
%3 = alloca i8*
%4 = call i64 @time(i32* null)
store i64 %4, i64* %1
%5 = load i64, i64* %1
%6 = icmp eq i64 %5, -1
br i1 %6, label %7, label %10
7: ; preds = %0
%8 = load i32, i32* @stderr
%9 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %7, %0
%11 = call i8* @ctime(i64* %1)
store i8* %11, i8** %2
%12 = load i8*, i8** %2
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %17
14: ; preds = %10
%15 = load i32, i32* @stderr
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %17
17: ; preds = %14, %10
%18 = load i8*, i8** %2
%19 = call i32 @_remove_char(i8* %18, i8 signext 32)
%20 = load i8*, i8** %2
%21 = call i32 @_remove_char(i8* %20, i8 signext 58)
%22 = call i8* @malloc(i32 21)
store i8* %22, i8** %3
%23 = load i8*, i8** %3
%24 = call i32 @memset(i8* %23, i8 signext 0, i32 21)
%25 = load i8*, i8** %3
%26 = call i32 @memcpy(i8* %25, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 20)
%27 = load i8*, i8** %3
%28 = load i8*, i8** %2
%29 = load i8*, i8** %2
%30 = call i32 @strlen(i8* %29)
%31 = sub nsw i32 %30, 1
%32 = call i32 @memcpy(i8* %27, i8* %28, i32 %31)
%33 = load i8*, i8** %3
ret i8* %33
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [20 x i8] c"Failure to compute.\00"
@.str.1 = [20 x i8] c"Failure to convert.\00"
@.str.2 = [21 x i8] c"RRRRRRRRRRRRRRRRRRRR\00"
define i8* @generate_peer_id() {
%1 = alloca i64
%2 = bitcast i64* %1 to i8*
%3 = tail call i64 @time(i32* null)
store i64 %3, i64* %1
%4 = icmp eq i64 %3, -1
br i1 %4, label %5, label %8
5: ; preds = %0
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %5, %0
%9 = call i8* @ctime(i64* %1)
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %14
14: ; preds = %11, %8
%15 = call i32 @_remove_char(i8* %9, i8 signext 32)
%16 = call i32 @_remove_char(i8* %9, i8 signext 58)
%17 = call dereferenceable_or_null(21) i8* @malloc(i32 21)
%18 = call i32 @memset(i8* %17, i8 signext 0, i32 21)
%19 = call i32 @memcpy(i8* %17, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 20)
%20 = call i32 @strlen(i8* %9)
%21 = add nsw i32 %20, -1
%22 = call i32 @memcpy(i8* %17, i8* %9, i32 %21)
ret i8* %17
}