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

/* Variables and functions */
int /*<<< orphan*/ keytostr(char *, int, unsigned int);
int /*<<< orphan*/ pstrcat(char *, int, char *);
const char *keys_to_str(char *buf, int buf_size, unsigned int *keys,
                        int nb_keys) {
  char buf1[64];
  int i;
  buf[0] = '\0';
  for (i = 0; i < nb_keys; i++) {
    keytostr(buf1, sizeof(buf1), keys[i]);
    if (i != 0)
      pstrcat(buf, buf_size, " ");
    pstrcat(buf, buf_size, buf1);
  }
  return buf;
}


x86 assembly (clang, -O0):
<keys_to_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x0,-0x64(%rbp)
mov    -0x64(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11a4 <keys_to_str+0x84>
lea    -0x60(%rbp),%rdi
mov    -0x18(%rbp),%rax
movslq -0x64(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    $0x40,%esi
call   1040 <keytostr@plt>
cmpl   $0x0,-0x64(%rbp)
je     1186 <keys_to_str+0x66>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
lea    0xe7f(%rip),%rdx
call   1030 <pstrcat@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
lea    -0x60(%rbp),%rdx
call   1030 <pstrcat@plt>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    1144 <keys_to_str+0x24>
mov    -0x8(%rbp),%rax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<keys_to_str>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rdi,%rbx
movb   $0x0,(%rdi)
test   %ecx,%ecx
jle    11b8 <keys_to_str+0x98>
mov    %ecx,%r15d
mov    %rdx,%r14
mov    %esi,%ebp
mov    (%rdx),%edx
mov    %rsp,%r12
mov    %r12,%rdi
mov    $0x40,%esi
call   1040 <keytostr@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r12,%rdx
call   1030 <pstrcat@plt>
cmp    $0x1,%r15d
je     11b8 <keys_to_str+0x98>
mov    %r15d,%r13d
mov    $0x1,%r12d
mov    %rsp,%r15
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r14,%r12,4),%edx
mov    %r15,%rdi
mov    $0x40,%esi
call   1040 <keytostr@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
lea    0xe63(%rip),%rdx
call   1030 <pstrcat@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r15,%rdx
call   1030 <pstrcat@plt>
add    $0x1,%r12
cmp    %r12,%r13
jne    1180 <keys_to_str+0x60>
mov    %rbx,%rax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
define i8* @keys_to_str(i8* %0, i32 %1, i32* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32
%9 = alloca [64 x i8]
%10 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32* %2, i32** %7
store i32 %3, i32* %8
%11 = load i8*, i8** %5
%12 = getelementptr inbounds i8, i8* %11, i64 0
store i8 0, i8* %12
store i32 0, i32* %10
br label %13
13: ; preds = %36, %4
%14 = load i32, i32* %10
%15 = load i32, i32* %8
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %39
17: ; preds = %13
%18 = getelementptr inbounds [64 x i8], [64 x i8]* %9, i64 0, i64 0
%19 = load i32*, i32** %7
%20 = load i32, i32* %10
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %19, i64 %21
%23 = load i32, i32* %22
%24 = call i32 @keytostr(i8* %18, i32 64, i32 %23)
%25 = load i32, i32* %10
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %31
27: ; preds = %17
%28 = load i8*, i8** %5
%29 = load i32, i32* %6
%30 = call i32 @pstrcat(i8* %28, i32 %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %31
31: ; preds = %27, %17
%32 = load i8*, i8** %5
%33 = load i32, i32* %6
%34 = getelementptr inbounds [64 x i8], [64 x i8]* %9, i64 0, i64 0
%35 = call i32 @pstrcat(i8* %32, i32 %33, i8* %34)
br label %36
36: ; preds = %31
%37 = load i32, i32* %10
%38 = add nsw i32 %37, 1
store i32 %38, i32* %10
br label %13
39: ; preds = %13
%40 = load i8*, i8** %5
ret i8* %40
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
define i8* @keys_to_str(i8* returned %0, i32 %1, i32* nocapture %2, i32 %3) {
%5 = alloca [64 x i8]
%6 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
store i8 0, i8* %0
%7 = icmp sgt i32 %3, 0
br i1 %7, label %8, label %23
8: ; preds = %4
%9 = zext i32 %3 to i64
%10 = load i32, i32* %2
%11 = call i32 @keytostr(i8* %6, i32 64, i32 %10)
%12 = call i32 @pstrcat(i8* %0, i32 %1, i8* %6)
%13 = icmp eq i32 %3, 1
br i1 %13, label %23, label %14
14: ; preds = %8, %14
%15 = phi i64 [ %21, %14 ], [ 1, %8 ]
%16 = getelementptr inbounds i32, i32* %2, i64 %15
%17 = load i32, i32* %16
%18 = call i32 @keytostr(i8* %6, i32 64, i32 %17)
%19 = call i32 @pstrcat(i8* %0, i32 %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%20 = call i32 @pstrcat(i8* %0, i32 %1, i8* %6)
%21 = add nuw nsw i64 %15, 1
%22 = icmp eq i64 %21, %9
br i1 %22, label %23, label %14
23: ; preds = %14, %8, %4
ret i8* %0
}