#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;
char *fextract(int /*<<< orphan*/ *, long, long);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, long const, int /*<<< orphan*/);
long fstrchr(int /*<<< orphan*/ *, long, char);
long ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
char *get_tooltip_text(FILE *stream) {
  char *ttext = NULL;
  const long stream_pos = ftell(stream);
  rewind(stream);
  long start_pos = fstrchr(stream, ftell(stream), '\'');
  if (-1 == start_pos) {
    fprintf(stderr, "couldnt' find tooltip text in file\n");
    goto clean_exit;
  }
  long end_pos = fstrchr(stream, ftell(stream), '\n');
  if (-1 == end_pos) {
    fprintf(stderr, "formatting error, tooltip text invalid\n");
    goto clean_exit;
  }
  ttext = fextract(stream, start_pos + 1, end_pos - 1);
clean_exit:
  fseek(stream, stream_pos, SEEK_SET);
  return ttext;
}


x86 assembly (clang, -O0):
<get_tooltip_text>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <ftell@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <rewind@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <ftell@plt>
mov    -0x30(%rbp),%rdi
mov    %rax,%rsi
mov    $0x27,%edx
call   1030 <fstrchr@plt>
mov    %rax,-0x20(%rbp)
mov    $0xffffffffffffffff,%rax
cmp    -0x20(%rbp),%rax
jne    11db <get_tooltip_text+0x7b>
mov    0x2e18(%rip),%rax
mov    (%rax),%edi
lea    0xe2f(%rip),%rsi
call   1050 <fprintf@plt>
jmp    1249 <get_tooltip_text+0xe9>
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <ftell@plt>
mov    -0x38(%rbp),%rdi
mov    %rax,%rsi
mov    $0xa,%edx
call   1030 <fstrchr@plt>
mov    %rax,-0x28(%rbp)
mov    $0xffffffffffffffff,%rax
cmp    -0x28(%rbp),%rax
jne    122c <get_tooltip_text+0xcc>
mov    0x2dc7(%rip),%rax
mov    (%rax),%edi
lea    0xe02(%rip),%rsi
call   1050 <fprintf@plt>
jmp    1249 <get_tooltip_text+0xe9>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
add    $0x1,%rsi
mov    -0x28(%rbp),%rdx
sub    $0x1,%rdx
call   1070 <fextract@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    0x2d80(%rip),%rax
mov    (%rax),%edx
call   1080 <fseek@plt>
mov    -0x10(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_tooltip_text>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
call   1060 <ftell@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1040 <rewind@plt>
mov    %rbx,%rdi
call   1060 <ftell@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
mov    $0x27,%edx
call   1030 <fstrchr@plt>
cmp    $0xffffffffffffffff,%rax
je     11d2 <get_tooltip_text+0x72>
mov    %rax,%r15
mov    %rbx,%rdi
call   1060 <ftell@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
mov    $0xa,%edx
call   1030 <fstrchr@plt>
cmp    $0xffffffffffffffff,%rax
je     11e4 <get_tooltip_text+0x84>
add    $0x1,%r15
add    $0xffffffffffffffff,%rax
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %rax,%rdx
call   1070 <fextract@plt>
mov    %rax,%r15
jmp    11fc <get_tooltip_text+0x9c>
mov    0x2e07(%rip),%rax
mov    (%rax),%edi
lea    0xe1e(%rip),%rsi
jmp    11f4 <get_tooltip_text+0x94>
mov    0x2df5(%rip),%rax
mov    (%rax),%edi
lea    0xe30(%rip),%rsi
call   1050 <fprintf@plt>
xor    %r15d,%r15d
mov    0x2dd5(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1080 <fseek@plt>
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [36 x i8] c"couldnt' find tooltip text in file\0A\00"
@.str.1 = [40 x i8] c"formatting error, tooltip text invalid\0A\00"
@SEEK_SET = global i32 0
define i8* @get_tooltip_text(i32* %0) {
%2 = alloca i32*
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
store i32* %0, i32** %2
store i8* null, i8** %3
%7 = load i32*, i32** %2
%8 = call i64 @ftell(i32* %7)
store i64 %8, i64* %4
%9 = load i32*, i32** %2
%10 = call i32 @rewind(i32* %9)
%11 = load i32*, i32** %2
%12 = load i32*, i32** %2
%13 = call i64 @ftell(i32* %12)
%14 = call i64 @fstrchr(i32* %11, i64 %13, i8 signext 39)
store i64 %14, i64* %5
%15 = load i64, i64* %5
%16 = icmp eq i64 -1, %15
br i1 %16, label %17, label %20
17: ; preds = %1
%18 = load i32, i32* @stderr
%19 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
br label %37
20: ; preds = %1
%21 = load i32*, i32** %2
%22 = load i32*, i32** %2
%23 = call i64 @ftell(i32* %22)
%24 = call i64 @fstrchr(i32* %21, i64 %23, i8 signext 10)
store i64 %24, i64* %6
%25 = load i64, i64* %6
%26 = icmp eq i64 -1, %25
br i1 %26, label %27, label %30
27: ; preds = %20
%28 = load i32, i32* @stderr
%29 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
br label %37
30: ; preds = %20
%31 = load i32*, i32** %2
%32 = load i64, i64* %5
%33 = add nsw i64 %32, 1
%34 = load i64, i64* %6
%35 = sub nsw i64 %34, 1
%36 = call i8* @fextract(i32* %31, i64 %33, i64 %35)
store i8* %36, i8** %3
br label %37
37: ; preds = %30, %27, %17
%38 = load i32*, i32** %2
%39 = load i64, i64* %4
%40 = load i32, i32* @SEEK_SET
%41 = call i32 @fseek(i32* %38, i64 %39, i32 %40)
%42 = load i8*, i8** %3
ret i8* %42
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [36 x i8] c"couldnt' find tooltip text in file\0A\00"
@.str.1 = [40 x i8] c"formatting error, tooltip text invalid\0A\00"
@SEEK_SET = global i32 0
define i8* @get_tooltip_text(i32* %0) {
%2 = tail call i64 @ftell(i32* %0)
%3 = tail call i32 @rewind(i32* %0)
%4 = tail call i64 @ftell(i32* %0)
%5 = tail call i64 @fstrchr(i32* %0, i64 %4, i8 signext 39)
%6 = icmp eq i64 %5, -1
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
br label %21
10: ; preds = %1
%11 = tail call i64 @ftell(i32* %0)
%12 = tail call i64 @fstrchr(i32* %0, i64 %11, i8 signext 10)
%13 = icmp eq i64 %12, -1
br i1 %13, label %14, label %17
14: ; preds = %10
%15 = load i32, i32* @stderr
%16 = tail call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
br label %21
17: ; preds = %10
%18 = add nuw nsw i64 %5, 1
%19 = add nsw i64 %12, -1
%20 = tail call i8* @fextract(i32* %0, i64 %18, i64 %19)
br label %21
21: ; preds = %17, %14, %7
%22 = phi i8* [ null, %7 ], [ null, %14 ], [ %20, %17 ]
%23 = load i32, i32* @SEEK_SET
%24 = tail call i32 @fseek(i32* %0, i64 %2, i32 %23)
ret i8* %22
}