#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*/ mach_alphanum(int, unsigned int);
void print_seg_num(unsigned num) {
  int i;
  unsigned int nibble;
  for (i = 0; i < 8; i++) {
    nibble = ((num >> (i * 4)) & 0xf);
    mach_alphanum(7 - i, nibble + ((nibble > 9) ? 55 : 48));
  }
}


x86 assembly (clang, -O0):
<print_seg_num>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x8,-0x8(%rbp)
jge    1170 <print_seg_num+0x60>
mov    -0x4(%rbp),%eax
mov    -0x8(%rbp),%ecx
shl    $0x2,%ecx
shr    %cl,%eax
and    $0xf,%eax
mov    %eax,-0xc(%rbp)
mov    $0x7,%edi
sub    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    $0x30,%eax
mov    $0x37,%ecx
cmp    $0x9,%edx
cmova  %ecx,%eax
add    %eax,%esi
call   1030 <mach_alphanum@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1122 <print_seg_num+0x12>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_seg_num>:
push   %rbx
mov    %edi,%ebx
mov    %edi,%eax
and    $0xf,%eax
lea    0x30(%rax),%ecx
lea    0x37(%rax),%esi
cmp    $0xa,%eax
cmovb  %ecx,%esi
mov    $0x7,%edi
call   1030 <mach_alphanum@plt>
mov    %ebx,%eax
shr    $0x4,%eax
and    $0xf,%eax
lea    0x30(%rax),%ecx
lea    0x37(%rax),%esi
cmp    $0xa,%eax
cmovb  %ecx,%esi
mov    $0x6,%edi
call   1030 <mach_alphanum@plt>
mov    %ebx,%eax
shr    $0x8,%eax
and    $0xf,%eax
lea    0x30(%rax),%ecx
lea    0x37(%rax),%esi
cmp    $0xa,%eax
cmovb  %ecx,%esi
mov    $0x5,%edi
call   1030 <mach_alphanum@plt>
mov    %ebx,%eax
shr    $0xc,%eax
and    $0xf,%eax
lea    0x30(%rax),%ecx
lea    0x37(%rax),%esi
cmp    $0xa,%eax
cmovb  %ecx,%esi
mov    $0x4,%edi
call   1030 <mach_alphanum@plt>
mov    %ebx,%eax
shr    $0x10,%eax
and    $0xf,%eax
lea    0x30(%rax),%ecx
lea    0x37(%rax),%esi
cmp    $0xa,%eax
cmovb  %ecx,%esi
mov    $0x3,%edi
call   1030 <mach_alphanum@plt>
mov    %ebx,%eax
shr    $0x14,%eax
and    $0xf,%eax
lea    0x30(%rax),%ecx
lea    0x37(%rax),%esi
cmp    $0xa,%eax
cmovb  %ecx,%esi
mov    $0x2,%edi
call   1030 <mach_alphanum@plt>
mov    %ebx,%eax
shr    $0x18,%eax
and    $0xf,%eax
lea    0x30(%rax),%ecx
lea    0x37(%rax),%esi
cmp    $0xa,%eax
cmovb  %ecx,%esi
mov    $0x1,%edi
call   1030 <mach_alphanum@plt>
mov    %ebx,%esi
shr    $0x1c,%esi
lea    0x30(%rsi),%eax
add    $0x37,%esi
cmp    $0xa0000000,%ebx
cmovb  %eax,%esi
xor    %edi,%edi
pop    %rbx
jmp    1030 <mach_alphanum@plt>

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

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