#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*/ uart_send(int);
void hexstrings(unsigned int d) {
  unsigned int rb;
  unsigned int rc;
  rb = 32;
  while (1) {
    rb -= 4;
    rc = (d >> rb) & 0xF;
    if (rc > 9)
      rc += 0x37;
    else
      rc += 0x30;
    uart_send(rc);
    if (rb == 0)
      break;
  }
  uart_send(0x20);
}


x86 assembly (clang, -O0):
<hexstrings>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x20,-0x8(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x4,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    -0x8(%rbp),%ecx
shr    %cl,%eax
and    $0xf,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x9,-0xc(%rbp)
jbe    1151 <hexstrings+0x41>
mov    -0xc(%rbp),%eax
add    $0x37,%eax
mov    %eax,-0xc(%rbp)
jmp    115a <hexstrings+0x4a>
mov    -0xc(%rbp),%eax
add    $0x30,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <uart_send@plt>
cmpl   $0x0,-0x8(%rbp)
jne    1171 <hexstrings+0x61>
jmp    1176 <hexstrings+0x66>
jmp    1122 <hexstrings+0x12>
mov    $0x20,%edi
call   1030 <uart_send@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hexstrings>:
push   %rbx
mov    %edi,%ebx
shr    $0x1c,%edi
lea    0x37(%rdi),%eax
or     $0x30,%edi
cmp    $0xa0000000,%ebx
cmovae %eax,%edi
call   1030 <uart_send@plt>
mov    %ebx,%eax
shr    $0x18,%eax
and    $0xf,%eax
lea    0x37(%rax),%ecx
lea    0x30(%rax),%edi
cmp    $0xa,%eax
cmovae %ecx,%edi
call   1030 <uart_send@plt>
mov    %ebx,%eax
shr    $0x14,%eax
and    $0xf,%eax
lea    0x37(%rax),%ecx
lea    0x30(%rax),%edi
cmp    $0xa,%eax
cmovae %ecx,%edi
call   1030 <uart_send@plt>
mov    %ebx,%eax
shr    $0x10,%eax
and    $0xf,%eax
lea    0x37(%rax),%ecx
lea    0x30(%rax),%edi
cmp    $0xa,%eax
cmovae %ecx,%edi
call   1030 <uart_send@plt>
mov    %ebx,%eax
shr    $0xc,%eax
and    $0xf,%eax
lea    0x37(%rax),%ecx
lea    0x30(%rax),%edi
cmp    $0xa,%eax
cmovae %ecx,%edi
call   1030 <uart_send@plt>
mov    %ebx,%eax
shr    $0x8,%eax
and    $0xf,%eax
lea    0x37(%rax),%ecx
lea    0x30(%rax),%edi
cmp    $0xa,%eax
cmovae %ecx,%edi
call   1030 <uart_send@plt>
mov    %ebx,%eax
shr    $0x4,%eax
and    $0xf,%eax
lea    0x37(%rax),%ecx
lea    0x30(%rax),%edi
cmp    $0xa,%eax
cmovae %ecx,%edi
call   1030 <uart_send@plt>
and    $0xf,%ebx
lea    0x37(%rbx),%eax
lea    0x30(%rbx),%edi
cmp    $0xa,%ebx
cmovae %eax,%edi
call   1030 <uart_send@plt>
mov    $0x20,%edi
pop    %rbx
jmp    1030 <uart_send@plt>

LLVM IR (-O0):
define void @hexstrings(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
store i32 32, i32* %3
br label %5
5: ; preds = %1, %26
%6 = load i32, i32* %3
%7 = sub i32 %6, 4
store i32 %7, i32* %3
%8 = load i32, i32* %2
%9 = load i32, i32* %3
%10 = lshr i32 %8, %9
%11 = and i32 %10, 15
store i32 %11, i32* %4
%12 = load i32, i32* %4
%13 = icmp ugt i32 %12, 9
br i1 %13, label %14, label %17
14: ; preds = %5
%15 = load i32, i32* %4
%16 = add i32 %15, 55
store i32 %16, i32* %4
br label %20
17: ; preds = %5
%18 = load i32, i32* %4
%19 = add i32 %18, 48
store i32 %19, i32* %4
br label %20
20: ; preds = %17, %14
%21 = load i32, i32* %4
%22 = call i32 @uart_send(i32 %21)
%23 = load i32, i32* %3
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %20
br label %27
26: ; preds = %20
br label %5
27: ; preds = %25
%28 = call i32 @uart_send(i32 32)
ret void
}

LLVM IR (-O2):
define void @hexstrings(i32 %0) {
%2 = lshr i32 %0, 28
%3 = icmp ugt i32 %0, -1610612737
%4 = add nuw nsw i32 %2, 55
%5 = or i32 %2, 48
%6 = select i1 %3, i32 %4, i32 %5
%7 = tail call i32 @uart_send(i32 %6)
%8 = lshr i32 %0, 24
%9 = and i32 %8, 15
%10 = icmp ugt i32 %9, 9
%11 = add nuw nsw i32 %9, 55
%12 = or i32 %9, 48
%13 = select i1 %10, i32 %11, i32 %12
%14 = tail call i32 @uart_send(i32 %13)
%15 = lshr i32 %0, 20
%16 = and i32 %15, 15
%17 = icmp ugt i32 %16, 9
%18 = add nuw nsw i32 %16, 55
%19 = or i32 %16, 48
%20 = select i1 %17, i32 %18, i32 %19
%21 = tail call i32 @uart_send(i32 %20)
%22 = lshr i32 %0, 16
%23 = and i32 %22, 15
%24 = icmp ugt i32 %23, 9
%25 = add nuw nsw i32 %23, 55
%26 = or i32 %23, 48
%27 = select i1 %24, i32 %25, i32 %26
%28 = tail call i32 @uart_send(i32 %27)
%29 = lshr i32 %0, 12
%30 = and i32 %29, 15
%31 = icmp ugt i32 %30, 9
%32 = add nuw nsw i32 %30, 55
%33 = or i32 %30, 48
%34 = select i1 %31, i32 %32, i32 %33
%35 = tail call i32 @uart_send(i32 %34)
%36 = lshr i32 %0, 8
%37 = and i32 %36, 15
%38 = icmp ugt i32 %37, 9
%39 = add nuw nsw i32 %37, 55
%40 = or i32 %37, 48
%41 = select i1 %38, i32 %39, i32 %40
%42 = tail call i32 @uart_send(i32 %41)
%43 = lshr i32 %0, 4
%44 = and i32 %43, 15
%45 = icmp ugt i32 %44, 9
%46 = add nuw nsw i32 %44, 55
%47 = or i32 %44, 48
%48 = select i1 %45, i32 %46, i32 %47
%49 = tail call i32 @uart_send(i32 %48)
%50 = and i32 %0, 15
%51 = icmp ugt i32 %50, 9
%52 = add nuw nsw i32 %50, 55
%53 = or i32 %50, 48
%54 = select i1 %51, i32 %52, i32 %53
%55 = tail call i32 @uart_send(i32 %54)
%56 = tail call i32 @uart_send(i32 32)
ret void
}