#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*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *,
                           char const *, char *);
scalar_t__ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int try_fseek_start(FILE *f, const char *name, const char *func) {
  if (0 != fseek(f, 0, SEEK_SET)) {
    fprintf(stderr, "%s : Couldn't seek on %s : %s\n", func, name,
            strerror(errno));
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<try_fseek_start>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e81(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1040 <fseek@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     11b6 <try_fseek_start+0x86>
mov    0x2e73(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    0x2e4f(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    -0x34(%rbp),%edi
mov    -0x30(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    %rax,%r8
lea    0xe5b(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11bd <try_fseek_start+0x8d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<try_fseek_start>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%rbx
mov    0x2e8f(%rip),%rax
mov    (%rax),%edx
xor    %ebp,%ebp
xor    %esi,%esi
call   1040 <fseek@plt>
test   %rax,%rax
je     1184 <try_fseek_start+0x54>
mov    0x2e88(%rip),%rax
mov    (%rax),%ebp
mov    0x2e77(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
lea    0xe91(%rip),%rsi
mov    %ebp,%edi
mov    %r14,%rdx
mov    %rbx,%rcx
mov    %rax,%r8
call   1030 <fprintf@plt>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@SEEK_SET = global i32 0
@stderr = global i32 0
@.str = [31 x i8] c"%s : Couldn't seek on %s : %s\0A\00"
@errno = global i32 0
define i32 @try_fseek_start(i32* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i8*
store i32* %0, i32** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%8 = load i32*, i32** %5
%9 = load i32, i32* @SEEK_SET
%10 = call i64 @fseek(i32* %8, i32 0, i32 %9)
%11 = icmp ne i64 0, %10
br i1 %11, label %12, label %19
12: ; preds = %3
%13 = load i32, i32* @stderr
%14 = load i8*, i8** %7
%15 = load i8*, i8** %6
%16 = load i32, i32* @errno
%17 = call i8* @strerror(i32 %16)
%18 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %14, i8* %15, i8* %17)
store i32 -1, i32* %4
br label %20
19: ; preds = %3
store i32 0, i32* %4
br label %20
20: ; preds = %19, %12
%21 = load i32, i32* %4
ret i32 %21
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
@stderr = global i32 0
@.str = [31 x i8] c"%s : Couldn't seek on %s : %s\0A\00"
@errno = global i32 0
define i32 @try_fseek_start(i32* nocapture %0, i8* %1, i8* %2) {
%4 = load i32, i32* @SEEK_SET
%5 = tail call i64 @fseek(i32* %0, i32 0, i32 %4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %12, label %7
7: ; preds = %3
%8 = load i32, i32* @stderr
%9 = load i32, i32* @errno
%10 = tail call i8* @strerror(i32 %9)
%11 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %2, i8* %1, i8* %10)
br label %12
12: ; preds = %3, %7
%13 = phi i32 [ -1, %7 ], [ 0, %3 ]
ret i32 %13
}