#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 u_int16_t;
typedef int /*<<< orphan*/ __m128i;

/* Variables and functions */
int /*<<< orphan*/ _mm_store_si128(int /*<<< orphan*/ *, int /*<<< orphan*/);
int sprintf(char *, char *, int);
char *format_epu16(__m128i v, char *buf) {
  u_int16_t __attribute__((aligned(16))) v16[8];
  char *ptr = buf;
  int i, j;
  _mm_store_si128((__m128i *)v16, v);
  *ptr++ = '{';
  for (i = 0; i < 8; i++) {
    j = sprintf(ptr, "%u,", v16[i]);
    ptr += j;
  }
  ptr--;
  *ptr++ = '}';
  *ptr = '\0';
  return buf;
}


x86 assembly (clang, -O0):
<format_epu16>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1030 <_mm_store_si128@plt>
mov    -0x38(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x38(%rbp)
movb   $0x7b,(%rax)
movl   $0x0,-0x3c(%rbp)
cmpl   $0x8,-0x3c(%rbp)
jge    11a0 <format_epu16+0x80>
mov    -0x38(%rbp),%rdi
movslq -0x3c(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%edx
lea    0xe87(%rip),%rsi
call   1040 <sprintf@plt>
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%ecx
mov    -0x38(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    115c <format_epu16+0x3c>
mov    -0x38(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x38(%rbp)
movb   $0x7d,(%rax)
mov    -0x38(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<format_epu16>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%r14
mov    %edi,%esi
mov    %rsp,%rdi
call   1030 <_mm_store_si128@plt>
lea    0x1(%r14),%rdi
movb   $0x7b,(%r14)
mov    (%rsp),%edx
lea    0xeb4(%rip),%r15
mov    %r15,%rsi
call   1040 <sprintf@plt>
cltq
lea    (%r14,%rax,1),%r12
add    $0x1,%r12
mov    0x4(%rsp),%edx
mov    %r12,%rdi
mov    %r15,%rsi
call   1040 <sprintf@plt>
movslq %eax,%rbx
add    %r12,%rbx
mov    0x8(%rsp),%edx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <sprintf@plt>
movslq %eax,%r12
add    %rbx,%r12
mov    0xc(%rsp),%edx
mov    %r12,%rdi
mov    %r15,%rsi
call   1040 <sprintf@plt>
movslq %eax,%rbx
add    %r12,%rbx
mov    0x10(%rsp),%edx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <sprintf@plt>
movslq %eax,%r12
add    %rbx,%r12
mov    0x14(%rsp),%edx
mov    %r12,%rdi
mov    %r15,%rsi
call   1040 <sprintf@plt>
movslq %eax,%r13
add    %r12,%r13
mov    0x18(%rsp),%edx
mov    %r13,%rdi
mov    %r15,%rsi
call   1040 <sprintf@plt>
movslq %eax,%rbx
add    %r13,%rbx
mov    0x1c(%rsp),%edx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <sprintf@plt>
cltq
movw   $0x7d,-0x1(%rax,%rbx,1)
mov    %r14,%rax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%u,\00"
define i8* @format_epu16(i32 %0, i8* returned writeonly %1) {
%3 = alloca [8 x i32]
%4 = bitcast [8 x i32]* %3 to i8*
%5 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 0
%6 = call i32 @_mm_store_si128(i32* %5, i32 %0)
%7 = getelementptr inbounds i8, i8* %1, i64 1
store i8 123, i8* %1
%8 = load i32, i32* %5
%9 = call i32 @sprintf(i8* dereferenceable(1) %7, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %7, i64 %10
%12 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 1
%13 = load i32, i32* %12
%14 = call i32 @sprintf(i8* dereferenceable(1) %11, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %11, i64 %15
%17 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 2
%18 = load i32, i32* %17
%19 = call i32 @sprintf(i8* dereferenceable(1) %16, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %16, i64 %20
%22 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 3
%23 = load i32, i32* %22
%24 = call i32 @sprintf(i8* dereferenceable(1) %21, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %23)
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %21, i64 %25
%27 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 4
%28 = load i32, i32* %27
%29 = call i32 @sprintf(i8* dereferenceable(1) %26, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %28)
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %26, i64 %30
%32 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 5
%33 = load i32, i32* %32
%34 = call i32 @sprintf(i8* dereferenceable(1) %31, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %33)
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %31, i64 %35
%37 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 6
%38 = load i32, i32* %37
%39 = call i32 @sprintf(i8* dereferenceable(1) %36, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %38)
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %36, i64 %40
%42 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 7
%43 = load i32, i32* %42
%44 = call i32 @sprintf(i8* dereferenceable(1) %41, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %43)
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* %41, i64 %45
%47 = getelementptr inbounds i8, i8* %46, i64 -1
store i8 125, i8* %47
store i8 0, i8* %46
ret i8* %1
}