#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 SUBSET_SUM_R(int arr[], int start, int end, int T) {
  printf("\nstart :%d end :%d T :%d", start, end, T);
  if (T == 0) {
    printf(" returned 1");
    return 1;
  } else if (T < 0 || end < 0) {
    printf(" returned zero");
    return 0;
  }
  printf(" going for more recursion");
  return (SUBSET_SUM_R(arr, start, end - 1, T) ||
          SUBSET_SUM_R(arr, start, end - 1, T - arr[end]));
}


x86 assembly (clang, -O0):
<SUBSET_SUM_R>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
lea    0xebb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x1c(%rbp)
jne    1170 <SUBSET_SUM_R+0x50>
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    120b <SUBSET_SUM_R+0xeb>
cmpl   $0x0,-0x1c(%rbp)
jl     1184 <SUBSET_SUM_R+0x64>
cmpl   $0x0,-0x18(%rbp)
jge    119e <SUBSET_SUM_R+0x7e>
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    120b <SUBSET_SUM_R+0xeb>
jmp    11a3 <SUBSET_SUM_R+0x83>
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
sub    $0x1,%edx
mov    -0x1c(%rbp),%ecx
call   1040 <SUBSET_SUM_R@plt>
mov    %eax,%ecx
mov    $0x1,%al
cmp    $0x0,%ecx
mov    %al,-0x1d(%rbp)
jne    1200 <SUBSET_SUM_R+0xe0>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
sub    $0x1,%edx
mov    -0x1c(%rbp),%ecx
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%r8
sub    (%rax,%r8,4),%ecx
call   1040 <SUBSET_SUM_R@plt>
cmp    $0x0,%eax
setne  %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SUBSET_SUM_R>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%ebx
mov    %edx,%r12d
mov    %esi,%r15d
mov    %rdi,%r14
lea    0xec3(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
test   %ebx,%ebx
je     119c <SUBSET_SUM_R+0x7c>
mov    %ebx,%eax
or     %r12d,%eax
js     11b1 <SUBSET_SUM_R+0x91>
lea    0xede(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    -0x1(%r12),%r13d
mov    %r14,%rdi
mov    %r15d,%esi
mov    %r13d,%edx
mov    %ebx,%ecx
call   1040 <SUBSET_SUM_R@plt>
mov    $0x1,%ebp
test   %eax,%eax
jne    11c1 <SUBSET_SUM_R+0xa1>
movslq %r12d,%rax
sub    (%r14,%rax,4),%ebx
mov    %r14,%rdi
mov    %r15d,%esi
mov    %r13d,%edx
mov    %ebx,%ecx
call   1040 <SUBSET_SUM_R@plt>
xor    %ebp,%ebp
test   %eax,%eax
setne  %bpl
jmp    11c1 <SUBSET_SUM_R+0xa1>
lea    0xe76(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%ebp
jmp    11c1 <SUBSET_SUM_R+0xa1>
lea    0xe6d(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"\0Astart :%d end :%d T :%d\00"
@.str.1 = [12 x i8] c" returned 1\00"
@.str.2 = [15 x i8] c" returned zero\00"
@.str.3 = [26 x i8] c" going for more recursion\00"
define i32 @SUBSET_SUM_R(i32* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32* %0, i32** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%10 = load i32, i32* %7
%11 = load i32, i32* %8
%12 = load i32, i32* %9
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %11, i32 %12)
%14 = load i32, i32* %9
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %4
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %5
br label %53
18: ; preds = %4
%19 = load i32, i32* %9
%20 = icmp slt i32 %19, 0
br i1 %20, label %24, label %21
21: ; preds = %18
%22 = load i32, i32* %8
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %21, %18
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %5
br label %53
26: ; preds = %21
br label %27
27: ; preds = %26
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%29 = load i32*, i32** %6
%30 = load i32, i32* %7
%31 = load i32, i32* %8
%32 = sub nsw i32 %31, 1
%33 = load i32, i32* %9
%34 = call i32 @SUBSET_SUM_R(i32* %29, i32 %30, i32 %32, i32 %33)
%35 = icmp ne i32 %34, 0
br i1 %35, label %50, label %36
36: ; preds = %27
%37 = load i32*, i32** %6
%38 = load i32, i32* %7
%39 = load i32, i32* %8
%40 = sub nsw i32 %39, 1
%41 = load i32, i32* %9
%42 = load i32*, i32** %6
%43 = load i32, i32* %8
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i32, i32* %42, i64 %44
%46 = load i32, i32* %45
%47 = sub nsw i32 %41, %46
%48 = call i32 @SUBSET_SUM_R(i32* %37, i32 %38, i32 %40, i32 %47)
%49 = icmp ne i32 %48, 0
br label %50
50: ; preds = %36, %27
%51 = phi i1 [ true, %27 ], [ %49, %36 ]
%52 = zext i1 %51 to i32
store i32 %52, i32* %5
br label %53
53: ; preds = %50, %24, %16
%54 = load i32, i32* %5
ret i32 %54
}

LLVM IR (-O2):
@.str = [25 x i8] c"\0Astart :%d end :%d T :%d\00"
@.str.1 = [12 x i8] c" returned 1\00"
@.str.2 = [15 x i8] c" returned zero\00"
@.str.3 = [26 x i8] c" going for more recursion\00"
define i32 @SUBSET_SUM_R(i32* %0, i32 %1, i32 %2, i32 %3) {
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %1, i32 %2, i32 %3)
%6 = icmp eq i32 %3, 0
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %19
9: ; preds = %4
%10 = or i32 %3, %2
%11 = icmp sgt i32 %10, -1
br i1 %11, label %14, label %12
12: ; preds = %9
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
br label %19
14: ; preds = %9
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%16 = add nsw i32 %2, -1
%17 = tail call i32 @SUBSET_SUM_R(i32* %0, i32 %1, i32 %16, i32 %3)
%18 = icmp eq i32 %17, 0
br i1 %18, label %21, label %19
19: ; preds = %7, %12, %14, %21
%20 = phi i32 [ %28, %21 ], [ 1, %7 ], [ 0, %12 ], [ 1, %14 ]
ret i32 %20
21: ; preds = %14
%22 = sext i32 %2 to i64
%23 = getelementptr inbounds i32, i32* %0, i64 %22
%24 = load i32, i32* %23
%25 = sub nsw i32 %3, %24
%26 = tail call i32 @SUBSET_SUM_R(i32* %0, i32 %1, i32 %16, i32 %25)
%27 = icmp ne i32 %26, 0
%28 = zext i1 %27 to i32
br label %19
}