#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*/ data;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ my_fread(long *, int, int /*<<< orphan*/ *);
int my_getw(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, long, long, long);
void LinkDump(FILE *HelpFile) {
  long data[3];
  int n, i;
  n = my_getw(HelpFile);
  for (i = 0; i < n; i++) {
    my_fread(data, sizeof(data), HelpFile);
    printf("Annotation for topic 0x%08lx 0x%08lx 0x%08lx\n", data[0], data[1],
           data[2]);
  }
}


x86 assembly (clang, -O0):
<LinkDump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <my_getw@plt>
mov    %eax,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1193 <LinkDump+0x63>
lea    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x18,%esi
call   1030 <my_fread@plt>
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xe80(%rip),%rdi
call   1040 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    114f <LinkDump+0x1f>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LinkDump>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
call   1050 <my_getw@plt>
test   %eax,%eax
jle    118b <LinkDump+0x5b>
mov    %eax,%ebp
mov    %rsp,%r14
lea    0xeae(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    $0x18,%esi
mov    %rbx,%rdx
call   1030 <my_fread@plt>
mov    (%rsp),%rsi
mov    0x8(%rsp),%rdx
mov    0x10(%rsp),%rcx
mov    %r15,%rdi
call   1040 <printf@plt>
add    $0xffffffff,%ebp
jne    1160 <LinkDump+0x30>
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [46 x i8] c"Annotation for topic 0x%08lx 0x%08lx 0x%08lx\0A\00"
define void @LinkDump(i32* %0) {
%2 = alloca i32*
%3 = alloca [3 x i64]
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %2
%6 = load i32*, i32** %2
%7 = call i32 @my_getw(i32* %6)
store i32 %7, i32* %4
store i32 0, i32* %5
br label %8
8: ; preds = %23, %1
%9 = load i32, i32* %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %26
12: ; preds = %8
%13 = getelementptr inbounds [3 x i64], [3 x i64]* %3, i64 0, i64 0
%14 = load i32*, i32** %2
%15 = call i32 @my_fread(i64* %13, i32 24, i32* %14)
%16 = getelementptr inbounds [3 x i64], [3 x i64]* %3, i64 0, i64 0
%17 = load i64, i64* %16
%18 = getelementptr inbounds [3 x i64], [3 x i64]* %3, i64 0, i64 1
%19 = load i64, i64* %18
%20 = getelementptr inbounds [3 x i64], [3 x i64]* %3, i64 0, i64 2
%21 = load i64, i64* %20
%22 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i64 %17, i64 %19, i64 %21)
br label %23
23: ; preds = %12
%24 = load i32, i32* %5
%25 = add nsw i32 %24, 1
store i32 %25, i32* %5
br label %8
26: ; preds = %8
ret void
}

LLVM IR (-O2):
@.str = [46 x i8] c"Annotation for topic 0x%08lx 0x%08lx 0x%08lx\0A\00"
define void @LinkDump(i32* %0) {
%2 = alloca [3 x i64]
%3 = bitcast [3 x i64]* %2 to i8*
%4 = tail call i32 @my_getw(i32* %0)
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %19
6: ; preds = %1
%7 = getelementptr inbounds [3 x i64], [3 x i64]* %2, i64 0, i64 0
%8 = getelementptr inbounds [3 x i64], [3 x i64]* %2, i64 0, i64 1
%9 = getelementptr inbounds [3 x i64], [3 x i64]* %2, i64 0, i64 2
br label %10
10: ; preds = %6, %10
%11 = phi i32 [ 0, %6 ], [ %17, %10 ]
%12 = call i32 @my_fread(i64* %7, i32 24, i32* %0)
%13 = load i64, i64* %7
%14 = load i64, i64* %8
%15 = load i64, i64* %9
%16 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i64 %13, i64 %14, i64 %15)
%17 = add nuw nsw i32 %11, 1
%18 = icmp eq i32 %17, %4
br i1 %18, label %19, label %10
19: ; preds = %10, %1
ret void
}