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

/* Variables and functions */
int /*<<< orphan*/ hexdump(int /*<<< orphan*/, int /*<<< orphan*/ *, int, int);
int /*<<< orphan*/ printf(char *);
int read_record(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ select_fid(int, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ stdout;
void dump_aids(void) {
  uint8_t buf[256];
  int res = 1, i;
  select_fid(0x2f00, buf, 256);
  printf("AIDs:\n");
  for (i = 1; i < 256; i++) {
    res = read_record(buf, 256);
    if (res > 0) {
      printf(" * ");
      hexdump(stdout, buf, res, 1);
      printf("\n");
    } else
      break;
  }
}


x86 assembly (clang, -O0):
<dump_aids>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
movl   $0x1,-0x404(%rbp)
lea    -0x400(%rbp),%rsi
mov    $0x2f00,%edi
mov    $0x100,%edx
call   1060 <select_fid@plt>
lea    0xe8e(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x408(%rbp)
cmpl   $0x100,-0x408(%rbp)
jge    1210 <dump_aids+0xd0>
lea    -0x400(%rbp),%rdi
mov    $0x100,%esi
call   1030 <read_record@plt>
mov    %eax,-0x404(%rbp)
cmpl   $0x0,-0x404(%rbp)
jle    11f2 <dump_aids+0xb2>
lea    0xe4b(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e18(%rip),%rax
mov    (%rax),%edi
lea    -0x400(%rbp),%rsi
mov    -0x404(%rbp),%edx
mov    $0x1,%ecx
call   1050 <hexdump@plt>
lea    0xe1d(%rip),%rdi
call   1040 <printf@plt>
jmp    11f7 <dump_aids+0xb7>
jmp    1210 <dump_aids+0xd0>
jmp    11fc <dump_aids+0xbc>
mov    -0x408(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x408(%rbp)
jmp    1181 <dump_aids+0x41>
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_aids>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x400,%rsp
mov    %rsp,%r15
mov    $0x2f00,%edi
mov    %r15,%rsi
mov    $0x100,%edx
call   1080 <select_fid@plt>
lea    0xe79(%rip),%rdi
call   1040 <puts@plt>
mov    $0xff,%ebx
lea    0xe64(%rip),%r14
mov    0x2e3d(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r15,%rdi
mov    $0x100,%esi
call   1050 <read_record@plt>
test   %eax,%eax
jle    11ed <dump_aids+0x8d>
mov    %eax,%ebp
mov    %r14,%rdi
call   1060 <printf@plt>
mov    (%r12),%edi
mov    %r15,%rsi
mov    %ebp,%edx
mov    $0x1,%ecx
call   1070 <hexdump@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    11b0 <dump_aids+0x50>
add    $0x400,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"AIDs:\0A\00"
@.str.1 = [4 x i8] c" * \00"
@stdout = global i32 0
@.str.2 = [2 x i8] c"\0A\00"
define void @dump_aids() {
%1 = alloca [256 x i32]
%2 = alloca i32
%3 = alloca i32
store i32 1, i32* %2
%4 = getelementptr inbounds [256 x i32], [256 x i32]* %1, i64 0, i64 0
%5 = call i32 @select_fid(i32 12032, i32* %4, i32 256)
%6 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %7
7: ; preds = %24, %0
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 256
br i1 %9, label %10, label %27
10: ; preds = %7
%11 = getelementptr inbounds [256 x i32], [256 x i32]* %1, i64 0, i64 0
%12 = call i32 @read_record(i32* %11, i32 256)
store i32 %12, i32* %2
%13 = load i32, i32* %2
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %22
15: ; preds = %10
%16 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%17 = load i32, i32* @stdout
%18 = getelementptr inbounds [256 x i32], [256 x i32]* %1, i64 0, i64 0
%19 = load i32, i32* %2
%20 = call i32 @hexdump(i32 %17, i32* %18, i32 %19, i32 1)
%21 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %23
22: ; preds = %10
br label %27
23: ; preds = %15
br label %24
24: ; preds = %23
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 1
store i32 %26, i32* %3
br label %7
27: ; preds = %22, %7
ret void
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c" * \00"
@stdout = global i32 0
@str = [6 x i8] c"AIDs:\00"
define void @dump_aids() {
%1 = alloca [256 x i32]
%2 = bitcast [256 x i32]* %1 to i8*
%3 = getelementptr inbounds [256 x i32], [256 x i32]* %1, i64 0, i64 0
%4 = call i32 @select_fid(i32 12032, i32* %3, i32 256)
%5 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
br label %6
6: ; preds = %0, %10
%7 = phi i32 [ 1, %0 ], [ %15, %10 ]
%8 = call i32 @read_record(i32* %3, i32 256)
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %17
10: ; preds = %6
%11 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%12 = load i32, i32* @stdout
%13 = call i32 @hexdump(i32 %12, i32* %3, i32 %8, i32 1)
%14 = call i32 @putchar(i32 10)
%15 = add nuw nsw i32 %7, 1
%16 = icmp eq i32 %15, 256
br i1 %16, label %17, label %6
17: ; preds = %6, %10
ret void
}