#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 */

/* Variables and functions */
long long Spsum(long long, long long);
long long pow(int, int);
long long presum(int);
long long int Difsum(long long int x, long long int y, int d1, int d2) {
  long long int s = 0;
  int i;
  s = s + Spsum(x, (pow(10, d1) - 1));
  s = s + Spsum(pow(10, d2 - 1), y);
  for (i = d1 + 1; i < d2; i++)
    s = s + presum(i);
  return s;
}


x86 assembly (clang, -O0):
<Difsum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x14(%rbp),%esi
mov    $0xa,%edi
call   1050 <pow@plt>
mov    -0x40(%rbp),%rdi
mov    %rax,%rsi
sub    $0x1,%rsi
call   1030 <Spsum@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%esi
sub    $0x1,%esi
mov    $0xa,%edi
call   1050 <pow@plt>
mov    %rax,%rdi
mov    -0x10(%rbp),%rsi
call   1030 <Spsum@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11fc <Difsum+0xcc>
mov    -0x20(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x24(%rbp),%edi
call   1040 <presum@plt>
mov    %rax,%rcx
mov    -0x48(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11c4 <Difsum+0x94>
mov    -0x20(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Difsum>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %ecx,%r14d
mov    %edx,%ebp
mov    %rsi,%r15
mov    %rdi,%rbx
mov    $0xa,%edi
mov    %edx,%esi
call   1050 <pow@plt>
lea    -0x1(%rax),%rsi
mov    %rbx,%rdi
call   1030 <Spsum@plt>
mov    %rax,%r12
lea    -0x1(%r14),%esi
mov    $0xa,%edi
call   1050 <pow@plt>
mov    %rax,%rdi
mov    %r15,%rsi
call   1030 <Spsum@plt>
mov    %rax,%rbx
add    %r12,%rbx
add    $0x1,%ebp
cmp    %r14d,%ebp
jge    11a2 <Difsum+0x72>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebp,%edi
call   1040 <presum@plt>
add    %rax,%rbx
add    $0x1,%ebp
cmp    %ebp,%r14d
jne    1190 <Difsum+0x60>
mov    %rbx,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i64 @Difsum(i64 %0, i64 %1, i32 %2, i32 %3) {
%5 = alloca i64
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
%9 = alloca i64
%10 = alloca i32
store i64 %0, i64* %5
store i64 %1, i64* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store i64 0, i64* %9
%11 = load i64, i64* %9
%12 = load i64, i64* %5
%13 = load i32, i32* %7
%14 = call i64 @pow(i32 10, i32 %13)
%15 = sub nsw i64 %14, 1
%16 = call i64 @Spsum(i64 %12, i64 %15)
%17 = add nsw i64 %11, %16
store i64 %17, i64* %9
%18 = load i64, i64* %9
%19 = load i32, i32* %8
%20 = sub nsw i32 %19, 1
%21 = call i64 @pow(i32 10, i32 %20)
%22 = load i64, i64* %6
%23 = call i64 @Spsum(i64 %21, i64 %22)
%24 = add nsw i64 %18, %23
store i64 %24, i64* %9
%25 = load i32, i32* %7
%26 = add nsw i32 %25, 1
store i32 %26, i32* %10
br label %27
27: ; preds = %36, %4
%28 = load i32, i32* %10
%29 = load i32, i32* %8
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %39
31: ; preds = %27
%32 = load i64, i64* %9
%33 = load i32, i32* %10
%34 = call i64 @presum(i32 %33)
%35 = add nsw i64 %32, %34
store i64 %35, i64* %9
br label %36
36: ; preds = %31
%37 = load i32, i32* %10
%38 = add nsw i32 %37, 1
store i32 %38, i32* %10
br label %27
39: ; preds = %27
%40 = load i64, i64* %9
ret i64 %40
}

LLVM IR (-O2):
define i64 @Difsum(i64 %0, i64 %1, i32 %2, i32 %3) {
%5 = tail call i64 @pow(i32 10, i32 %2)
%6 = add nsw i64 %5, -1
%7 = tail call i64 @Spsum(i64 %0, i64 %6)
%8 = add nsw i32 %3, -1
%9 = tail call i64 @pow(i32 10, i32 %8)
%10 = tail call i64 @Spsum(i64 %9, i64 %1)
%11 = add nsw i64 %10, %7
%12 = add nsw i32 %2, 1
%13 = icmp slt i32 %12, %3
br i1 %13, label %14, label %21
14: ; preds = %4, %14
%15 = phi i32 [ %19, %14 ], [ %12, %4 ]
%16 = phi i64 [ %18, %14 ], [ %11, %4 ]
%17 = tail call i64 @presum(i32 %15)
%18 = add nsw i64 %17, %16
%19 = add i32 %15, 1
%20 = icmp eq i32 %19, %3
br i1 %20, label %21, label %14
21: ; preds = %14, %4
%22 = phi i64 [ %11, %4 ], [ %18, %14 ]
ret i64 %22
}