#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 u_int32_t;
typedef int /*<<< orphan*/ bitmap;

/* Variables and functions */
int /*<<< orphan*/ bzero(char *, int);
char *numtobitmap(u_int32_t num) {
  static char bitmap[36];
  int x, y, z;
  bzero((char *)bitmap, sizeof(bitmap));
  y = 1;
  z = 0;
  for (x = 0; x < 32; x++) {
    if (!((num >> (31 - x)) & 1))
      bitmap[z] = '0';
    else
      bitmap[z] = '1';
    if (y == 8 && z < 34) {
      z++;
      bitmap[z] = '.';
      y = 0;
    }
    y++;
    z++;
  }
  return bitmap;
}


x86 assembly (clang, -O0):
<numtobitmap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    0x2f1e(%rip),%rdi
mov    $0x24,%esi
call   1030 <bzero@plt>
movl   $0x1,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x20,-0x8(%rbp)
jge    11da <numtobitmap+0xca>
mov    -0x4(%rbp),%eax
mov    $0x1f,%ecx
sub    -0x8(%rbp),%ecx
sar    %cl,%eax
and    $0x1,%eax
cmp    $0x0,%eax
jne    1178 <numtobitmap+0x68>
movslq -0x10(%rbp),%rcx
lea    0x2ed1(%rip),%rax
movb   $0x30,(%rax,%rcx,1)
jmp    1187 <numtobitmap+0x77>
movslq -0x10(%rbp),%rcx
lea    0x2ebd(%rip),%rax
movb   $0x31,(%rax,%rcx,1)
cmpl   $0x8,-0xc(%rbp)
jne    11ba <numtobitmap+0xaa>
cmpl   $0x22,-0x10(%rbp)
jge    11ba <numtobitmap+0xaa>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
movslq -0x10(%rbp),%rcx
lea    0x2e91(%rip),%rax
movb   $0x2e,(%rax,%rcx,1)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1141 <numtobitmap+0x31>
lea    0x2e5f(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<numtobitmap>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebp
lea    0x2f23(%rip),%r14
mov    %r14,%rdi
mov    $0x24,%esi
call   1030 <bzero@plt>
mov    $0x1,%eax
xor    %edx,%edx
xor    %ecx,%ecx
jmp    114e <numtobitmap+0x3e>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%eax
add    $0x1,%edx
add    $0x1,%ecx
cmp    $0x20,%ecx
je     1181 <numtobitmap+0x71>
mov    %ebp,%edi
shl    %cl,%edi
and    $0x80000000,%edi
movslq %edx,%rsi
cmp    $0x1,%edi
mov    $0x31,%bl
sbb    $0x0,%bl
mov    %bl,(%rsi,%r14,1)
cmp    $0x8,%eax
jne    1140 <numtobitmap+0x30>
cmp    $0x21,%edx
jg     1140 <numtobitmap+0x30>
movb   $0x2e,0x1(%rsi,%r14,1)
add    $0x1,%rsi
xor    %eax,%eax
mov    %esi,%edx
jmp    1140 <numtobitmap+0x30>
lea    0x2eb8(%rip),%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@numtobitmap.bitmap = internal global [36 x i8] zeroinitializer
define i8* @numtobitmap(i32 %0) {
%2 = tail call i32 @bzero(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @numtobitmap.bitmap, i64 0, i64 0), i32 36)
br label %3
3: ; preds = %1, %20
%4 = phi i32 [ 0, %1 ], [ %24, %20 ]
%5 = phi i32 [ 1, %1 ], [ %23, %20 ]
%6 = phi i32 [ 0, %1 ], [ %25, %20 ]
%7 = lshr i32 -2147483648, %6
%8 = and i32 %7, %0
%9 = icmp eq i32 %8, 0
%10 = sext i32 %4 to i64
%11 = getelementptr inbounds [36 x i8], [36 x i8]* @numtobitmap.bitmap, i64 0, i64 %10
%12 = select i1 %9, i8 48, i8 49
store i8 %12, i8* %11
%13 = icmp eq i32 %5, 8
%14 = icmp slt i32 %4, 34
%15 = select i1 %13, i1 %14, i1 false
br i1 %15, label %16, label %20
16: ; preds = %3
%17 = add nsw i32 %4, 1
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [36 x i8], [36 x i8]* @numtobitmap.bitmap, i64 0, i64 %18
store i8 46, i8* %19
br label %20
20: ; preds = %16, %3
%21 = phi i32 [ 0, %16 ], [ %5, %3 ]
%22 = phi i32 [ %17, %16 ], [ %4, %3 ]
%23 = add nsw i32 %21, 1
%24 = add nsw i32 %22, 1
%25 = add nuw nsw i32 %6, 1
%26 = icmp eq i32 %25, 32
br i1 %26, label %27, label %3
27: ; preds = %20
ret i8* getelementptr inbounds ([36 x i8], [36 x i8]* @numtobitmap.bitmap, i64 0, i64 0)
}