char *libswd_bin32_string(int *data) {
  static char string[33];
  string[32] = 0;
  unsigned int i, bits = *data;
  for (i = 0; i < 32; i++)
    string[31 - i] = (bits & (1 << i)) ? '1' : '0';
  return string;
}


x86 assembly (clang, -O0):
<libswd_bin32_string>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movb   $0x0,0x2f41(%rip)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x20,-0xc(%rbp)
jae    116e <libswd_bin32_string+0x6e>
mov    -0x10(%rbp),%edx
mov    -0xc(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
and    %eax,%edx
mov    $0x30,%eax
mov    $0x31,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %al,%dl
mov    $0x1f,%eax
sub    -0xc(%rbp),%eax
mov    %eax,%eax
mov    %eax,%ecx
lea    0x2ed3(%rip),%rax
mov    %dl,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    111f <libswd_bin32_string+0x1f>
lea    0x2ebb(%rip),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<libswd_bin32_string>:
movb   $0x0,0x2f49(%rip)
lea    0x2f22(%rip),%rax
movd   (%rdi),%xmm0
pshufd $0x0,%xmm0,%xmm1
movdqa 0xee1(%rip),%xmm3
pand   %xmm1,%xmm3
movdqa 0xee5(%rip),%xmm2
pand   %xmm1,%xmm2
movdqa 0xee9(%rip),%xmm4
pand   %xmm1,%xmm4
movdqa 0xeed(%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 0xed1(%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,%xmm3
packuswb %xmm4,%xmm3
movdqa %xmm3,0x2e97(%rip)
movdqa 0xe9f(%rip),%xmm3
pand   %xmm1,%xmm3
movdqa 0xea3(%rip),%xmm4
pand   %xmm1,%xmm4
movdqa 0xea7(%rip),%xmm5
pand   %xmm1,%xmm5
pand   0xeab(%rip),%xmm1
pcmpeqd %xmm0,%xmm1
pcmpeqd %xmm0,%xmm5
packssdw %xmm1,%xmm5
pcmpeqd %xmm0,%xmm4
pcmpeqd %xmm0,%xmm3
packssdw %xmm4,%xmm3
packsswb %xmm5,%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
movdqa %xmm0,0x2e05(%rip)
ret

LLVM IR (-O0):
@libswd_bin32_string.string = internal global [33 x i8] zeroinitializer
define i8* @libswd_bin32_string(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
store i32* %0, i32** %2
store i8 0, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @libswd_bin32_string.string, i64 0, i64 32)
%5 = load i32*, i32** %2
%6 = load i32, i32* %5
store i32 %6, i32* %4
store i32 0, i32* %3
br label %7
7: ; preds = %23, %1
%8 = load i32, i32* %3
%9 = icmp ult i32 %8, 32
br i1 %9, label %10, label %26
10: ; preds = %7
%11 = load i32, i32* %4
%12 = load i32, i32* %3
%13 = shl i32 1, %12
%14 = and i32 %11, %13
%15 = icmp ne i32 %14, 0
%16 = zext i1 %15 to i64
%17 = select i1 %15, i32 49, i32 48
%18 = trunc i32 %17 to i8
%19 = load i32, i32* %3
%20 = sub i32 31, %19
%21 = zext i32 %20 to i64
%22 = getelementptr inbounds [33 x i8], [33 x i8]* @libswd_bin32_string.string, i64 0, i64 %21
store i8 %18, i8* %22
br label %23
23: ; preds = %10
%24 = load i32, i32* %3
%25 = add i32 %24, 1
store i32 %25, i32* %3
br label %7
26: ; preds = %7
ret i8* getelementptr inbounds ([33 x i8], [33 x i8]* @libswd_bin32_string.string, i64 0, i64 0)
}

LLVM IR (-O2):
@libswd_bin32_string.string = internal global [33 x i8] zeroinitializer
define i8* @libswd_bin32_string(i32* nocapture %0) {
store i8 0, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @libswd_bin32_string.string, i64 0, i64 32)
%2 = load i32, i32* %0
%3 = insertelement <16 x i32> poison, i32 %2, 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>
store <16 x i8> %8, <16 x i8>* bitcast (i8* getelementptr inbounds ([33 x i8], [33 x i8]* @libswd_bin32_string.string, i64 0, i64 16) to <16 x i8>*)
%9 = 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>
%10 = icmp eq <16 x i32> %9, zeroinitializer
%11 = select <16 x i1> %10, <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>
%12 = shufflevector <16 x i8> %11, <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>
store <16 x i8> %12, <16 x i8>* bitcast ([33 x i8]* @libswd_bin32_string.string to <16 x i8>*)
ret i8* getelementptr inbounds ([33 x i8], [33 x i8]* @libswd_bin32_string.string, i64 0, i64 0)
}