#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 usb_crc5(unsigned char, unsigned char);
void make_usb_token(unsigned char pid, unsigned int elevenbits,
                    unsigned char *out) {
  out[0] = pid;
  out[1] = elevenbits & 0xff;
  out[2] = (elevenbits & 0x700) >> 8;
  out[2] |= usb_crc5(out[1], out[2]) << 3;
}


x86 assembly (clang, -O0):
<make_usb_token>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x1(%rbp),%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x8(%rbp),%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x8(%rbp),%eax
and    $0x700,%eax
shr    $0x8,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x2(%rax)
mov    -0x10(%rbp),%rax
mov    0x1(%rax),%cl
mov    -0x10(%rbp),%rax
movzbl %cl,%edi
movzbl 0x2(%rax),%esi
call   1030 <usb_crc5@plt>
mov    %eax,%edx
shl    $0x3,%edx
mov    -0x10(%rbp),%rax
movzbl 0x2(%rax),%ecx
or     %edx,%ecx
mov    %cl,0x2(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_usb_token>:
push   %rbx
mov    %rdx,%rbx
mov    %dil,(%rdx)
mov    %sil,0x1(%rdx)
mov    %esi,%eax
shr    $0x8,%eax
mov    %eax,%ecx
and    $0x7,%cl
mov    %cl,0x2(%rdx)
movzbl %sil,%edi
and    $0x7,%eax
mov    %eax,%esi
call   1030 <usb_crc5@plt>
shl    $0x3,%al
or     %al,0x2(%rbx)
pop    %rbx
ret

LLVM IR (-O0):
define void @make_usb_token(i8 zeroext %0, i32 %1, i8* %2) {
%4 = alloca i8
%5 = alloca i32
%6 = alloca i8*
store i8 %0, i8* %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%7 = load i8, i8* %4
%8 = load i8*, i8** %6
%9 = getelementptr inbounds i8, i8* %8, i64 0
store i8 %7, i8* %9
%10 = load i32, i32* %5
%11 = and i32 %10, 255
%12 = trunc i32 %11 to i8
%13 = load i8*, i8** %6
%14 = getelementptr inbounds i8, i8* %13, i64 1
store i8 %12, i8* %14
%15 = load i32, i32* %5
%16 = and i32 %15, 1792
%17 = lshr i32 %16, 8
%18 = trunc i32 %17 to i8
%19 = load i8*, i8** %6
%20 = getelementptr inbounds i8, i8* %19, i64 2
store i8 %18, i8* %20
%21 = load i8*, i8** %6
%22 = getelementptr inbounds i8, i8* %21, i64 1
%23 = load i8, i8* %22
%24 = load i8*, i8** %6
%25 = getelementptr inbounds i8, i8* %24, i64 2
%26 = load i8, i8* %25
%27 = call i32 @usb_crc5(i8 zeroext %23, i8 zeroext %26)
%28 = shl i32 %27, 3
%29 = load i8*, i8** %6
%30 = getelementptr inbounds i8, i8* %29, i64 2
%31 = load i8, i8* %30
%32 = zext i8 %31 to i32
%33 = or i32 %32, %28
%34 = trunc i32 %33 to i8
store i8 %34, i8* %30
ret void
}

LLVM IR (-O2):
define void @make_usb_token(i8 zeroext %0, i32 %1, i8* nocapture %2) {
store i8 %0, i8* %2
%4 = trunc i32 %1 to i8
%5 = getelementptr inbounds i8, i8* %2, i64 1
store i8 %4, i8* %5
%6 = lshr i32 %1, 8
%7 = trunc i32 %6 to i8
%8 = and i8 %7, 7
%9 = getelementptr inbounds i8, i8* %2, i64 2
store i8 %8, i8* %9
%10 = tail call i32 @usb_crc5(i8 zeroext %4, i8 zeroext %8)
%11 = load i8, i8* %9
%12 = trunc i32 %10 to i8
%13 = shl i8 %12, 3
%14 = or i8 %13, %11
store i8 %14, i8* %9
ret void
}