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

/* Variables and functions */
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
void print_selector(FILE *out, unsigned sel) {
  int k;
  for (k = (8 + 3) - 1; k >= 0; --k, sel <<= 1) {
    int c;
    fputc((sel & (1 << ((8 + 3) - 1))) ? '1' : '0', out);
    if (!(k & 7))
      fputc(' ', out);
  }
}


x86 assembly (clang, -O0):
<print_selector>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0xa,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jl     118e <print_selector+0x7e>
mov    -0xc(%rbp),%edx
and    $0x400,%edx
mov    $0x30,%eax
mov    $0x31,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    -0x8(%rbp),%rsi
movsbl %al,%edi
call   1030 <fputc@plt>
mov    -0x10(%rbp),%eax
and    $0x7,%eax
cmp    $0x0,%eax
jne    1172 <print_selector+0x62>
mov    -0x8(%rbp),%rsi
mov    $0x20,%edi
call   1030 <fputc@plt>
jmp    1177 <print_selector+0x67>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1126 <print_selector+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_selector>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebx
mov    %rdi,%r14
mov    $0xa,%ebp
jmp    1127 <print_selector+0x17>
add    %ebx,%ebx
add    $0xffffffff,%ebp
jae    1156 <print_selector+0x46>
mov    %ebx,%eax
and    $0x400,%eax
cmp    $0x1,%eax
mov    $0x31,%edi
sbb    $0x0,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
test   $0x7,%bpl
jne    1120 <print_selector+0x10>
mov    $0x20,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
jmp    1120 <print_selector+0x10>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @print_selector(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
store i32 10, i32* %5
br label %7
7: ; preds = %26, %2
%8 = load i32, i32* %5
%9 = icmp sge i32 %8, 0
br i1 %9, label %10, label %31
10: ; preds = %7
%11 = load i32, i32* %4
%12 = and i32 %11, 1024
%13 = icmp ne i32 %12, 0
%14 = zext i1 %13 to i64
%15 = select i1 %13, i32 49, i32 48
%16 = trunc i32 %15 to i8
%17 = load i32*, i32** %3
%18 = call i32 @fputc(i8 signext %16, i32* %17)
%19 = load i32, i32* %5
%20 = and i32 %19, 7
%21 = icmp ne i32 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %10
%23 = load i32*, i32** %3
%24 = call i32 @fputc(i8 signext 32, i32* %23)
br label %25
25: ; preds = %22, %10
br label %26
26: ; preds = %25
%27 = load i32, i32* %5
%28 = add nsw i32 %27, -1
store i32 %28, i32* %5
%29 = load i32, i32* %4
%30 = shl i32 %29, 1
store i32 %30, i32* %4
br label %7
31: ; preds = %7
ret void
}

LLVM IR (-O2):
define void @print_selector(i32* nocapture %0, i32 %1) {
br label %3
3: ; preds = %2, %14
%4 = phi i32 [ %1, %2 ], [ %16, %14 ]
%5 = phi i32 [ 10, %2 ], [ %15, %14 ]
%6 = and i32 %4, 1024
%7 = icmp eq i32 %6, 0
%8 = select i1 %7, i8 48, i8 49
%9 = tail call i32 @fputc(i8 signext %8, i32* %0)
%10 = and i32 %5, 7
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %3
%13 = tail call i32 @fputc(i8 signext 32, i32* %0)
br label %14
14: ; preds = %12, %3
%15 = add nsw i32 %5, -1
%16 = shl i32 %4, 1
%17 = icmp eq i32 %5, 0
br i1 %17, label %18, label %3
18: ; preds = %14
ret void
}