#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);
int /*<<< orphan*/ scanf(char *, int *, ...);
void test_case() {
  int l, n;
  scanf("%d %d", &l, &n);
  int min_max = 0, max_max = 0;
  while (n--) {
    int m, k;
    scanf("%d", &m);
    k = l - m;
    if (m < k)
      m ^= k ^= m ^= k;
    if (k > min_max)
      min_max = k;
    if (m > max_max)
      max_max = m;
  }
  printf("%d %d\n", min_max, max_max);
}


x86 assembly (clang, -O0):
<test_case>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xed1(%rip),%rdi
lea    -0x4(%rbp),%rsi
lea    -0x8(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
je     11c5 <test_case+0xa5>
lea    0xe9c(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x4(%rbp),%eax
sub    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    119c <test_case+0x7c>
mov    -0x18(%rbp),%eax
xor    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
xor    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
xor    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    11ae <test_case+0x8e>
mov    -0x18(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jle    11c0 <test_case+0xa0>
mov    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    114c <test_case+0x2c>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe34(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_case>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xecf(%rip),%rdi
xor    %ebx,%ebx
lea    0x14(%rsp),%rsi
lea    0xc(%rsp),%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
subl   $0x1,0xc(%rsp)
mov    $0x0,%ebp
jb     1192 <test_case+0x72>
lea    0xeac(%rip),%r14
lea    0x10(%rsp),%r15
xor    %ebp,%ebp
xor    %ebx,%ebx
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x14(%rsp),%eax
mov    0x10(%rsp),%ecx
sub    %ecx,%eax
cmp    %eax,%ecx
mov    %ecx,%edx
cmovl  %eax,%edx
cmovl  %ecx,%eax
cmp    %ebx,%eax
cmovg  %eax,%ebx
cmp    %ebp,%edx
cmovg  %edx,%ebp
subl   $0x1,0xc(%rsp)
jae    1160 <test_case+0x40>
lea    0xe6d(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
call   1030 <printf@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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