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

/* Variables and functions */
int /*<<< orphan*/ strcat(char *, char *);
const char *word_to_binary(uint16_t x) {
  static char b[17];
  b[0] = '\0';
  int z;
  for (z = 0x8000; z > 0; z >>= 1) {
    strcat(b, ((x & z) == z) ? "1" : "0");
  }
  return b;
}


x86 assembly (clang, -O0):
<word_to_binary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movb   $0x0,0x2f1e(%rip)
movl   $0x8000,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    116a <word_to_binary+0x5a>
mov    -0x4(%rbp),%ecx
and    -0x8(%rbp),%ecx
mov    -0x8(%rbp),%edx
lea    0xebf(%rip),%rsi
lea    0xeb6(%rip),%rax
cmp    %edx,%ecx
cmove  %rax,%rsi
lea    0x2ee9(%rip),%rdi
call   1030 <strcat@plt>
mov    -0x8(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1129 <word_to_binary+0x19>
lea    0x2ecf(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<word_to_binary>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebp
movb   $0x0,0x2f20(%rip)
lea    0x2f19(%rip),%r14
test   $0x8000,%edi
lea    0xece(%rip),%r15
lea    0xec5(%rip),%rbx
mov    %rbx,%rsi
cmove  %r15,%rsi
mov    %r14,%rdi
call   1030 <strcat@plt>
test   $0x4000,%ebp
mov    %rbx,%rsi
cmove  %r15,%rsi
mov    %r14,%rdi
call   1030 <strcat@plt>
test   $0x2000,%ebp
mov    %rbx,%rsi
cmove  %r15,%rsi
mov    %r14,%rdi
call   1030 <strcat@plt>
test   $0x1000,%ebp
mov    %rbx,%rsi
cmove  %r15,%rsi
mov    %r14,%rdi
call   1030 <strcat@plt>
test   $0x800,%ebp
mov    %rbx,%rsi
cmove  %r15,%rsi
mov    %r14,%rdi
call   1030 <strcat@plt>
test   $0x400,%ebp
mov    %rbx,%rsi
cmove  %r15,%rsi
mov    %r14,%rdi
call   1030 <strcat@plt>
test   $0x200,%ebp
mov    %rbx,%rsi
cmove  %r15,%rsi
mov    %r14,%rdi
call   1030 <strcat@plt>
test   $0x100,%ebp
mov    %rbx,%rsi
cmove  %r15,%rsi
mov    %r14,%rdi
call   1030 <strcat@plt>
test   $0x80,%bpl
mov    %rbx,%rsi
cmove  %r15,%rsi
mov    %r14,%rdi
call   1030 <strcat@plt>
test   $0x40,%bpl
mov    %rbx,%rsi
cmove  %r15,%rsi
mov    %r14,%rdi
call   1030 <strcat@plt>
test   $0x20,%bpl
mov    %rbx,%rsi
cmove  %r15,%rsi
mov    %r14,%rdi
call   1030 <strcat@plt>
test   $0x10,%bpl
mov    %rbx,%rsi
cmove  %r15,%rsi
mov    %r14,%rdi
call   1030 <strcat@plt>
test   $0x8,%bpl
mov    %rbx,%rsi
cmove  %r15,%rsi
mov    %r14,%rdi
call   1030 <strcat@plt>
test   $0x4,%bpl
mov    %rbx,%rsi
cmove  %r15,%rsi
mov    %r14,%rdi
call   1030 <strcat@plt>
test   $0x2,%bpl
mov    %rbx,%rsi
cmove  %r15,%rsi
mov    %r14,%rdi
call   1030 <strcat@plt>
test   $0x1,%bpl
cmove  %r15,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcat@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@word_to_binary.b = internal global [17 x i8] zeroinitializer
@.str = [2 x i8] c"1\00"
@.str.1 = [2 x i8] c"0\00"
define i8* @word_to_binary(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i8 0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @word_to_binary.b, i64 0, i64 0)
store i32 32768, i32* %3
br label %4
4: ; preds = %16, %1
%5 = load i32, i32* %3
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %19
7: ; preds = %4
%8 = load i32, i32* %2
%9 = load i32, i32* %3
%10 = and i32 %8, %9
%11 = load i32, i32* %3
%12 = icmp eq i32 %10, %11
%13 = zext i1 %12 to i64
%14 = select i1 %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)
%15 = call i32 @strcat(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @word_to_binary.b, i64 0, i64 0), i8* %14)
br label %16
16: ; preds = %7
%17 = load i32, i32* %3
%18 = ashr i32 %17, 1
store i32 %18, i32* %3
br label %4
19: ; preds = %4
ret i8* getelementptr inbounds ([17 x i8], [17 x i8]* @word_to_binary.b, i64 0, i64 0)
}

