#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*/ fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
scalar_t__ memcmp(char *, char *, int);
int /*<<< orphan*/ mkpydict(int /*<<< orphan*/ *, char **);
int /*<<< orphan*/ writepyim(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                             char **);
int readandwrite(FILE *in, FILE *out) {
  char buffer[5], *pydict[413];
  fseek(in, 0x1540, SEEK_SET);
  fread(buffer, 1, 4, in);
  if (memcmp(buffer, "\x9D\x01\x00\x00", 4) != 0)
    return -1;
  mkpydict(in, pydict);
  writepyim(in, out, pydict);
  for (size_t i = 0; i < 413; i++)
    free(pydict[i]);
  return 0;
}


x86 assembly (clang, -O0):
<readandwrite>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e62(%rip),%rax
mov    (%rax),%edx
mov    $0x1540,%esi
call   1080 <fseek@plt>
lea    -0x1d(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
mov    $0x4,%edx
call   1040 <fread@plt>
lea    -0x1d(%rbp),%rdi
lea    0xe54(%rip),%rsi
mov    $0x4,%edx
call   1070 <memcmp@plt>
cmp    $0x0,%rax
je     11cc <readandwrite+0x6c>
movl   $0xffffffff,-0x4(%rbp)
jmp    123e <readandwrite+0xde>
mov    -0x10(%rbp),%rdi
lea    -0xd10(%rbp),%rsi
call   1050 <mkpydict@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0xd10(%rbp),%rdx
call   1060 <writepyim@plt>
movq   $0x0,-0xd18(%rbp)
cmpq   $0x19d,-0xd18(%rbp)
jae    1237 <readandwrite+0xd7>
mov    -0xd18(%rbp),%rax
mov    -0xd10(%rbp,%rax,8),%rdi
ff
call   1030 <free@plt>
mov    -0xd18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xd18(%rbp)
jmp    11fb <readandwrite+0x9b>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xd20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readandwrite>:
push   %r15
push   %r14
push   %rbx
sub    $0xd00,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    0x2e67(%rip),%rax
mov    (%rax),%edx
mov    $0x1540,%esi
call   1080 <fseek@plt>
lea    0xb(%rsp),%r15
mov    %r15,%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
lea    0xe5a(%rip),%rsi
mov    %r15,%rdi
mov    $0x4,%edx
call   1070 <memcmp@plt>
mov    $0xffffffff,%r15d
test   %rax,%rax
jne    1207 <readandwrite+0xa7>
lea    0x10(%rsp),%r15
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <mkpydict@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1060 <writepyim@plt>
xor    %r15d,%r15d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x10(%rsp,%rbx,8),%rdi
call   1030 <free@plt>
add    $0x1,%rbx
cmp    $0x19d,%rbx
jne    11f0 <readandwrite+0x90>
mov    %r15d,%eax
add    $0xd00,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@SEEK_SET = global i32 0
@.str = [5 x i8] c"\9D\01\00\00\00"
define i32 @readandwrite(i32* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca [5 x i8]
%7 = alloca [413 x i8*]
%8 = alloca i64
store i32* %0, i32** %4
store i32* %1, i32** %5
%9 = load i32*, i32** %4
%10 = load i32, i32* @SEEK_SET
%11 = call i32 @fseek(i32* %9, i32 5440, i32 %10)
%12 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%13 = load i32*, i32** %4
%14 = call i32 @fread(i8* %12, i32 1, i32 4, i32* %13)
%15 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%16 = call i64 @memcmp(i8* %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %2
store i32 -1, i32* %3
br label %39
19: ; preds = %2
%20 = load i32*, i32** %4
%21 = getelementptr inbounds [413 x i8*], [413 x i8*]* %7, i64 0, i64 0
%22 = call i32 @mkpydict(i32* %20, i8** %21)
%23 = load i32*, i32** %4
%24 = load i32*, i32** %5
%25 = getelementptr inbounds [413 x i8*], [413 x i8*]* %7, i64 0, i64 0
%26 = call i32 @writepyim(i32* %23, i32* %24, i8** %25)
store i64 0, i64* %8
br label %27
27: ; preds = %35, %19
%28 = load i64, i64* %8
%29 = icmp ult i64 %28, 413
br i1 %29, label %30, label %38
30: ; preds = %27
%31 = load i64, i64* %8
%32 = getelementptr inbounds [413 x i8*], [413 x i8*]* %7, i64 0, i64 %31
%33 = load i8*, i8** %32
%34 = call i32 @free(i8* %33)
br label %35
35: ; preds = %30
%36 = load i64, i64* %8
%37 = add i64 %36, 1
store i64 %37, i64* %8
br label %27
38: ; preds = %27
store i32 0, i32* %3
br label %39
39: ; preds = %38, %18
%40 = load i32, i32* %3
ret i32 %40
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
@.str = [5 x i8] c"\9D\01\00\00\00"
define i32 @readandwrite(i32* %0, i32* %1) {
%3 = alloca [5 x i8]
%4 = alloca [413 x i8*]
%5 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
%6 = bitcast [413 x i8*]* %4 to i8*
%7 = load i32, i32* @SEEK_SET
%8 = tail call i32 @fseek(i32* %0, i32 5440, i32 %7)
%9 = call i32 @fread(i8* %5, i32 1, i32 4, i32* %0)
%10 = call i64 @memcmp(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %23
12: ; preds = %2
%13 = getelementptr inbounds [413 x i8*], [413 x i8*]* %4, i64 0, i64 0
%14 = call i32 @mkpydict(i32* %0, i8** %13)
%15 = call i32 @writepyim(i32* %0, i32* %1, i8** %13)
br label %16
16: ; preds = %12, %16
%17 = phi i64 [ 0, %12 ], [ %21, %16 ]
%18 = getelementptr inbounds [413 x i8*], [413 x i8*]* %4, i64 0, i64 %17
%19 = load i8*, i8** %18
%20 = call i32 @free(i8* %19)
%21 = add nuw nsw i64 %17, 1
%22 = icmp eq i64 %21, 413
br i1 %22, label %23, label %16
23: ; preds = %16, %2
%24 = phi i32 [ -1, %2 ], [ 0, %16 ]
ret i32 %24
}