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

/* Variables and functions */
scalar_t__ pow(int, int);
int title2string(char *line, long title) {
  int rc = 0, i = 0, l = 0, counter = 0;
  for (i = 47 - 1, l = 0; i >= l; i--) {
    line[counter++] = (title & (long)pow(2, i)) ? 'X' : ' ';
  }
  line[counter] = '\0';
  return rc;
}


x86 assembly (clang, -O0):
<title2string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x2e,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jl     11a8 <title2string+0x98>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%esi
mov    $0x2,%edi
call   1030 <pow@plt>
mov    -0x28(%rbp),%rdx
and    %rax,%rdx
mov    $0x20,%eax
mov    $0x58,%ecx
cmp    $0x0,%rdx
cmovne %ecx,%eax
mov    %al,%dl
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x20(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    114a <title2string+0x3a>
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<title2string>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
lea    0x1(%rdi),%r12
mov    $0x2e,%ebx
mov    $0x20,%ebp
nopl   0x0(%rax)
mov    $0x2,%edi
mov    %ebx,%esi
call   1030 <pow@plt>
test   %r15,%rax
mov    $0x58,%eax
cmove  %ebp,%eax
mov    %al,-0x1(%r12)
test   %rbx,%rbx
je     1177 <title2string+0x67>
lea    -0x1(%rbx),%esi
mov    $0x2,%edi
call   1030 <pow@plt>
test   %r15,%rax
mov    $0x58,%eax
cmove  %ebp,%eax
mov    %al,(%r12)
add    $0x2,%r12
add    $0xfffffffffffffffe,%rbx
jmp    1130 <title2string+0x20>
movb   $0x0,0x2f(%r14)
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @title2string(i8* nocapture writeonly %0, i64 %1) {
br label %3
3: ; preds = %13, %2
%4 = phi i64 [ 0, %2 ], [ %19, %13 ]
%5 = phi i32 [ 46, %2 ], [ %21, %13 ]
%6 = tail call i64 @pow(i32 2, i32 %5)
%7 = and i64 %6, %1
%8 = icmp eq i64 %7, 0
%9 = select i1 %8, i8 32, i8 88
%10 = or i64 %4, 1
%11 = getelementptr inbounds i8, i8* %0, i64 %4
store i8 %9, i8* %11
%12 = icmp eq i64 %10, 47
br i1 %12, label %22, label %13
13: ; preds = %3
%14 = add nsw i32 %5, -1
%15 = tail call i64 @pow(i32 2, i32 %14)
%16 = and i64 %15, %1
%17 = icmp eq i64 %16, 0
%18 = select i1 %17, i8 32, i8 88
%19 = add nuw nsw i64 %4, 2
%20 = getelementptr inbounds i8, i8* %0, i64 %10
store i8 %18, i8* %20
%21 = add nsw i32 %5, -2
br label %3
22: ; preds = %3
%23 = getelementptr inbounds i8, i8* %0, i64 47
store i8 0, i8* %23
ret i32 0
}