#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*/ printf(char *, ...);
void dump_half(void *p, long count, unsigned long offset) {
  unsigned short *d = p;
  int i;
  while (count > 0) {
    printf("%08lx:", offset);
    for (i = 0; i < 8 && count--; i++)
      printf(" %04x", *d++);
    printf("\n");
    offset += 16;
  }
}


x86 assembly (clang, -O0):
<dump_half>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
jle    11d5 <dump_half+0xc5>
mov    -0x18(%rbp),%rsi
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x24(%rbp)
xor    %eax,%eax
cmpl   $0x8,-0x24(%rbp)
mov    %al,-0x25(%rbp)
jge    1178 <dump_half+0x68>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x10(%rbp)
cmp    $0x0,%rax
setne  %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
test   $0x1,%al
jne    1188 <dump_half+0x78>
jmp    11b6 <dump_half+0xa6>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x2,%rcx
mov    %rcx,-0x20(%rbp)
movzwl (%rax),%esi
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1150 <dump_half+0x40>
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x18(%rbp)
jmp    112c <dump_half+0x1c>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_half>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
test   %rsi,%rsi
jle    126a <dump_half+0x14a>
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
lea    -0x7(%rsi),%rax
mov    %rax,0x8(%rsp)
lea    -0x6(%rsi),%rax
mov    %rax,0x10(%rsp)
lea    -0x5(%rsi),%rax
mov    %rax,0x18(%rsp)
lea    -0x4(%rsi),%rax
mov    %rax,0x20(%rsp)
lea    -0x3(%rsi),%rax
mov    %rax,0x28(%rsp)
lea    -0x2(%rsi),%rax
mov    %rax,0x30(%rsp)
lea    -0x1(%rsi),%rbp
lea    0xe86(%rip),%r13
xor    %r12d,%r12d
lea    0xe75(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
movzwl (%rbx,%r12,2),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %r12,%rbp
je     1279 <dump_half+0x159>
movzwl 0x2(%rbx,%r12,2),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %r12,0x30(%rsp)
je     1279 <dump_half+0x159>
movzwl 0x4(%rbx,%r12,2),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %r12,0x28(%rsp)
je     1279 <dump_half+0x159>
movzwl 0x6(%rbx,%r12,2),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %r12,0x20(%rsp)
je     1279 <dump_half+0x159>
movzwl 0x8(%rbx,%r12,2),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %r12,0x18(%rsp)
je     1279 <dump_half+0x159>
movzwl 0xa(%rbx,%r12,2),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %r12,0x10(%rsp)
je     1279 <dump_half+0x159>
movzwl 0xc(%rbx,%r12,2),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %r12,0x8(%rsp)
je     1279 <dump_half+0x159>
movzwl 0xe(%rbx,%r12,2),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x10,%r15
add    $0x8,%r12
cmp    %r12,%r14
jne    1184 <dump_half+0x64>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0xa,%edi
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"%08lx:\00"
@.str.1 = [6 x i8] c" %04x\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @dump_half(i8* %0, i64 %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
%7 = alloca i16*
%8 = alloca i32
store i8* %0, i8** %4
store i64 %1, i64* %5
store i64 %2, i64* %6
%9 = load i8*, i8** %4
%10 = bitcast i8* %9 to i16*
store i16* %10, i16** %7
br label %11
11: ; preds = %35, %3
%12 = load i64, i64* %5
%13 = icmp sgt i64 %12, 0
br i1 %13, label %14, label %39
14: ; preds = %11
%15 = load i64, i64* %6
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i64 %15)
store i32 0, i32* %8
br label %17
17: ; preds = %32, %14
%18 = load i32, i32* %8
%19 = icmp slt i32 %18, 8
br i1 %19, label %20, label %24
20: ; preds = %17
%21 = load i64, i64* %5
%22 = add nsw i64 %21, -1
store i64 %22, i64* %5
%23 = icmp ne i64 %21, 0
br label %24
24: ; preds = %20, %17
%25 = phi i1 [ false, %17 ], [ %23, %20 ]
br i1 %25, label %26, label %35
26: ; preds = %24
%27 = load i16*, i16** %7
%28 = getelementptr inbounds i16, i16* %27, i32 1
store i16* %28, i16** %7
%29 = load i16, i16* %27
%30 = zext i16 %29 to i32
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %30)
br label %32
32: ; preds = %26
%33 = load i32, i32* %8
%34 = add nsw i32 %33, 1
store i32 %34, i32* %8
br label %17
35: ; preds = %24
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%37 = load i64, i64* %6
%38 = add i64 %37, 16
store i64 %38, i64* %6
br label %11
39: ; preds = %11
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"%08lx:\00"
@.str.1 = [6 x i8] c" %04x\00"
define void @dump_half(i8* nocapture %0, i64 %1, i64 %2) {
%4 = icmp sgt i64 %1, 0
br i1 %4, label %5, label %64
5: ; preds = %3
%6 = bitcast i8* %0 to i16*
br label %7
7: ; preds = %54, %5
%8 = phi i16* [ %57, %54 ], [ %6, %5 ]
%9 = phi i64 [ %62, %54 ], [ %2, %5 ]
%10 = phi i64 [ %56, %54 ], [ %1, %5 ]
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i64 %9)
%12 = load i16, i16* %8
%13 = zext i16 %12 to i32
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%15 = icmp eq i64 %10, 1
br i1 %15, label %52, label %16
16: ; preds = %7
%17 = getelementptr inbounds i16, i16* %8, i64 1
%18 = load i16, i16* %17
%19 = zext i16 %18 to i32
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%21 = icmp eq i64 %10, 2
br i1 %21, label %52, label %22
22: ; preds = %16
%23 = getelementptr inbounds i16, i16* %8, i64 2
%24 = load i16, i16* %23
%25 = zext i16 %24 to i32
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %25)
%27 = icmp eq i64 %10, 3
br i1 %27, label %52, label %28
28: ; preds = %22
%29 = getelementptr inbounds i16, i16* %8, i64 3
%30 = load i16, i16* %29
%31 = zext i16 %30 to i32
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %31)
%33 = icmp eq i64 %10, 4
br i1 %33, label %52, label %34
34: ; preds = %28
%35 = getelementptr inbounds i16, i16* %8, i64 4
%36 = load i16, i16* %35
%37 = zext i16 %36 to i32
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %37)
%39 = icmp eq i64 %10, 5
br i1 %39, label %52, label %40
40: ; preds = %34
%41 = getelementptr inbounds i16, i16* %8, i64 5
%42 = load i16, i16* %41
%43 = zext i16 %42 to i32
%44 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %43)
%45 = icmp eq i64 %10, 6
br i1 %45, label %52, label %46
46: ; preds = %40
%47 = getelementptr inbounds i16, i16* %8, i64 6
%48 = load i16, i16* %47
%49 = zext i16 %48 to i32
%50 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %49)
%51 = icmp eq i64 %10, 7
br i1 %51, label %52, label %54
52: ; preds = %7, %16, %22, %28, %34, %40, %46
%53 = tail call i32 @putchar(i32 10)
br label %64
54: ; preds = %46
%55 = getelementptr inbounds i16, i16* %8, i64 7
%56 = add nsw i64 %10, -8
%57 = getelementptr inbounds i16, i16* %8, i64 8
%58 = load i16, i16* %55
%59 = zext i16 %58 to i32
%60 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %59)
%61 = tail call i32 @putchar(i32 10)
%62 = add i64 %9, 16
%63 = icmp eq i64 %56, 0
br i1 %63, label %64, label %7
64: ; preds = %54, %52, %3
ret void
}