#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 */
scalar_t__ EOF;
int /*<<< orphan*/ SEEK_SET;
scalar_t__ fputc(char, int /*<<< orphan*/ *);
scalar_t__ fseek(int /*<<< orphan*/ *, unsigned long, int /*<<< orphan*/);
unsigned long ftell(int /*<<< orphan*/ *);
int SetHelpFilePosition(FILE *ofptr, int pos, unsigned long offset, int index) {
  int i;
  unsigned long fpos = ftell(ofptr);
  if (fseek(ofptr,
            pos * sizeof(unsigned long) * 3 + sizeof(unsigned long) * index +
                sizeof(int),
            SEEK_SET))
    return 1;
  for (i = 0; i < sizeof(unsigned long); i++)
    if (fputc(*(((char *)(&offset)) + i), ofptr) == EOF)
      return 1;
  if (fseek(ofptr, fpos, SEEK_SET))
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<SetHelpFilePosition>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <ftell@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rax
shl    $0x3,%rax
imul   $0x3,%rax,%rsi
movslq -0x24(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
add    $0x4,%rsi
mov    0x2e5f(%rip),%rax
mov    (%rax),%edx
call   1050 <fseek@plt>
cmp    $0x0,%rax
je     1196 <SetHelpFilePosition+0x66>
movl   $0x1,-0x4(%rbp)
jmp    1221 <SetHelpFilePosition+0xf1>
movl   $0x0,-0x28(%rbp)
movslq -0x28(%rbp),%rax
cmp    $0x8,%rax
jae    11ee <SetHelpFilePosition+0xbe>
movslq -0x28(%rbp),%rax
mov    -0x20(%rbp,%rax,1),%al
mov    -0x10(%rbp),%rsi
movsbl %al,%edi
call   1030 <fputc@plt>
mov    0x2e22(%rip),%rcx
cmp    (%rcx),%rax
jne    11db <SetHelpFilePosition+0xab>
movl   $0x1,-0x4(%rbp)
jmp    1221 <SetHelpFilePosition+0xf1>
jmp    11e0 <SetHelpFilePosition+0xb0>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    119d <SetHelpFilePosition+0x6d>
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    0x2ddb(%rip),%rax
mov    (%rax),%edx
call   1050 <fseek@plt>
cmp    $0x0,%rax
je     121a <SetHelpFilePosition+0xea>
movl   $0x1,-0x4(%rbp)
jmp    1221 <SetHelpFilePosition+0xf1>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SetHelpFilePosition>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%ebp
mov    %rdx,%r15
mov    %esi,%ebx
mov    %rdi,%r12
call   1040 <ftell@plt>
mov    %rax,%r14
movslq %ebx,%rax
lea    (%rax,%rax,2),%rax
shl    $0x3,%rax
movslq %ebp,%rcx
lea    (%rax,%rcx,8),%rsi
add    $0x4,%rsi
mov    0x2e6e(%rip),%rbx
mov    (%rbx),%edx
mov    %r12,%rdi
call   1050 <fseek@plt>
mov    $0x1,%ebp
test   %rax,%rax
jne    1263 <SetHelpFilePosition+0x133>
movsbl %r15b,%edi
mov    %r12,%rsi
call   1030 <fputc@plt>
mov    0x2e53(%rip),%r13
cmp    0x0(%r13),%rax
je     1263 <SetHelpFilePosition+0x133>
mov    %r15,%rax
shr    $0x8,%rax
movsbl %al,%edi
mov    %r12,%rsi
call   1030 <fputc@plt>
cmp    0x0(%r13),%rax
je     1263 <SetHelpFilePosition+0x133>
mov    %r15,%rax
shr    $0x10,%rax
movsbl %al,%edi
mov    %r12,%rsi
call   1030 <fputc@plt>
cmp    0x0(%r13),%rax
je     1263 <SetHelpFilePosition+0x133>
mov    %r15,%rax
shr    $0x18,%rax
movsbl %al,%edi
mov    %r12,%rsi
call   1030 <fputc@plt>
cmp    0x0(%r13),%rax
je     1263 <SetHelpFilePosition+0x133>
mov    %r15,%rax
shr    $0x20,%rax
movsbl %al,%edi
mov    %r12,%rsi
call   1030 <fputc@plt>
cmp    0x0(%r13),%rax
je     1263 <SetHelpFilePosition+0x133>
mov    %r15,%rax
shr    $0x28,%rax
movsbl %al,%edi
mov    %r12,%rsi
call   1030 <fputc@plt>
cmp    0x0(%r13),%rax
je     1263 <SetHelpFilePosition+0x133>
mov    %r15,%rax
shr    $0x30,%rax
movsbl %al,%edi
mov    %r12,%rsi
call   1030 <fputc@plt>
cmp    0x0(%r13),%rax
je     1263 <SetHelpFilePosition+0x133>
shr    $0x38,%r15
movsbl %r15b,%edi
mov    %r12,%rsi
call   1030 <fputc@plt>
cmp    0x0(%r13),%rax
je     1263 <SetHelpFilePosition+0x133>
mov    (%rbx),%edx
mov    %r12,%rdi
mov    %r14,%rsi
call   1050 <fseek@plt>
xor    %ebp,%ebp
test   %rax,%rax
setne  %bpl
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@SEEK_SET = global i32 0
@EOF = global i64 0
define i32 @SetHelpFilePosition(i32* %0, i32 %1, i64 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32
%11 = alloca i64
store i32* %0, i32** %6
store i32 %1, i32* %7
store i64 %2, i64* %8
store i32 %3, i32* %9
%12 = load i32*, i32** %6
%13 = call i64 @ftell(i32* %12)
store i64 %13, i64* %11
%14 = load i32*, i32** %6
%15 = load i32, i32* %7
%16 = sext i32 %15 to i64
%17 = mul i64 %16, 8
%18 = mul i64 %17, 3
%19 = load i32, i32* %9
%20 = sext i32 %19 to i64
%21 = mul i64 8, %20
%22 = add i64 %18, %21
%23 = add i64 %22, 4
%24 = load i32, i32* @SEEK_SET
%25 = call i64 @fseek(i32* %14, i64 %23, i32 %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %4
store i32 1, i32* %5
br label %56
28: ; preds = %4
store i32 0, i32* %10
br label %29
29: ; preds = %45, %28
%30 = load i32, i32* %10
%31 = sext i32 %30 to i64
%32 = icmp ult i64 %31, 8
br i1 %32, label %33, label %48
33: ; preds = %29
%34 = bitcast i64* %8 to i8*
%35 = load i32, i32* %10
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %34, i64 %36
%38 = load i8, i8* %37
%39 = load i32*, i32** %6
%40 = call i64 @fputc(i8 signext %38, i32* %39)
%41 = load i64, i64* @EOF
%42 = icmp eq i64 %40, %41
br i1 %42, label %43, label %44
43: ; preds = %33
store i32 1, i32* %5
br label %56
44: ; preds = %33
br label %45
45: ; preds = %44
%46 = load i32, i32* %10
%47 = add nsw i32 %46, 1
store i32 %47, i32* %10
br label %29
48: ; preds = %29
%49 = load i32*, i32** %6
%50 = load i64, i64* %11
%51 = load i32, i32* @SEEK_SET
%52 = call i64 @fseek(i32* %49, i64 %50, i32 %51)
%53 = icmp ne i64 %52, 0
br i1 %53, label %54, label %55
54: ; preds = %48
store i32 1, i32* %5
br label %56
55: ; preds = %48
store i32 0, i32* %5
br label %56
56: ; preds = %55, %54, %43, %27
%57 = load i32, i32* %5
ret i32 %57
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
@EOF = global i64 0
define i32 @SetHelpFilePosition(i32* nocapture %0, i32 %1, i64 %2, i32 %3) {
%5 = lshr i64 %2, 8
%6 = trunc i64 %5 to i8
%7 = lshr i64 %2, 16
%8 = trunc i64 %7 to i8
%9 = lshr i64 %2, 24
%10 = trunc i64 %9 to i8
%11 = lshr i64 %2, 32
%12 = trunc i64 %11 to i8
%13 = lshr i64 %2, 40
%14 = trunc i64 %13 to i8
%15 = lshr i64 %2, 48
%16 = trunc i64 %15 to i8
%17 = lshr i64 %2, 56
%18 = trunc i64 %17 to i8
%19 = tail call i64 @ftell(i32* %0)
%20 = sext i32 %1 to i64
%21 = mul nsw i64 %20, 24
%22 = sext i32 %3 to i64
%23 = shl nsw i64 %22, 3
%24 = add nsw i64 %23, %21
%25 = or i64 %24, 4
%26 = load i32, i32* @SEEK_SET
%27 = tail call i64 @fseek(i32* %0, i64 %25, i32 %26)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %67
29: ; preds = %4
%30 = trunc i64 %2 to i8
%31 = tail call i64 @fputc(i8 signext %30, i32* %0)
%32 = load i64, i64* @EOF
%33 = icmp eq i64 %31, %32
br i1 %33, label %67, label %34
34: ; preds = %29
%35 = tail call i64 @fputc(i8 signext %6, i32* %0)
%36 = load i64, i64* @EOF
%37 = icmp eq i64 %35, %36
br i1 %37, label %67, label %38
38: ; preds = %34
%39 = tail call i64 @fputc(i8 signext %8, i32* %0)
%40 = load i64, i64* @EOF
%41 = icmp eq i64 %39, %40
br i1 %41, label %67, label %42
42: ; preds = %38
%43 = tail call i64 @fputc(i8 signext %10, i32* %0)
%44 = load i64, i64* @EOF
%45 = icmp eq i64 %43, %44
br i1 %45, label %67, label %46
46: ; preds = %42
%47 = tail call i64 @fputc(i8 signext %12, i32* %0)
%48 = load i64, i64* @EOF
%49 = icmp eq i64 %47, %48
br i1 %49, label %67, label %50
50: ; preds = %46
%51 = tail call i64 @fputc(i8 signext %14, i32* %0)
%52 = load i64, i64* @EOF
%53 = icmp eq i64 %51, %52
br i1 %53, label %67, label %54
54: ; preds = %50
%55 = tail call i64 @fputc(i8 signext %16, i32* %0)
%56 = load i64, i64* @EOF
%57 = icmp eq i64 %55, %56
br i1 %57, label %67, label %58
58: ; preds = %54
%59 = tail call i64 @fputc(i8 signext %18, i32* %0)
%60 = load i64, i64* @EOF
%61 = icmp eq i64 %59, %60
br i1 %61, label %67, label %62
62: ; preds = %58
%63 = load i32, i32* @SEEK_SET
%64 = tail call i64 @fseek(i32* %0, i64 %19, i32 %63)
%65 = icmp ne i64 %64, 0
%66 = zext i1 %65 to i32
br label %67
67: ; preds = %29, %34, %38, %42, %46, %50, %54, %58, %62, %4
%68 = phi i32 [ 1, %4 ], [ %66, %62 ], [ 1, %58 ], [ 1, %54 ], [ 1, %50 ], [ 1, %46 ], [ 1, %42 ], [ 1, %38 ], [ 1, %34 ], [ 1, %29 ]
ret i32 %68
}