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

/* Variables and functions */
const char *tobinary(uint32_t chord) {
  static char buffer[12];
  for (int i = 1; i <= 5; i++)
    buffer[i - 1] = (chord & (1 << i)) ? '1' : '0';
  buffer[5] = ',';
  for (int i = 6; i <= 10; i++)
    buffer[i] = (chord & (1 << i)) ? '1' : '0';
  buffer[11] = '\0';
  return buffer;
}


x86 assembly (clang, -O0):
<tobinary>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
cmpl   $0x5,-0x8(%rbp)
jg     115a <tobinary+0x5a>
mov    -0x4(%rbp),%edx
mov    -0x8(%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    -0x8(%rbp),%eax
sub    $0x1,%eax
movslq %eax,%rcx
lea    0x2ed8(%rip),%rax
mov    %dl,(%rax,%rcx,1)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    110e <tobinary+0xe>
movb   $0x2c,0x2ec5(%rip)
movl   $0x6,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jg     11af <tobinary+0xaf>
mov    -0x4(%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
movslq -0xc(%rbp),%rcx
lea    0x2e83(%rip),%rax
mov    %dl,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1168 <tobinary+0x68>
movb   $0x0,0x2e76(%rip)
lea    0x2e64(%rip),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<tobinary>:
mov    %edi,%eax
and    $0x2,%eax
cmp    $0x1,%eax
mov    $0x31,%al
sbb    $0x0,%al
mov    $0x31,%cl
mov    %al,0x2f0d(%rip)
lea    0x2f06(%rip),%rax
movd   %edi,%xmm0
and    $0x4,%edi
cmp    $0x1,%edi
sbb    $0x0,%cl
mov    %cl,0x2ef4(%rip)
pshufd $0x0,%xmm0,%xmm0
movdqa 0xec5(%rip),%xmm1
pand   %xmm0,%xmm1
pand   0xec9(%rip),%xmm0
pxor   %xmm2,%xmm2
pcmpeqd %xmm2,%xmm0
pcmpeqd %xmm2,%xmm1
packssdw %xmm0,%xmm1
packsswb %xmm1,%xmm1
pmovmskb %xmm1,%esi
mov    %esi,%r10d
and    $0x2,%r10b
shr    %r10b
mov    %esi,%edi
and    $0x4,%dil
shr    $0x2,%dil
mov    %esi,%r8d
and    $0x8,%r8b
shr    $0x3,%r8b
mov    %esi,%r9d
and    $0x10,%r9b
shr    $0x4,%r9b
mov    %esi,%r11d
and    $0x20,%r11b
shr    $0x5,%r11b
mov    %esi,%ecx
and    $0x40,%cl
shr    $0x6,%cl
mov    %esi,%edx
sar    $0x7,%dl
add    $0x31,%dl
mov    %dl,0x2e79(%rip)
xor    $0x31,%cl
mov    %cl,0x2e71(%rip)
xor    $0x31,%r11b
mov    %r11b,0x2e67(%rip)
movb   $0x2c,0x2e61(%rip)
xor    $0x31,%r9b
mov    %r9b,0x2e57(%rip)
xor    $0x31,%r8b
mov    %r8b,0x2e4d(%rip)
xor    $0x31,%dil
mov    %dil,0x2e43(%rip)
xor    $0x31,%r10b
mov    %r10b,0x2e39(%rip)
and    $0x1,%sil
xor    $0x31,%sil
mov    %sil,0x2e2b(%rip)
movb   $0x0,0x2e25(%rip)
ret

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

LLVM IR (-O2):
@tobinary.buffer = internal global [12 x i8] zeroinitializer
define i8* @tobinary(i32 %0) {
%2 = and i32 %0, 2
%3 = icmp eq i32 %2, 0
%4 = select i1 %3, i8 48, i8 49
store i8 %4, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @tobinary.buffer, i64 0, i64 0)
%5 = and i32 %0, 4
%6 = icmp eq i32 %5, 0
%7 = select i1 %6, i8 48, i8 49
store i8 %7, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @tobinary.buffer, i64 0, i64 1)
%8 = insertelement <8 x i32> poison, i32 %0, i64 0
%9 = shufflevector <8 x i32> %8, <8 x i32> poison, <8 x i32> zeroinitializer
%10 = and <8 x i32> %9, <i32 1024, i32 512, i32 256, i32 128, i32 64, i32 32, i32 16, i32 8>
%11 = icmp eq <8 x i32> %10, zeroinitializer
%12 = extractelement <8 x i1> %11, i64 7
%13 = select i1 %12, i8 48, i8 49
store i8 %13, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @tobinary.buffer, i64 0, i64 2)
%14 = extractelement <8 x i1> %11, i64 6
%15 = select i1 %14, i8 48, i8 49
store i8 %15, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @tobinary.buffer, i64 0, i64 3)
%16 = extractelement <8 x i1> %11, i64 5
%17 = select i1 %16, i8 48, i8 49
store i8 %17, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @tobinary.buffer, i64 0, i64 4)
store i8 44, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @tobinary.buffer, i64 0, i64 5)
%18 = extractelement <8 x i1> %11, i64 4
%19 = select i1 %18, i8 48, i8 49
store i8 %19, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @tobinary.buffer, i64 0, i64 6)
%20 = extractelement <8 x i1> %11, i64 3
%21 = select i1 %20, i8 48, i8 49
store i8 %21, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @tobinary.buffer, i64 0, i64 7)
%22 = extractelement <8 x i1> %11, i64 2
%23 = select i1 %22, i8 48, i8 49
store i8 %23, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @tobinary.buffer, i64 0, i64 8)
%24 = extractelement <8 x i1> %11, i64 1
%25 = select i1 %24, i8 48, i8 49
store i8 %25, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @tobinary.buffer, i64 0, i64 9)
%26 = extractelement <8 x i1> %11, i64 0
%27 = select i1 %26, i8 48, i8 49
store i8 %27, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @tobinary.buffer, i64 0, i64 10)
store i8 0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @tobinary.buffer, i64 0, i64 11)
ret i8* getelementptr inbounds ([12 x i8], [12 x i8]* @tobinary.buffer, i64 0, i64 0)
}