#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 */
int /*<<< orphan*/ big_endian();
char *bits(char ch) {
  static char arr[9];
  int i = (int)ch;
  if (!big_endian())
    i = i >> 24;
  arr[0] = ((ch & 128) == 128) + '0';
  arr[1] = ((ch & 64) == 64) + '0';
  arr[2] = ((ch & 32) == 32) + '0';
  arr[3] = ((ch & 16) == 16) + '0';
  arr[4] = ((ch & 8) == 8) + '0';
  arr[5] = ((ch & 4) == 4) + '0';
  arr[6] = ((ch & 2) == 2) + '0';
  arr[7] = ((ch & 1) == 1) + '0';
  arr[8] = '\0';
  return arr;
}


x86 assembly (clang, -O0):
<bits>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1030 <big_endian@plt>
cmp    $0x0,%eax
jne    113e <bits+0x2e>
mov    -0x8(%rbp),%eax
sar    $0x18,%eax
mov    %eax,-0x8(%rbp)
movsbl -0x1(%rbp),%eax
and    $0x80,%eax
cmp    $0x80,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
add    $0x30,%eax
mov    %al,0x2ecc(%rip)
movsbl -0x1(%rbp),%eax
and    $0x40,%eax
cmp    $0x40,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
add    $0x30,%eax
mov    %al,0x2eb2(%rip)
movsbl -0x1(%rbp),%eax
and    $0x20,%eax
cmp    $0x20,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
add    $0x30,%eax
mov    %al,0x2e98(%rip)
movsbl -0x1(%rbp),%eax
and    $0x10,%eax
cmp    $0x10,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
add    $0x30,%eax
mov    %al,0x2e7e(%rip)
movsbl -0x1(%rbp),%eax
and    $0x8,%eax
cmp    $0x8,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
add    $0x30,%eax
mov    %al,0x2e64(%rip)
movsbl -0x1(%rbp),%eax
and    $0x4,%eax
cmp    $0x4,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
add    $0x30,%eax
mov    %al,0x2e4a(%rip)
movsbl -0x1(%rbp),%eax
and    $0x2,%eax
cmp    $0x2,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
add    $0x30,%eax
mov    %al,0x2e30(%rip)
movsbl -0x1(%rbp),%eax
and    $0x1,%eax
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
add    $0x30,%eax
mov    %al,0x2e16(%rip)
movb   $0x0,0x2e10(%rip)
lea    0x2e01(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bits>:
push   %rbx
mov    %edi,%ebx
xor    %eax,%eax
call   1030 <big_endian@plt>
mov    %ebx,%eax
shr    $0x7,%al
or     $0x30,%al
mov    %al,0x2f02(%rip)
lea    0x2efb(%rip),%rax
mov    %ebx,%ecx
shr    $0x6,%cl
and    $0x1,%cl
or     $0x30,%cl
mov    %cl,0x2eeb(%rip)
mov    %ebx,%ecx
shr    $0x5,%cl
and    $0x1,%cl
or     $0x30,%cl
mov    %cl,0x2edb(%rip)
mov    %ebx,%ecx
shr    $0x4,%cl
and    $0x1,%cl
or     $0x30,%cl
mov    %cl,0x2ecb(%rip)
mov    %ebx,%ecx
shr    $0x3,%cl
and    $0x1,%cl
or     $0x30,%cl
mov    %cl,0x2ebb(%rip)
mov    %ebx,%ecx
shr    $0x2,%cl
and    $0x1,%cl
or     $0x30,%cl
mov    %cl,0x2eab(%rip)
mov    %ebx,%ecx
shr    %cl
and    $0x1,%cl
or     $0x30,%cl
mov    %cl,0x2e9c(%rip)
and    $0x1,%bl
or     $0x30,%bl
mov    %bl,0x2e91(%rip)
movb   $0x0,0x2e8b(%rip)
pop    %rbx
ret

LLVM IR (-O0):
@bits.arr = internal global [9 x i8] zeroinitializer
define i8* @bits(i8 signext %0) {
%2 = alloca i8
%3 = alloca i32
store i8 %0, i8* %2
%4 = load i8, i8* %2
%5 = sext i8 %4 to i32
store i32 %5, i32* %3
%6 = call i32 (...) @big_endian()
%7 = icmp ne i32 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %1
%9 = load i32, i32* %3
%10 = ashr i32 %9, 24
store i32 %10, i32* %3
br label %11
11: ; preds = %8, %1
%12 = load i8, i8* %2
%13 = sext i8 %12 to i32
%14 = and i32 %13, 128
%15 = icmp eq i32 %14, 128
%16 = zext i1 %15 to i32
%17 = add nsw i32 %16, 48
%18 = trunc i32 %17 to i8
store i8 %18, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @bits.arr, i64 0, i64 0)
%19 = load i8, i8* %2
%20 = sext i8 %19 to i32
%21 = and i32 %20, 64
%22 = icmp eq i32 %21, 64
%23 = zext i1 %22 to i32
%24 = add nsw i32 %23, 48
%25 = trunc i32 %24 to i8
store i8 %25, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @bits.arr, i64 0, i64 1)
%26 = load i8, i8* %2
%27 = sext i8 %26 to i32
%28 = and i32 %27, 32
%29 = icmp eq i32 %28, 32
%30 = zext i1 %29 to i32
%31 = add nsw i32 %30, 48
%32 = trunc i32 %31 to i8
store i8 %32, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @bits.arr, i64 0, i64 2)
%33 = load i8, i8* %2
%34 = sext i8 %33 to i32
%35 = and i32 %34, 16
%36 = icmp eq i32 %35, 16
%37 = zext i1 %36 to i32
%38 = add nsw i32 %37, 48
%39 = trunc i32 %38 to i8
store i8 %39, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @bits.arr, i64 0, i64 3)
%40 = load i8, i8* %2
%41 = sext i8 %40 to i32
%42 = and i32 %41, 8
%43 = icmp eq i32 %42, 8
%44 = zext i1 %43 to i32
%45 = add nsw i32 %44, 48
%46 = trunc i32 %45 to i8
store i8 %46, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @bits.arr, i64 0, i64 4)
%47 = load i8, i8* %2
%48 = sext i8 %47 to i32
%49 = and i32 %48, 4
%50 = icmp eq i32 %49, 4
%51 = zext i1 %50 to i32
%52 = add nsw i32 %51, 48
%53 = trunc i32 %52 to i8
store i8 %53, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @bits.arr, i64 0, i64 5)
%54 = load i8, i8* %2
%55 = sext i8 %54 to i32
%56 = and i32 %55, 2
%57 = icmp eq i32 %56, 2
%58 = zext i1 %57 to i32
%59 = add nsw i32 %58, 48
%60 = trunc i32 %59 to i8
store i8 %60, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @bits.arr, i64 0, i64 6)
%61 = load i8, i8* %2
%62 = sext i8 %61 to i32
%63 = and i32 %62, 1
%64 = icmp eq i32 %63, 1
%65 = zext i1 %64 to i32
%66 = add nsw i32 %65, 48
%67 = trunc i32 %66 to i8
store i8 %67, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @bits.arr, i64 0, i64 7)
store i8 0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @bits.arr, i64 0, i64 8)
ret i8* getelementptr inbounds ([9 x i8], [9 x i8]* @bits.arr, i64 0, i64 0)
}

