#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*/ fgetlastl(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ sscanf(char *, char *, int *);
scalar_t__ time(int /*<<< orphan*/ *);
void print_elapsed(FILE *fd) {
  char buf[128];
  int tnow = (int)time(NULL);
  int tprev = 0;
  fgetlastl(fd, buf, 128);
  sscanf(buf, "%i", &tprev);
  printf("%i\n", (tnow - tprev));
}


x86 assembly (clang, -O0):
<print_elapsed>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,-0x94(%rbp)
movl   $0x0,-0x98(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x90(%rbp),%rsi
mov    $0x80,%edx
call   1060 <fgetlastl@plt>
lea    -0x90(%rbp),%rdi
lea    0xe75(%rip),%rsi
lea    -0x98(%rbp),%rdx
call   1050 <sscanf@plt>
mov    -0x94(%rbp),%esi
sub    -0x98(%rbp),%esi
lea    0xe59(%rip),%rdi
call   1030 <printf@plt>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_elapsed>:
push   %r15
push   %r14
push   %rbx
sub    $0x90,%rsp
mov    %rdi,%r14
xor    %edi,%edi
call   1040 <time@plt>
mov    %rax,%rbx
movl   $0x0,0xc(%rsp)
lea    0x10(%rsp),%r15
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x80,%edx
call   1060 <fgetlastl@plt>
lea    0xe83(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %r15,%rdi
call   1050 <sscanf@plt>
sub    0xc(%rsp),%ebx
lea    0xe6e(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
add    $0x90,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%i\00"
@.str.1 = [4 x i8] c"%i\0A\00"
define void @print_elapsed(i32* %0) {
%2 = alloca i32*
%3 = alloca [128 x i8]
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %2
%6 = call i64 @time(i32* null)
%7 = trunc i64 %6 to i32
store i32 %7, i32* %4
store i32 0, i32* %5
%8 = load i32*, i32** %2
%9 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%10 = call i32 @fgetlastl(i32* %8, i8* %9, i32 128)
%11 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%12 = call i32 @sscanf(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%13 = load i32, i32* %4
%14 = load i32, i32* %5
%15 = sub nsw i32 %13, %14
%16 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %15)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%i\00"
@.str.1 = [4 x i8] c"%i\0A\00"
define void @print_elapsed(i32* %0) {
%2 = alloca [128 x i8]
%3 = alloca i32
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%5 = tail call i64 @time(i32* null)
%6 = trunc i64 %5 to i32
%7 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%8 = call i32 @fgetlastl(i32* %0, i8* %4, i32 128)
%9 = call i32 @sscanf(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%10 = load i32, i32* %3
%11 = sub nsw i32 %6, %10
%12 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %11)
ret void
}