#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*/ EXIT_FAILURE;
int INT_MAX;
int /*<<< orphan*/ clear_graph();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int min(int, int /*<<< orphan*/);
int /*<<< orphan*/ min_cut(int, int);
int /*<<< orphan*/ printf(char *, int);
int scanf(char *, int *, ...);
void read_problems_write_answers() {
  int n_probs, i, n_cp, main_cp, j, prob_min_cut, a_cp;
  if (scanf("%d", &n_probs) != 1)
    exit(EXIT_FAILURE);
  for (i = 0; i < n_probs; i++) {
    if (scanf("%d %d", &n_cp, &main_cp) != 2)
      exit(EXIT_FAILURE);
    for (j = 1, prob_min_cut = INT_MAX; j < n_cp; j++) {
      if (scanf("%d", &a_cp) != 1)
        exit(EXIT_FAILURE);
      prob_min_cut = min(prob_min_cut, min_cut(main_cp, a_cp));
      clear_graph();
    }
    printf("%d\n", prob_min_cut);
  }
}


x86 assembly (clang, -O0):
<read_problems_write_answers>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xe94(%rip),%rdi
lea    -0x4(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
cmp    $0x1,%eax
je     1191 <read_problems_write_answers+0x31>
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1269 <read_problems_write_answers+0x109>
lea    0xe55(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1070 <scanf@plt>
cmp    $0x2,%eax
je     11d1 <read_problems_write_answers+0x71>
mov    0x2e0e(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
movl   $0x1,-0x14(%rbp)
mov    0x2e09(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    124c <read_problems_write_answers+0xec>
lea    0xe0c(%rip),%rdi
lea    -0x1c(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
cmp    $0x1,%eax
je     1219 <read_problems_write_answers+0xb9>
mov    0x2dc6(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1030 <min_cut@plt>
mov    -0x20(%rbp),%edi
mov    %eax,%esi
call   1050 <min@plt>
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   1060 <clear_graph@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11e4 <read_problems_write_answers+0x84>
mov    -0x18(%rbp),%esi
lea    0xdb0(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1198 <read_problems_write_answers+0x38>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_problems_write_answers>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe8e(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
cmp    $0x1,%eax
jne    1252 <read_problems_write_answers+0xf2>
cmpl   $0x0,0xc(%rsp)
jle    1243 <read_problems_write_answers+0xe3>
lea    0xe67(%rip),%r13
lea    0x10(%rsp),%rbx
lea    0xe5e(%rip),%rbp
xor    %r15d,%r15d
jmp    11c6 <read_problems_write_answers+0x66>
nopl   (%rax)
mov    %rbp,%rdi
mov    %r14d,%esi
call   1040 <printf@plt>
add    $0x1,%r15d
cmp    0xc(%rsp),%r15d
jge    1243 <read_problems_write_answers+0xe3>
lea    0xe33(%rip),%rdi
lea    0x8(%rsp),%rsi
lea    0x14(%rsp),%rdx
xor    %eax,%eax
call   1070 <scanf@plt>
cmp    $0x2,%eax
jne    1252 <read_problems_write_answers+0xf2>
mov    0x2dfe(%rip),%rax
mov    (%rax),%r14d
cmpl   $0x2,0x8(%rsp)
jl     11b0 <read_problems_write_answers+0x50>
mov    $0x1,%r12d
nopw   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
cmp    $0x1,%eax
jne    1252 <read_problems_write_answers+0xf2>
mov    0x14(%rsp),%edi
mov    0x10(%rsp),%esi
call   1030 <min_cut@plt>
mov    %r14d,%edi
mov    %eax,%esi
call   1050 <min@plt>
mov    %eax,%r14d
xor    %eax,%eax
call   1060 <clear_graph@plt>
add    $0x1,%r12d
cmp    0x8(%rsp),%r12d
jl     1200 <read_problems_write_answers+0xa0>
jmp    11b0 <read_problems_write_answers+0x50>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d7f(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [6 x i8] c"%d %d\00"
@INT_MAX = global i32 0
@.str.2 = [4 x i8] c"%d\0A\00"
define void @read_problems_write_answers() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %14
11: ; preds = %0
%12 = load i32, i32* %1
%13 = icmp sgt i32 %12, 0
br i1 %13, label %17, label %51
14: ; preds = %0
%15 = load i32, i32* @EXIT_FAILURE
%16 = call i32 @exit(i32 %15)
unreachable
17: ; preds = %11, %45
%18 = phi i32 [ %48, %45 ], [ 0, %11 ]
%19 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3)
%20 = icmp eq i32 %19, 2
br i1 %20, label %24, label %21
21: ; preds = %17
%22 = load i32, i32* @EXIT_FAILURE
%23 = call i32 @exit(i32 %22)
unreachable
24: ; preds = %17
%25 = load i32, i32* @INT_MAX
%26 = load i32, i32* %2
%27 = icmp sgt i32 %26, 1
br i1 %27, label %28, label %45
28: ; preds = %24, %36
%29 = phi i32 [ %40, %36 ], [ %25, %24 ]
%30 = phi i32 [ %42, %36 ], [ 1, %24 ]
%31 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%32 = icmp eq i32 %31, 1
br i1 %32, label %36, label %33
33: ; preds = %28
%34 = load i32, i32* @EXIT_FAILURE
%35 = call i32 @exit(i32 %34)
unreachable
36: ; preds = %28
%37 = load i32, i32* %3
%38 = load i32, i32* %4
%39 = call i32 @min_cut(i32 %37, i32 %38)
%40 = call i32 @min(i32 %29, i32 %39)
%41 = call i32 (...) @clear_graph()
%42 = add nuw nsw i32 %30, 1
%43 = load i32, i32* %2
%44 = icmp slt i32 %42, %43
br i1 %44, label %28, label %45
45: ; preds = %36, %24
%46 = phi i32 [ %25, %24 ], [ %40, %36 ]
%47 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %46)
%48 = add nuw nsw i32 %18, 1
%49 = load i32, i32* %1
%50 = icmp slt i32 %48, %49
br i1 %50, label %17, label %51
51: ; preds = %45, %11
ret void
}