#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*/ uint8_t;
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ writebit(int);
int /*<<< orphan*/ writeregisteraddress(int /*<<< orphan*/);
void setvtxregister(uint8_t which, uint32_t value) {
  int i;
  writeregisteraddress(which);
  writebit(true);
  for (i = 0; i < 20; i++) {
    writebit((value >> i) & 1);
  }
}


x86 assembly (clang, -O0):
<setvtxregister>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <writeregisteraddress@plt>
mov    $0x1,%edi
call   1030 <writebit@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x14,-0xc(%rbp)
jge    116f <setvtxregister+0x4f>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%ecx
sar    %cl,%edi
and    $0x1,%edi
call   1030 <writebit@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1147 <setvtxregister+0x27>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setvtxregister>:
push   %rbx
mov    %esi,%ebx
call   1040 <writeregisteraddress@plt>
mov    $0x1,%edi
call   1030 <writebit@plt>
mov    %ebx,%edi
and    $0x1,%edi
call   1030 <writebit@plt>
mov    %ebx,%edi
shr    %edi
and    $0x1,%edi
call   1030 <writebit@plt>
mov    %ebx,%edi
shr    $0x2,%edi
and    $0x1,%edi
call   1030 <writebit@plt>
mov    %ebx,%edi
shr    $0x3,%edi
and    $0x1,%edi
call   1030 <writebit@plt>
mov    %ebx,%edi
shr    $0x4,%edi
and    $0x1,%edi
call   1030 <writebit@plt>
mov    %ebx,%edi
shr    $0x5,%edi
and    $0x1,%edi
call   1030 <writebit@plt>
mov    %ebx,%edi
shr    $0x6,%edi
and    $0x1,%edi
call   1030 <writebit@plt>
mov    %ebx,%edi
shr    $0x7,%edi
and    $0x1,%edi
call   1030 <writebit@plt>
mov    %ebx,%edi
shr    $0x8,%edi
and    $0x1,%edi
call   1030 <writebit@plt>
mov    %ebx,%edi
shr    $0x9,%edi
and    $0x1,%edi
call   1030 <writebit@plt>
mov    %ebx,%edi
shr    $0xa,%edi
and    $0x1,%edi
call   1030 <writebit@plt>
mov    %ebx,%edi
shr    $0xb,%edi
and    $0x1,%edi
call   1030 <writebit@plt>
mov    %ebx,%edi
shr    $0xc,%edi
and    $0x1,%edi
call   1030 <writebit@plt>
mov    %ebx,%edi
shr    $0xd,%edi
and    $0x1,%edi
call   1030 <writebit@plt>
mov    %ebx,%edi
shr    $0xe,%edi
and    $0x1,%edi
call   1030 <writebit@plt>
mov    %ebx,%edi
shr    $0xf,%edi
and    $0x1,%edi
call   1030 <writebit@plt>
mov    %ebx,%edi
shr    $0x10,%edi
and    $0x1,%edi
call   1030 <writebit@plt>
mov    %ebx,%edi
shr    $0x11,%edi
and    $0x1,%edi
call   1030 <writebit@plt>
mov    %ebx,%edi
shr    $0x12,%edi
and    $0x1,%edi
call   1030 <writebit@plt>
shr    $0x13,%ebx
and    $0x1,%ebx
mov    %ebx,%edi
pop    %rbx
jmp    1030 <writebit@plt>

LLVM IR (-O0):
define void @setvtxregister(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = load i32, i32* %3
%7 = call i32 @writeregisteraddress(i32 %6)
%8 = call i32 @writebit(i32 1)
store i32 0, i32* %5
br label %9
9: ; preds = %18, %2
%10 = load i32, i32* %5
%11 = icmp slt i32 %10, 20
br i1 %11, label %12, label %21
12: ; preds = %9
%13 = load i32, i32* %4
%14 = load i32, i32* %5
%15 = ashr i32 %13, %14
%16 = and i32 %15, 1
%17 = call i32 @writebit(i32 %16)
br label %18
18: ; preds = %12
%19 = load i32, i32* %5
%20 = add nsw i32 %19, 1
store i32 %20, i32* %5
br label %9
21: ; preds = %9
ret void
}

LLVM IR (-O2):
define void @setvtxregister(i32 %0, i32 %1) {
%3 = tail call i32 @writeregisteraddress(i32 %0)
%4 = tail call i32 @writebit(i32 1)
%5 = and i32 %1, 1
%6 = tail call i32 @writebit(i32 %5)
%7 = lshr i32 %1, 1
%8 = and i32 %7, 1
%9 = tail call i32 @writebit(i32 %8)
%10 = lshr i32 %1, 2
%11 = and i32 %10, 1
%12 = tail call i32 @writebit(i32 %11)
%13 = lshr i32 %1, 3
%14 = and i32 %13, 1
%15 = tail call i32 @writebit(i32 %14)
%16 = lshr i32 %1, 4
%17 = and i32 %16, 1
%18 = tail call i32 @writebit(i32 %17)
%19 = lshr i32 %1, 5
%20 = and i32 %19, 1
%21 = tail call i32 @writebit(i32 %20)
%22 = lshr i32 %1, 6
%23 = and i32 %22, 1
%24 = tail call i32 @writebit(i32 %23)
%25 = lshr i32 %1, 7
%26 = and i32 %25, 1
%27 = tail call i32 @writebit(i32 %26)
%28 = lshr i32 %1, 8
%29 = and i32 %28, 1
%30 = tail call i32 @writebit(i32 %29)
%31 = lshr i32 %1, 9
%32 = and i32 %31, 1
%33 = tail call i32 @writebit(i32 %32)
%34 = lshr i32 %1, 10
%35 = and i32 %34, 1
%36 = tail call i32 @writebit(i32 %35)
%37 = lshr i32 %1, 11
%38 = and i32 %37, 1
%39 = tail call i32 @writebit(i32 %38)
%40 = lshr i32 %1, 12
%41 = and i32 %40, 1
%42 = tail call i32 @writebit(i32 %41)
%43 = lshr i32 %1, 13
%44 = and i32 %43, 1
%45 = tail call i32 @writebit(i32 %44)
%46 = lshr i32 %1, 14
%47 = and i32 %46, 1
%48 = tail call i32 @writebit(i32 %47)
%49 = lshr i32 %1, 15
%50 = and i32 %49, 1
%51 = tail call i32 @writebit(i32 %50)
%52 = lshr i32 %1, 16
%53 = and i32 %52, 1
%54 = tail call i32 @writebit(i32 %53)
%55 = lshr i32 %1, 17
%56 = and i32 %55, 1
%57 = tail call i32 @writebit(i32 %56)
%58 = lshr i32 %1, 18
%59 = and i32 %58, 1
%60 = tail call i32 @writebit(i32 %59)
%61 = lshr i32 %1, 19
%62 = and i32 %61, 1
%63 = tail call i32 @writebit(i32 %62)
ret void
}