#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 */
scalar_t__ DPSubsetSum(int *, int, int);
int /*<<< orphan*/ printf(char *);
scalar_t__ recurSubsetSum(int *, int, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int n, i, sum = 0;
  printf("enter no. of elements : ");
  scanf("%d", &n);
  int arr[n];
  printf("enter elements : ");
  for (i = 0; i < n; ++i)
    scanf("%d", &arr[i]);
  printf("enter sum : ");
  scanf("%d", &sum);
  if (recurSubsetSum(arr, n, sum))
    printf("Yes\n");
  else
    printf("No\n");
  if (DPSubsetSum(arr, n, sum))
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xea3(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb0(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
lea    0xe7c(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11e1 <main+0xa1>
mov    -0x28(%rbp),%rsi
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe4b(%rip),%rdi
call   1060 <scanf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11ac <main+0x6c>
lea    0xe46(%rip),%rdi
call   1030 <printf@plt>
lea    0xe25(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1040 <recurSubsetSum@plt>
cmp    $0x0,%rax
je     1227 <main+0xe7>
lea    0xe1e(%rip),%rdi
call   1030 <printf@plt>
jmp    1233 <main+0xf3>
lea    0xe12(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1050 <DPSubsetSum@plt>
cmp    $0x0,%rax
je     125d <main+0x11d>
lea    0xde8(%rip),%rdi
call   1030 <printf@plt>
jmp    1269 <main+0x129>
lea    0xddc(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movl   $0x0,-0x30(%rbp)
lea    0xe94(%rip),%rdi
call   1040 <printf@plt>
lea    0xea1(%rip),%rdi
lea    -0x2c(%rbp),%rsi
call   1070 <scanf@plt>
mov    %rsp,%r12
mov    -0x2c(%rbp),%eax
mov    %rsp,%r14
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
lea    0xe79(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0x0,-0x2c(%rbp)
jle    11dc <main+0x8c>
xor    %r13d,%r13d
lea    0xe61(%rip),%r15
mov    %r14,%rbx
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
add    $0x1,%r13
movslq -0x2c(%rbp),%rax
add    $0x4,%rbx
cmp    %rax,%r13
jl     11c0 <main+0x70>
lea    0xe4b(%rip),%rdi
call   1040 <printf@plt>
lea    0xe2a(%rip),%rdi
lea    -0x30(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x2c(%rbp),%esi
mov    -0x30(%rbp),%edx
mov    %r14,%rdi
call   1050 <recurSubsetSum@plt>
test   %rax,%rax
lea    0xe2b(%rip),%r15
lea    0xe27(%rip),%rbx
mov    %rbx,%rdi
cmove  %r15,%rdi
call   1030 <puts@plt>
mov    -0x2c(%rbp),%esi
mov    -0x30(%rbp),%edx
mov    %r14,%rdi
call   1060 <DPSubsetSum@plt>
test   %rax,%rax
cmove  %r15,%rbx
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %r12,%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"enter no. of elements : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [18 x i8] c"enter elements : \00"
@.str.3 = [13 x i8] c"enter sum : \00"
@.str.4 = [5 x i8] c"Yes\0A\00"
@.str.5 = [4 x i8] c"No\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
store i32 0, i32* %1
store i32 0, i32* %4
%7 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %2
%10 = zext i32 %9 to i64
%11 = call i8* @llvm.stacksave()
store i8* %11, i8** %5
%12 = alloca i32, i64 %10
store i64 %10, i64* %6
%13 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %14
14: ; preds = %23, %0
%15 = load i32, i32* %3
%16 = load i32, i32* %2
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %26
18: ; preds = %14
%19 = load i32, i32* %3
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %12, i64 %20
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %21)
br label %23
23: ; preds = %18
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 1
store i32 %25, i32* %3
br label %14
26: ; preds = %14
%27 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%28 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%29 = load i32, i32* %2
%30 = load i32, i32* %4
%31 = call i64 @recurSubsetSum(i32* %12, i32 %29, i32 %30)
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %26
%34 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %37
35: ; preds = %26
%36 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
br label %37
37: ; preds = %35, %33
%38 = load i32, i32* %2
%39 = load i32, i32* %4
%40 = call i64 @DPSubsetSum(i32* %12, i32 %38, i32 %39)
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %37
%43 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %46
44: ; preds = %37
%45 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
br label %46
46: ; preds = %44, %42
store i32 0, i32* %1
%47 = load i8*, i8** %5
%48 = load i32, i32* %1
ret i32 %48
}

LLVM IR (-O2):
@.str = [25 x i8] c"enter no. of elements : \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [18 x i8] c"enter elements : \00"
@.str.3 = [13 x i8] c"enter sum : \00"
@str.6 = [3 x i8] c"No\00"
@str.8 = [4 x i8] c"Yes\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = zext i32 %7 to i64
%9 = call i8* @llvm.stacksave()
%10 = alloca i32, i64 %8
%11 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%12 = load i32, i32* %1
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %22
14: ; preds = %0, %14
%15 = phi i64 [ %18, %14 ], [ 0, %0 ]
%16 = getelementptr inbounds i32, i32* %10, i64 %15
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %16)
%18 = add nuw nsw i64 %15, 1
%19 = load i32, i32* %1
%20 = sext i32 %19 to i64
%21 = icmp slt i64 %18, %20
br i1 %21, label %14, label %22
22: ; preds = %14, %0
%23 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%25 = load i32, i32* %1
%26 = load i32, i32* %2
%27 = call i64 @recurSubsetSum(i32* %10, i32 %25, i32 %26)
%28 = icmp eq i64 %27, 0
%29 = select i1 %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @str.6, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @str.8, i64 0, i64 0)
%30 = call i32 @puts(i8* dereferenceable(1) %29)
%31 = load i32, i32* %1
%32 = load i32, i32* %2
%33 = call i64 @DPSubsetSum(i32* %10, i32 %31, i32 %32)
%34 = icmp eq i64 %33, 0
%35 = select i1 %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @str.6, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @str.8, i64 0, i64 0)
%36 = call i32 @puts(i8* dereferenceable(1) %35)
ret i32 0
}