#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*/ fscanf(int /*<<< orphan*/, char *, int *);
int /*<<< orphan*/ printf(char *, int, ...);
int /*<<< orphan*/ stdin;
int main(int argc, char **argv) {
  int bgr, b, g, r, html;
  fscanf(stdin, "%x", &bgr);
  b = (bgr >> 10) & 0x1f;
  g = (bgr >> 5) & 0x1f;
  r = bgr & 0x1f;
  printf("rgb %x %x %x\n", r, g, b);
  html = ((r << 3) << 16) | ((g << 3) << 8) | (b << 3);
  printf("HTML: %x\n", html);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2eab(%rip),%rax
mov    (%rax),%edi
lea    0xeba(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1040 <fscanf@plt>
mov    -0x14(%rbp),%eax
sar    $0xa,%eax
and    $0x1f,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
sar    $0x5,%eax
and    $0x1f,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
and    $0x1f,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
shl    $0x3,%eax
shl    $0x10,%eax
mov    -0x1c(%rbp),%ecx
shl    $0x3,%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    -0x18(%rbp),%ecx
shl    $0x3,%ecx
or     %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%esi
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    0x2eb9(%rip),%rax
mov    (%rax),%edi
lea    0xec8(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1040 <fscanf@plt>
mov    0xc(%rsp),%ebp
mov    %ebp,%r14d
shr    $0xa,%r14d
and    $0x1f,%r14d
mov    %ebp,%ebx
shr    $0x5,%ebx
and    $0x1f,%ebx
and    $0x1f,%ebp
lea    0xea0(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
mov    %r14d,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
shl    $0x13,%ebp
shl    $0xb,%ebx
or     %ebp,%ebx
lea    (%rbx,%r14,8),%esi
lea    0xe8d(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [3 x i8] c"%x\00"
@.str.1 = [14 x i8] c"rgb %x %x %x\0A\00"
@.str.2 = [10 x i8] c"HTML: %x\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* @stdin
%12 = call i32 @fscanf(i32 %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
%13 = load i32, i32* %6
%14 = ashr i32 %13, 10
%15 = and i32 %14, 31
store i32 %15, i32* %7
%16 = load i32, i32* %6
%17 = ashr i32 %16, 5
%18 = and i32 %17, 31
store i32 %18, i32* %8
%19 = load i32, i32* %6
%20 = and i32 %19, 31
store i32 %20, i32* %9
%21 = load i32, i32* %9
%22 = load i32, i32* %8
%23 = load i32, i32* %7
%24 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %21, i32 %22, i32 %23)
%25 = load i32, i32* %9
%26 = shl i32 %25, 3
%27 = shl i32 %26, 16
%28 = load i32, i32* %8
%29 = shl i32 %28, 3
%30 = shl i32 %29, 8
%31 = or i32 %27, %30
%32 = load i32, i32* %7
%33 = shl i32 %32, 3
%34 = or i32 %31, %33
store i32 %34, i32* %10
%35 = load i32, i32* %10
%36 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %35)
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [3 x i8] c"%x\00"
@.str.1 = [14 x i8] c"rgb %x %x %x\0A\00"
@.str.2 = [10 x i8] c"HTML: %x\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = load i32, i32* @stdin
%6 = call i32 @fscanf(i32 %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%7 = load i32, i32* %3
%8 = lshr i32 %7, 10
%9 = and i32 %8, 31
%10 = lshr i32 %7, 5
%11 = and i32 %10, 31
%12 = and i32 %7, 31
%13 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %12, i32 %11, i32 %9)
%14 = shl nuw nsw i32 %12, 19
%15 = shl nuw nsw i32 %11, 11
%16 = or i32 %15, %14
%17 = shl nuw nsw i32 %9, 3
%18 = or i32 %16, %17
%19 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %18)
ret i32 0
}