#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 connection(int *, int *);
int /*<<< orphan*/ increment(int *);
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ vectInit(int *);
int main(void) {
  int y = 6;
  int S[10];
  int V[10];
  int j, k, t;
  int w = 0;
  int cuts = 0;
  vectInit(V);
  for (j = 0; V[9] < 1; j++) {
    y = connection(S, V);
    w += y;
    if (y) {
      k = 0;
      for (t = 0; t < 5; t++) {
        while (1 - V[k])
          k++;
        V[k] = 0;
        y = connection(S, V);
        cuts += 1 - y;
        V[k] = 1;
        k++;
      }
    }
    increment(V);
  }
  printf("patterns %d  wins %d \n", j, w);
  printf("cutnodes %d  total nodes %d \n", cuts, w * 5);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x6,-0x8(%rbp)
movl   $0x0,-0x70(%rbp)
movl   $0x0,-0x74(%rbp)
lea    -0x60(%rbp),%rdi
call   1040 <vectInit@plt>
movl   $0x0,-0x64(%rbp)
cmpl   $0x1,-0x3c(%rbp)
jge    124e <main+0x10e>
lea    -0x30(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1030 <connection@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    -0x70(%rbp),%eax
mov    %eax,-0x70(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1237 <main+0xf7>
movl   $0x0,-0x68(%rbp)
movl   $0x0,-0x6c(%rbp)
cmpl   $0x5,-0x6c(%rbp)
jge    1232 <main+0xf2>
jmp    11c1 <main+0x81>
movslq -0x68(%rbp),%rcx
mov    $0x1,%eax
sub    -0x60(%rbp,%rcx,4),%eax
cmp    $0x0,%eax
je     11e5 <main+0xa5>
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    11c1 <main+0x81>
movslq -0x68(%rbp),%rax
movl   $0x0,-0x60(%rbp,%rax,4)
lea    -0x30(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1030 <connection@plt>
mov    %eax,-0x8(%rbp)
mov    $0x1,%eax
sub    -0x8(%rbp),%eax
add    -0x74(%rbp),%eax
mov    %eax,-0x74(%rbp)
movslq -0x68(%rbp),%rax
movl   $0x1,-0x60(%rbp,%rax,4)
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
jmp    11b2 <main+0x72>
jmp    1237 <main+0xf7>
lea    -0x60(%rbp),%rdi
call   1050 <increment@plt>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    1177 <main+0x37>
mov    -0x64(%rbp),%esi
mov    -0x70(%rbp),%edx
lea    0xda5(%rip),%rdi
call   1060 <printf@plt>
mov    -0x74(%rbp),%esi
imul   $0x5,-0x70(%rbp),%edx
lea    0xda9(%rip),%rdi
call   1060 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
lea    0x20(%rsp),%rdi
call   1040 <vectInit@plt>
xor    %r13d,%r13d
cmpl   $0x0,0x44(%rsp)
mov    $0x0,%ebx
mov    $0x0,%ebp
jle    119f <main+0x5f>
lea    0xe8d(%rip),%rdi
mov    %r13d,%esi
mov    %ebx,%edx
call   1060 <printf@plt>
lea    (%rbx,%rbx,4),%edx
lea    0xe90(%rip),%rdi
mov    %ebp,%esi
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
movabs $0x100000000,%r14
xor    %ebp,%ebp
lea    0x20(%rsp),%r15
xor    %ebx,%ebx
xor    %r13d,%r13d
jmp    11d5 <main+0x95>
nopw   0x0(%rax,%rax,1)
add    %eax,%ebx
mov    %r15,%rdi
call   1050 <increment@plt>
add    $0x1,%r13d
cmpl   $0x0,0x44(%rsp)
jg     116c <main+0x2c>
lea    0x50(%rsp),%rdi
mov    %r15,%rsi
call   1030 <connection@plt>
test   %eax,%eax
je     11c0 <main+0x80>
mov    %eax,0xc(%rsp)
mov    %rbx,0x18(%rsp)
mov    %rbp,0x10(%rsp)
xor    %r12d,%r12d
lea    0x1c(%rsp),%rbx
nopl   0x0(%rax)
add    %r14,%r12
cmpl   $0x1,0x4(%rbx)
lea    0x4(%rbx),%rbx
jne    1200 <main+0xc0>
movl   $0x0,(%rbx)
lea    0x50(%rsp),%rdi
mov    %r15,%rbp
mov    %r15,%rsi
call   1030 <connection@plt>
mov    %eax,%r15d
movl   $0x1,(%rbx)
mov    %r12,%rax
sar    $0x20,%rax
lea    0x1c(%rsp),%rcx
lea    (%rcx,%rax,4),%rbx
movabs $0xffffffff00000000,%rax
ff ff ff
and    %rax,%r12
nopl   0x0(%rax)
add    %r14,%r12
cmpl   $0x1,0x4(%rbx)
lea    0x4(%rbx),%rbx
jne    1250 <main+0x110>
movl   $0x0,(%rbx)
lea    0x50(%rsp),%rdi
mov    %rbp,%rsi
call   1030 <connection@plt>
movl   $0x1,(%rbx)
mov    %r12,%rcx
sar    $0x20,%rcx
lea    0x1c(%rsp),%rdx
lea    (%rdx,%rcx,4),%rbx
movabs $0xffffffff00000000,%rcx
ff ff ff
and    %rcx,%r12
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    %r14,%r12
cmpl   $0x1,0x4(%rbx)
lea    0x4(%rbx),%rbx
jne    12a0 <main+0x160>
add    %eax,%r15d
movl   $0x0,(%rbx)
lea    0x50(%rsp),%rdi
mov    %rbp,%rsi
call   1030 <connection@plt>
movl   $0x1,(%rbx)
mov    %r12,%rcx
sar    $0x20,%rcx
lea    0x1c(%rsp),%rdx
lea    (%rdx,%rcx,4),%rbx
movabs $0xffffffff00000000,%rcx
ff ff ff
and    %rcx,%r12
cs nopw 0x0(%rax,%rax,1)
add    %r14,%r12
cmpl   $0x1,0x4(%rbx)
lea    0x4(%rbx),%rbx
jne    12f0 <main+0x1b0>
add    %eax,%r15d
movl   $0x0,(%rbx)
lea    0x50(%rsp),%rdi
mov    %rbp,%rsi
call   1030 <connection@plt>
movl   $0x1,(%rbx)
sar    $0x20,%r12
lea    0x1c(%rsp),%rcx
lea    (%rcx,%r12,4),%rbx
cs nopw 0x0(%rax,%rax,1)
cmpl   $0x1,0x4(%rbx)
lea    0x4(%rbx),%rbx
jne    1330 <main+0x1f0>
add    %eax,%r15d
movl   $0x0,(%rbx)
lea    0x50(%rsp),%rdi
mov    %rbp,%rsi
call   1030 <connection@plt>
add    %r15d,%eax
mov    %rbp,%r15
mov    0x10(%rsp),%rbp
sub    %eax,%ebp
add    $0x5,%ebp
movl   $0x1,(%rbx)
mov    0x18(%rsp),%rbx
mov    0xc(%rsp),%eax
jmp    11c0 <main+0x80>

LLVM IR (-O0):
@.str = [23 x i8] c"patterns %d wins %d \0A\00"
@.str.1 = [30 x i8] c"cutnodes %d total nodes %d \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [10 x i32]
%4 = alloca [10 x i32]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
store i32 6, i32* %2
store i32 0, i32* %8
store i32 0, i32* %9
%10 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 0
%11 = call i32 @vectInit(i32* %10)
store i32 0, i32* %5
br label %12
12: ; preds = %63, %0
%13 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 9
%14 = load i32, i32* %13
%15 = icmp slt i32 %14, 1
br i1 %15, label %16, label %66
16: ; preds = %12
%17 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
%18 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 0
%19 = call i32 @connection(i32* %17, i32* %18)
store i32 %19, i32* %2
%20 = load i32, i32* %2
%21 = load i32, i32* %8
%22 = add nsw i32 %21, %20
store i32 %22, i32* %8
%23 = load i32, i32* %2
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %60
25: ; preds = %16
store i32 0, i32* %6
store i32 0, i32* %7
br label %26
26: ; preds = %56, %25
%27 = load i32, i32* %7
%28 = icmp slt i32 %27, 5
br i1 %28, label %29, label %59
29: ; preds = %26
br label %30
30: ; preds = %37, %29
%31 = load i32, i32* %6
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 %32
%34 = load i32, i32* %33
%35 = sub nsw i32 1, %34
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %30
%38 = load i32, i32* %6
%39 = add nsw i32 %38, 1
store i32 %39, i32* %6
br label %30
40: ; preds = %30
%41 = load i32, i32* %6
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 %42
store i32 0, i32* %43
%44 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
%45 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 0
%46 = call i32 @connection(i32* %44, i32* %45)
store i32 %46, i32* %2
%47 = load i32, i32* %2
%48 = sub nsw i32 1, %47
%49 = load i32, i32* %9
%50 = add nsw i32 %49, %48
store i32 %50, i32* %9
%51 = load i32, i32* %6
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 %52
store i32 1, i32* %53
%54 = load i32, i32* %6
%55 = add nsw i32 %54, 1
store i32 %55, i32* %6
br label %56
56: ; preds = %40
%57 = load i32, i32* %7
%58 = add nsw i32 %57, 1
store i32 %58, i32* %7
br label %26
59: ; preds = %26
br label %60
60: ; preds = %59, %16
%61 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 0
%62 = call i32 @increment(i32* %61)
br label %63
63: ; preds = %60
%64 = load i32, i32* %5
%65 = add nsw i32 %64, 1
store i32 %65, i32* %5
br label %12
66: ; preds = %12
%67 = load i32, i32* %5
%68 = load i32, i32* %8
%69 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %67, i32 %68)
%70 = load i32, i32* %9
%71 = load i32, i32* %8
%72 = mul nsw i32 %71, 5
%73 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %70, i32 %72)
%74 = load i32, i32* %1
ret i32 %74
}

LLVM IR (-O2):
@.str = [23 x i8] c"patterns %d wins %d \0A\00"
@.str.1 = [30 x i8] c"cutnodes %d total nodes %d \0A\00"
define i32 @main() {
%1 = alloca [10 x i32]
%2 = alloca [10 x i32]
%3 = bitcast [10 x i32]* %1 to i8*
%4 = bitcast [10 x i32]* %2 to i8*
%5 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%6 = call i32 @vectInit(i32* %5)
%7 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 9
%8 = load i32, i32* %7
%9 = icmp slt i32 %8, 1
br i1 %9, label %10, label %88
10: ; preds = %0
%11 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
br label %12
12: ; preds = %10, %82
%13 = phi i32 [ 0, %10 ], [ %83, %82 ]
%14 = phi i32 [ 0, %10 ], [ %17, %82 ]
%15 = phi i32 [ 0, %10 ], [ %85, %82 ]
%16 = call i32 @connection(i32* %11, i32* %5)
%17 = add nsw i32 %16, %14
%18 = icmp eq i32 %16, 0
br i1 %18, label %82, label %19
19: ; preds = %12, %19
%20 = phi i64 [ %24, %19 ], [ 0, %12 ]
%21 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %20
%22 = load i32, i32* %21
%23 = icmp eq i32 %22, 1
%24 = add i64 %20, 1
br i1 %23, label %25, label %19
25: ; preds = %19
%26 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %20
store i32 0, i32* %26
%27 = call i32 @connection(i32* %11, i32* %5)
store i32 1, i32* %26
%28 = shl i64 %20, 32
%29 = add i64 %28, 4294967296
%30 = ashr exact i64 %29, 32
br label %31
31: ; preds = %31, %25
%32 = phi i64 [ %36, %31 ], [ %30, %25 ]
%33 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %32
%34 = load i32, i32* %33
%35 = icmp eq i32 %34, 1
%36 = add i64 %32, 1
br i1 %35, label %37, label %31
37: ; preds = %31
%38 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %32
store i32 0, i32* %38
%39 = call i32 @connection(i32* %11, i32* %5)
store i32 1, i32* %38
%40 = shl i64 %32, 32
%41 = add i64 %40, 4294967296
%42 = ashr exact i64 %41, 32
br label %43
43: ; preds = %43, %37
%44 = phi i64 [ %48, %43 ], [ %42, %37 ]
%45 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %44
%46 = load i32, i32* %45
%47 = icmp eq i32 %46, 1
%48 = add i64 %44, 1
br i1 %47, label %49, label %43
49: ; preds = %43
%50 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %44
%51 = add i32 %27, %39
store i32 0, i32* %50
%52 = call i32 @connection(i32* %11, i32* %5)
store i32 1, i32* %50
%53 = shl i64 %44, 32
%54 = add i64 %53, 4294967296
%55 = ashr exact i64 %54, 32
br label %56
56: ; preds = %56, %49
%57 = phi i64 [ %61, %56 ], [ %55, %49 ]
%58 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %57
%59 = load i32, i32* %58
%60 = icmp eq i32 %59, 1
%61 = add i64 %57, 1
br i1 %60, label %62, label %56
62: ; preds = %56
%63 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %57
%64 = add i32 %51, %52
store i32 0, i32* %63
%65 = call i32 @connection(i32* %11, i32* %5)
store i32 1, i32* %63
%66 = shl i64 %57, 32
%67 = add i64 %66, 4294967296
%68 = ashr exact i64 %67, 32
br label %69
69: ; preds = %69, %62
%70 = phi i64 [ %74, %69 ], [ %68, %62 ]
%71 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %70
%72 = load i32, i32* %71
%73 = icmp eq i32 %72, 1
%74 = add i64 %70, 1
br i1 %73, label %75, label %69
75: ; preds = %69
%76 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %70
%77 = add i32 %64, %65
store i32 0, i32* %76
%78 = call i32 @connection(i32* %11, i32* %5)
%79 = add i32 %13, 5
%80 = add i32 %77, %78
%81 = sub i32 %79, %80
store i32 1, i32* %76
br label %82
82: ; preds = %75, %12
%83 = phi i32 [ %13, %12 ], [ %81, %75 ]
%84 = call i32 @increment(i32* %5)
%85 = add nuw nsw i32 %15, 1
%86 = load i32, i32* %7
%87 = icmp slt i32 %86, 1
br i1 %87, label %12, label %88
88: ; preds = %82, %0
%89 = phi i32 [ 0, %0 ], [ %85, %82 ]
%90 = phi i32 [ 0, %0 ], [ %17, %82 ]
%91 = phi i32 [ 0, %0 ], [ %83, %82 ]
%92 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %89, i32 %90)
%93 = mul nsw i32 %90, 5
%94 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %91, i32 %93)
ret i32 0
}