LLVM IR (-O2):
@bits.arr = internal global [9 x i8] zeroinitializer
define i8* @bits(i8 signext %0) {
%2 = tail call i32 (...) @big_endian()
%3 = lshr i8 %0, 7
%4 = or i8 %3, 48
store i8 %4, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @bits.arr, i64 0, i64 0)
%5 = lshr i8 %0, 6
%6 = and i8 %5, 1
%7 = or i8 %6, 48
store i8 %7, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @bits.arr, i64 0, i64 1)
%8 = lshr i8 %0, 5
%9 = and i8 %8, 1
%10 = or i8 %9, 48
store i8 %10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @bits.arr, i64 0, i64 2)
%11 = lshr i8 %0, 4
%12 = and i8 %11, 1
%13 = or i8 %12, 48
store i8 %13, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @bits.arr, i64 0, i64 3)
%14 = lshr i8 %0, 3
%15 = and i8 %14, 1
%16 = or i8 %15, 48
store i8 %16, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @bits.arr, i64 0, i64 4)
%17 = lshr i8 %0, 2
%18 = and i8 %17, 1
%19 = or i8 %18, 48
store i8 %19, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @bits.arr, i64 0, i64 5)
%20 = lshr i8 %0, 1
%21 = and i8 %20, 1
%22 = or i8 %21, 48
store i8 %22, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @bits.arr, i64 0, i64 6)
%23 = and i8 %0, 1
%24 = or i8 %23, 48
store i8 %24, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @bits.arr, i64 0, i64 7)
store i8 0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @bits.arr, i64 0, i64 8)
ret i8* getelementptr inbounds ([9 x i8], [9 x i8]* @bits.arr, i64 0, i64 0)
}