#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_END;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ memcpy(int *, int *, int);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
scalar_t__ strcmp(char *, char *);
void get_entry_offsets(char *tarname, int *roffsets) {
  int offsets[100000];
  char magic[5];
  int oi, i, size = 0;
  FILE *tar;
  tar = fopen(tarname, "rb");
  fseek(tar, 0, SEEK_END);
  size = ftell(tar);
  rewind(tar);
  for (i = 257; i <= size; i++) {
    fseek(tar, i, SEEK_SET);
    fgets(magic, 6, tar);
    if (strcmp(magic, "ustar") == 0 || strcmp(magic, "ustar ") == 0) {
      offsets[oi] = (i + 249) - 506;
      oi++;
    }
  }
  fclose(tar);
  memcpy(roffsets, offsets, 10000);
}


x86 assembly (clang, -O0):
<get_entry_offsets>:
push   %rbp
mov    %rsp,%rbp
sub    $0x61ab0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x61aa4(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe58(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x61ab0(%rbp)
mov    -0x61ab0(%rbp),%rdi
mov    0x2e26(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1090 <fseek@plt>
mov    -0x61ab0(%rbp),%rdi
call   1070 <ftell@plt>
mov    %eax,-0x61aa4(%rbp)
mov    -0x61ab0(%rbp),%rdi
call   1040 <rewind@plt>
movl   $0x101,-0x61aa0(%rbp)
mov    -0x61aa0(%rbp),%eax
cmp    -0x61aa4(%rbp),%eax
jg     12ba <get_entry_offsets+0x13a>
mov    -0x61ab0(%rbp),%rdi
mov    -0x61aa0(%rbp),%esi
mov    0x2dbf(%rip),%rax
mov    (%rax),%edx
call   1090 <fseek@plt>
lea    -0x61a95(%rbp),%rdi
mov    -0x61ab0(%rbp),%rdx
mov    $0x6,%esi
call   1050 <fgets@plt>
lea    -0x61a95(%rbp),%rdi
lea    0xdbd(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     1272 <get_entry_offsets+0xf2>
lea    -0x61a95(%rbp),%rdi
lea    0xda6(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    12a1 <get_entry_offsets+0x121>
mov    -0x61aa0(%rbp),%ecx
add    $0xf9,%ecx
sub    $0x1fa,%ecx
movslq -0x61a9c(%rbp),%rax
mov    %ecx,-0x61a90(%rbp,%rax,4)
mov    -0x61a9c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x61a9c(%rbp)
jmp    12a6 <get_entry_offsets+0x126>
mov    -0x61aa0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x61aa0(%rbp)
jmp    11f3 <get_entry_offsets+0x73>
mov    -0x61ab0(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x10(%rbp),%rdi
lea    -0x61a90(%rbp),%rsi
mov    $0x2710,%edx
call   1080 <memcpy@plt>
add    $0x61ab0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_entry_offsets>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x61a98,%rsp
mov    %rsi,(%rsp)
lea    0xe64(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%rbx
mov    0x2e3d(%rip),%rax
mov    (%rax),%edx
xor    %r14d,%r14d
mov    %rbx,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
mov    %rbx,%rdi
call   1070 <ftell@plt>
mov    %eax,%r15d
mov    %rbx,%rdi
call   1040 <rewind@plt>
cmp    $0x101,%r15d
jge    1203 <get_entry_offsets+0x83>
mov    %rbx,%rdi
call   1030 <fclose@plt>
lea    0x10(%rsp),%rsi
mov    (%rsp),%rdi
mov    $0x2710,%edx
call   1080 <memcpy@plt>
add    $0x61a98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
add    $0xffffff00,%r15d
lea    0xb(%rsp),%rbp
lea    0xded(%rip),%r12
jmp    1235 <get_entry_offsets+0xb5>
nopl   0x0(%rax,%rax,1)
movslq %r13d,%r13
mov    %r14d,0x10(%rsp,%r13,4)
add    $0x1,%r13d
add    $0x1,%r14d
cmp    %r14d,%r15d
je     11d6 <get_entry_offsets+0x56>
lea    0x101(%r14),%esi
mov    0x2d95(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
call   1090 <fseek@plt>
mov    %rbp,%rdi
mov    $0x6,%esi
mov    %rbx,%rdx
call   1050 <fgets@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1220 <get_entry_offsets+0xa0>
mov    %rbp,%rdi
lea    0xd92(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    122c <get_entry_offsets+0xac>
jmp    1220 <get_entry_offsets+0xa0>

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.1 = [6 x i8] c"ustar\00"
@.str.2 = [7 x i8] c"ustar \00"
define void @get_entry_offsets(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca [100000 x i32]
%6 = alloca [5 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32*
store i8* %0, i8** %3
store i32* %1, i32** %4
store i32 0, i32* %9
%11 = load i8*, i8** %3
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %12, i32** %10
%13 = load i32*, i32** %10
%14 = load i32, i32* @SEEK_END
%15 = call i32 @fseek(i32* %13, i32 0, i32 %14)
%16 = load i32*, i32** %10
%17 = call i32 @ftell(i32* %16)
store i32 %17, i32* %9
%18 = load i32*, i32** %10
%19 = call i32 @rewind(i32* %18)
store i32 257, i32* %8
br label %20
20: ; preds = %49, %2
%21 = load i32, i32* %8
%22 = load i32, i32* %9
%23 = icmp sle i32 %21, %22
br i1 %23, label %24, label %52
24: ; preds = %20
%25 = load i32*, i32** %10
%26 = load i32, i32* %8
%27 = load i32, i32* @SEEK_SET
%28 = call i32 @fseek(i32* %25, i32 %26, i32 %27)
%29 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%30 = load i32*, i32** %10
%31 = call i32 @fgets(i8* %29, i32 6, i32* %30)
%32 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%33 = call i64 @strcmp(i8* %32, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %39, label %35
35: ; preds = %24
%36 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%37 = call i64 @strcmp(i8* %36, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %48
39: ; preds = %35, %24
%40 = load i32, i32* %8
%41 = add nsw i32 %40, 249
%42 = sub nsw i32 %41, 506
%43 = load i32, i32* %7
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [100000 x i32], [100000 x i32]* %5, i64 0, i64 %44
store i32 %42, i32* %45
%46 = load i32, i32* %7
%47 = add nsw i32 %46, 1
store i32 %47, i32* %7
br label %48
48: ; preds = %39, %35
br label %49
49: ; preds = %48
%50 = load i32, i32* %8
%51 = add nsw i32 %50, 1
store i32 %51, i32* %8
br label %20
52: ; preds = %20
%53 = load i32*, i32** %10
%54 = call i32 @fclose(i32* %53)
%55 = load i32*, i32** %4
%56 = getelementptr inbounds [100000 x i32], [100000 x i32]* %5, i64 0, i64 0
%57 = call i32 @memcpy(i32* %55, i32* %56, i32 10000)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.1 = [6 x i8] c"ustar\00"
@.str.2 = [7 x i8] c"ustar \00"
define void @get_entry_offsets(i8* nocapture %0, i32* %1) {
%3 = alloca [100000 x i32]
%4 = alloca [5 x i8]
%5 = bitcast [100000 x i32]* %3 to i8*
%6 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%7 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* @SEEK_END
%9 = tail call i32 @fseek(i32* %7, i32 0, i32 %8)
%10 = tail call i32 @ftell(i32* %7)
%11 = tail call i32 @rewind(i32* %7)
%12 = icmp slt i32 %10, 257
br i1 %12, label %33, label %13
13: ; preds = %2, %29
%14 = phi i32 [ %30, %29 ], [ undef, %2 ]
%15 = phi i32 [ %31, %29 ], [ 257, %2 ]
%16 = load i32, i32* @SEEK_SET
%17 = call i32 @fseek(i32* %7, i32 %15, i32 %16)
%18 = call i32 @fgets(i8* %6, i32 6, i32* %7)
%19 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %24, label %21
21: ; preds = %13
%22 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %29
24: ; preds = %21, %13
%25 = add nsw i32 %15, -257
%26 = sext i32 %14 to i64
%27 = getelementptr inbounds [100000 x i32], [100000 x i32]* %3, i64 0, i64 %26
store i32 %25, i32* %27
%28 = add nsw i32 %14, 1
br label %29
29: ; preds = %21, %24
%30 = phi i32 [ %28, %24 ], [ %14, %21 ]
%31 = add nuw i32 %15, 1
%32 = icmp eq i32 %15, %10
br i1 %32, label %33, label %13
33: ; preds = %29, %2
%34 = call i32 @fclose(i32* %7)
%35 = getelementptr inbounds [100000 x i32], [100000 x i32]* %3, i64 0, i64 0
%36 = call i32 @memcpy(i32* %1, i32* %35, i32 10000)
ret void
}