program main
    implicit none
    integer(8) n
    integer(8) sum, n3, n5, n15
    integer(8) sub
    read(*,*) n

    sum = n*(n+1)/2
    
    n3 = (n - mod(n,3))/3
    n5 = (n - mod(n,5))/5
    n15 = (n - mod(n,15))/15
    
    sub = 3*n3*(n3+1)/2 + 5*n5*(n5+1)/2 - 15*n15*(n15+1)/2

    write(*,*) sum-sub
    
end program
; ModuleID = 'FIRModule'
source_filename = "FIRModule"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"

@_QQcl.565c5b58e972de8c3346cbee9812ed17 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_1790/source.f\00"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

define void @_QQmain() local_unnamed_addr {
  %1 = alloca i64, align 8
  %2 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.565c5b58e972de8c3346cbee9812ed17, i32 6)
  %3 = call i1 @_FortranAioInputInteger(ptr %2, ptr nonnull %1, i32 8)
  %4 = call i32 @_FortranAioEndIoStatement(ptr %2)
  %5 = load i64, ptr %1, align 8, !tbaa !3
  %6 = add i64 %5, 1
  %7 = mul i64 %6, %5
  %8 = sdiv i64 %7, 2
  %9 = sdiv i64 %5, 3
  %10 = sdiv i64 %5, 5
  %11 = sdiv i64 %5, 15
  %12 = mul nsw i64 %9, 3
  %13 = add nsw i64 %9, 1
  %14 = mul i64 %12, %13
  %.neg5 = sdiv i64 %14, -2
  %15 = mul nsw i64 %10, 5
  %16 = add nsw i64 %10, 1
  %17 = mul i64 %15, %16
  %.neg6 = sdiv i64 %17, -2
  %18 = mul nsw i64 %11, 15
  %19 = add nsw i64 %11, 1
  %20 = mul i64 %18, %19
  %.neg.neg = sdiv i64 %20, 2
  %21 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.565c5b58e972de8c3346cbee9812ed17, i32 16)
  %.neg7 = add nsw i64 %.neg6, %8
  %.neg8 = add i64 %.neg7, %.neg5
  %22 = add i64 %.neg8, %.neg.neg
  %23 = call i1 @_FortranAioOutputInteger64(ptr %21, i64 %22)
  %24 = call i32 @_FortranAioEndIoStatement(ptr %21)
  ret void
}

declare ptr @_FortranAioBeginExternalListInput(i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioInputInteger(ptr, ptr, i32) local_unnamed_addr

declare i32 @_FortranAioEndIoStatement(ptr) local_unnamed_addr

declare ptr @_FortranAioBeginExternalListOutput(i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioOutputInteger64(ptr, i64) local_unnamed_addr

!llvm.module.flags = !{!0, !1, !2}

!0 = !{i32 2, !"Debug Info Version", i32 3}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{!4, !4, i64 0}
!4 = !{!"any data access", !5, i64 0}
!5 = !{!"any access", !6, i64 0}
!6 = !{!"Flang Type TBAA Root"}
