#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 /*<<< orphan*/ res;

/* Variables and functions */
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
char *binary(int b, int len) {
  static char res[33];
  int x;
  memset(res, 0, sizeof(res));
  if (len > 32)
    len = 32;
  for (x = 1; x <= len; x++)
    res[x - 1] = b & (1 << (len - x)) ? '1' : '0';
  return res;
}


x86 assembly (clang, -O0):
<binary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
lea    0x2f1b(%rip),%rdi
xor    %esi,%esi
mov    $0x21,%edx
call   1030 <memset@plt>
cmpl   $0x20,-0x8(%rbp)
jle    1142 <binary+0x32>
movl   $0x20,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     119a <binary+0x8a>
mov    -0x4(%rbp),%edx
mov    -0x8(%rbp),%ecx
sub    -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    -0xc(%rbp),%eax
sub    $0x1,%eax
movslq %eax,%rcx
lea    0x2eb7(%rip),%rax
mov    %dl,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1149 <binary+0x39>
lea    0x2e9f(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<binary>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %esi,%ebp
mov    %edi,%r15d
lea    0x2f1a(%rip),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x21,%edx
call   1030 <memset@plt>
cmp    $0x20,%ebp
mov    $0x20,%eax
cmovl  %ebp,%eax
test   %eax,%eax
jle    157a <binary+0x46a>
mov    %eax,%ecx
mov    $0x1,%edx
cmp    $0x10,%eax
jb     1555 <binary+0x445>
mov    %ecx,%edx
and    $0xfffffff0,%edx
movd   %eax,%xmm0
pshufd $0x0,%xmm0,%xmm5
movd   %r15d,%xmm0
pshufd $0x0,%xmm0,%xmm4
lea    -0x10(%rdx),%rsi
mov    %rsi,%rbp
shr    $0x4,%rbp
add    $0x1,%rbp
test   %rsi,%rsi
je     158c <binary+0x47c>
mov    %rbp,%rdi
and    $0xfffffffffffffffe,%rdi
movdqa 0xe68(%rip),%xmm13
movdqa 0xe70(%rip),%xmm0
movdqa 0xe78(%rip),%xmm2
movdqa 0xe7f(%rip),%xmm15
xor    %esi,%esi
movdqa 0xe95(%rip),%xmm7
movdqa 0xe7c(%rip),%xmm14
pxor   %xmm12,%xmm12
nopl   0x0(%rax)
movdqa %xmm2,(%rsp)
movdqa %xmm0,0x10(%rsp)
movdqa %xmm5,%xmm6
psubd  %xmm13,%xmm6
movdqa %xmm5,%xmm1
psubd  %xmm0,%xmm1
movdqa %xmm5,%xmm0
psubd  %xmm2,%xmm0
movdqa %xmm5,%xmm8
psubd  %xmm15,%xmm8
movdqa %xmm8,%xmm2
pslld  $0x17,%xmm2
paddd  %xmm14,%xmm2
cvttps2dq %xmm2,%xmm2
pshufd $0xf5,%xmm2,%xmm3
pmuludq %xmm7,%xmm2
pshufd $0xe8,%xmm2,%xmm9
pmuludq %xmm7,%xmm3
pshufd $0xe8,%xmm3,%xmm2
punpckldq %xmm2,%xmm9
movdqa %xmm0,%xmm2
pslld  $0x17,%xmm2
paddd  %xmm14,%xmm2
cvttps2dq %xmm2,%xmm2
pshufd $0xf5,%xmm2,%xmm3
pmuludq %xmm7,%xmm2
pshufd $0xe8,%xmm2,%xmm10
pmuludq %xmm7,%xmm3
pshufd $0xe8,%xmm3,%xmm2
punpckldq %xmm2,%xmm10
movdqa %xmm1,%xmm2
pslld  $0x17,%xmm2
paddd  %xmm14,%xmm2
cvttps2dq %xmm2,%xmm2
pshufd $0xf5,%xmm2,%xmm3
pmuludq %xmm7,%xmm2
pshufd $0xe8,%xmm2,%xmm11
pmuludq %xmm7,%xmm3
pshufd $0xe8,%xmm3,%xmm2
punpckldq %xmm2,%xmm11
movdqa %xmm6,%xmm2
pslld  $0x17,%xmm2
paddd  %xmm14,%xmm2
cvttps2dq %xmm2,%xmm2
pshufd $0xf5,%xmm2,%xmm3
pmuludq %xmm7,%xmm2
pshufd $0xe8,%xmm2,%xmm2
pmuludq %xmm7,%xmm3
pshufd $0xe8,%xmm3,%xmm3
punpckldq %xmm3,%xmm2
pand   %xmm4,%xmm10
pand   %xmm4,%xmm9
pcmpeqd %xmm12,%xmm9
pcmpeqd %xmm12,%xmm10
packssdw %xmm10,%xmm9
pand   %xmm4,%xmm2
pand   %xmm4,%xmm11
pcmpeqd %xmm12,%xmm11
pcmpeqd %xmm12,%xmm2
packssdw %xmm2,%xmm11
packsswb %xmm11,%xmm9
movdqa 0xd68(%rip),%xmm10
paddb  %xmm10,%xmm9
movdqa %xmm9,(%rsi,%r14,1)
movdqa 0xd65(%rip),%xmm2
psubd  %xmm2,%xmm6
psubd  %xmm2,%xmm1
psubd  %xmm2,%xmm0
psubd  %xmm2,%xmm8
pslld  $0x17,%xmm8
paddd  %xmm14,%xmm8
cvttps2dq %xmm8,%xmm2
pshufd $0xf5,%xmm2,%xmm3
pmuludq %xmm7,%xmm2
pshufd $0xe8,%xmm2,%xmm2
pmuludq %xmm7,%xmm3
pshufd $0xe8,%xmm3,%xmm3
punpckldq %xmm3,%xmm2
pslld  $0x17,%xmm0
paddd  %xmm14,%xmm0
cvttps2dq %xmm0,%xmm0
pshufd $0xf5,%xmm0,%xmm3
pmuludq %xmm7,%xmm0
pshufd $0xe8,%xmm0,%xmm0
pmuludq %xmm7,%xmm3
pshufd $0xe8,%xmm3,%xmm3
punpckldq %xmm3,%xmm0
pslld  $0x17,%xmm1
paddd  %xmm14,%xmm1
cvttps2dq %xmm1,%xmm1
pshufd $0xf5,%xmm1,%xmm3
pmuludq %xmm7,%xmm1
pshufd $0xe8,%xmm1,%xmm1
pmuludq %xmm7,%xmm3
pshufd $0xe8,%xmm3,%xmm3
punpckldq %xmm3,%xmm1
pslld  $0x17,%xmm6
paddd  %xmm14,%xmm6
cvttps2dq %xmm6,%xmm3
pshufd $0xf5,%xmm3,%xmm6
pmuludq %xmm7,%xmm3
pshufd $0xe8,%xmm3,%xmm3
pmuludq %xmm7,%xmm6
pshufd $0xe8,%xmm6,%xmm6
punpckldq %xmm6,%xmm3
pand   %xmm4,%xmm0
pand   %xmm4,%xmm2
pcmpeqd %xmm12,%xmm2
pcmpeqd %xmm12,%xmm0
packssdw %xmm0,%xmm2
movdqa 0x10(%rsp),%xmm0
pand   %xmm4,%xmm3
pand   %xmm4,%xmm1
pcmpeqd %xmm12,%xmm1
pcmpeqd %xmm12,%xmm3
packssdw %xmm3,%xmm1
packsswb %xmm1,%xmm2
paddb  %xmm10,%xmm2
movdqa %xmm2,0x10(%rsi,%r14,1)
movdqa (%rsp),%xmm2
add    $0x20,%rsi
movdqa 0xc6b(%rip),%xmm1
paddd  %xmm1,%xmm15
paddd  %xmm1,%xmm2
paddd  %xmm1,%xmm0
paddd  %xmm1,%xmm13
add    $0xfffffffffffffffe,%rdi
jne    11d0 <binary+0xc0>
test   $0x1,%bpl
je     154c <binary+0x43c>
movdqa %xmm5,%xmm1
psubd  %xmm13,%xmm1
movdqa %xmm5,%xmm7
psubd  %xmm0,%xmm7
movdqa %xmm5,%xmm3
psubd  %xmm2,%xmm3
psubd  %xmm15,%xmm5
pslld  $0x17,%xmm5
movdqa 0xbd9(%rip),%xmm8
paddd  %xmm8,%xmm5
cvttps2dq %xmm5,%xmm0
movdqa 0xbd8(%rip),%xmm2
pshufd $0xf5,%xmm0,%xmm6
pmuludq %xmm2,%xmm0
pshufd $0xe8,%xmm0,%xmm0
pmuludq %xmm2,%xmm6
pshufd $0xe8,%xmm6,%xmm6
punpckldq %xmm6,%xmm0
pslld  $0x17,%xmm3
paddd  %xmm8,%xmm3
cvttps2dq %xmm3,%xmm3
pshufd $0xf5,%xmm3,%xmm6
pmuludq %xmm2,%xmm3
pshufd $0xe8,%xmm3,%xmm3
pmuludq %xmm2,%xmm6
pshufd $0xe8,%xmm6,%xmm6
punpckldq %xmm6,%xmm3
pslld  $0x17,%xmm7
paddd  %xmm8,%xmm7
cvttps2dq %xmm7,%xmm5
pshufd $0xf5,%xmm5,%xmm6
pmuludq %xmm2,%xmm5
pshufd $0xe8,%xmm5,%xmm5
pmuludq %xmm2,%xmm6
pshufd $0xe8,%xmm6,%xmm6
punpckldq %xmm6,%xmm5
pslld  $0x17,%xmm1
paddd  %xmm8,%xmm1
cvttps2dq %xmm1,%xmm1
pshufd $0xf5,%xmm1,%xmm6
pmuludq %xmm2,%xmm1
pshufd $0xe8,%xmm1,%xmm1
pmuludq %xmm2,%xmm6
pshufd $0xe8,%xmm6,%xmm2
punpckldq %xmm2,%xmm1
pand   %xmm4,%xmm1
pand   %xmm4,%xmm5
pand   %xmm4,%xmm3
pand   %xmm4,%xmm0
pxor   %xmm2,%xmm2
pcmpeqd %xmm2,%xmm0
pcmpeqd %xmm2,%xmm3
packssdw %xmm3,%xmm0
pcmpeqd %xmm2,%xmm5
pcmpeqd %xmm2,%xmm1
packssdw %xmm1,%xmm5
packsswb %xmm5,%xmm0
paddb  0xb1a(%rip),%xmm0
movdqa %xmm0,(%rsi,%r14,1)
cmp    %rdx,%rcx
je     157a <binary+0x46a>
or     $0x1,%rdx
add    $0x1,%rcx
sub    %edx,%eax
nopl   0x0(%rax,%rax,1)
bt     %eax,%r15d
mov    $0x31,%bl
adc    $0xff,%bl
mov    %bl,-0x1(%rdx,%r14,1)
add    $0x1,%rdx
add    $0xffffffff,%eax
cmp    %rdx,%rcx
jne    1560 <binary+0x450>
lea    0x2abf(%rip),%rax
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
movdqa 0xa6b(%rip),%xmm13
movdqa 0xa73(%rip),%xmm0
movdqa 0xa7b(%rip),%xmm2
movdqa 0xa82(%rip),%xmm15
xor    %esi,%esi
test   $0x1,%bpl
jne    143b <binary+0x32b>
jmp    154c <binary+0x43c>

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

LLVM IR (-O2):
@binary.res = internal global [33 x i8] zeroinitializer
define i8* @binary(i32 %0, i32 %1) {
%3 = tail call i32 @memset(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @binary.res, i64 0, i64 0), i32 0, i32 33)
%4 = icmp slt i32 %1, 32
%5 = select i1 %4, i32 %1, i32 32
%6 = icmp slt i32 %5, 1
br i1 %6, label %78, label %7
7: ; preds = %2
%8 = add nuw nsw i32 %5, 1
%9 = zext i32 %8 to i64
%10 = add nsw i64 %9, -1
%11 = icmp ult i64 %10, 16
br i1 %11, label %64, label %12
12: ; preds = %7
%13 = and i64 %10, -16
%14 = or i64 %13, 1
%15 = insertelement <16 x i32> poison, i32 %5, i64 0
%16 = shufflevector <16 x i32> %15, <16 x i32> poison, <16 x i32> zeroinitializer
%17 = insertelement <16 x i32> poison, i32 %0, i64 0
%18 = shufflevector <16 x i32> %17, <16 x i32> poison, <16 x i32> zeroinitializer
%19 = add nsw i64 %13, -16
%20 = lshr exact i64 %19, 4
%21 = add nuw nsw i64 %20, 1
%22 = and i64 %21, 1
%23 = icmp eq i64 %19, 0
br i1 %23, label %50, label %24
24: ; preds = %12
%25 = and i64 %21, 2305843009213693950
br label %26
26: ; preds = %26, %24
%27 = phi i64 [ 0, %24 ], [ %46, %26 ]
%28 = phi <16 x i32> [ <i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16>, %24 ], [ %47, %26 ]
%29 = phi i64 [ 0, %24 ], [ %48, %26 ]
%30 = sub <16 x i32> %16, %28
%31 = shl nuw <16 x i32> <i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1>, %30
%32 = and <16 x i32> %31, %18
%33 = icmp eq <16 x i32> %32, zeroinitializer
%34 = select <16 x i1> %33, <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>
%35 = getelementptr inbounds [33 x i8], [33 x i8]* @binary.res, i64 0, i64 %27
%36 = bitcast i8* %35 to <16 x i8>*
store <16 x i8> %34, <16 x i8>* %36
%37 = or i64 %27, 16
%38 = add <16 x i32> %28, <i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16>
%39 = sub <16 x i32> %16, %38
%40 = shl nuw <16 x i32> <i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1>, %39
%41 = and <16 x i32> %40, %18
%42 = icmp eq <16 x i32> %41, zeroinitializer
%43 = select <16 x i1> %42, <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>
%44 = getelementptr inbounds [33 x i8], [33 x i8]* @binary.res, i64 0, i64 %37
%45 = bitcast i8* %44 to <16 x i8>*
store <16 x i8> %43, <16 x i8>* %45
%46 = add nuw i64 %27, 32
%47 = add <16 x i32> %28, <i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32, i32 32>
%48 = add i64 %29, 2
%49 = icmp eq i64 %48, %25
br i1 %49, label %50, label %26
50: ; preds = %26, %12
%51 = phi i64 [ 0, %12 ], [ %46, %26 ]
%52 = phi <16 x i32> [ <i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16>, %12 ], [ %47, %26 ]
%53 = icmp eq i64 %22, 0
br i1 %53, label %62, label %54
54: ; preds = %50
%55 = sub <16 x i32> %16, %52
%56 = shl nuw <16 x i32> <i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1>, %55
%57 = and <16 x i32> %56, %18
%58 = icmp eq <16 x i32> %57, zeroinitializer
%59 = select <16 x i1> %58, <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>
%60 = getelementptr inbounds [33 x i8], [33 x i8]* @binary.res, i64 0, i64 %51
%61 = bitcast i8* %60 to <16 x i8>*
store <16 x i8> %59, <16 x i8>* %61
br label %62
62: ; preds = %50, %54
%63 = icmp eq i64 %10, %13
br i1 %63, label %78, label %64
64: ; preds = %7, %62
%65 = phi i64 [ 1, %7 ], [ %14, %62 ]
br label %66
66: ; preds = %64, %66
%67 = phi i64 [ %76, %66 ], [ %65, %64 ]
%68 = trunc i64 %67 to i32
%69 = sub i32 %5, %68
%70 = shl nuw i32 1, %69
%71 = and i32 %70, %0
%72 = icmp eq i32 %71, 0
%73 = select i1 %72, i8 48, i8 49
%74 = add nsw i64 %67, -1
%75 = getelementptr inbounds [33 x i8], [33 x i8]* @binary.res, i64 0, i64 %74
store i8 %73, i8* %75
%76 = add nuw nsw i64 %67, 1
%77 = icmp eq i64 %76, %9
br i1 %77, label %78, label %66
78: ; preds = %66, %62, %2
ret i8* getelementptr inbounds ([33 x i8], [33 x i8]* @binary.res, i64 0, i64 0)
}