#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 int32_t;

/* Variables and functions */
int /*<<< orphan*/ ieee_putascii(char *, ...);
int32_t ieee_putld(int32_t start, int32_t end, uint8_t *buf) {
  int32_t val;
  if (start == end)
    return (start);
  val = start % 1024;
  while (end - start >= 32) {
    int i;
    ieee_putascii("LD");
    for (i = 0; i < 32; i++) {
      ieee_putascii("%02X", buf[val++]);
      start++;
    }
    ieee_putascii(".\n");
  }
  if (start == end)
    return (start);
  ieee_putascii("LD");
  while (start < end) {
    ieee_putascii("%02X", buf[val++]);
    start++;
  }
  ieee_putascii(".\n");
  return (start);
}


x86 assembly (clang, -O0):
<ieee_putld>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    1139 <ieee_putld+0x29>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1238 <ieee_putld+0x128>
mov    -0x8(%rbp),%eax
mov    $0x400,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
sub    -0x8(%rbp),%eax
cmp    $0x20,%eax
jl     11c2 <ieee_putld+0xb2>
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <ieee_putascii@plt>
movl   $0x0,-0x20(%rbp)
cmpl   $0x20,-0x20(%rbp)
jge    11af <ieee_putld+0x9f>
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x1c(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1030 <ieee_putascii@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    116b <ieee_putld+0x5b>
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1030 <ieee_putascii@plt>
jmp    1147 <ieee_putld+0x37>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    11d9 <ieee_putld+0xc9>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1238 <ieee_putld+0x128>
lea    0xe20(%rip),%rdi
mov    $0x0,%al
call   1030 <ieee_putascii@plt>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1224 <ieee_putld+0x114>
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x1c(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%esi
lea    0xdf4(%rip),%rdi
mov    $0x0,%al
call   1030 <ieee_putascii@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11e7 <ieee_putld+0xd7>
lea    0xddd(%rip),%rdi
mov    $0x0,%al
call   1030 <ieee_putascii@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ieee_putld>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,0x10(%rsp)
mov    %esi,%ebx
mov    %esi,%eax
sub    %edi,%eax
je     122e <ieee_putld+0x11e>
mov    %edi,%r12d
lea    0x3ff(%r12),%ecx
test   %edi,%edi
cmovns %edi,%ecx
and    $0xfffffc00,%ecx
mov    %edi,%r13d
sub    %ecx,%r13d
cmp    $0x20,%eax
mov    %ebx,0xc(%rsp)
jl     11c2 <ieee_putld+0xb2>
lea    0xea8(%rip),%rbp
nopl   0x0(%rax,%rax,1)
mov    %r13d,%r15d
lea    0xe96(%rip),%rdi
xor    %eax,%eax
call   1030 <ieee_putascii@plt>
movslq %r13d,%rax
mov    0x10(%rsp),%rcx
lea    (%rcx,%rax,4),%rbx
xor    %r14d,%r14d
mov    (%rbx,%r14,4),%esi
mov    %rbp,%rdi
xor    %eax,%eax
call   1030 <ieee_putascii@plt>
add    $0x1,%r14
cmp    $0x20,%r14d
jne    1180 <ieee_putld+0x70>
add    $0x20,%r12d
lea    (%r15,%r14,1),%r13d
lea    0xe61(%rip),%rdi
xor    %eax,%eax
call   1030 <ieee_putascii@plt>
mov    0xc(%rsp),%ebx
mov    %ebx,%eax
sub    %r12d,%eax
cmp    $0x1f,%eax
jg     1160 <ieee_putld+0x50>
add    %r14d,%r15d
mov    %r15d,%r13d
cmp    %ebx,%r12d
je     122e <ieee_putld+0x11e>
lea    0xe32(%rip),%rdi
xor    %eax,%eax
call   1030 <ieee_putascii@plt>
cmp    %ebx,%r12d
jge    121d <ieee_putld+0x10d>
movslq %r13d,%rax
mov    0x10(%rsp),%rcx
lea    (%rcx,%rax,4),%r14
mov    %ebx,%ebp
sub    %r12d,%ebp
lea    0xe11(%rip),%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r14,%rbx,4),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <ieee_putascii@plt>
add    $0x1,%rbx
cmp    %ebx,%ebp
jne    1200 <ieee_putld+0xf0>
mov    0xc(%rsp),%eax
mov    %eax,%r12d
lea    0xde4(%rip),%rdi
xor    %eax,%eax
call   1030 <ieee_putascii@plt>
mov    %r12d,%ebx
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"LD\00"
@.str.1 = [5 x i8] c"%02X\00"
@.str.2 = [3 x i8] c".\0A\00"
define i32 @ieee_putld(i32 %0, i32 %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32* %2, i32** %7
%10 = load i32, i32* %5
%11 = load i32, i32* %6
%12 = icmp eq i32 %10, %11
br i1 %12, label %13, label %15
13: ; preds = %3
%14 = load i32, i32* %5
store i32 %14, i32* %4
br label %68
15: ; preds = %3
%16 = load i32, i32* %5
%17 = srem i32 %16, 1024
store i32 %17, i32* %8
br label %18
18: ; preds = %41, %15
%19 = load i32, i32* %6
%20 = load i32, i32* %5
%21 = sub nsw i32 %19, %20
%22 = icmp sge i32 %21, 32
br i1 %22, label %23, label %43
23: ; preds = %18
%24 = call i32 (i8*, ...) @ieee_putascii(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %9
br label %25
25: ; preds = %38, %23
%26 = load i32, i32* %9
%27 = icmp slt i32 %26, 32
br i1 %27, label %28, label %41
28: ; preds = %25
%29 = load i32*, i32** %7
%30 = load i32, i32* %8
%31 = add nsw i32 %30, 1
store i32 %31, i32* %8
%32 = sext i32 %30 to i64
%33 = getelementptr inbounds i32, i32* %29, i64 %32
%34 = load i32, i32* %33
%35 = call i32 (i8*, ...) @ieee_putascii(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %34)
%36 = load i32, i32* %5
%37 = add nsw i32 %36, 1
store i32 %37, i32* %5
br label %38
38: ; preds = %28
%39 = load i32, i32* %9
%40 = add nsw i32 %39, 1
store i32 %40, i32* %9
br label %25
41: ; preds = %25
%42 = call i32 (i8*, ...) @ieee_putascii(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %18
43: ; preds = %18
%44 = load i32, i32* %5
%45 = load i32, i32* %6
%46 = icmp eq i32 %44, %45
br i1 %46, label %47, label %49
47: ; preds = %43
%48 = load i32, i32* %5
store i32 %48, i32* %4
br label %68
49: ; preds = %43
%50 = call i32 (i8*, ...) @ieee_putascii(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %51
51: ; preds = %55, %49
%52 = load i32, i32* %5
%53 = load i32, i32* %6
%54 = icmp slt i32 %52, %53
br i1 %54, label %55, label %65
55: ; preds = %51
%56 = load i32*, i32** %7
%57 = load i32, i32* %8
%58 = add nsw i32 %57, 1
store i32 %58, i32* %8
%59 = sext i32 %57 to i64
%60 = getelementptr inbounds i32, i32* %56, i64 %59
%61 = load i32, i32* %60
%62 = call i32 (i8*, ...) @ieee_putascii(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %61)
%63 = load i32, i32* %5
%64 = add nsw i32 %63, 1
store i32 %64, i32* %5
br label %51
65: ; preds = %51
%66 = call i32 (i8*, ...) @ieee_putascii(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%67 = load i32, i32* %5
store i32 %67, i32* %4
br label %68
68: ; preds = %65, %47, %13
%69 = load i32, i32* %4
ret i32 %69
}

LLVM IR (-O2):
@.str = [3 x i8] c"LD\00"
@.str.1 = [5 x i8] c"%02X\00"
@.str.2 = [3 x i8] c".\0A\00"
define i32 @ieee_putld(i32 %0, i32 %1, i32* nocapture %2) {
%4 = icmp eq i32 %1, %0
br i1 %4, label %52, label %5
5: ; preds = %3
%6 = srem i32 %0, 1024
%7 = sub nsw i32 %1, %0
%8 = icmp sgt i32 %7, 31
br i1 %8, label %9, label %31
9: ; preds = %5, %23
%10 = phi i32 [ %25, %23 ], [ %6, %5 ]
%11 = phi i32 [ %24, %23 ], [ %0, %5 ]
%12 = tail call i32 (i8*, ...) @ieee_putascii(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%13 = sext i32 %10 to i64
br label %14
14: ; preds = %9, %14
%15 = phi i64 [ %13, %9 ], [ %17, %14 ]
%16 = phi i32 [ 0, %9 ], [ %21, %14 ]
%17 = add nsw i64 %15, 1
%18 = getelementptr inbounds i32, i32* %2, i64 %15
%19 = load i32, i32* %18
%20 = tail call i32 (i8*, ...) @ieee_putascii(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%21 = add nuw nsw i32 %16, 1
%22 = icmp eq i32 %21, 32
br i1 %22, label %23, label %14
23: ; preds = %14
%24 = add i32 %11, 32
%25 = trunc i64 %17 to i32
%26 = tail call i32 (i8*, ...) @ieee_putascii(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%27 = sub nsw i32 %1, %24
%28 = icmp sgt i32 %27, 31
br i1 %28, label %9, label %29
29: ; preds = %23
%30 = trunc i64 %17 to i32
br label %31
31: ; preds = %29, %5
%32 = phi i32 [ %0, %5 ], [ %24, %29 ]
%33 = phi i32 [ %6, %5 ], [ %30, %29 ]
%34 = icmp eq i32 %32, %1
br i1 %34, label %52, label %35
35: ; preds = %31
%36 = tail call i32 (i8*, ...) @ieee_putascii(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%37 = icmp slt i32 %32, %1
br i1 %37, label %38, label %49
38: ; preds = %35
%39 = sext i32 %33 to i64
br label %40
40: ; preds = %38, %40
%41 = phi i64 [ %39, %38 ], [ %43, %40 ]
%42 = phi i32 [ %32, %38 ], [ %47, %40 ]
%43 = add nsw i64 %41, 1
%44 = getelementptr inbounds i32, i32* %2, i64 %41
%45 = load i32, i32* %44
%46 = tail call i32 (i8*, ...) @ieee_putascii(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %45)
%47 = add i32 %42, 1
%48 = icmp eq i32 %47, %1
br i1 %48, label %49, label %40
49: ; preds = %40, %35
%50 = phi i32 [ %32, %35 ], [ %1, %40 ]
%51 = tail call i32 (i8*, ...) @ieee_putascii(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %52
52: ; preds = %31, %3, %49
%53 = phi i32 [ %50, %49 ], [ %1, %3 ], [ %1, %31 ]
ret i32 %53
}