LLVM IR (-O2):
@word_to_binary.b = internal global [17 x i8] zeroinitializer
@.str = [2 x i8] c"1\00"
@.str.1 = [2 x i8] c"0\00"
define i8* @word_to_binary(i32 %0) {
store i8 0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @word_to_binary.b, i64 0, i64 0)
%2 = and i32 %0, 32768
%3 = icmp eq i32 %2, 0
%4 = select i1 %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0)
%5 = tail call i32 @strcat(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @word_to_binary.b, i64 0, i64 0), i8* %4)
%6 = and i32 %0, 16384
%7 = icmp eq i32 %6, 0
%8 = select i1 %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0)
%9 = tail call i32 @strcat(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @word_to_binary.b, i64 0, i64 0), i8* %8)
%10 = and i32 %0, 8192
%11 = icmp eq i32 %10, 0
%12 = select i1 %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0)
%13 = tail call i32 @strcat(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @word_to_binary.b, i64 0, i64 0), i8* %12)
%14 = and i32 %0, 4096
%15 = icmp eq i32 %14, 0
%16 = select i1 %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0)
%17 = tail call i32 @strcat(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @word_to_binary.b, i64 0, i64 0), i8* %16)
%18 = and i32 %0, 2048
%19 = icmp eq i32 %18, 0
%20 = select i1 %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0)
%21 = tail call i32 @strcat(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @word_to_binary.b, i64 0, i64 0), i8* %20)
%22 = and i32 %0, 1024
%23 = icmp eq i32 %22, 0
%24 = select i1 %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0)
%25 = tail call i32 @strcat(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @word_to_binary.b, i64 0, i64 0), i8* %24)
%26 = and i32 %0, 512
%27 = icmp eq i32 %26, 0
%28 = select i1 %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0)
%29 = tail call i32 @strcat(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @word_to_binary.b, i64 0, i64 0), i8* %28)
%30 = and i32 %0, 256
%31 = icmp eq i32 %30, 0
%32 = select i1 %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0)
%33 = tail call i32 @strcat(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @word_to_binary.b, i64 0, i64 0), i8* %32)
%34 = and i32 %0, 128
%35 = icmp eq i32 %34, 0
%36 = select i1 %35, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0)
%37 = tail call i32 @strcat(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @word_to_binary.b, i64 0, i64 0), i8* %36)
%38 = and i32 %0, 64
%39 = icmp eq i32 %38, 0
%40 = select i1 %39, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0)
%41 = tail call i32 @strcat(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @word_to_binary.b, i64 0, i64 0), i8* %40)
%42 = and i32 %0, 32
%43 = icmp eq i32 %42, 0
%44 = select i1 %43, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0)
%45 = tail call i32 @strcat(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @word_to_binary.b, i64 0, i64 0), i8* %44)
%46 = and i32 %0, 16
%47 = icmp eq i32 %46, 0
%48 = select i1 %47, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0)
%49 = tail call i32 @strcat(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @word_to_binary.b, i64 0, i64 0), i8* %48)
%50 = and i32 %0, 8
%51 = icmp eq i32 %50, 0
%52 = select i1 %51, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0)
%53 = tail call i32 @strcat(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @word_to_binary.b, i64 0, i64 0), i8* %52)
%54 = and i32 %0, 4
%55 = icmp eq i32 %54, 0
%56 = select i1 %55, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0)
%57 = tail call i32 @strcat(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @word_to_binary.b, i64 0, i64 0), i8* %56)
%58 = and i32 %0, 2
%59 = icmp eq i32 %58, 0
%60 = select i1 %59, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0)
%61 = tail call i32 @strcat(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @word_to_binary.b, i64 0, i64 0), i8* %60)
%62 = and i32 %0, 1
%63 = icmp eq i32 %62, 0
%64 = select i1 %63, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0)
%65 = tail call i32 @strcat(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @word_to_binary.b, i64 0, i64 0), i8* %64)
ret i8* getelementptr inbounds ([17 x i8], [17 x i8]* @word_to_binary.b, i64 0, i64 0)
}