#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 uint16_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ bin_to_hex4(int /*<<< orphan*/);
int /*<<< orphan*/ putc(int /*<<< orphan*/, int /*<<< orphan*/ *);
void puth2(uint16_t hex, FILE *f) {
  putc(bin_to_hex4((uint8_t)(hex >> 12)), f);
  putc(bin_to_hex4((uint8_t)(hex >> 8)), f);
  putc(bin_to_hex4((uint8_t)(hex >> 4)), f);
  putc(bin_to_hex4((uint8_t)(hex >> 0)), f);
}


x86 assembly (clang, -O0):
<puth2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%edi
sar    $0xc,%edi
call   1040 <bin_to_hex4@plt>
mov    %eax,%edi
mov    -0x10(%rbp),%rsi
call   1030 <putc@plt>
mov    -0x4(%rbp),%edi
sar    $0x8,%edi
call   1040 <bin_to_hex4@plt>
mov    %eax,%edi
mov    -0x10(%rbp),%rsi
call   1030 <putc@plt>
mov    -0x4(%rbp),%edi
sar    $0x4,%edi
call   1040 <bin_to_hex4@plt>
mov    %eax,%edi
mov    -0x10(%rbp),%rsi
call   1030 <putc@plt>
mov    -0x4(%rbp),%edi
sar    $0x0,%edi
call   1040 <bin_to_hex4@plt>
mov    %eax,%edi
mov    -0x10(%rbp),%rsi
call   1030 <putc@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<puth2>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
sar    $0xc,%edi
call   1040 <bin_to_hex4@plt>
mov    %eax,%edi
mov    %rbx,%rsi
call   1030 <putc@plt>
mov    %ebp,%edi
sar    $0x8,%edi
call   1040 <bin_to_hex4@plt>
mov    %eax,%edi
mov    %rbx,%rsi
call   1030 <putc@plt>
mov    %ebp,%edi
sar    $0x4,%edi
call   1040 <bin_to_hex4@plt>
mov    %eax,%edi
mov    %rbx,%rsi
call   1030 <putc@plt>
mov    %ebp,%edi
call   1040 <bin_to_hex4@plt>
mov    %eax,%edi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <putc@plt>

LLVM IR (-O0):
define void @puth2(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
store i32 %0, i32* %3
store i32* %1, i32** %4
%5 = load i32, i32* %3
%6 = ashr i32 %5, 12
%7 = call i32 @bin_to_hex4(i32 %6)
%8 = load i32*, i32** %4
%9 = call i32 @putc(i32 %7, i32* %8)
%10 = load i32, i32* %3
%11 = ashr i32 %10, 8
%12 = call i32 @bin_to_hex4(i32 %11)
%13 = load i32*, i32** %4
%14 = call i32 @putc(i32 %12, i32* %13)
%15 = load i32, i32* %3
%16 = ashr i32 %15, 4
%17 = call i32 @bin_to_hex4(i32 %16)
%18 = load i32*, i32** %4
%19 = call i32 @putc(i32 %17, i32* %18)
%20 = load i32, i32* %3
%21 = ashr i32 %20, 0
%22 = call i32 @bin_to_hex4(i32 %21)
%23 = load i32*, i32** %4
%24 = call i32 @putc(i32 %22, i32* %23)
ret void
}

LLVM IR (-O2):
define void @puth2(i32 %0, i32* nocapture %1) {
%3 = ashr i32 %0, 12
%4 = tail call i32 @bin_to_hex4(i32 %3)
%5 = tail call i32 @putc(i32 %4, i32* %1)
%6 = ashr i32 %0, 8
%7 = tail call i32 @bin_to_hex4(i32 %6)
%8 = tail call i32 @putc(i32 %7, i32* %1)
%9 = ashr i32 %0, 4
%10 = tail call i32 @bin_to_hex4(i32 %9)
%11 = tail call i32 @putc(i32 %10, i32* %1)
%12 = tail call i32 @bin_to_hex4(i32 %0)
%13 = tail call i32 @putc(i32 %12, i32* %1)
ret void
}