#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*/ free(int *);
int /*<<< orphan*/ getchar();
scalar_t__ malloc(int);
int picnic(int, int, int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main(int argc, char const *argv[]) {
  printf("type the case count: ");
  int case_count;
  scanf("%d", &case_count);
  int i = 0, j = 0;
  int student_count;
  int friendship_count;
  int *friendships;
  for (i = 0; i < case_count; i++) {
    printf("type student count and friendship count for case %d: ", i);
    scanf("%d", &student_count);
    getchar();
    scanf("%d", &friendship_count);
    friendships = (int *)malloc(sizeof(int) * 2 * friendship_count);
    printf("please input the friendships: ");
    for (j = 0; j < 2 * friendship_count;) {
      scanf("%d", &friendships[j++]);
      getchar();
      scanf("%d", &friendships[j++]);
    }
    printf("%d\n", picnic(student_count, friendship_count, friendships));
    free(friendships);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe8b(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1080 <scanf@plt>
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    12b0 <main+0x150>
mov    -0x18(%rbp),%esi
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe49(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1080 <scanf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
lea    0xe32(%rip),%rdi
lea    -0x24(%rbp),%rsi
call   1080 <scanf@plt>
movslq -0x24(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x30(%rbp)
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x24(%rbp),%ecx
shl    $0x1,%ecx
cmp    %ecx,%eax
jge    127a <main+0x11a>
mov    -0x30(%rbp),%rsi
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x1c(%rbp)
cltq
shl    $0x2,%rax
add    %rax,%rsi
lea    0xdd1(%rip),%rdi
call   1080 <scanf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    -0x30(%rbp),%rsi
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x1c(%rbp)
cltq
shl    $0x2,%rax
add    %rax,%rsi
lea    0xda6(%rip),%rdi
call   1080 <scanf@plt>
jmp    1215 <main+0xb5>
mov    -0x20(%rbp),%edi
mov    -0x24(%rbp),%esi
mov    -0x30(%rbp),%rdx
call   1030 <picnic@plt>
mov    %eax,%esi
lea    0xddc(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x30(%rbp),%rdi
call   1040 <free@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11a9 <main+0x49>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe8b(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe93(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1080 <scanf@plt>
cmpl   $0x0,0x10(%rsp)
jle    1279 <main+0x119>
lea    0xe77(%rip),%rbx
lea    0xec8(%rip),%rbp
xor    %r14d,%r14d
jmp    11df <main+0x7f>
nopl   0x0(%rax,%rax,1)
mov    0x14(%rsp),%edi
mov    %r12,%rdx
call   1030 <picnic@plt>
mov    %rbp,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12,%rdi
call   1040 <free@plt>
add    $0x1,%r14d
cmp    0x10(%rsp),%r14d
jge    1279 <main+0x119>
lea    0xe33(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
lea    0x14(%rsp),%rsi
call   1080 <scanf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
mov    %rbx,%rdi
lea    0xc(%rsp),%rsi
call   1080 <scanf@plt>
mov    0xc(%rsp),%edi
shl    $0x3,%edi
call   1070 <malloc@plt>
mov    %rax,%r12
lea    0xe28(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rsp),%esi
test   %esi,%esi
jle    11b0 <main+0x50>
mov    %r12,%r15
xor    %r13d,%r13d
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <scanf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
add    $0x2,%r13
lea    0x4(%r15),%rsi
mov    %rbx,%rdi
call   1080 <scanf@plt>
movslq 0xc(%rsp),%rsi
lea    (%rsi,%rsi,1),%rax
add    $0x8,%r15
cmp    %rax,%r13
jl     1240 <main+0xe0>
jmp    11b0 <main+0x50>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"type the case count: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [54 x i8] c"type student count and friendship count for case %d: \00"
@.str.3 = [31 x i8] c"please input the friendships: \00"
@.str.4 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %7
br label %14
14: ; preds = %58, %2
%15 = load i32, i32* %7
%16 = load i32, i32* %6
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %61
18: ; preds = %14
%19 = load i32, i32* %7
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i64 0, i64 0), i32 %19)
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %9)
%22 = call i32 (...) @getchar()
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %10)
%24 = load i32, i32* %10
%25 = sext i32 %24 to i64
%26 = mul i64 8, %25
%27 = trunc i64 %26 to i32
%28 = call i64 @malloc(i32 %27)
%29 = inttoptr i64 %28 to i32*
store i32* %29, i32** %11
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %8
br label %31
31: ; preds = %36, %18
%32 = load i32, i32* %8
%33 = load i32, i32* %10
%34 = mul nsw i32 2, %33
%35 = icmp slt i32 %32, %34
br i1 %35, label %36, label %50
36: ; preds = %31
%37 = load i32*, i32** %11
%38 = load i32, i32* %8
%39 = add nsw i32 %38, 1
store i32 %39, i32* %8
%40 = sext i32 %38 to i64
%41 = getelementptr inbounds i32, i32* %37, i64 %40
%42 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %41)
%43 = call i32 (...) @getchar()
%44 = load i32*, i32** %11
%45 = load i32, i32* %8
%46 = add nsw i32 %45, 1
store i32 %46, i32* %8
%47 = sext i32 %45 to i64
%48 = getelementptr inbounds i32, i32* %44, i64 %47
%49 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %48)
br label %31
50: ; preds = %31
%51 = load i32, i32* %9
%52 = load i32, i32* %10
%53 = load i32*, i32** %11
%54 = call i32 @picnic(i32 %51, i32 %52, i32* %53)
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %54)
%56 = load i32*, i32** %11
%57 = call i32 @free(i32* %56)
br label %58
58: ; preds = %50
%59 = load i32, i32* %7
%60 = add nsw i32 %59, 1
store i32 %60, i32* %7
br label %14
61: ; preds = %14
ret i32 0
}

LLVM IR (-O2):
@.str = [22 x i8] c"type the case count: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [54 x i8] c"type student count and friendship count for case %d: \00"
@.str.3 = [31 x i8] c"please input the friendships: \00"
@.str.4 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%7 = bitcast i32* %3 to i8*
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%9 = bitcast i32* %4 to i8*
%10 = bitcast i32* %5 to i8*
%11 = load i32, i32* %3
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %48
13: ; preds = %2, %39
%14 = phi i32 [ %45, %39 ], [ 0, %2 ]
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i64 0, i64 0), i32 %14)
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%17 = call i32 (...) @getchar()
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%19 = load i32, i32* %5
%20 = shl i32 %19, 3
%21 = call i64 @malloc(i32 %20)
%22 = inttoptr i64 %21 to i32*
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
%24 = load i32, i32* %5
%25 = icmp sgt i32 %24, 0
br i1 %25, label %26, label %39
26: ; preds = %13, %26
%27 = phi i64 [ %32, %26 ], [ 0, %13 ]
%28 = or i64 %27, 1
%29 = getelementptr inbounds i32, i32* %22, i64 %27
%30 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %29)
%31 = call i32 (...) @getchar()
%32 = add nuw nsw i64 %27, 2
%33 = getelementptr inbounds i32, i32* %22, i64 %28
%34 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %33)
%35 = load i32, i32* %5
%36 = shl nsw i32 %35, 1
%37 = sext i32 %36 to i64
%38 = icmp slt i64 %32, %37
br i1 %38, label %26, label %39
39: ; preds = %26, %13
%40 = phi i32 [ %24, %13 ], [ %35, %26 ]
%41 = load i32, i32* %4
%42 = call i32 @picnic(i32 %41, i32 %40, i32* %22)
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %42)
%44 = call i32 @free(i32* %22)
%45 = add nuw nsw i32 %14, 1
%46 = load i32, i32* %3
%47 = icmp slt i32 %45, %46
br i1 %47, label %13, label %48
48: ; preds = %39, %2
ret i32 0
}