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

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int fscanf_s(int /*<<< orphan*/ *, char *, int *, int *);
int /*<<< orphan*/ stdout;
int read_first_values(FILE *fIn, int *N, int *M) {
  int res = 0;
  res = fscanf_s(fIn, "%d%d", N, M);
  if (res < 2) {
    fprintf(stdout, "bad number of lines\n");
    return (-1);
  }
  if (!(0 <= *N && *N <= 5000)) {
    fprintf(stdout, "bad number of vertices\n");
    return (-1);
  }
  if (!(0 <= *M && *M <= (*N) * (*N + 1) / 2)) {
    fprintf(stdout, "bad number of edges\n");
    return (-1);
  }
  return (0);
}


x86 assembly (clang, -O0):
<read_first_values>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xeb2(%rip),%rsi
call   1040 <fscanf_s@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x2,-0x24(%rbp)
jge    1181 <read_first_values+0x61>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
lea    0xe95(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1226 <read_first_values+0x106>
mov    -0x18(%rbp),%rcx
xor    %eax,%eax
cmp    (%rcx),%eax
jg     119f <read_first_values+0x7f>
mov    -0x18(%rbp),%rax
cmpl   $0x1388,(%rax)
jle    11c0 <read_first_values+0xa0>
mov    0x2e3a(%rip),%rax
mov    (%rax),%edi
lea    0xe6b(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1226 <read_first_values+0x106>
mov    -0x20(%rbp),%rcx
xor    %eax,%eax
cmp    (%rcx),%eax
jg     11fe <read_first_values+0xde>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    -0x18(%rbp),%rcx
mov    (%rcx),%ecx
add    $0x1,%ecx
imul   %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
cmp    %ecx,%eax
jle    121f <read_first_values+0xff>
mov    0x2ddb(%rip),%rax
mov    (%rax),%edi
lea    0xe24(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1226 <read_first_values+0x106>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_first_values>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbx
lea    0xecf(%rip),%rsi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1040 <fscanf_s@plt>
cmp    $0x2,%eax
jge    114a <read_first_values+0x2a>
lea    0xebd(%rip),%rsi
jmp    1178 <read_first_values+0x58>
mov    (%rbx),%eax
cmp    $0x1388,%eax
ja     1171 <read_first_values+0x51>
mov    (%r14),%ecx
lea    0xed5(%rip),%rsi
test   %ecx,%ecx
js     1178 <read_first_values+0x58>
lea    0x1(%rax),%edx
imul   %eax,%edx
shr    %edx
xor    %eax,%eax
cmp    %edx,%ecx
ja     1178 <read_first_values+0x58>
jmp    118b <read_first_values+0x6b>
lea    0xea2(%rip),%rsi
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
call   1030 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%d%d\00"
@stdout = global i32 0
@.str.1 = [21 x i8] c"bad number of lines\0A\00"
@.str.2 = [24 x i8] c"bad number of vertices\0A\00"
@.str.3 = [21 x i8] c"bad number of edges\0A\00"
define i32 @read_first_values(i32* %0, i32* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i32 0, i32* %8
%9 = load i32*, i32** %5
%10 = load i32*, i32** %6
%11 = load i32*, i32** %7
%12 = call i32 @fscanf_s(i32* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %10, i32* %11)
store i32 %12, i32* %8
%13 = load i32, i32* %8
%14 = icmp slt i32 %13, 2
br i1 %14, label %15, label %18
15: ; preds = %3
%16 = load i32, i32* @stdout
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %4
br label %48
18: ; preds = %3
%19 = load i32*, i32** %6
%20 = load i32, i32* %19
%21 = icmp sle i32 0, %20
br i1 %21, label %22, label %26
22: ; preds = %18
%23 = load i32*, i32** %6
%24 = load i32, i32* %23
%25 = icmp sle i32 %24, 5000
br i1 %25, label %29, label %26
26: ; preds = %22, %18
%27 = load i32, i32* @stdout
%28 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %4
br label %48
29: ; preds = %22
%30 = load i32*, i32** %7
%31 = load i32, i32* %30
%32 = icmp sle i32 0, %31
br i1 %32, label %33, label %44
33: ; preds = %29
%34 = load i32*, i32** %7
%35 = load i32, i32* %34
%36 = load i32*, i32** %6
%37 = load i32, i32* %36
%38 = load i32*, i32** %6
%39 = load i32, i32* %38
%40 = add nsw i32 %39, 1
%41 = mul nsw i32 %37, %40
%42 = sdiv i32 %41, 2
%43 = icmp sle i32 %35, %42
br i1 %43, label %47, label %44
44: ; preds = %33, %29
%45 = load i32, i32* @stdout
%46 = call i32 @fprintf(i32 %45, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %4
br label %48
47: ; preds = %33
store i32 0, i32* %4
br label %48
48: ; preds = %47, %44, %26, %15
%49 = load i32, i32* %4
ret i32 %49
}

LLVM IR (-O2):
@.str = [5 x i8] c"%d%d\00"
@stdout = global i32 0
@.str.1 = [21 x i8] c"bad number of lines\0A\00"
@.str.2 = [24 x i8] c"bad number of vertices\0A\00"
@.str.3 = [21 x i8] c"bad number of edges\0A\00"
define i32 @read_first_values(i32* %0, i32* %1, i32* %2) {
%4 = tail call i32 @fscanf_s(i32* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%5 = icmp slt i32 %4, 2
br i1 %5, label %17, label %6
6: ; preds = %3
%7 = load i32, i32* %1
%8 = icmp ult i32 %7, 5001
br i1 %8, label %9, label %17
9: ; preds = %6
%10 = load i32, i32* %2
%11 = icmp sgt i32 %10, -1
br i1 %11, label %12, label %17
12: ; preds = %9
%13 = add nuw nsw i32 %7, 1
%14 = mul nuw nsw i32 %13, %7
%15 = lshr i32 %14, 1
%16 = icmp ugt i32 %10, %15
br i1 %16, label %17, label %21
17: ; preds = %9, %12, %6, %3
%18 = phi i8* [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), %3 ], [ getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), %6 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), %12 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), %9 ]
%19 = load i32, i32* @stdout
%20 = tail call i32 @fprintf(i32 %19, i8* %18)
br label %21
21: ; preds = %17, %12
%22 = phi i32 [ 0, %12 ], [ -1, %17 ]
ret i32 %22
}