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

/* Variables and functions */
int /*<<< orphan*/ memset(char *, char, int);
char *Q_BitConv(int val) {
  int i, j;
  static char buf[40];
  memset(buf, '?', sizeof(buf));
  for (j = 0, i = 38; i >= 0; i--) {
    if ((i + 1) % 5 == 0 && i != 38 && i != 0) {
      buf[i] = ' ';
    } else if (val & 1 << j) {
      buf[i] = '1';
      j++;
    } else {
      buf[i] = '0';
      j++;
    }
  }
  buf[39] = 0;
  return buf;
}


x86 assembly (clang, -O0):
<Q_BitConv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    0x2f1e(%rip),%rdi
mov    $0x3f,%esi
mov    $0x28,%edx
call   1030 <memset@plt>
movl   $0x0,-0xc(%rbp)
movl   $0x26,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     11ef <Q_BitConv+0xdf>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1188 <Q_BitConv+0x78>
cmpl   $0x26,-0x8(%rbp)
je     1188 <Q_BitConv+0x78>
cmpl   $0x0,-0x8(%rbp)
je     1188 <Q_BitConv+0x78>
movslq -0x8(%rbp),%rcx
lea    0x2ec1(%rip),%rax
movb   $0x20,(%rax,%rcx,1)
jmp    11dc <Q_BitConv+0xcc>
mov    -0x4(%rbp),%eax
mov    -0xc(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     11bf <Q_BitConv+0xaf>
movslq -0x8(%rbp),%rcx
lea    0x2e93(%rip),%rax
movb   $0x31,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11d7 <Q_BitConv+0xc7>
movslq -0x8(%rbp),%rcx
lea    0x2e76(%rip),%rax
movb   $0x30,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11dc <Q_BitConv+0xcc>
jmp    11e1 <Q_BitConv+0xd1>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    113f <Q_BitConv+0x2f>
movb   $0x0,0x2e71(%rip)
lea    0x2e43(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Q_BitConv>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
lea    0x2f23(%rip),%r14
mov    %r14,%rdi
mov    $0x3f,%esi
mov    $0x28,%edx
call   1030 <memset@plt>
mov    $0x26,%ecx
xor    %eax,%eax
jmp    1151 <Q_BitConv+0x41>
nopl   0x0(%rax,%rax,1)
movb   $0x30,(%rdx,%r14,1)
add    $0x1,%eax
lea    -0x1(%rcx),%edx
test   %ecx,%ecx
mov    %edx,%ecx
jle    1190 <Q_BitConv+0x80>
imul   $0xcccccccd,%ecx,%esi
add    $0xcccccccd,%esi
mov    %ecx,%edx
cmp    $0x33333333,%esi
jbe    1180 <Q_BitConv+0x70>
bt     %eax,%ebx
jae    1140 <Q_BitConv+0x30>
movb   $0x31,(%rdx,%r14,1)
jmp    1145 <Q_BitConv+0x35>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
test   %ecx,%ecx
je     1167 <Q_BitConv+0x57>
cmp    $0x26,%ecx
je     1167 <Q_BitConv+0x57>
movb   $0x20,(%rdx,%r14,1)
jmp    1148 <Q_BitConv+0x38>
movb   $0x0,0x2ed0(%rip)
lea    0x2ea2(%rip),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@Q_BitConv.buf = internal global [40 x i8] zeroinitializer
define i8* @Q_BitConv(i32 %0) {
%2 = tail call i32 @memset(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @Q_BitConv.buf, i64 0, i64 0), i8 signext 63, i32 40)
br label %3
3: ; preds = %1, %24
%4 = phi i32 [ 0, %1 ], [ %25, %24 ]
%5 = phi i32 [ 38, %1 ], [ %26, %24 ]
%6 = freeze i32 %5
%7 = add i32 %6, 1
%8 = urem i32 %7, 5
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %3
switch i32 %6, label %11 [
i32 38, label %14
i32 0, label %14
]
11: ; preds = %10
%12 = zext i32 %6 to i64
%13 = getelementptr inbounds [40 x i8], [40 x i8]* @Q_BitConv.buf, i64 0, i64 %12
store i8 32, i8* %13
br label %24
14: ; preds = %10, %10, %3
%15 = shl nuw i32 1, %4
%16 = and i32 %15, %0
%17 = icmp eq i32 %16, 0
%18 = zext i32 %6 to i64
%19 = getelementptr inbounds [40 x i8], [40 x i8]* @Q_BitConv.buf, i64 0, i64 %18
br i1 %17, label %22, label %20
20: ; preds = %14
store i8 49, i8* %19
%21 = add nsw i32 %4, 1
br label %24
22: ; preds = %14
store i8 48, i8* %19
%23 = add nsw i32 %4, 1
br label %24
24: ; preds = %11, %22, %20
%25 = phi i32 [ %4, %11 ], [ %21, %20 ], [ %23, %22 ]
%26 = add nsw i32 %6, -1
%27 = icmp sgt i32 %6, 0
br i1 %27, label %3, label %28
28: ; preds = %24
store i8 0, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @Q_BitConv.buf, i64 0, i64 39)
ret i8* getelementptr inbounds ([40 x i8], [40 x i8]* @Q_BitConv.buf, i64 0, i64 0)
}