#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*/ fpos_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fsetpos(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int /*<<< orphan*/);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
void tranfile(FILE *f, fpos_t *pos) {
  fseek(f, 100, SEEK_SET);
  printf("current position is: %ld\n", ftell(f));
  fsetpos(f, pos);
  printf("current position is: %ld\n", ftell(f));
  fseek(f, -100, SEEK_END);
  printf("current position is: %ld\n", ftell(f));
  rewind(f);
  printf("current position is: %ld\n", ftell(f));
}


x86 assembly (clang, -O0):
<tranfile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2e6d(%rip),%rax
mov    (%rax),%edx
mov    $0x64,%esi
call   1060 <fseek@plt>
mov    -0x8(%rbp),%rdi
call   1050 <ftell@plt>
mov    %eax,%esi
lea    0xe77(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1070 <fsetpos@plt>
mov    -0x8(%rbp),%rdi
call   1050 <ftell@plt>
mov    %eax,%esi
lea    0xe53(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    0x2e2b(%rip),%rax
mov    (%rax),%edx
mov    $0xffffff9c,%esi
call   1060 <fseek@plt>
mov    -0x8(%rbp),%rdi
call   1050 <ftell@plt>
mov    %eax,%esi
lea    0xe25(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1040 <rewind@plt>
mov    -0x8(%rbp),%rdi
call   1050 <ftell@plt>
mov    %eax,%esi
lea    0xe05(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tranfile>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%rbx
mov    0x2e76(%rip),%rax
mov    (%rax),%edx
mov    $0x64,%esi
call   1060 <fseek@plt>
mov    %rbx,%rdi
call   1050 <ftell@plt>
lea    0xe83(%rip),%r14
mov    %r14,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1070 <fsetpos@plt>
mov    %rbx,%rdi
call   1050 <ftell@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    0x2e3d(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0xffffff9c,%esi
call   1060 <fseek@plt>
mov    %rbx,%rdi
call   1050 <ftell@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1040 <rewind@plt>
mov    %rbx,%rdi
call   1050 <ftell@plt>
mov    %r14,%rdi
mov    %eax,%esi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <printf@plt>

LLVM IR (-O0):
@SEEK_SET = global i32 0
@.str = [26 x i8] c"current position is: %ld\0A\00"
@SEEK_END = global i32 0
define void @tranfile(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
store i32* %0, i32** %3
store i32* %1, i32** %4
%5 = load i32*, i32** %3
%6 = load i32, i32* @SEEK_SET
%7 = call i32 @fseek(i32* %5, i32 100, i32 %6)
%8 = load i32*, i32** %3
%9 = call i32 @ftell(i32* %8)
%10 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = load i32*, i32** %3
%12 = load i32*, i32** %4
%13 = call i32 @fsetpos(i32* %11, i32* %12)
%14 = load i32*, i32** %3
%15 = call i32 @ftell(i32* %14)
%16 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = load i32*, i32** %3
%18 = load i32, i32* @SEEK_END
%19 = call i32 @fseek(i32* %17, i32 -100, i32 %18)
%20 = load i32*, i32** %3
%21 = call i32 @ftell(i32* %20)
%22 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %21)
%23 = load i32*, i32** %3
%24 = call i32 @rewind(i32* %23)
%25 = load i32*, i32** %3
%26 = call i32 @ftell(i32* %25)
%27 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %26)
ret void
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
@.str = [26 x i8] c"current position is: %ld\0A\00"
@SEEK_END = global i32 0
define void @tranfile(i32* nocapture %0, i32* %1) {
%3 = load i32, i32* @SEEK_SET
%4 = tail call i32 @fseek(i32* %0, i32 100, i32 %3)
%5 = tail call i32 @ftell(i32* %0)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = tail call i32 @fsetpos(i32* %0, i32* %1)
%8 = tail call i32 @ftell(i32* %0)
%9 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = load i32, i32* @SEEK_END
%11 = tail call i32 @fseek(i32* %0, i32 -100, i32 %10)
%12 = tail call i32 @ftell(i32* %0)
%13 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = tail call i32 @rewind(i32* %0)
%15 = tail call i32 @ftell(i32* %0)
%16 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %15)
ret void
}