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

/* Variables and functions */
int HEA(int, int);
int HEM(int, int);
int /*<<< orphan*/ printf(char *, int);
void fsl(int slot1, int slot2, uint32_t *src, uint32_t *dest) {
  uint8_t B1 = (uint8_t)((*src) & 0xF);
  printf("%u\n", B1);
  uint8_t A1 = (uint8_t)((*src) & 0xF0);
  printf("%u\n", A1);
  uint8_t B2 = (uint8_t)((*src) & 0xF00);
  printf("%u\n", B2);
  uint8_t A2 = (uint8_t)((*src) & 0xF000);
  printf("%u\n", A2);
  if ((*src) & 1 << 16) {
    (*dest) = HEM(A1, B1) | HEM(A2, B2) << 8;
  } else {
    (*dest) = HEA(A1, B1) | HEA(A2, B2) << 8;
  }
}


x86 assembly (clang, -O0):
<fsl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
and    $0xf,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xea4(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
and    $0xf0,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%esi
lea    0xe87(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
and    $0xf00,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%esi
lea    0xe6a(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
and    $0xf000,%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%esi
lea    0xe4d(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
and    $0x10000,%eax
cmp    $0x0,%eax
je     11f8 <fsl+0xc8>
mov    -0x20(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1050 <HEM@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%edi
mov    -0x24(%rbp),%esi
call   1050 <HEM@plt>
mov    -0x2c(%rbp),%ecx
shl    $0x8,%eax
or     %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    121f <fsl+0xef>
mov    -0x20(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1030 <HEA@plt>
mov    %eax,-0x30(%rbp)
mov    -0x28(%rbp),%edi
mov    -0x24(%rbp),%esi
call   1030 <HEA@plt>
mov    -0x30(%rbp),%ecx
shl    $0x8,%eax
or     %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fsl>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,(%rsp)
mov    %rdx,%rbp
mov    (%rdx),%r15d
and    $0xf,%r15d
lea    0xeb0(%rip),%r14
mov    %r14,%rdi
mov    %r15d,%esi
call   1040 <printf@plt>
mov    $0xf0,%r13d
and    0x0(%rbp),%r13d
mov    %r14,%rdi
mov    %r13d,%esi
call   1040 <printf@plt>
mov    $0xf00,%r12d
and    0x0(%rbp),%r12d
mov    %r14,%rdi
mov    %r12d,%esi
call   1040 <printf@plt>
mov    $0xf000,%ebx
and    0x0(%rbp),%ebx
mov    %r14,%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
testb  $0x1,0x2(%rbp)
jne    11b6 <fsl+0x86>
mov    %r13d,%edi
mov    %r15d,%esi
call   1030 <HEA@plt>
mov    %eax,%ebp
mov    %ebx,%edi
mov    %r12d,%esi
call   1030 <HEA@plt>
jmp    11cd <fsl+0x9d>
mov    %r13d,%edi
mov    %r15d,%esi
call   1050 <HEM@plt>
mov    %eax,%ebp
mov    %ebx,%edi
mov    %r12d,%esi
call   1050 <HEM@plt>
shl    $0x8,%eax
or     %ebp,%eax
mov    (%rsp),%rcx
mov    %eax,(%rcx)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%u\0A\00"
define void @fsl(i32 %0, i32 %1, i32* %2, i32* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32* %2, i32** %7
store i32* %3, i32** %8
%13 = load i32*, i32** %7
%14 = load i32, i32* %13
%15 = and i32 %14, 15
store i32 %15, i32* %9
%16 = load i32, i32* %9
%17 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = load i32*, i32** %7
%19 = load i32, i32* %18
%20 = and i32 %19, 240
store i32 %20, i32* %10
%21 = load i32, i32* %10
%22 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %21)
%23 = load i32*, i32** %7
%24 = load i32, i32* %23
%25 = and i32 %24, 3840
store i32 %25, i32* %11
%26 = load i32, i32* %11
%27 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %26)
%28 = load i32*, i32** %7
%29 = load i32, i32* %28
%30 = and i32 %29, 61440
store i32 %30, i32* %12
%31 = load i32, i32* %12
%32 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %31)
%33 = load i32*, i32** %7
%34 = load i32, i32* %33
%35 = and i32 %34, 65536
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %47
37: ; preds = %4
%38 = load i32, i32* %10
%39 = load i32, i32* %9
%40 = call i32 @HEM(i32 %38, i32 %39)
%41 = load i32, i32* %12
%42 = load i32, i32* %11
%43 = call i32 @HEM(i32 %41, i32 %42)
%44 = shl i32 %43, 8
%45 = or i32 %40, %44
%46 = load i32*, i32** %8
store i32 %45, i32* %46
br label %57
47: ; preds = %4
%48 = load i32, i32* %10
%49 = load i32, i32* %9
%50 = call i32 @HEA(i32 %48, i32 %49)
%51 = load i32, i32* %12
%52 = load i32, i32* %11
%53 = call i32 @HEA(i32 %51, i32 %52)
%54 = shl i32 %53, 8
%55 = or i32 %50, %54
%56 = load i32*, i32** %8
store i32 %55, i32* %56
br label %57
57: ; preds = %47, %37
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%u\0A\00"
define void @fsl(i32 %0, i32 %1, i32* nocapture %2, i32* nocapture writeonly %3) {
%5 = load i32, i32* %2
%6 = and i32 %5, 15
%7 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = load i32, i32* %2
%9 = and i32 %8, 240
%10 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = load i32, i32* %2
%12 = and i32 %11, 3840
%13 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = load i32, i32* %2
%15 = and i32 %14, 61440
%16 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = load i32, i32* %2
%18 = and i32 %17, 65536
%19 = icmp eq i32 %18, 0
br i1 %19, label %23, label %20
20: ; preds = %4
%21 = tail call i32 @HEM(i32 %9, i32 %6)
%22 = tail call i32 @HEM(i32 %15, i32 %12)
br label %26
23: ; preds = %4
%24 = tail call i32 @HEA(i32 %9, i32 %6)
%25 = tail call i32 @HEA(i32 %15, i32 %12)
br label %26
26: ; preds = %23, %20
%27 = phi i32 [ %25, %23 ], [ %22, %20 ]
%28 = phi i32 [ %24, %23 ], [ %21, %20 ]
%29 = shl i32 %27, 8
%30 = or i32 %29, %28
store i32 %30, i32* %3
ret void
}