#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 int64_t;

/* Variables and functions */
int /*<<< orphan*/ sprintf(char *, char *, int, int, ...);
void tostr(int64_t *m, int numElems, char *outstr) {
  switch (numElems) {
  case 1:
    sprintf(outstr, "{0x%08X%08X}", (int)(*m >> 32), (int)*m);
    break;
  case 2:
    sprintf(outstr, "{0x%08X%08X,0x%08X%08X}", (int)(*m >> 32), (int)*m,
            (int)(m[1] >> 32), (int)m[1]);
  }
}


x86 assembly (clang, -O0):
<tostr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x1,%eax
je     1148 <tostr+0x38>
jmp    1137 <tostr+0x27>
mov    -0x1c(%rbp),%eax
sub    $0x2,%eax
je     1172 <tostr+0x62>
jmp    11b5 <tostr+0xa5>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    (%rax),%edx
mov    $0x20,%ecx
sar    %cl,%edx
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
lea    0xe9a(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    11b5 <tostr+0xa5>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    (%rax),%edx
mov    $0x20,%ecx
sar    %cl,%edx
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%r8d
mov    $0x20,%ecx
sar    %cl,%r8d
mov    -0x20(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%r9d
lea    0xe5f(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tostr>:
cmp    $0x2,%esi
je     112d <tostr+0x1d>
cmp    $0x1,%esi
jne    1144 <tostr+0x34>
mov    (%rdi),%ecx
lea    0xedd(%rip),%rsi
mov    %rdx,%rdi
xor    %eax,%eax
jmp    1030 <sprintf@plt>
mov    (%rdi),%ecx
mov    0x4(%rdi),%r9d
lea    0xed3(%rip),%rsi
mov    %rdx,%rdi
xor    %eax,%eax
jmp    1030 <sprintf@plt>
ret

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

LLVM IR (-O2):
@.str = [13 x i8] c"{0x%08X%08X}\00"
@.str.1 = [24 x i8] c"{0x%08X%08X,0x%08X%08X}\00"
define void @tostr(i32* nocapture %0, i32 %1, i8* nocapture writeonly %2) {
switch i32 %1, label %12 [
i32 1, label %4
i32 2, label %7
]
4: ; preds = %3
%5 = load i32, i32* %0
%6 = tail call i32 (i8*, i8*, i32, i32, ...) @sprintf(i8* dereferenceable(1) %2, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 poison, i32 %5)
br label %12
7: ; preds = %3
%8 = load i32, i32* %0
%9 = getelementptr inbounds i32, i32* %0, i64 1
%10 = load i32, i32* %9
%11 = tail call i32 (i8*, i8*, i32, i32, ...) @sprintf(i8* dereferenceable(1) %2, i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 poison, i32 %8, i32 poison, i32 %10)
br label %12
12: ; preds = %7, %3, %4
ret void
}