#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;
scalar_t__ calloc(int, int);
int /*<<< orphan*/ fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int /*<<< orphan*/ sscanf(char *, char *, int *);
int getTravelStreamLength(FILE *file, int offset) {
  fseek(file, offset, SEEK_SET);
  char *readBuf = (char *)calloc(24, 1);
  fread(readBuf, 23, 1, file);
  int streamLength;
  sscanf(readBuf, "34 0 obj\x0a%d\x0aendobj", &streamLength);
  free(readBuf);
  return streamLength;
}


x86 assembly (clang, -O0):
<getTravelStreamLength>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    0x2e73(%rip),%rax
mov    (%rax),%edx
call   1070 <fseek@plt>
mov    $0x18,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x17,%esi
mov    $0x1,%edx
call   1040 <fread@plt>
mov    -0x18(%rbp),%rdi
lea    0xe57(%rip),%rsi
lea    -0x1c(%rbp),%rdx
call   1060 <sscanf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getTravelStreamLength>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    0x2e82(%rip),%rax
mov    (%rax),%edx
call   1070 <fseek@plt>
mov    $0x18,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x17,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1040 <fread@plt>
lea    0xe6d(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %rbx,%rdi
call   1060 <sscanf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x4(%rsp),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@SEEK_SET = global i32 0
@.str = [18 x i8] c"34 0 obj\0A%d\AEndobj\00"
define i32 @getTravelStreamLength(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%7 = load i32*, i32** %3
%8 = load i32, i32* %4
%9 = load i32, i32* @SEEK_SET
%10 = call i32 @fseek(i32* %7, i32 %8, i32 %9)
%11 = call i64 @calloc(i32 24, i32 1)
%12 = inttoptr i64 %11 to i8*
store i8* %12, i8** %5
%13 = load i8*, i8** %5
%14 = load i32*, i32** %3
%15 = call i32 @fread(i8* %13, i32 23, i32 1, i32* %14)
%16 = load i8*, i8** %5
%17 = call i32 @sscanf(i8* %16, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32* %6)
%18 = load i8*, i8** %5
%19 = call i32 @free(i8* %18)
%20 = load i32, i32* %6
ret i32 %20
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
@.str = [18 x i8] c"34 0 obj\0A%d\AEndobj\00"
define i32 @getTravelStreamLength(i32* nocapture %0, i32 %1) {
%3 = alloca i32
%4 = load i32, i32* @SEEK_SET
%5 = tail call i32 @fseek(i32* %0, i32 %1, i32 %4)
%6 = tail call i64 @calloc(i32 24, i32 1)
%7 = inttoptr i64 %6 to i8*
%8 = tail call i32 @fread(i8* %7, i32 23, i32 1, i32* %0)
%9 = bitcast i32* %3 to i8*
%10 = call i32 @sscanf(i8* %7, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32* %3)
%11 = call i32 @free(i8* %7)
%12 = load i32, i32* %3
ret i32 %12
}