#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__ calloc(scalar_t__, int);
int /*<<< orphan*/ printf(char *, char *, char *);
scalar_t__ starts_with(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
bool wordBreak_recur(char *s, char **wordDict, int wordDictSize) {
  for (int w = 0; w < wordDictSize; w++) {
    if (starts_with(s, wordDict[w])) {
      printf("%s starts with %s\n", s, wordDict[w]);
      char *new_s = (char *)calloc(strlen(s), sizeof(char));
      strcpy(new_s, s + strlen(wordDict[w]));
      if (wordBreak_recur(new_s, wordDict, wordDictSize))
        return true;
    }
  }
  return (strlen(s) == 0);
}


x86 assembly (clang, -O0):
<wordBreak_recur>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1249 <wordBreak_recur+0xe9>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1070 <starts_with@plt>
cmp    $0x0,%rax
je     1236 <wordBreak_recur+0xd6>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe44(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rdi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <strlen@plt>
mov    -0x38(%rbp),%rsi
mov    -0x30(%rbp),%rdi
add    %rax,%rsi
call   1030 <strcpy@plt>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1080 <wordBreak_recur@plt>
cmp    $0x0,%eax
je     1231 <wordBreak_recur+0xd1>
movl   $0x1,-0x4(%rbp)
jmp    1261 <wordBreak_recur+0x101>
jmp    1236 <wordBreak_recur+0xd6>
jmp    123b <wordBreak_recur+0xdb>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    117a <wordBreak_recur+0x1a>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wordBreak_recur>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r13
mov    %edx,0x4(%rsp)
test   %edx,%edx
jle    11ff <wordBreak_recur+0x9f>
mov    %rsi,%r12
mov    0x4(%rsp),%r15d
xor    %r14d,%r14d
mov    $0x1,%ebp
jmp    1199 <wordBreak_recur+0x39>
nopl   0x0(%rax)
add    $0x1,%r14
cmp    %r14,%r15
je     11ff <wordBreak_recur+0x9f>
mov    (%r12,%r14,8),%rsi
mov    %r13,%rdi
call   1070 <starts_with@plt>
test   %rax,%rax
je     1190 <wordBreak_recur+0x30>
mov    (%r12,%r14,8),%rdx
lea    0xe4b(%rip),%rdi
mov    %r13,%rsi
call   1050 <printf@plt>
mov    %r13,%rdi
call   1040 <strlen@plt>
mov    %rax,%rdi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,%rbx
mov    (%r12,%r14,8),%rdi
call   1040 <strlen@plt>
lea    (%rax,%r13,1),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    0x4(%rsp),%edx
call   1080 <wordBreak_recur@plt>
test   %eax,%eax
je     1190 <wordBreak_recur+0x30>
jmp    120a <wordBreak_recur+0xaa>
xor    %ebp,%ebp
cmpb   $0x0,0x0(%r13)
sete   %bpl
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"%s starts with %s\0A\00"
define i32 @wordBreak_recur(i8* %0, i8** %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8**
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
store i8* %0, i8** %5
store i8** %1, i8*** %6
store i32 %2, i32* %7
store i32 0, i32* %8
br label %10
10: ; preds = %53, %3
%11 = load i32, i32* %8
%12 = load i32, i32* %7
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %56
14: ; preds = %10
%15 = load i8*, i8** %5
%16 = load i8**, i8*** %6
%17 = load i32, i32* %8
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8*, i8** %16, i64 %18
%20 = load i8*, i8** %19
%21 = call i64 @starts_with(i8* %15, i8* %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %52
23: ; preds = %14
%24 = load i8*, i8** %5
%25 = load i8**, i8*** %6
%26 = load i32, i32* %8
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8*, i8** %25, i64 %27
%29 = load i8*, i8** %28
%30 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %24, i8* %29)
%31 = load i8*, i8** %5
%32 = call i64 @strlen(i8* %31)
%33 = call i64 @calloc(i64 %32, i32 1)
%34 = inttoptr i64 %33 to i8*
store i8* %34, i8** %9
%35 = load i8*, i8** %9
%36 = load i8*, i8** %5
%37 = load i8**, i8*** %6
%38 = load i32, i32* %8
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8*, i8** %37, i64 %39
%41 = load i8*, i8** %40
%42 = call i64 @strlen(i8* %41)
%43 = getelementptr inbounds i8, i8* %36, i64 %42
%44 = call i32 @strcpy(i8* %35, i8* %43)
%45 = load i8*, i8** %9
%46 = load i8**, i8*** %6
%47 = load i32, i32* %7
%48 = call i32 @wordBreak_recur(i8* %45, i8** %46, i32 %47)
%49 = icmp ne i32 %48, 0
br i1 %49, label %50, label %51
50: ; preds = %23
store i32 1, i32* %4
br label %61
51: ; preds = %23
br label %52
52: ; preds = %51, %14
br label %53
53: ; preds = %52
%54 = load i32, i32* %8
%55 = add nsw i32 %54, 1
store i32 %55, i32* %8
br label %10
56: ; preds = %10
%57 = load i8*, i8** %5
%58 = call i64 @strlen(i8* %57)
%59 = icmp eq i64 %58, 0
%60 = zext i1 %59 to i32
store i32 %60, i32* %4
br label %61
61: ; preds = %56, %50
%62 = load i32, i32* %4
ret i32 %62
}

LLVM IR (-O2):
@.str = [19 x i8] c"%s starts with %s\0A\00"
define i32 @wordBreak_recur(i8* %0, i8** nocapture %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %28
5: ; preds = %3
%6 = zext i32 %2 to i64
br label %7
7: ; preds = %5, %25
%8 = phi i64 [ 0, %5 ], [ %26, %25 ]
%9 = getelementptr inbounds i8*, i8** %1, i64 %8
%10 = load i8*, i8** %9
%11 = tail call i64 @starts_with(i8* %0, i8* %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %25, label %13
13: ; preds = %7
%14 = load i8*, i8** %9
%15 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %14)
%16 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%17 = tail call i64 @calloc(i64 %16, i32 1)
%18 = inttoptr i64 %17 to i8*
%19 = load i8*, i8** %9
%20 = tail call i64 @strlen(i8* dereferenceable(1) %19)
%21 = getelementptr inbounds i8, i8* %0, i64 %20
%22 = tail call i32 @strcpy(i8* %18, i8* %21)
%23 = tail call i32 @wordBreak_recur(i8* %18, i8** %1, i32 %2)
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %32
25: ; preds = %7, %13
%26 = add nuw nsw i64 %8, 1
%27 = icmp eq i64 %26, %6
br i1 %27, label %28, label %7
28: ; preds = %25, %3
%29 = load i8, i8* %0
%30 = icmp eq i8 %29, 0
%31 = zext i1 %30 to i32
br label %32
32: ; preds = %13, %28
%33 = phi i32 [ %31, %28 ], [ 1, %13 ]
ret i32 %33
}