#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
char *xfread_string(int /*<<< orphan*/ *, char *);
void dump_extern(FILE *fp, char *filename, long fp_start, long fp_end) {
  char *name;
  printf("  External names:\n");
  fseek(fp, fp_start, SEEK_SET);
  while (ftell(fp) < fp_end) {
    name = xfread_string(fp, filename);
    printf("    U         %s\n", name);
  }
}


x86 assembly (clang, -O0):
<dump_extern>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    0x2e6b(%rip),%rax
mov    (%rax),%edx
call   1060 <fseek@plt>
mov    -0x8(%rbp),%rdi
call   1040 <ftell@plt>
cmp    -0x20(%rbp),%rax
jge    11b7 <dump_extern+0x77>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <xfread_string@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rsi
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    117c <dump_extern+0x3c>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_extern>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xea7(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e69(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    %r12,%rsi
call   1070 <fseek@plt>
mov    %rbx,%rdi
call   1050 <ftell@plt>
cmp    %r15,%rax
jge    11c5 <dump_extern+0x75>
lea    0xe68(%rip),%r12
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <xfread_string@plt>
mov    %r12,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1050 <ftell@plt>
cmp    %r15,%rax
jl     11a0 <dump_extern+0x50>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [19 x i8] c" External names:\0A\00"
@SEEK_SET = global i32 0
@.str.1 = [18 x i8] c" U %s\0A\00"
define void @dump_extern(i32* %0, i8* %1, i64 %2, i64 %3) {
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i8*
store i32* %0, i32** %5
store i8* %1, i8** %6
store i64 %2, i64* %7
store i64 %3, i64* %8
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%11 = load i32*, i32** %5
%12 = load i64, i64* %7
%13 = load i32, i32* @SEEK_SET
%14 = call i32 @fseek(i32* %11, i64 %12, i32 %13)
br label %15
15: ; preds = %20, %4
%16 = load i32*, i32** %5
%17 = call i64 @ftell(i32* %16)
%18 = load i64, i64* %8
%19 = icmp slt i64 %17, %18
br i1 %19, label %20, label %26
20: ; preds = %15
%21 = load i32*, i32** %5
%22 = load i8*, i8** %6
%23 = call i8* @xfread_string(i32* %21, i8* %22)
store i8* %23, i8** %9
%24 = load i8*, i8** %9
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %24)
br label %15
26: ; preds = %15
ret void
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
@.str.1 = [18 x i8] c" U %s\0A\00"
@str = [18 x i8] c" External names:\00"
define void @dump_extern(i32* %0, i8* %1, i64 %2, i64 %3) {
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%6 = load i32, i32* @SEEK_SET
%7 = tail call i32 @fseek(i32* %0, i64 %2, i32 %6)
%8 = tail call i64 @ftell(i32* %0)
%9 = icmp slt i64 %8, %3
br i1 %9, label %10, label %15
10: ; preds = %4, %10
%11 = tail call i8* @xfread_string(i32* %0, i8* %1)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = tail call i64 @ftell(i32* %0)
%14 = icmp slt i64 %13, %3
br i1 %14, label %10, label %15
15: ; preds = %10, %4
ret void
}