#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*/ exit(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, unsigned long *);
int main() {
  unsigned long int hex, h1, h2, l1, l2;
  printf("Enter a eight-digit hex value: ");
  scanf("%x", &hex);
  h1 = hex & 0xFF000000;
  h2 = hex & 0x00FF0000;
  l1 = hex & 0x0000FF00;
  l2 = hex & 0x000000FF;
  h1 >>= 24;
  h2 >>= 16;
  l1 >>= 8;
  printf("0x%08X is composed first of %02X and %02X, then %02X and %02X\n", hex,
         h1, h2, l1, l2);
  exit(65789);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecc(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
movabs $0xff000000,%rax
and    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
and    $0xff0000,%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
and    $0xff00,%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
and    $0xff,%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
shr    $0x18,%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
shr    $0x10,%rax
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rax
shr    $0x8,%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    -0x30(%rbp),%r9
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x100fd,%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xec4(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed6(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x8(%rsp),%rax
movzbl %al,%r9d
mov    %eax,%edx
shr    $0x18,%edx
mov    %eax,%ecx
shr    $0x10,%ecx
movzbl %cl,%ecx
movzbl %ah,%ebx
lea    0xeaf(%rip),%rdi
mov    %rax,%rsi
mov    %rbx,%r8
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x100fd,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [32 x i8] c"Enter a eight-digit hex value: \00"
@.str.1 = [3 x i8] c"%x\00"
@.str.2 = [63 x i8] c"0x%08X is composed first of %02X and %02X, then %02X and %02X\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i64* %2)
%9 = load i64, i64* %2
%10 = and i64 %9, 4278190080
store i64 %10, i64* %3
%11 = load i64, i64* %2
%12 = and i64 %11, 16711680
store i64 %12, i64* %4
%13 = load i64, i64* %2
%14 = and i64 %13, 65280
store i64 %14, i64* %5
%15 = load i64, i64* %2
%16 = and i64 %15, 255
store i64 %16, i64* %6
%17 = load i64, i64* %3
%18 = lshr i64 %17, 24
store i64 %18, i64* %3
%19 = load i64, i64* %4
%20 = lshr i64 %19, 16
store i64 %20, i64* %4
%21 = load i64, i64* %5
%22 = lshr i64 %21, 8
store i64 %22, i64* %5
%23 = load i64, i64* %2
%24 = load i64, i64* %3
%25 = load i64, i64* %4
%26 = load i64, i64* %5
%27 = load i64, i64* %6
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.2, i64 0, i64 0), i64 %23, i64 %24, i64 %25, i64 %26, i64 %27)
%29 = call i32 @exit(i32 65789)
unreachable
}

LLVM IR (-O2):
@.str = [32 x i8] c"Enter a eight-digit hex value: \00"
@.str.1 = [3 x i8] c"%x\00"
@.str.2 = [63 x i8] c"0x%08X is composed first of %02X and %02X, then %02X and %02X\0A\00"
define i32 @main() {
%1 = alloca i64
%2 = bitcast i64* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i64* %1)
%5 = load i64, i64* %1
%6 = and i64 %5, 255
%7 = lshr i64 %5, 24
%8 = and i64 %7, 255
%9 = lshr i64 %5, 16
%10 = and i64 %9, 255
%11 = lshr i64 %5, 8
%12 = and i64 %11, 255
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @.str.2, i64 0, i64 0), i64 %5, i64 %8, i64 %10, i64 %12, i64 %6)
%14 = call i32 @exit(i32 65789)
unreachable
}