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

/* Variables and functions */
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ assert(int);
char *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
scalar_t__ ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int);
int sscanf(char *, char *, int *, int *);
int time(int /*<<< orphan*/ *);
void print_report(FILE *fd, time_t start, time_t end) {
  assert(start <= end);
  char lbuf[128];
  char *ret;
  int c;
  int tstart, tend, tsum = 0, tnow = time(NULL);
  if (ftell(fd) != 0)
    fseek(fd, 0, SEEK_SET);
  while ((ret = fgets(lbuf, 128, fd)) != NULL) {
    c = sscanf(lbuf, "%i %i", &tstart, &tend);
    if (tstart >= start && tend <= end) {
      if (c == 1) {
        tsum += (tnow - tstart);
      } else {
        tsum += (tend - tstart);
      }
    }
  }
  printf("%i\n", (int)tsum);
}


x86 assembly (clang, -O0):
<print_report>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
setle  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
movl   $0x0,-0xa8(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,-0xac(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <ftell@plt>
cmp    $0x0,%rax
je     11d8 <print_report+0x68>
mov    -0x8(%rbp),%rdi
mov    0x2e11(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1090 <fseek@plt>
jmp    11dd <print_report+0x6d>
lea    -0x90(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x80,%esi
call   1040 <fgets@plt>
mov    %rax,-0x98(%rbp)
cmp    $0x0,%rax
je     1294 <print_report+0x124>
lea    -0x90(%rbp),%rdi
lea    0xdef(%rip),%rsi
lea    -0xa0(%rbp),%rdx
lea    -0xa4(%rbp),%rcx
call   1080 <sscanf@plt>
mov    %eax,-0x9c(%rbp)
mov    -0xa0(%rbp),%eax
cmp    -0xc(%rbp),%eax
jl     128f <print_report+0x11f>
mov    -0xa4(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     128f <print_report+0x11f>
cmpl   $0x1,-0x9c(%rbp)
jne    1272 <print_report+0x102>
mov    -0xac(%rbp),%eax
sub    -0xa0(%rbp),%eax
add    -0xa8(%rbp),%eax
mov    %eax,-0xa8(%rbp)
jmp    128a <print_report+0x11a>
mov    -0xa4(%rbp),%eax
sub    -0xa0(%rbp),%eax
add    -0xa8(%rbp),%eax
mov    %eax,-0xa8(%rbp)
jmp    128f <print_report+0x11f>
jmp    11dd <print_report+0x6d>
mov    -0xa8(%rbp),%esi
lea    0xd65(%rip),%rdi
call   1030 <printf@plt>
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_report>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    %esi,%r15d
mov    %rdi,%rbx
xor    %edi,%edi
mov    %edx,0x4(%rsp)
cmp    %edx,%esi
setle  %dil
call   1050 <assert@plt>
xor    %ebp,%ebp
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,(%rsp)
mov    %rbx,%rdi
call   1060 <ftell@plt>
test   %rax,%rax
je     11c4 <print_report+0x54>
mov    0x2e28(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
lea    0x10(%rsp),%rdi
mov    $0x80,%esi
mov    %rbx,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     1249 <print_report+0xd9>
xor    %ebp,%ebp
lea    0x10(%rsp),%r12
lea    0xc(%rsp),%r14
lea    0x8(%rsp),%r13
jmp    1215 <print_report+0xa5>
sub    %ecx,%ebp
add    %edx,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r12,%rdi
mov    $0x80,%esi
mov    %rbx,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     1249 <print_report+0xd9>
mov    %r12,%rdi
lea    0xde1(%rip),%rsi
mov    %r14,%rdx
mov    %r13,%rcx
call   1080 <sscanf@plt>
mov    0xc(%rsp),%ecx
cmp    %r15d,%ecx
jl     1200 <print_report+0x90>
mov    0x8(%rsp),%edx
cmp    0x4(%rsp),%edx
jg     1200 <print_report+0x90>
cmp    $0x1,%eax
jne    11ee <print_report+0x7e>
add    (%rsp),%ebp
sub    %ecx,%ebp
jmp    1200 <print_report+0x90>
lea    0xdb6(%rip),%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@SEEK_SET = global i32 0
@.str = [6 x i8] c"%i %i\00"
@.str.1 = [4 x i8] c"%i\0A\00"
define void @print_report(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca [128 x i8]
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%14 = load i32, i32* %5
%15 = load i32, i32* %6
%16 = icmp sle i32 %14, %15
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
store i32 0, i32* %12
%19 = call i32 @time(i32* null)
store i32 %19, i32* %13
%20 = load i32*, i32** %4
%21 = call i64 @ftell(i32* %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %3
%24 = load i32*, i32** %4
%25 = load i32, i32* @SEEK_SET
%26 = call i32 @fseek(i32* %24, i32 0, i32 %25)
br label %27
27: ; preds = %23, %3
br label %28
28: ; preds = %59, %27
%29 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%30 = load i32*, i32** %4
%31 = call i8* @fgets(i8* %29, i32 128, i32* %30)
store i8* %31, i8** %8
%32 = icmp ne i8* %31, null
br i1 %32, label %33, label %60
33: ; preds = %28
%34 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%35 = call i32 @sscanf(i8* %34, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %10, i32* %11)
store i32 %35, i32* %9
%36 = load i32, i32* %10
%37 = load i32, i32* %5
%38 = icmp sge i32 %36, %37
br i1 %38, label %39, label %59
39: ; preds = %33
%40 = load i32, i32* %11
%41 = load i32, i32* %6
%42 = icmp sle i32 %40, %41
br i1 %42, label %43, label %59
43: ; preds = %39
%44 = load i32, i32* %9
%45 = icmp eq i32 %44, 1
br i1 %45, label %46, label %52
46: ; preds = %43
%47 = load i32, i32* %13
%48 = load i32, i32* %10
%49 = sub nsw i32 %47, %48
%50 = load i32, i32* %12
%51 = add nsw i32 %50, %49
store i32 %51, i32* %12
br label %58
52: ; preds = %43
%53 = load i32, i32* %11
%54 = load i32, i32* %10
%55 = sub nsw i32 %53, %54
%56 = load i32, i32* %12
%57 = add nsw i32 %56, %55
store i32 %57, i32* %12
br label %58
58: ; preds = %52, %46
br label %59
59: ; preds = %58, %39, %33
br label %28
60: ; preds = %28
%61 = load i32, i32* %12
%62 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %61)
ret void
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
@.str = [6 x i8] c"%i %i\00"
@.str.1 = [4 x i8] c"%i\0A\00"
define void @print_report(i32* nocapture %0, i32 %1, i32 %2) {
%4 = alloca [128 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = icmp sle i32 %1, %2
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
%10 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%11 = bitcast i32* %5 to i8*
%12 = bitcast i32* %6 to i8*
%13 = tail call i32 @time(i32* null)
%14 = tail call i64 @ftell(i32* %0)
%15 = icmp eq i64 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %3
%17 = load i32, i32* @SEEK_SET
%18 = tail call i32 @fseek(i32* %0, i32 0, i32 %17)
br label %19
19: ; preds = %16, %3
%20 = call i8* @fgets(i8* %10, i32 128, i32* %0)
%21 = icmp eq i8* %20, null
br i1 %21, label %42, label %22
22: ; preds = %19, %38
%23 = phi i32 [ %39, %38 ], [ 0, %19 ]
%24 = call i32 @sscanf(i8* %10, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %5, i32* %6)
%25 = load i32, i32* %5
%26 = icmp slt i32 %25, %1
br i1 %26, label %38, label %27
27: ; preds = %22
%28 = load i32, i32* %6
%29 = icmp sgt i32 %28, %2
br i1 %29, label %38, label %30
30: ; preds = %27
%31 = icmp eq i32 %24, 1
br i1 %31, label %32, label %35
32: ; preds = %30
%33 = add i32 %23, %13
%34 = sub i32 %33, %25
br label %38
35: ; preds = %30
%36 = sub i32 %23, %25
%37 = add i32 %36, %28
br label %38
38: ; preds = %32, %35, %27, %22
%39 = phi i32 [ %34, %32 ], [ %37, %35 ], [ %23, %27 ], [ %23, %22 ]
%40 = call i8* @fgets(i8* %10, i32 128, i32* %0)
%41 = icmp eq i8* %40, null
br i1 %41, label %42, label %22
42: ; preds = %38, %19
%43 = phi i32 [ 0, %19 ], [ %39, %38 ]
%44 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %43)
ret void
}