#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_CUR;
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
scalar_t__ ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int);
int main() {
  FILE *f;
  f = fopen("tmp.txt", "r");
  printf("\nI am at: %d\n", (int)ftell(f));
  getc(f);
  printf("\nNow I am at: %d\n", (int)ftell(f));
  fseek(f, 1, SEEK_CUR);
  printf("\nNow I am back at: %d\n", (int)ftell(f));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
lea    0xe9b(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <ftell@plt>
mov    %eax,%esi
lea    0xe82(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1070 <getc@plt>
mov    -0x10(%rbp),%rdi
call   1040 <ftell@plt>
mov    %eax,%esi
lea    0xe70(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    0x2e30(%rip),%rax
mov    (%rax),%edx
mov    $0x1,%esi
call   1050 <fseek@plt>
mov    -0x10(%rbp),%rdi
call   1040 <ftell@plt>
mov    %eax,%esi
lea    0xe54(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xea8(%rip),%rdi
lea    0xea9(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <ftell@plt>
lea    0xe94(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1070 <getc@plt>
mov    %rbx,%rdi
call   1040 <ftell@plt>
lea    0xe84(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    0x2e46(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0x1,%esi
call   1050 <fseek@plt>
mov    %rbx,%rdi
call   1040 <ftell@plt>
lea    0xe6a(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [8 x i8] c"tmp.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [14 x i8] c"\0AI am at: %d\0A\00"
@.str.3 = [18 x i8] c"\0ANow I am at: %d\0A\00"
@SEEK_CUR = global i32 0
@.str.4 = [23 x i8] c"\0ANow I am back at: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
store i32 0, i32* %1
%3 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %3, i32** %2
%4 = load i32*, i32** %2
%5 = call i64 @ftell(i32* %4)
%6 = trunc i64 %5 to i32
%7 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %6)
%8 = load i32*, i32** %2
%9 = call i32 @getc(i32* %8)
%10 = load i32*, i32** %2
%11 = call i64 @ftell(i32* %10)
%12 = trunc i64 %11 to i32
%13 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 %12)
%14 = load i32*, i32** %2
%15 = load i32, i32* @SEEK_CUR
%16 = call i32 @fseek(i32* %14, i32 1, i32 %15)
%17 = load i32*, i32** %2
%18 = call i64 @ftell(i32* %17)
%19 = trunc i64 %18 to i32
%20 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %19)
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"tmp.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [14 x i8] c"\0AI am at: %d\0A\00"
@.str.3 = [18 x i8] c"\0ANow I am at: %d\0A\00"
@SEEK_CUR = global i32 0
@.str.4 = [23 x i8] c"\0ANow I am back at: %d\0A\00"
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i64 @ftell(i32* %1)
%3 = trunc i64 %2 to i32
%4 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %3)
%5 = tail call i32 @getc(i32* %1)
%6 = tail call i64 @ftell(i32* %1)
%7 = trunc i64 %6 to i32
%8 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 %7)
%9 = load i32, i32* @SEEK_CUR
%10 = tail call i32 @fseek(i32* %1, i32 1, i32 %9)
%11 = tail call i64 @ftell(i32* %1)
%12 = trunc i64 %11 to i32
%13 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %12)
ret i32 0
}