#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*/ printf(char *, ...);
int find_count(int target, int current, int *numbers, int num_size) {
  int total_num = 0;
  for (int i = 0; i < num_size; ++i) {
    printf("%d ", numbers[i]);
  }
  printf("\n");
  for (int i = 0; i < num_size; ++i) {
    int v = numbers[i];
    int new_num = current + v;
    if (new_num == target) {
      printf("found: %d\n", target);
      ++total_num;
    }
    if (new_num >= target) {
      printf("total: %d; break\n", new_num);
      printf("\n");
      break;
    }
    int new_num_size = num_size - i - 1;
    printf("i=%d v=%d find_count(%d, %d, &numbers[%d], %d)\n", i, v, target,
           new_num, i + 1, new_num_size);
    total_num += find_count(target, new_num, &numbers[i + 1], new_num_size);
  }
  return total_num;
}


x86 assembly (clang, -O0):
<find_count>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1176 <find_count+0x56>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1143 <find_count+0x23>
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    126e <find_count+0x14e>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x4(%rbp),%eax
jne    11d4 <find_count+0xb4>
mov    -0x4(%rbp),%esi
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x4(%rbp),%eax
jl     1204 <find_count+0xe4>
mov    -0x28(%rbp),%esi
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    126e <find_count+0x14e>
mov    -0x14(%rbp),%eax
sub    -0x20(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x4(%rbp),%ecx
mov    -0x28(%rbp),%r8d
mov    -0x20(%rbp),%r9d
add    $0x1,%r9d
mov    -0x2c(%rbp),%eax
lea    0xdf2(%rip),%rdi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
mov    -0x28(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    -0x20(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x2,%rax
add    %rax,%rdx
mov    -0x2c(%rbp),%ecx
call   1040 <find_count@plt>
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    118b <find_count+0x6b>
mov    -0x18(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_count>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,0x10(%rsp)
test   %ecx,%ecx
jle    1216 <find_count+0xe6>
mov    %ecx,%r14d
mov    %rdx,%r15
mov    %edi,%r13d
mov    %ecx,%ebp
lea    0xea3(%rip),%r12
xor    %ebx,%ebx
nop
mov    (%r15,%rbx,4),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1160 <find_count+0x30>
mov    $0xa,%edi
call   1030 <putchar@plt>
test   %r14d,%r14d
jle    121b <find_count+0xeb>
add    $0x4,%r15
xor    %r14d,%r14d
xor    %r12d,%r12d
mov    %r13d,%ebx
nopw   0x0(%rax,%rax,1)
mov    -0x4(%r15),%edx
mov    0x10(%rsp),%rax
lea    (%rdx,%rax,1),%r13d
cmp    %ebx,%r13d
jne    11d0 <find_count+0xa0>
lea    0xe4b(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
mov    %rdx,0x8(%rsp)
call   1040 <printf@plt>
mov    0x8(%rsp),%rdx
add    $0x1,%r12d
cmp    %ebx,%r13d
jge    1220 <find_count+0xf0>
add    $0xffffffffffffffff,%rbp
lea    0x1(%r14),%r9d
mov    %ebp,(%rsp)
lea    0xe3a(%rip),%rdi
mov    %r14d,%esi
mov    %ebx,%ecx
mov    %r13d,%r8d
mov    %r9d,%r14d
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%edi
mov    %r13d,%esi
mov    %r15,%rdx
mov    %ebp,%ecx
call   1050 <find_count@plt>
add    %eax,%r12d
add    $0x4,%r15
test   %rbp,%rbp
jne    11a0 <find_count+0x70>
jmp    123b <find_count+0x10b>
xor    %r12d,%r12d
jmp    1231 <find_count+0x101>
xor    %r12d,%r12d
jmp    123b <find_count+0x10b>
lea    0xde8(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r12d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
@.str.2 = [11 x i8] c"found: %d\0A\00"
@.str.3 = [18 x i8] c"total: %d; break\0A\00"
@.str.4 = [48 x i8] c"i=%d v=%d find_count(%d, %d, &numbers[%d], %d)\0A\00"
define i32 @find_count(i32 %0, i32 %1, i32* nocapture %2, i32 %3) {
%5 = icmp sgt i32 %3, 0
br i1 %5, label %6, label %45
6: ; preds = %4
%7 = zext i32 %3 to i64
br label %12
8: ; preds = %12
%9 = tail call i32 @putchar(i32 10)
br i1 %5, label %10, label %48
10: ; preds = %8
%11 = zext i32 %3 to i64
br label %19
12: ; preds = %6, %12
%13 = phi i64 [ 0, %6 ], [ %17, %12 ]
%14 = getelementptr inbounds i32, i32* %2, i64 %13
%15 = load i32, i32* %14
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = add nuw nsw i64 %13, 1
%18 = icmp eq i64 %17, %7
br i1 %18, label %8, label %12
19: ; preds = %10, %35
%20 = phi i64 [ 0, %10 ], [ %38, %35 ]
%21 = phi i32 [ 0, %10 ], [ %43, %35 ]
%22 = trunc i64 %20 to i32
%23 = getelementptr inbounds i32, i32* %2, i64 %20
%24 = load i32, i32* %23
%25 = add nsw i32 %24, %1
%26 = icmp eq i32 %25, %0
br i1 %26, label %27, label %30
27: ; preds = %19
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %0)
%29 = add nsw i32 %21, 1
br label %30
30: ; preds = %27, %19
%31 = phi i32 [ %29, %27 ], [ %21, %19 ]
%32 = icmp slt i32 %25, %0
br i1 %32, label %35, label %33
33: ; preds = %30
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 %25)
br label %45
35: ; preds = %30
%36 = xor i32 %22, -1
%37 = add i32 %36, %3
%38 = add nuw nsw i64 %20, 1
%39 = add nuw nsw i32 %22, 1
%40 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0), i32 %22, i32 %24, i32 %0, i32 %25, i32 %39, i32 %37)
%41 = getelementptr inbounds i32, i32* %2, i64 %38
%42 = tail call i32 @find_count(i32 %0, i32 %25, i32* %41, i32 %37)
%43 = add nsw i32 %42, %31
%44 = icmp eq i64 %38, %11
br i1 %44, label %48, label %19
45: ; preds = %4, %33
%46 = phi i32 [ %31, %33 ], [ 0, %4 ]
%47 = tail call i32 @putchar(i32 10)
br label %48
48: ; preds = %35, %45, %8
%49 = phi i32 [ 0, %8 ], [ %46, %45 ], [ %43, %35 ]
ret i32 %49
}