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

/* Variables and functions */
void conv_bin_str(uint64_t val, char str[]) {
  int ii, jj;
  for (ii = 0, jj = (48 - 1); jj >= 0; ii++, jj--) {
    if (val & (((uint64_t)1) << ii))
      str[jj] = '1';
    else
      str[jj] = '0';
  }
  str[48] = '\0';
}


x86 assembly (clang, -O0):
<conv_bin_str>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x2f,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jl     1176 <conv_bin_str+0x76>
mov    -0x4(%rbp),%eax
mov    -0x14(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     114e <conv_bin_str+0x4e>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movb   $0x31,(%rax,%rcx,1)
jmp    115a <conv_bin_str+0x5a>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movb   $0x30,(%rax,%rcx,1)
jmp    115f <conv_bin_str+0x5f>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    1119 <conv_bin_str+0x19>
mov    -0x10(%rbp),%rax
movb   $0x0,0x30(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<conv_bin_str>:
movd   %edi,%xmm0
pshufd $0x0,%xmm0,%xmm1
movdqa 0xeef(%rip),%xmm3
pand   %xmm1,%xmm3
movdqa 0xef3(%rip),%xmm2
pand   %xmm1,%xmm2
movdqa 0xef7(%rip),%xmm4
pand   %xmm1,%xmm4
movdqa 0xefb(%rip),%xmm5
pand   %xmm1,%xmm5
pxor   %xmm0,%xmm0
pcmpeqd %xmm0,%xmm5
pcmpeqd %xmm0,%xmm4
packssdw %xmm5,%xmm4
pcmpeqd %xmm0,%xmm2
pcmpeqd %xmm0,%xmm3
packssdw %xmm2,%xmm3
packsswb %xmm4,%xmm3
movdqa 0xedf(%rip),%xmm2
paddb  %xmm2,%xmm3
movdqa %xmm3,%xmm4
punpcklbw %xmm0,%xmm4
pshufd $0x4e,%xmm4,%xmm4
pshuflw $0x1b,%xmm4,%xmm4
pshufhw $0x1b,%xmm4,%xmm4
punpckhbw %xmm0,%xmm3
pshufd $0x4e,%xmm3,%xmm3
pshuflw $0x1b,%xmm3,%xmm3
pshufhw $0x1b,%xmm3,%xmm5
packuswb %xmm4,%xmm5
movdqa 0xeb5(%rip),%xmm3
pand   %xmm1,%xmm3
movdqa 0xeb9(%rip),%xmm4
pand   %xmm1,%xmm4
movdqa 0xebd(%rip),%xmm6
pand   %xmm1,%xmm6
pand   0xec1(%rip),%xmm1
movdqu %xmm5,0x20(%rsi)
pcmpeqd %xmm0,%xmm1
pcmpeqd %xmm0,%xmm6
packssdw %xmm1,%xmm6
pcmpeqd %xmm0,%xmm4
pcmpeqd %xmm0,%xmm3
packssdw %xmm4,%xmm3
packsswb %xmm6,%xmm3
paddb  %xmm2,%xmm3
movdqa %xmm3,%xmm1
punpcklbw %xmm0,%xmm1
pshufd $0x4e,%xmm1,%xmm1
pshuflw $0x1b,%xmm1,%xmm1
pshufhw $0x1b,%xmm1,%xmm1
punpckhbw %xmm0,%xmm3
pshufd $0x4e,%xmm3,%xmm0
pshuflw $0x1b,%xmm0,%xmm0
pshufhw $0x1b,%xmm0,%xmm0
packuswb %xmm1,%xmm0
movdqu %xmm0,0x10(%rsi)
movb   $0x0,0x30(%rsi)
ret

LLVM IR (-O0):
define void @conv_bin_str(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i8* %1, i8** %4
store i32 0, i32* %5
store i32 47, i32* %6
br label %7
7: ; preds = %27, %2
%8 = load i32, i32* %6
%9 = icmp sge i32 %8, 0
br i1 %9, label %10, label %32
10: ; preds = %7
%11 = load i32, i32* %3
%12 = load i32, i32* %5
%13 = shl i32 1, %12
%14 = and i32 %11, %13
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %10
%17 = load i8*, i8** %4
%18 = load i32, i32* %6
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
store i8 49, i8* %20
br label %26
21: ; preds = %10
%22 = load i8*, i8** %4
%23 = load i32, i32* %6
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
store i8 48, i8* %25
br label %26
26: ; preds = %21, %16
br label %27
27: ; preds = %26
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 1
store i32 %29, i32* %5
%30 = load i32, i32* %6
%31 = add nsw i32 %30, -1
store i32 %31, i32* %6
br label %7
32: ; preds = %7
%33 = load i8*, i8** %4
%34 = getelementptr inbounds i8, i8* %33, i64 48
store i8 0, i8* %34
ret void
}

LLVM IR (-O2):
define void @conv_bin_str(i32 %0, i8* nocapture writeonly %1) {
%3 = insertelement <16 x i32> poison, i32 %0, i64 0
%4 = shufflevector <16 x i32> %3, <16 x i32> poison, <16 x i32> zeroinitializer
%5 = and <16 x i32> %4, <i32 1, i32 2, i32 4, i32 8, i32 16, i32 32, i32 64, i32 128, i32 256, i32 512, i32 1024, i32 2048, i32 4096, i32 8192, i32 16384, i32 32768>
%6 = icmp eq <16 x i32> %5, zeroinitializer
%7 = select <16 x i1> %6, <16 x i8> <i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48>, <16 x i8> <i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49>
%8 = shufflevector <16 x i8> %7, <16 x i8> poison, <16 x i32> <i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
%9 = getelementptr inbounds i8, i8* %1, i64 32
%10 = bitcast i8* %9 to <16 x i8>*
store <16 x i8> %8, <16 x i8>* %10
%11 = and <16 x i32> %4, <i32 65536, i32 131072, i32 262144, i32 524288, i32 1048576, i32 2097152, i32 4194304, i32 8388608, i32 16777216, i32 33554432, i32 67108864, i32 134217728, i32 268435456, i32 536870912, i32 1073741824, i32 -2147483648>
%12 = icmp eq <16 x i32> %11, zeroinitializer
%13 = select <16 x i1> %12, <16 x i8> <i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48, i8 48>, <16 x i8> <i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49, i8 49>
%14 = shufflevector <16 x i8> %13, <16 x i8> poison, <16 x i32> <i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
%15 = getelementptr inbounds i8, i8* %1, i64 16
%16 = bitcast i8* %15 to <16 x i8>*
store <16 x i8> %14, <16 x i8>* %16
%17 = getelementptr inbounds i8, i8* %1, i64 48
store i8 0, i8* %17
ret void
}