#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*/ bufcon_putc(char *, unsigned char);
int /*<<< orphan*/ bufcon_puts(char *, char *);
char *bufcon_putX(char *buffer, unsigned int p) {
  int offset;
  unsigned char c;
  int found = 0;
  bufcon_puts(buffer, "0x");
  for (offset = 28; offset >= 0; offset -= 4) {
    c = (p >> offset) & 0xF;
    if (c != 0)
      found = 1;
    if (found == 1) {
      if (c < 10)
        bufcon_putc(buffer, c + '0');
      else
        bufcon_putc(buffer, c - 10 + 'A');
    }
  }
  if (found == 0)
    bufcon_putc(buffer, '0');
  return buffer;
}


x86 assembly (clang, -O0):
<bufcon_putX>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xebf(%rip),%rsi
call   1040 <bufcon_puts@plt>
movl   $0x1c,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jl     11d6 <bufcon_putX+0xb6>
mov    -0xc(%rbp),%eax
mov    -0x10(%rbp),%ecx
shr    %cl,%eax
and    $0xf,%eax
mov    %al,-0x11(%rbp)
movzbl -0x11(%rbp),%eax
cmp    $0x0,%eax
je     1179 <bufcon_putX+0x59>
movl   $0x1,-0x18(%rbp)
cmpl   $0x1,-0x18(%rbp)
jne    11c3 <bufcon_putX+0xa3>
movzbl -0x11(%rbp),%eax
cmp    $0xa,%eax
jge    11a8 <bufcon_putX+0x88>
mov    -0x8(%rbp),%rdi
movzbl -0x11(%rbp),%eax
add    $0x30,%eax
movzbl %al,%esi
call   1030 <bufcon_putc@plt>
jmp    11be <bufcon_putX+0x9e>
mov    -0x8(%rbp),%rdi
movzbl -0x11(%rbp),%eax
sub    $0xa,%eax
add    $0x41,%eax
movzbl %al,%esi
call   1030 <bufcon_putc@plt>
jmp    11c3 <bufcon_putX+0xa3>
jmp    11c8 <bufcon_putX+0xa8>
mov    -0x10(%rbp),%eax
sub    $0x4,%eax
mov    %eax,-0x10(%rbp)
jmp    114d <bufcon_putX+0x2d>
cmpl   $0x0,-0x18(%rbp)
jne    11ee <bufcon_putX+0xce>
mov    -0x8(%rbp),%rdi
mov    $0x30,%esi
call   1030 <bufcon_putc@plt>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bufcon_putX>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r15d
mov    %rdi,%r14
lea    0xecb(%rip),%rsi
call   1040 <bufcon_puts@plt>
cmp    $0x10000000,%r15d
jb     1169 <bufcon_putX+0x49>
mov    %r15d,%eax
shr    $0x1c,%eax
lea    0x37(%rax),%ecx
or     $0x30,%al
cmp    $0xa0000000,%r15d
movzbl %al,%eax
movzbl %cl,%ecx
cmovb  %eax,%ecx
movzbl %cl,%esi
mov    %r14,%rdi
call   1030 <bufcon_putc@plt>
cmp    $0x10000000,%r15d
setae  %cl
mov    %r15d,%eax
shr    $0x18,%eax
and    $0xf,%eax
setne  %bl
or     %cl,%bl
cmp    $0x1,%bl
jne    11a5 <bufcon_putX+0x85>
lea    0x37(%rax),%ecx
mov    %eax,%edx
or     $0x30,%dl
cmp    $0xa,%eax
movzbl %dl,%eax
movzbl %cl,%ecx
cmovb  %eax,%ecx
movzbl %cl,%esi
mov    %r14,%rdi
call   1030 <bufcon_putc@plt>
mov    %r15d,%eax
shr    $0x14,%eax
and    $0xf,%eax
setne  %bpl
or     %bl,%bpl
cmp    $0x1,%bpl
jne    11da <bufcon_putX+0xba>
lea    0x37(%rax),%ecx
mov    %eax,%edx
or     $0x30,%dl
cmp    $0xa,%eax
movzbl %dl,%eax
movzbl %cl,%ecx
cmovb  %eax,%ecx
movzbl %cl,%esi
mov    %r14,%rdi
call   1030 <bufcon_putc@plt>
mov    %r15d,%eax
shr    $0x10,%eax
and    $0xf,%eax
setne  %bl
or     %bpl,%bl
cmp    $0x1,%bl
jne    120d <bufcon_putX+0xed>
lea    0x37(%rax),%ecx
mov    %eax,%edx
or     $0x30,%dl
cmp    $0xa,%eax
movzbl %dl,%eax
movzbl %cl,%ecx
cmovb  %eax,%ecx
movzbl %cl,%esi
mov    %r14,%rdi
call   1030 <bufcon_putc@plt>
mov    %r15d,%eax
shr    $0xc,%eax
and    $0xf,%eax
setne  %bpl
or     %bl,%bpl
cmp    $0x1,%bpl
jne    1242 <bufcon_putX+0x122>
lea    0x37(%rax),%ecx
mov    %eax,%edx
or     $0x30,%dl
cmp    $0xa,%eax
movzbl %dl,%eax
movzbl %cl,%ecx
cmovb  %eax,%ecx
movzbl %cl,%esi
mov    %r14,%rdi
call   1030 <bufcon_putc@plt>
mov    %r15d,%eax
shr    $0x8,%eax
and    $0xf,%eax
setne  %r12b
or     %bpl,%r12b
cmp    $0x1,%r12b
jne    1277 <bufcon_putX+0x157>
lea    0x37(%rax),%ecx
mov    %eax,%edx
or     $0x30,%dl
cmp    $0xa,%eax
movzbl %dl,%eax
movzbl %cl,%ecx
cmovb  %eax,%ecx
movzbl %cl,%esi
mov    %r14,%rdi
call   1030 <bufcon_putc@plt>
mov    %r15d,%eax
shr    $0x4,%eax
and    $0xf,%eax
setne  %bl
or     %r12b,%bl
cmp    $0x1,%bl
jne    12aa <bufcon_putX+0x18a>
lea    0x37(%rax),%ecx
mov    %eax,%edx
or     $0x30,%dl
cmp    $0xa,%eax
movzbl %dl,%eax
movzbl %cl,%ecx
cmovb  %eax,%ecx
movzbl %cl,%esi
mov    %r14,%rdi
call   1030 <bufcon_putc@plt>
and    $0xf,%r15d
setne  %al
or     %bl,%al
cmp    $0x1,%al
jne    12d6 <bufcon_putX+0x1b6>
lea    0x37(%r15),%eax
mov    %r15d,%ecx
or     $0x30,%cl
cmp    $0xa,%r15d
movzbl %cl,%ecx
movzbl %al,%eax
cmovb  %ecx,%eax
movzbl %al,%esi
mov    %r14,%rdi
jmp    12de <bufcon_putX+0x1be>
mov    %r14,%rdi
mov    $0x30,%esi
call   1030 <bufcon_putc@plt>
mov    %r14,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"0x\00"
define i8* @bufcon_putX(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8
%7 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 0, i32* %7
%8 = load i8*, i8** %3
%9 = call i32 @bufcon_puts(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 28, i32* %5
br label %10
10: ; preds = %47, %2
%11 = load i32, i32* %5
%12 = icmp sge i32 %11, 0
br i1 %12, label %13, label %50
13: ; preds = %10
%14 = load i32, i32* %4
%15 = load i32, i32* %5
%16 = lshr i32 %14, %15
%17 = and i32 %16, 15
%18 = trunc i32 %17 to i8
store i8 %18, i8* %6
%19 = load i8, i8* %6
%20 = zext i8 %19 to i32
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %13
store i32 1, i32* %7
br label %23
23: ; preds = %22, %13
%24 = load i32, i32* %7
%25 = icmp eq i32 %24, 1
br i1 %25, label %26, label %46
26: ; preds = %23
%27 = load i8, i8* %6
%28 = zext i8 %27 to i32
%29 = icmp slt i32 %28, 10
br i1 %29, label %30, label %37
30: ; preds = %26
%31 = load i8*, i8** %3
%32 = load i8, i8* %6
%33 = zext i8 %32 to i32
%34 = add nsw i32 %33, 48
%35 = trunc i32 %34 to i8
%36 = call i32 @bufcon_putc(i8* %31, i8 zeroext %35)
br label %45
37: ; preds = %26
%38 = load i8*, i8** %3
%39 = load i8, i8* %6
%40 = zext i8 %39 to i32
%41 = sub nsw i32 %40, 10
%42 = add nsw i32 %41, 65
%43 = trunc i32 %42 to i8
%44 = call i32 @bufcon_putc(i8* %38, i8 zeroext %43)
br label %45
45: ; preds = %37, %30
br label %46
46: ; preds = %45, %23
br label %47
47: ; preds = %46
%48 = load i32, i32* %5
%49 = sub nsw i32 %48, 4
store i32 %49, i32* %5
br label %10
50: ; preds = %10
%51 = load i32, i32* %7
%52 = icmp eq i32 %51, 0
br i1 %52, label %53, label %56
53: ; preds = %50
%54 = load i8*, i8** %3
%55 = call i32 @bufcon_putc(i8* %54, i8 zeroext 48)
br label %56
56: ; preds = %53, %50
%57 = load i8*, i8** %3
ret i8* %57
}

LLVM IR (-O2):
@.str = [3 x i8] c"0x\00"
define i8* @bufcon_putX(i8* returned %0, i32 %1) {
%3 = tail call i32 @bufcon_puts(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%4 = icmp ugt i32 %1, 268435455
br i1 %4, label %5, label %13
5: ; preds = %2
%6 = lshr i32 %1, 28
%7 = icmp ult i32 %1, -1610612736
%8 = trunc i32 %6 to i8
%9 = add nuw nsw i8 %8, 55
%10 = or i8 %8, 48
%11 = select i1 %7, i8 %10, i8 %9
%12 = tail call i32 @bufcon_putc(i8* %0, i8 zeroext %11)
br label %13
13: ; preds = %5, %2
%14 = lshr i32 %1, 24
%15 = and i32 %14, 15
%16 = icmp ne i32 %15, 0
%17 = or i1 %16, %4
br i1 %17, label %18, label %25
18: ; preds = %13
%19 = icmp ult i32 %15, 10
%20 = trunc i32 %15 to i8
%21 = add nuw nsw i8 %20, 55
%22 = or i8 %20, 48
%23 = select i1 %19, i8 %22, i8 %21
%24 = tail call i32 @bufcon_putc(i8* %0, i8 zeroext %23)
br label %25
25: ; preds = %18, %13
%26 = lshr i32 %1, 20
%27 = and i32 %26, 15
%28 = icmp ne i32 %27, 0
%29 = or i1 %28, %17
br i1 %29, label %30, label %37
30: ; preds = %25
%31 = icmp ult i32 %27, 10
%32 = trunc i32 %27 to i8
%33 = add nuw nsw i8 %32, 55
%34 = or i8 %32, 48
%35 = select i1 %31, i8 %34, i8 %33
%36 = tail call i32 @bufcon_putc(i8* %0, i8 zeroext %35)
br label %37
37: ; preds = %30, %25
%38 = lshr i32 %1, 16
%39 = and i32 %38, 15
%40 = icmp ne i32 %39, 0
%41 = or i1 %40, %29
br i1 %41, label %42, label %49
42: ; preds = %37
%43 = icmp ult i32 %39, 10
%44 = trunc i32 %39 to i8
%45 = add nuw nsw i8 %44, 55
%46 = or i8 %44, 48
%47 = select i1 %43, i8 %46, i8 %45
%48 = tail call i32 @bufcon_putc(i8* %0, i8 zeroext %47)
br label %49
49: ; preds = %42, %37
%50 = lshr i32 %1, 12
%51 = and i32 %50, 15
%52 = icmp ne i32 %51, 0
%53 = or i1 %52, %41
br i1 %53, label %54, label %61
54: ; preds = %49
%55 = icmp ult i32 %51, 10
%56 = trunc i32 %51 to i8
%57 = add nuw nsw i8 %56, 55
%58 = or i8 %56, 48
%59 = select i1 %55, i8 %58, i8 %57
%60 = tail call i32 @bufcon_putc(i8* %0, i8 zeroext %59)
br label %61
61: ; preds = %54, %49
%62 = lshr i32 %1, 8
%63 = and i32 %62, 15
%64 = icmp ne i32 %63, 0
%65 = or i1 %64, %53
br i1 %65, label %66, label %73
66: ; preds = %61
%67 = icmp ult i32 %63, 10
%68 = trunc i32 %63 to i8
%69 = add nuw nsw i8 %68, 55
%70 = or i8 %68, 48
%71 = select i1 %67, i8 %70, i8 %69
%72 = tail call i32 @bufcon_putc(i8* %0, i8 zeroext %71)
br label %73
73: ; preds = %66, %61
%74 = lshr i32 %1, 4
%75 = and i32 %74, 15
%76 = icmp ne i32 %75, 0
%77 = select i1 %76, i1 true, i1 %65
br i1 %77, label %78, label %85
78: ; preds = %73
%79 = icmp ult i32 %75, 10
%80 = trunc i32 %75 to i8
%81 = add nuw nsw i8 %80, 55
%82 = or i8 %80, 48
%83 = select i1 %79, i8 %82, i8 %81
%84 = tail call i32 @bufcon_putc(i8* %0, i8 zeroext %83)
br label %85
85: ; preds = %78, %73
%86 = and i32 %1, 15
%87 = icmp ne i32 %86, 0
%88 = select i1 %87, i1 true, i1 %77
br i1 %88, label %89, label %96
89: ; preds = %85
%90 = icmp ult i32 %86, 10
%91 = trunc i32 %86 to i8
%92 = add nuw nsw i8 %91, 55
%93 = or i8 %91, 48
%94 = select i1 %90, i8 %93, i8 %92
%95 = tail call i32 @bufcon_putc(i8* %0, i8 zeroext %94)
br label %98
96: ; preds = %85
%97 = tail call i32 @bufcon_putc(i8* %0, i8 zeroext 48)
br label %98
98: ; preds = %89, %96
ret i8* %0
}