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

/* Variables and functions */
int /*<<< orphan*/ reverse(char *);
void my2bin(long long n, char s[]) {
  int i;
  for (i = 0; i < sizeof(n) * 8; i++) {
    if (n & 1)
      s[i] = '1';
    else
      s[i] = '0';
    n = n >> 1;
  }
  s[i] = 0;
  reverse(s);
}


x86 assembly (clang, -O0):
<my2bin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movslq -0x14(%rbp),%rax
cmp    $0x40,%rax
jae    117e <my2bin+0x6e>
mov    -0x8(%rbp),%rax
and    $0x1,%rax
cmp    $0x0,%rax
je     1158 <my2bin+0x48>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x31,(%rax,%rcx,1)
jmp    1164 <my2bin+0x54>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x30,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
sar    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1127 <my2bin+0x17>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rdi
call   1030 <reverse@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my2bin>:
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %edi,%ecx
and    $0x1,%cl
or     $0x30,%cl
mov    %cl,(%rsi,%rax,1)
mov    %edi,%ecx
and    $0x2,%ecx
cmp    $0x1,%rcx
mov    $0x31,%cl
sbb    $0x0,%cl
mov    %cl,0x1(%rsi,%rax,1)
sar    $0x2,%rdi
add    $0x2,%rax
cmp    $0x40,%rax
jne    1120 <my2bin+0x10>
movb   $0x0,0x40(%rsi)
mov    %rsi,%rdi
jmp    1030 <reverse@plt>

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

LLVM IR (-O2):
define void @my2bin(i64 %0, i8* %1) {
br label %3
3: ; preds = %3, %2
%4 = phi i64 [ 0, %2 ], [ %16, %3 ]
%5 = phi i64 [ %0, %2 ], [ %15, %3 ]
%6 = and i64 %5, 1
%7 = icmp eq i64 %6, 0
%8 = select i1 %7, i8 48, i8 49
%9 = getelementptr inbounds i8, i8* %1, i64 %4
store i8 %8, i8* %9
%10 = or i64 %4, 1
%11 = and i64 %5, 2
%12 = icmp eq i64 %11, 0
%13 = select i1 %12, i8 48, i8 49
%14 = getelementptr inbounds i8, i8* %1, i64 %10
store i8 %13, i8* %14
%15 = ashr i64 %5, 2
%16 = add nuw nsw i64 %4, 2
%17 = icmp eq i64 %16, 64
br i1 %17, label %18, label %3
18: ; preds = %3
%19 = getelementptr inbounds i8, i8* %1, i64 64
store i8 0, i8* %19
%20 = tail call i32 @reverse(i8* %1)
ret void
}