#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*/ free(char *);
int /*<<< orphan*/ printf(char *, unsigned int, char *);
unsigned int sis32toh(unsigned int);
scalar_t__ sisRead(int /*<<< orphan*/ *, ...);
char *sisReadOffsetAlloc(int /*<<< orphan*/ *, unsigned int, unsigned int,
                         char *, int);
int /*<<< orphan*/ uni2ascii(char *, unsigned int);
int optionsFile(FILE *fp, char *err, int errlen) {
  unsigned int numopt, j;
  unsigned char selected[16];
  if (sisRead(fp, &numopt, 4, err, errlen))
    return 1;
  numopt = sis32toh(numopt);
  for (j = 0; j < numopt; j++) {
    unsigned int optlen, optoff;
    char *optstr;
    if (sisRead(fp, &optlen, 4, err, errlen))
      return 1;
    if (sisRead(fp, &optoff, 4, err, errlen))
      return 1;
    optlen = sis32toh(optlen);
    optoff = sis32toh(optoff);
    if ((optstr = sisReadOffsetAlloc(fp, optlen, optoff, err, errlen)) == NULL)
      return 1;
    uni2ascii(optstr, optlen);
    printf("  option %d: %s\n", numopt - j, optstr);
    free(optstr);
  }
  if (sisRead(fp, selected, 16, err, errlen))
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<optionsFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    -0x1c(%rbp),%r8d
lea    -0x20(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   1070 <sisRead@plt>
cmp    $0x0,%rax
je     11a5 <optionsFile+0x45>
movl   $0x1,-0x4(%rbp)
jmp    12e0 <optionsFile+0x180>
mov    -0x20(%rbp),%edi
call   1040 <sis32toh@plt>
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x20(%rbp),%eax
jae    12a7 <optionsFile+0x147>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    -0x1c(%rbp),%r8d
lea    -0x44(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   1070 <sisRead@plt>
cmp    $0x0,%rax
je     11f5 <optionsFile+0x95>
movl   $0x1,-0x4(%rbp)
jmp    12e0 <optionsFile+0x180>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    -0x1c(%rbp),%r8d
lea    -0x48(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   1070 <sisRead@plt>
cmp    $0x0,%rax
je     1227 <optionsFile+0xc7>
movl   $0x1,-0x4(%rbp)
jmp    12e0 <optionsFile+0x180>
mov    -0x44(%rbp),%edi
call   1040 <sis32toh@plt>
mov    %eax,-0x44(%rbp)
mov    -0x48(%rbp),%edi
call   1040 <sis32toh@plt>
mov    %eax,-0x48(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x44(%rbp),%esi
mov    -0x48(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    -0x1c(%rbp),%r8d
call   1080 <sisReadOffsetAlloc@plt>
mov    %rax,-0x50(%rbp)
cmp    $0x0,%rax
jne    126e <optionsFile+0x10e>
movl   $0x1,-0x4(%rbp)
jmp    12e0 <optionsFile+0x180>
mov    -0x50(%rbp),%rdi
mov    -0x44(%rbp),%esi
call   1060 <uni2ascii@plt>
mov    -0x20(%rbp),%esi
sub    -0x24(%rbp),%esi
mov    -0x50(%rbp),%rdx
lea    0xd75(%rip),%rdi
call   1050 <printf@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11b7 <optionsFile+0x57>
mov    -0x10(%rbp),%rdi
lea    -0x40(%rbp),%rsi
mov    -0x18(%rbp),%rcx
mov    -0x1c(%rbp),%r8d
mov    $0x10,%edx
mov    $0x0,%al
call   1070 <sisRead@plt>
cmp    $0x0,%rax
je     12d9 <optionsFile+0x179>
movl   $0x1,-0x4(%rbp)
jmp    12e0 <optionsFile+0x180>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<optionsFile>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %rdi,%rbp
lea    0x8(%rsp),%rsi
mov    $0x4,%edx
mov    %rbx,%rcx
mov    %r14d,%r8d
xor    %eax,%eax
call   1070 <sisRead@plt>
mov    $0x1,%ecx
test   %rax,%rax
jne    12a2 <optionsFile+0x142>
mov    0x8(%rsp),%edi
call   1040 <sis32toh@plt>
mov    %eax,0x8(%rsp)
test   %eax,%eax
je     1279 <optionsFile+0x119>
xor    %r12d,%r12d
xor    %r15d,%r15d
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rdi
lea    0x10(%rsp),%rsi
mov    $0x4,%edx
mov    %rbx,%rcx
mov    %r14d,%r8d
xor    %eax,%eax
call   1070 <sisRead@plt>
test   %rax,%rax
jne    129d <optionsFile+0x13d>
mov    %rbp,%rdi
lea    0xc(%rsp),%rsi
mov    $0x4,%edx
mov    %rbx,%rcx
mov    %r14d,%r8d
xor    %eax,%eax
call   1070 <sisRead@plt>
test   %rax,%rax
jne    129d <optionsFile+0x13d>
mov    0x10(%rsp),%edi
call   1040 <sis32toh@plt>
mov    %eax,0x10(%rsp)
mov    0xc(%rsp),%edi
call   1040 <sis32toh@plt>
mov    %eax,0xc(%rsp)
mov    0x10(%rsp),%esi
mov    %rbp,%rdi
mov    %eax,%edx
mov    %rbx,%rcx
mov    %r14d,%r8d
call   1080 <sisReadOffsetAlloc@plt>
test   %rax,%rax
je     129d <optionsFile+0x13d>
mov    %rax,%r13
mov    0x10(%rsp),%esi
mov    %rax,%rdi
call   1060 <uni2ascii@plt>
mov    0x8(%rsp),%esi
add    %r12d,%esi
lea    0xdaa(%rip),%rdi
mov    %r13,%rdx
call   1050 <printf@plt>
mov    %r13,%rdi
call   1030 <free@plt>
add    $0x1,%r15d
add    $0xffffffff,%r12d
cmp    0x8(%rsp),%r15d
jb     11c0 <optionsFile+0x60>
lea    0x10(%rsp),%rsi
mov    %rbp,%rdi
mov    $0x10,%edx
mov    %rbx,%rcx
mov    %r14d,%r8d
xor    %eax,%eax
call   1070 <sisRead@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
jmp    12a2 <optionsFile+0x142>
mov    $0x1,%ecx
mov    %ecx,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c" option %d: %s\0A\00"
define i32 @optionsFile(i32* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [16 x i8]
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8*
store i32* %0, i32** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%14 = load i32*, i32** %5
%15 = load i8*, i8** %6
%16 = load i32, i32* %7
%17 = call i64 (i32*, ...) @sisRead(i32* %14, i32* %8, i32 4, i8* %15, i32 %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %3
store i32 1, i32* %4
br label %77
20: ; preds = %3
%21 = load i32, i32* %8
%22 = call i32 @sis32toh(i32 %21)
store i32 %22, i32* %8
store i32 0, i32* %9
br label %23
23: ; preds = %65, %20
%24 = load i32, i32* %9
%25 = load i32, i32* %8
%26 = icmp ult i32 %24, %25
br i1 %26, label %27, label %68
27: ; preds = %23
%28 = load i32*, i32** %5
%29 = load i8*, i8** %6
%30 = load i32, i32* %7
%31 = call i64 (i32*, ...) @sisRead(i32* %28, i32* %11, i32 4, i8* %29, i32 %30)
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %27
store i32 1, i32* %4
br label %77
34: ; preds = %27
%35 = load i32*, i32** %5
%36 = load i8*, i8** %6
%37 = load i32, i32* %7
%38 = call i64 (i32*, ...) @sisRead(i32* %35, i32* %12, i32 4, i8* %36, i32 %37)
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %41
40: ; preds = %34
store i32 1, i32* %4
br label %77
41: ; preds = %34
%42 = load i32, i32* %11
%43 = call i32 @sis32toh(i32 %42)
store i32 %43, i32* %11
%44 = load i32, i32* %12
%45 = call i32 @sis32toh(i32 %44)
store i32 %45, i32* %12
%46 = load i32*, i32** %5
%47 = load i32, i32* %11
%48 = load i32, i32* %12
%49 = load i8*, i8** %6
%50 = load i32, i32* %7
%51 = call i8* @sisReadOffsetAlloc(i32* %46, i32 %47, i32 %48, i8* %49, i32 %50)
store i8* %51, i8** %13
%52 = icmp eq i8* %51, null
br i1 %52, label %53, label %54
53: ; preds = %41
store i32 1, i32* %4
br label %77
54: ; preds = %41
%55 = load i8*, i8** %13
%56 = load i32, i32* %11
%57 = call i32 @uni2ascii(i8* %55, i32 %56)
%58 = load i32, i32* %8
%59 = load i32, i32* %9
%60 = sub i32 %58, %59
%61 = load i8*, i8** %13
%62 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %60, i8* %61)
%63 = load i8*, i8** %13
%64 = call i32 @free(i8* %63)
br label %65
65: ; preds = %54
%66 = load i32, i32* %9
%67 = add i32 %66, 1
store i32 %67, i32* %9
br label %23
68: ; preds = %23
%69 = load i32*, i32** %5
%70 = getelementptr inbounds [16 x i8], [16 x i8]* %10, i64 0, i64 0
%71 = load i8*, i8** %6
%72 = load i32, i32* %7
%73 = call i64 (i32*, ...) @sisRead(i32* %69, i8* %70, i32 16, i8* %71, i32 %72)
%74 = icmp ne i64 %73, 0
br i1 %74, label %75, label %76
75: ; preds = %68
store i32 1, i32* %4
br label %77
76: ; preds = %68
store i32 0, i32* %4
br label %77
77: ; preds = %76, %75, %53, %40, %33, %19
%78 = load i32, i32* %4
ret i32 %78
}

LLVM IR (-O2):
@.str = [17 x i8] c" option %d: %s\0A\00"
define i32 @optionsFile(i32* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca [16 x i8]
%6 = alloca i32
%7 = alloca i32
%8 = bitcast i32* %4 to i8*
%9 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%10 = call i64 (i32*, ...) @sisRead(i32* %0, i32* %4, i32 4, i8* %1, i32 %2)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %49
12: ; preds = %3
%13 = load i32, i32* %4
%14 = call i32 @sis32toh(i32 %13)
store i32 %14, i32* %4
%15 = icmp eq i32 %14, 0
br i1 %15, label %45, label %16
16: ; preds = %12
%17 = bitcast i32* %6 to i8*
%18 = bitcast i32* %7 to i8*
br label %19
19: ; preds = %16, %34
%20 = phi i32 [ 0, %16 ], [ %41, %34 ]
%21 = call i64 (i32*, ...) @sisRead(i32* %0, i32* %6, i32 4, i8* %1, i32 %2)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %44
23: ; preds = %19
%24 = call i64 (i32*, ...) @sisRead(i32* %0, i32* %7, i32 4, i8* %1, i32 %2)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %44
26: ; preds = %23
%27 = load i32, i32* %6
%28 = call i32 @sis32toh(i32 %27)
store i32 %28, i32* %6
%29 = load i32, i32* %7
%30 = call i32 @sis32toh(i32 %29)
store i32 %30, i32* %7
%31 = load i32, i32* %6
%32 = call i8* @sisReadOffsetAlloc(i32* %0, i32 %31, i32 %30, i8* %1, i32 %2)
%33 = icmp eq i8* %32, null
br i1 %33, label %44, label %34
34: ; preds = %26
%35 = load i32, i32* %6
%36 = call i32 @uni2ascii(i8* %32, i32 %35)
%37 = load i32, i32* %4
%38 = sub i32 %37, %20
%39 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %38, i8* %32)
%40 = call i32 @free(i8* %32)
%41 = add nuw i32 %20, 1
%42 = load i32, i32* %4
%43 = icmp ult i32 %41, %42
br i1 %43, label %19, label %45
44: ; preds = %26, %23, %19
br label %49
45: ; preds = %34, %12
%46 = call i64 (i32*, ...) @sisRead(i32* %0, i8* %9, i32 16, i8* %1, i32 %2)
%47 = icmp ne i64 %46, 0
%48 = zext i1 %47 to i32
br label %49
49: ; preds = %45, %44, %3
%50 = phi i32 [ 1, %44 ], [ 1, %3 ], [ %48, %45 ]
ret i32 %50
}