#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*/ successes;
typedef int /*<<< orphan*/ failures;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int eval(int, int *, int *);
int /*<<< orphan*/ memset(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ pretty_print(int, int *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ puts(char *);
int solve(int const, int *, int, int *);
int /*<<< orphan*/ stdout;
int main() {
  const int M = 13;
  int buffer[4];
  int successes[][4] = {{5, 7, 3, 1},   {5, 7, 1, 3},    {8, 2, 2, 1},
                        {13, 1, 1, 1},  {13, 0, 0, 0},   {0, 10, 0, 3},
                        {15, -5, 3, 4}, {-8, -5, 13, 1}, {-8, -5, 13, 0},
                        {15, -5, 4, 3}};
  int failures[][4] = {{1, 2, 3, 4},  {5, 5, 5, 2},    {3, 3, 3, 3},
                       {0, 14, 1, 3}, {-1, -2, -3, 5}, {-13, 10, 1, 1}};
  const int no_successes = sizeof(successes) / sizeof(int[4]);
  const int no_failures = sizeof(failures) / sizeof(int[4]);
  size_t i = 0;
  for (i = 0; i < no_successes; ++i) {
    memset(buffer, 0, 4 * sizeof(int));
    {
      int res = solve(M, successes[i], 4, buffer);
      if (res) {
        assert(eval(4, successes[i], buffer) == M);
        pretty_print(4, buffer, stdout);
      } else {
        puts("ERROR");
      }
    }
  }
  for (i = 0; i < no_failures; ++i) {
    memset(buffer, 0, 4 * sizeof(int));
    {
      int res = solve(M, failures[i], 4, buffer);
      if (res) {
        printf("ERROR: %d", eval(4, failures[i], buffer));
        pretty_print(4, buffer, stdout);
      } else {
        puts("FAILURE EXPECTED.");
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xd,-0x8(%rbp)
lea    -0xc0(%rbp),%rdi
lea    0xe59(%rip),%rsi
mov    $0xa0,%edx
call   1090 <memcpy@plt>
lea    -0x120(%rbp),%rdi
lea    0xee1(%rip),%rsi
mov    $0x60,%edx
call   1090 <memcpy@plt>
movl   $0xa,-0x124(%rbp)
movl   $0x6,-0x128(%rbp)
movq   $0x0,-0x130(%rbp)
movq   $0x0,-0x130(%rbp)
cmpq   $0xa,-0x130(%rbp)
0a
jae    12c3 <main+0x143>
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1060 <memset@plt>
mov    -0x130(%rbp),%rax
lea    -0xc0(%rbp),%rsi
shl    $0x4,%rax
add    %rax,%rsi
lea    -0x20(%rbp),%rcx
mov    $0xd,%edi
mov    $0x4,%edx
call   1030 <solve@plt>
mov    %eax,-0x134(%rbp)
cmpl   $0x0,-0x134(%rbp)
je     129b <main+0x11b>
mov    -0x130(%rbp),%rax
lea    -0xc0(%rbp),%rsi
shl    $0x4,%rax
add    %rax,%rsi
lea    -0x20(%rbp),%rdx
mov    $0x4,%edi
call   10a0 <eval@plt>
cmp    $0xd,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
lea    -0x20(%rbp),%rsi
mov    0x2d56(%rip),%rax
mov    (%rax),%edx
mov    $0x4,%edi
call   1070 <pretty_print@plt>
jmp    12a7 <main+0x127>
lea    0xe5e(%rip),%rdi
call   1040 <puts@plt>
jmp    12ac <main+0x12c>
mov    -0x130(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x130(%rbp)
jmp    11f3 <main+0x73>
movq   $0x0,-0x130(%rbp)
cmpq   $0x6,-0x130(%rbp)
06
jae    139c <main+0x21c>
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1060 <memset@plt>
mov    -0x130(%rbp),%rax
lea    -0x120(%rbp),%rsi
shl    $0x4,%rax
add    %rax,%rsi
lea    -0x20(%rbp),%rcx
mov    $0xd,%edi
mov    $0x4,%edx
call   1030 <solve@plt>
mov    %eax,-0x138(%rbp)
cmpl   $0x0,-0x138(%rbp)
je     1374 <main+0x1f4>
mov    -0x130(%rbp),%rax
lea    -0x120(%rbp),%rsi
shl    $0x4,%rax
add    %rax,%rsi
lea    -0x20(%rbp),%rdx
mov    $0x4,%edi
call   10a0 <eval@plt>
mov    %eax,%esi
lea    0xdb3(%rip),%rdi
call   1050 <printf@plt>
lea    -0x20(%rbp),%rsi
mov    0x2c7d(%rip),%rax
mov    (%rax),%edx
mov    $0x4,%edi
call   1070 <pretty_print@plt>
jmp    1380 <main+0x200>
lea    0xd95(%rip),%rdi
call   1040 <puts@plt>
jmp    1385 <main+0x205>
mov    -0x130(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x130(%rbp)
jmp    12ce <main+0x14e>
xor    %eax,%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
lea    0xe68(%rip),%rsi
lea    0x70(%rsp),%rdi
mov    $0xa0,%edx
call   1090 <memcpy@plt>
movaps 0xf42(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xf26(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xf0a(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xeee(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xed2(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xeb6(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
xor    %ebx,%ebx
mov    %rsp,%r15
lea    0xf05(%rip),%r14
mov    0x2dde(%rip),%r13
jmp    1225 <main+0xa5>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
call   1040 <puts@plt>
add    $0x10,%rbx
cmp    $0xa0,%rbx
je     1286 <main+0x106>
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1060 <memset@plt>
lea    (%rsp,%rbx,1),%r12
add    $0x70,%r12
mov    $0xd,%edi
mov    %r12,%rsi
mov    $0x4,%edx
mov    %r15,%rcx
call   1030 <solve@plt>
test   %eax,%eax
je     1210 <main+0x90>
mov    $0x4,%edi
mov    %r12,%rsi
mov    %r15,%rdx
call   10a0 <eval@plt>
xor    %edi,%edi
cmp    $0xd,%eax
sete   %dil
call   1080 <assert@plt>
mov    0x0(%r13),%edx
mov    $0x4,%edi
mov    %r15,%rsi
call   1070 <pretty_print@plt>
jmp    1218 <main+0x98>
xor    %ebp,%ebp
mov    %rsp,%r12
lea    0xe7e(%rip),%r14
lea    0xe6d(%rip),%r15
jmp    12b2 <main+0x132>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1040 <puts@plt>
add    $0x10,%rbp
cmp    $0x60,%rbp
je     130f <main+0x18f>
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1060 <memset@plt>
lea    (%rsp,%rbp,1),%rbx
add    $0x10,%rbx
mov    $0xd,%edi
mov    %rbx,%rsi
mov    $0x4,%edx
mov    %r12,%rcx
call   1030 <solve@plt>
test   %eax,%eax
je     12a0 <main+0x120>
mov    $0x4,%edi
mov    %rbx,%rsi
mov    %r12,%rdx
call   10a0 <eval@plt>
mov    %r15,%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    0x0(%r13),%edx
mov    $0x4,%edi
mov    %r12,%rsi
call   1070 <pretty_print@plt>
jmp    12a8 <main+0x128>
xor    %eax,%eax
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.successes = [10 x [4 x i32]] [[4 x i32] [i32 5, i32 7, i32 3, i32 1], [4 x i32] [i32 5, i32 7, i32 1, i32 3], [4 x i32] [i32 8, i32 2, i32 2, i32 1], [4 x i32] [i32 13, i32 1, i32 1, i32 1], [4 x i32] [i32 13, i32 0, i32 0, i32 0], [4 x i32] [i32 0, i32 10, i32 0, i32 3], [4 x i32] [i32 15, i32 -5, i32 3, i32 4], [4 x i32] [i32 -8, i32 -5, i32 13, i32 1], [4 x i32] [i32 -8, i32 -5, i32 13, i32 0], [4 x i32] [i32 15, i32 -5, i32 4, i32 3]]
@__const.main.failures = [6 x [4 x i32]] [[4 x i32] [i32 1, i32 2, i32 3, i32 4], [4 x i32] [i32 5, i32 5, i32 5, i32 2], [4 x i32] [i32 3, i32 3, i32 3, i32 3], [4 x i32] [i32 0, i32 14, i32 1, i32 3], [4 x i32] [i32 -1, i32 -2, i32 -3, i32 5], [4 x i32] [i32 -13, i32 10, i32 1, i32 1]]
@stdout = global i32 0
@.str = [6 x i8] c"ERROR\00"
@.str.1 = [10 x i8] c"ERROR: %d\00"
@.str.2 = [18 x i8] c"FAILURE EXPECTED.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [4 x i32]
%4 = alloca [10 x [4 x i32]]
%5 = alloca [6 x [4 x i32]]
%6 = alloca i32
%7 = alloca i32
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %1
store i32 13, i32* %2
%11 = bitcast [10 x [4 x i32]]* %4 to i8*
%12 = bitcast [6 x [4 x i32]]* %5 to i8*
store i32 10, i32* %6
store i32 6, i32* %7
store i64 0, i64* %8
store i64 0, i64* %8
br label %13
13: ; preds = %41, %0
%14 = load i64, i64* %8
%15 = icmp ult i64 %14, 10
br i1 %15, label %16, label %44
16: ; preds = %13
%17 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 0
%18 = call i32 @memset(i32* %17, i32 0, i32 16)
%19 = load i64, i64* %8
%20 = getelementptr inbounds [10 x [4 x i32]], [10 x [4 x i32]]* %4, i64 0, i64 %19
%21 = getelementptr inbounds [4 x i32], [4 x i32]* %20, i64 0, i64 0
%22 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 0
%23 = call i32 @solve(i32 13, i32* %21, i32 4, i32* %22)
store i32 %23, i32* %9
%24 = load i32, i32* %9
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %38
26: ; preds = %16
%27 = load i64, i64* %8
%28 = getelementptr inbounds [10 x [4 x i32]], [10 x [4 x i32]]* %4, i64 0, i64 %27
%29 = getelementptr inbounds [4 x i32], [4 x i32]* %28, i64 0, i64 0
%30 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 0
%31 = call i32 @eval(i32 4, i32* %29, i32* %30)
%32 = icmp eq i32 %31, 13
%33 = zext i1 %32 to i32
%34 = call i32 @assert(i32 %33)
%35 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 0
%36 = load i32, i32* @stdout
%37 = call i32 @pretty_print(i32 4, i32* %35, i32 %36)
br label %40
38: ; preds = %16
%39 = call i32 @puts(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %40
40: ; preds = %38, %26
br label %41
41: ; preds = %40
%42 = load i64, i64* %8
%43 = add i64 %42, 1
store i64 %43, i64* %8
br label %13
44: ; preds = %13
store i64 0, i64* %8
br label %45
45: ; preds = %71, %44
%46 = load i64, i64* %8
%47 = icmp ult i64 %46, 6
br i1 %47, label %48, label %74
48: ; preds = %45
%49 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 0
%50 = call i32 @memset(i32* %49, i32 0, i32 16)
%51 = load i64, i64* %8
%52 = getelementptr inbounds [6 x [4 x i32]], [6 x [4 x i32]]* %5, i64 0, i64 %51
%53 = getelementptr inbounds [4 x i32], [4 x i32]* %52, i64 0, i64 0
%54 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 0
%55 = call i32 @solve(i32 13, i32* %53, i32 4, i32* %54)
store i32 %55, i32* %10
%56 = load i32, i32* %10
%57 = icmp ne i32 %56, 0
br i1 %57, label %58, label %68
58: ; preds = %48
%59 = load i64, i64* %8
%60 = getelementptr inbounds [6 x [4 x i32]], [6 x [4 x i32]]* %5, i64 0, i64 %59
%61 = getelementptr inbounds [4 x i32], [4 x i32]* %60, i64 0, i64 0
%62 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 0
%63 = call i32 @eval(i32 4, i32* %61, i32* %62)
%64 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %63)
%65 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 0
%66 = load i32, i32* @stdout
%67 = call i32 @pretty_print(i32 4, i32* %65, i32 %66)
br label %70
68: ; preds = %48
%69 = call i32 @puts(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
br label %70
70: ; preds = %68, %58
br label %71
71: ; preds = %70
%72 = load i64, i64* %8
%73 = add i64 %72, 1
store i64 %73, i64* %8
br label %45
74: ; preds = %45
ret i32 0
}

LLVM IR (-O2):
@__const.main.successes = [10 x [4 x i32]] [[4 x i32] [i32 5, i32 7, i32 3, i32 1], [4 x i32] [i32 5, i32 7, i32 1, i32 3], [4 x i32] [i32 8, i32 2, i32 2, i32 1], [4 x i32] [i32 13, i32 1, i32 1, i32 1], [4 x i32] [i32 13, i32 0, i32 0, i32 0], [4 x i32] [i32 0, i32 10, i32 0, i32 3], [4 x i32] [i32 15, i32 -5, i32 3, i32 4], [4 x i32] [i32 -8, i32 -5, i32 13, i32 1], [4 x i32] [i32 -8, i32 -5, i32 13, i32 0], [4 x i32] [i32 15, i32 -5, i32 4, i32 3]]
@__const.main.failures = [6 x [4 x i32]] [[4 x i32] [i32 1, i32 2, i32 3, i32 4], [4 x i32] [i32 5, i32 5, i32 5, i32 2], [4 x i32] [i32 3, i32 3, i32 3, i32 3], [4 x i32] [i32 0, i32 14, i32 1, i32 3], [4 x i32] [i32 -1, i32 -2, i32 -3, i32 5], [4 x i32] [i32 -13, i32 10, i32 1, i32 1]]
@stdout = global i32 0
@.str = [6 x i8] c"ERROR\00"
@.str.1 = [10 x i8] c"ERROR: %d\00"
@.str.2 = [18 x i8] c"FAILURE EXPECTED.\00"
define i32 @main() {
%1 = alloca [4 x i32]
%2 = alloca [10 x [4 x i32]]
%3 = alloca [6 x [4 x i32]]
%4 = bitcast [4 x i32]* %1 to i8*
%5 = bitcast [10 x [4 x i32]]* %2 to i8*
%6 = bitcast [6 x [4 x i32]]* %3 to i8*
%7 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
br label %8
8: ; preds = %0, %23
%9 = phi i64 [ 0, %0 ], [ %24, %23 ]
%10 = call i32 @memset(i32* %7, i32 0, i32 16)
%11 = getelementptr inbounds [10 x [4 x i32]], [10 x [4 x i32]]* %2, i64 0, i64 %9, i64 0
%12 = call i32 @solve(i32 13, i32* %11, i32 4, i32* %7)
%13 = icmp eq i32 %12, 0
br i1 %13, label %21, label %14
14: ; preds = %8
%15 = call i32 @eval(i32 4, i32* %11, i32* %7)
%16 = icmp eq i32 %15, 13
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = load i32, i32* @stdout
%20 = call i32 @pretty_print(i32 4, i32* %7, i32 %19)
br label %23
21: ; preds = %8
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %23
23: ; preds = %21, %14
%24 = add nuw nsw i64 %9, 1
%25 = icmp eq i64 %24, 10
br i1 %25, label %26, label %8
26: ; preds = %23, %39
%27 = phi i64 [ %40, %39 ], [ 0, %23 ]
%28 = call i32 @memset(i32* %7, i32 0, i32 16)
%29 = getelementptr inbounds [6 x [4 x i32]], [6 x [4 x i32]]* %3, i64 0, i64 %27, i64 0
%30 = call i32 @solve(i32 13, i32* %29, i32 4, i32* %7)
%31 = icmp eq i32 %30, 0
br i1 %31, label %37, label %32
32: ; preds = %26
%33 = call i32 @eval(i32 4, i32* %29, i32* %7)
%34 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %33)
%35 = load i32, i32* @stdout
%36 = call i32 @pretty_print(i32 4, i32* %7, i32 %35)
br label %39
37: ; preds = %26
%38 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
br label %39
39: ; preds = %37, %32
%40 = add nuw nsw i64 %27, 1
%41 = icmp eq i64 %40, 6
br i1 %41, label %42, label %26
42: ; preds = %39
ret i32 0
}