#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__ pthread_t;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
scalar_t__ snprintf(char *, size_t, char *, ...);
int strlen(char *);
void peer_connection_queue_name(pthread_t thread, char *out, size_t len) {
  assert(len >= strlen("/") + 2 * sizeof(pthread_t) + strlen("_queue") + 1);
  size_t plen = 0;
  plen += snprintf(out, len - plen, "/");
  for (unsigned char *cp = (unsigned char *)thread;
       cp < ((unsigned char *)thread) + sizeof(pthread_t); cp++) {
    plen += snprintf(out + plen, len - plen, "%02X", *cp);
    if (plen == len)
      return;
  }
  snprintf(out + plen, len - plen, "_queue");
}


x86 assembly (clang, -O0):
<peer_connection_queue_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
lea    0xead(%rip),%rdi
call   1030 <strlen@plt>
cltq
add    $0x10,%rax
mov    %rax,-0x38(%rbp)
lea    0xe99(%rip),%rdi
call   1030 <strlen@plt>
mov    -0x38(%rbp),%rcx
mov    %eax,%edx
mov    -0x30(%rbp),%rax
movslq %edx,%rdx
add    %rdx,%rcx
add    $0x1,%rcx
cmp    %rcx,%rax
setae  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
sub    -0x20(%rbp),%rsi
lea    0xe53(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x8(%rbp),%rcx
add    $0x8,%rcx
cmp    %rcx,%rax
jae    122f <peer_connection_queue_name+0xff>
mov    -0x10(%rbp),%rdi
add    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
sub    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rax
movzbl (%rax),%ecx
lea    0xe12(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jne    1219 <peer_connection_queue_name+0xe9>
jmp    124d <peer_connection_queue_name+0x11d>
jmp    121e <peer_connection_queue_name+0xee>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    11c4 <peer_connection_queue_name+0x94>
mov    -0x10(%rbp),%rdi
add    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
sub    -0x20(%rbp),%rsi
lea    0xdbc(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<peer_connection_queue_name>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdx,%r12
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xeb7(%rip),%r13
mov    %r13,%rdi
call   1030 <strlen@plt>
movslq %eax,%rbx
lea    0xea7(%rip),%rdi
call   1030 <strlen@plt>
cltq
add    %rbx,%rax
add    $0x11,%rax
xor    %edi,%edi
cmp    %r12,%rax
setbe  %dil
call   1050 <assert@plt>
mov    %r14,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1040 <snprintf@plt>
mov    %rax,%r13
lea    (%r14,%rax,1),%rdi
mov    %r12,%rsi
sub    %rax,%rsi
movzbl (%r15),%ecx
lea    0xe6a(%rip),%rdx
xor    %eax,%eax
call   1040 <snprintf@plt>
mov    %rax,%rbx
add    %r13,%rbx
cmp    %r12,%rbx
je     12d6 <peer_connection_queue_name+0x1a6>
lea    (%r14,%rbx,1),%rdi
mov    %r12,%rsi
sub    %rbx,%rsi
movzbl 0x1(%r15),%ecx
lea    0xe3e(%rip),%rdx
xor    %eax,%eax
call   1040 <snprintf@plt>
mov    %rax,%r13
add    %rbx,%r13
cmp    %r12,%r13
je     12d6 <peer_connection_queue_name+0x1a6>
lea    (%r14,%r13,1),%rdi
mov    %r12,%rsi
sub    %r13,%rsi
movzbl 0x2(%r15),%ecx
lea    0xe12(%rip),%rdx
xor    %eax,%eax
call   1040 <snprintf@plt>
mov    %rax,%rbx
add    %r13,%rbx
cmp    %r12,%rbx
je     12d6 <peer_connection_queue_name+0x1a6>
lea    (%r14,%rbx,1),%rdi
mov    %r12,%rsi
sub    %rbx,%rsi
movzbl 0x3(%r15),%ecx
lea    0xde6(%rip),%rdx
xor    %eax,%eax
call   1040 <snprintf@plt>
mov    %rax,%r13
add    %rbx,%r13
cmp    %r12,%r13
je     12d6 <peer_connection_queue_name+0x1a6>
lea    (%r14,%r13,1),%rdi
mov    %r12,%rsi
sub    %r13,%rsi
movzbl 0x4(%r15),%ecx
lea    0xdba(%rip),%rdx
xor    %eax,%eax
call   1040 <snprintf@plt>
mov    %rax,%rbx
add    %r13,%rbx
cmp    %r12,%rbx
je     12d6 <peer_connection_queue_name+0x1a6>
lea    (%r14,%rbx,1),%rdi
mov    %r12,%rsi
sub    %rbx,%rsi
movzbl 0x5(%r15),%ecx
lea    0xd92(%rip),%rdx
xor    %eax,%eax
call   1040 <snprintf@plt>
mov    %rax,%r13
add    %rbx,%r13
cmp    %r12,%r13
je     12d6 <peer_connection_queue_name+0x1a6>
lea    (%r14,%r13,1),%rdi
mov    %r12,%rsi
sub    %r13,%rsi
movzbl 0x6(%r15),%ecx
lea    0xd6a(%rip),%rdx
xor    %eax,%eax
call   1040 <snprintf@plt>
mov    %rax,%rbx
add    %r13,%rbx
cmp    %r12,%rbx
je     12d6 <peer_connection_queue_name+0x1a6>
lea    (%r14,%rbx,1),%rdi
mov    %r12,%rsi
sub    %rbx,%rsi
movzbl 0x7(%r15),%ecx
lea    0xd42(%rip),%rdx
xor    %eax,%eax
call   1040 <snprintf@plt>
add    %rbx,%rax
cmp    %r12,%rax
jne    12e0 <peer_connection_queue_name+0x1b0>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
add    %rax,%r14
sub    %rax,%r12
lea    0xd15(%rip),%rdx
mov    %r14,%rdi
mov    %r12,%rsi
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1040 <snprintf@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"/\00"
@.str.1 = [7 x i8] c"_queue\00"
@.str.2 = [5 x i8] c"%02X\00"
define void @peer_connection_queue_name(i64 %0, i8* %1, i64 %2) {
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i8*
store i64 %0, i64* %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%9 = load i64, i64* %6
%10 = call i32 @strlen(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = sext i32 %10 to i64
%12 = add i64 %11, 16
%13 = call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%14 = sext i32 %13 to i64
%15 = add i64 %12, %14
%16 = add i64 %15, 1
%17 = icmp uge i64 %9, %16
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
store i64 0, i64* %7
%20 = load i8*, i8** %5
%21 = load i64, i64* %6
%22 = load i64, i64* %7
%23 = sub i64 %21, %22
%24 = call i64 (i8*, i64, i8*, ...) @snprintf(i8* %20, i64 %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%25 = load i64, i64* %7
%26 = add i64 %25, %24
store i64 %26, i64* %7
%27 = load i64, i64* %4
%28 = inttoptr i64 %27 to i8*
store i8* %28, i8** %8
br label %29
29: ; preds = %53, %3
%30 = load i8*, i8** %8
%31 = load i64, i64* %4
%32 = inttoptr i64 %31 to i8*
%33 = getelementptr inbounds i8, i8* %32, i64 8
%34 = icmp ult i8* %30, %33
br i1 %34, label %35, label %56
35: ; preds = %29
%36 = load i8*, i8** %5
%37 = load i64, i64* %7
%38 = getelementptr inbounds i8, i8* %36, i64 %37
%39 = load i64, i64* %6
%40 = load i64, i64* %7
%41 = sub i64 %39, %40
%42 = load i8*, i8** %8
%43 = load i8, i8* %42
%44 = zext i8 %43 to i32
%45 = call i64 (i8*, i64, i8*, ...) @snprintf(i8* %38, i64 %41, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %44)
%46 = load i64, i64* %7
%47 = add i64 %46, %45
store i64 %47, i64* %7
%48 = load i64, i64* %7
%49 = load i64, i64* %6
%50 = icmp eq i64 %48, %49
br i1 %50, label %51, label %52
51: ; preds = %35
br label %64
52: ; preds = %35
br label %53
53: ; preds = %52
%54 = load i8*, i8** %8
%55 = getelementptr inbounds i8, i8* %54, i32 1
store i8* %55, i8** %8
br label %29
56: ; preds = %29
%57 = load i8*, i8** %5
%58 = load i64, i64* %7
%59 = getelementptr inbounds i8, i8* %57, i64 %58
%60 = load i64, i64* %6
%61 = load i64, i64* %7
%62 = sub i64 %60, %61
%63 = call i64 (i8*, i64, i8*, ...) @snprintf(i8* %59, i64 %62, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %64
64: ; preds = %56, %51
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"/\00"
@.str.1 = [7 x i8] c"_queue\00"
@.str.2 = [5 x i8] c"%02X\00"
define void @peer_connection_queue_name(i64 %0, i8* %1, i64 %2) {
%4 = tail call i32 @strlen(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = sext i32 %4 to i64
%6 = tail call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%7 = sext i32 %6 to i64
%8 = add nsw i64 %5, 17
%9 = add nsw i64 %8, %7
%10 = icmp ule i64 %9, %2
%11 = zext i1 %10 to i32
%12 = tail call i32 @assert(i32 %11)
%13 = tail call i64 (i8*, i64, i8*, ...) @snprintf(i8* %1, i64 %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = inttoptr i64 %0 to i8*
%15 = getelementptr inbounds i8, i8* %1, i64 %13
%16 = sub i64 %2, %13
%17 = load i8, i8* %14
%18 = zext i8 %17 to i32
%19 = tail call i64 (i8*, i64, i8*, ...) @snprintf(i8* %15, i64 %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %18)
%20 = add i64 %19, %13
%21 = icmp eq i64 %20, %2
br i1 %21, label %89, label %22
22: ; preds = %3
%23 = getelementptr inbounds i8, i8* %14, i64 1
%24 = getelementptr inbounds i8, i8* %1, i64 %20
%25 = sub i64 %2, %20
%26 = load i8, i8* %23
%27 = zext i8 %26 to i32
%28 = tail call i64 (i8*, i64, i8*, ...) @snprintf(i8* %24, i64 %25, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %27)
%29 = add i64 %28, %20
%30 = icmp eq i64 %29, %2
br i1 %30, label %89, label %31
31: ; preds = %22
%32 = getelementptr inbounds i8, i8* %14, i64 2
%33 = getelementptr inbounds i8, i8* %1, i64 %29
%34 = sub i64 %2, %29
%35 = load i8, i8* %32
%36 = zext i8 %35 to i32
%37 = tail call i64 (i8*, i64, i8*, ...) @snprintf(i8* %33, i64 %34, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %36)
%38 = add i64 %37, %29
%39 = icmp eq i64 %38, %2
br i1 %39, label %89, label %40
40: ; preds = %31
%41 = getelementptr inbounds i8, i8* %14, i64 3
%42 = getelementptr inbounds i8, i8* %1, i64 %38
%43 = sub i64 %2, %38
%44 = load i8, i8* %41
%45 = zext i8 %44 to i32
%46 = tail call i64 (i8*, i64, i8*, ...) @snprintf(i8* %42, i64 %43, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %45)
%47 = add i64 %46, %38
%48 = icmp eq i64 %47, %2
br i1 %48, label %89, label %49
49: ; preds = %40
%50 = getelementptr inbounds i8, i8* %14, i64 4
%51 = getelementptr inbounds i8, i8* %1, i64 %47
%52 = sub i64 %2, %47
%53 = load i8, i8* %50
%54 = zext i8 %53 to i32
%55 = tail call i64 (i8*, i64, i8*, ...) @snprintf(i8* %51, i64 %52, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %54)
%56 = add i64 %55, %47
%57 = icmp eq i64 %56, %2
br i1 %57, label %89, label %58
58: ; preds = %49
%59 = getelementptr inbounds i8, i8* %14, i64 5
%60 = getelementptr inbounds i8, i8* %1, i64 %56
%61 = sub i64 %2, %56
%62 = load i8, i8* %59
%63 = zext i8 %62 to i32
%64 = tail call i64 (i8*, i64, i8*, ...) @snprintf(i8* %60, i64 %61, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %63)
%65 = add i64 %64, %56
%66 = icmp eq i64 %65, %2
br i1 %66, label %89, label %67
67: ; preds = %58
%68 = getelementptr inbounds i8, i8* %14, i64 6
%69 = getelementptr inbounds i8, i8* %1, i64 %65
%70 = sub i64 %2, %65
%71 = load i8, i8* %68
%72 = zext i8 %71 to i32
%73 = tail call i64 (i8*, i64, i8*, ...) @snprintf(i8* %69, i64 %70, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %72)
%74 = add i64 %73, %65
%75 = icmp eq i64 %74, %2
br i1 %75, label %89, label %76
76: ; preds = %67
%77 = getelementptr inbounds i8, i8* %14, i64 7
%78 = getelementptr inbounds i8, i8* %1, i64 %74
%79 = sub i64 %2, %74
%80 = load i8, i8* %77
%81 = zext i8 %80 to i32
%82 = tail call i64 (i8*, i64, i8*, ...) @snprintf(i8* %78, i64 %79, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %81)
%83 = add i64 %82, %74
%84 = icmp eq i64 %83, %2
br i1 %84, label %89, label %85
85: ; preds = %76
%86 = getelementptr inbounds i8, i8* %1, i64 %83
%87 = sub i64 %2, %83
%88 = tail call i64 (i8*, i64, i8*, ...) @snprintf(i8* %86, i64 %87, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %89
89: ; preds = %3, %22, %31, %40, %49, %58, %67, %76, %85
ret void
}