#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 */
int /*<<< orphan*/ printf(char *, int, int);
void solve2(int n, int m) {
  int l, r;
  for (l = 1; l <= n; l++) {
    int sum = 0;
    for (r = l; r <= n; r++) {
      sum += r;
      if (sum == m)
        printf("[%d,%d]\n", l, r);
    }
  }
}


x86 assembly (clang, -O0):
<solve2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     1197 <solve2+0x87>
movl   $0x0,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     1184 <solve2+0x74>
mov    -0x10(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    1171 <solve2+0x61>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe94(%rip),%rdi
call   1030 <printf@plt>
jmp    1176 <solve2+0x66>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113e <solve2+0x2e>
jmp    1189 <solve2+0x79>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1125 <solve2+0x15>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<solve2>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,0x4(%rsp)
test   %edi,%edi
jle    1189 <solve2+0x79>
mov    %esi,%r13d
mov    0x4(%rsp),%eax
mov    %eax,%ebx
neg    %ebx
mov    $0x1,%r12d
lea    0xec5(%rip),%r15
jmp    114f <solve2+0x3f>
nopl   (%rax)
lea    0x1(%r12),%eax
cmp    0x4(%rsp),%r12d
mov    %eax,%r12d
je     1189 <solve2+0x79>
xor    %r14d,%r14d
mov    %r12d,%ebp
jmp    1172 <solve2+0x62>
nopw   0x0(%rax,%rax,1)
lea    (%rbx,%rbp,1),%eax
add    $0x1,%eax
mov    %ebp,%ecx
add    $0x1,%ecx
mov    %ecx,%ebp
cmp    $0x1,%eax
je     1140 <solve2+0x30>
add    %ebp,%r14d
cmp    %r13d,%r14d
jne    1160 <solve2+0x50>
mov    %r15,%rdi
mov    %r12d,%esi
mov    %ebp,%edx
call   1030 <printf@plt>
jmp    1160 <solve2+0x50>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"[%d,%d]\0A\00"
define void @solve2(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 1, i32* %5
br label %8
8: ; preds = %34, %2
%9 = load i32, i32* %5
%10 = load i32, i32* %3
%11 = icmp sle i32 %9, %10
br i1 %11, label %12, label %37
12: ; preds = %8
store i32 0, i32* %7
%13 = load i32, i32* %5
store i32 %13, i32* %6
br label %14
14: ; preds = %30, %12
%15 = load i32, i32* %6
%16 = load i32, i32* %3
%17 = icmp sle i32 %15, %16
br i1 %17, label %18, label %33
18: ; preds = %14
%19 = load i32, i32* %6
%20 = load i32, i32* %7
%21 = add nsw i32 %20, %19
store i32 %21, i32* %7
%22 = load i32, i32* %7
%23 = load i32, i32* %4
%24 = icmp eq i32 %22, %23
br i1 %24, label %25, label %29
25: ; preds = %18
%26 = load i32, i32* %5
%27 = load i32, i32* %6
%28 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %26, i32 %27)
br label %29
29: ; preds = %25, %18
br label %30
30: ; preds = %29
%31 = load i32, i32* %6
%32 = add nsw i32 %31, 1
store i32 %32, i32* %6
br label %14
33: ; preds = %14
br label %34
34: ; preds = %33
%35 = load i32, i32* %5
%36 = add nsw i32 %35, 1
store i32 %36, i32* %5
br label %8
37: ; preds = %8
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"[%d,%d]\0A\00"
define void @solve2(i32 %0, i32 %1) {
%3 = icmp slt i32 %0, 1
br i1 %3, label %19, label %4
4: ; preds = %2, %16
%5 = phi i32 [ %17, %16 ], [ 1, %2 ]
br label %6
6: ; preds = %4, %13
%7 = phi i32 [ %9, %13 ], [ 0, %4 ]
%8 = phi i32 [ %14, %13 ], [ %5, %4 ]
%9 = add nuw nsw i32 %7, %8
%10 = icmp eq i32 %9, %1
br i1 %10, label %11, label %13
11: ; preds = %6
%12 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %8)
br label %13
13: ; preds = %6, %11
%14 = add nuw i32 %8, 1
%15 = icmp eq i32 %8, %0
br i1 %15, label %16, label %6
16: ; preds = %13
%17 = add nuw i32 %5, 1
%18 = icmp eq i32 %5, %0
br i1 %18, label %19, label %4
19: ; preds = %16, %2
ret void
}