#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 */
size_t snprintf(char *, size_t, char *, int const, int const, int const);
size_t convert_inttostr_3(const void *input, size_t input_size, char *out,
                          size_t out_len) {
  if (input_size == sizeof(int) * 3) {
    const int *ptr = input;
    return snprintf(out, out_len, "%d %d %d", ptr[0], ptr[1], ptr[2]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<convert_inttostr_3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
cmpq   $0xc,-0x18(%rbp)
jne    116e <convert_inttostr_3+0x5e>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rax
mov    (%rax),%ecx
mov    -0x30(%rbp),%rax
mov    0x4(%rax),%r8d
mov    -0x30(%rbp),%rax
mov    0x8(%rax),%r9d
lea    0xea0(%rip),%rdx
call   1030 <snprintf@plt>
mov    %rax,-0x8(%rbp)
jmp    1176 <convert_inttostr_3+0x66>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convert_inttostr_3>:
cmp    $0xc,%rsi
jne    1137 <convert_inttostr_3+0x27>
mov    (%rdi),%eax
mov    0x4(%rdi),%r8d
mov    0x8(%rdi),%r9d
lea    0xed9(%rip),%r10
mov    %rdx,%rdi
mov    %rcx,%rsi
mov    %r10,%rdx
mov    %eax,%ecx
jmp    1030 <snprintf@plt>
xor    %eax,%eax
ret

LLVM IR (-O0):
@.str = [9 x i8] c"%d %d %d\00"
define i64 @convert_inttostr_3(i8* %0, i64 %1, i8* %2, i64 %3) {
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i32*
store i8* %0, i8** %6
store i64 %1, i64* %7
store i8* %2, i8** %8
store i64 %3, i64* %9
%11 = load i64, i64* %7
%12 = icmp eq i64 %11, 12
br i1 %12, label %13, label %28
13: ; preds = %4
%14 = load i8*, i8** %6
%15 = bitcast i8* %14 to i32*
store i32* %15, i32** %10
%16 = load i8*, i8** %8
%17 = load i64, i64* %9
%18 = load i32*, i32** %10
%19 = getelementptr inbounds i32, i32* %18, i64 0
%20 = load i32, i32* %19
%21 = load i32*, i32** %10
%22 = getelementptr inbounds i32, i32* %21, i64 1
%23 = load i32, i32* %22
%24 = load i32*, i32** %10
%25 = getelementptr inbounds i32, i32* %24, i64 2
%26 = load i32, i32* %25
%27 = call i64 @snprintf(i8* %16, i64 %17, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %20, i32 %23, i32 %26)
store i64 %27, i64* %5
br label %29
28: ; preds = %4
store i64 0, i64* %5
br label %29
29: ; preds = %28, %13
%30 = load i64, i64* %5
ret i64 %30
}

LLVM IR (-O2):
@.str = [9 x i8] c"%d %d %d\00"
define i64 @convert_inttostr_3(i8* nocapture %0, i64 %1, i8* %2, i64 %3) {
%5 = icmp eq i64 %1, 12
br i1 %5, label %6, label %16
6: ; preds = %4
%7 = bitcast i8* %0 to i32*
%8 = load i32, i32* %7
%9 = getelementptr inbounds i8, i8* %0, i64 4
%10 = bitcast i8* %9 to i32*
%11 = load i32, i32* %10
%12 = getelementptr inbounds i8, i8* %0, i64 8
%13 = bitcast i8* %12 to i32*
%14 = load i32, i32* %13
%15 = tail call i64 @snprintf(i8* %2, i64 %3, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %11, i32 %14)
br label %16
16: ; preds = %4, %6
%17 = phi i64 [ %15, %6 ], [ 0, %4 ]
ret i64 %17
}