#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 dfs(char *, char **, int *, int, int *, int /*<<< orphan*/);
int *malloc(int);
int /*<<< orphan*/ memset(int *, int, int);
int strlen(char *);
bool wordBreak(char *s, char **wordDict, int wordDictSize) {
  if (wordDictSize == 0) {
    return false;
  }
  int i, len = strlen(s);
  int *lens = malloc(wordDictSize * sizeof(int));
  for (i = 0; i < wordDictSize; i++) {
    lens[i] = strlen(wordDict[i]);
  }
  bool *ends = malloc(len);
  memset(ends, true, len);
  return dfs(s, wordDict, lens, wordDictSize, ends, 0);
}


x86 assembly (clang, -O0):
<wordBreak>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    1169 <wordBreak+0x29>
movl   $0x0,-0x4(%rbp)
jmp    1202 <wordBreak+0xc2>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x24(%rbp)
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11c7 <wordBreak+0x87>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <strlen@plt>
mov    %eax,%edx
mov    -0x30(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    118f <wordBreak+0x4f>
mov    -0x24(%rbp),%edi
call   1050 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x24(%rbp),%edx
mov    $0x1,%esi
call   1040 <memset@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x38(%rbp),%r8
xor    %r9d,%r9d
call   1060 <dfs@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wordBreak>:
test   %edx,%edx
je     11d7 <wordBreak+0x97>
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%r12
mov    %rdi,(%rsp)
call   1030 <strlen@plt>
mov    %eax,%r13d
lea    0x0(,%r14,4),%edi
call   1050 <malloc@plt>
mov    %rax,%r15
test   %r14d,%r14d
jle    1196 <wordBreak+0x56>
mov    %r14d,%ebx
xor    %ebp,%ebp
nop
mov    (%r12,%rbp,8),%rdi
call   1030 <strlen@plt>
mov    %eax,(%r15,%rbp,4)
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1180 <wordBreak+0x40>
mov    %r13d,%edi
call   1050 <malloc@plt>
mov    %r13d,%edx
mov    %rax,%r13
mov    %rax,%rdi
mov    $0x1,%esi
call   1040 <memset@plt>
mov    (%rsp),%rdi
mov    %r12,%rsi
mov    %r15,%rdx
mov    %r14d,%ecx
mov    %r13,%r8
xor    %r9d,%r9d
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <dfs@plt>
xor    %eax,%eax
ret

LLVM IR (-O0):
define i32 @wordBreak(i8* %0, i8** %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8**
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i32*
store i8* %0, i8** %5
store i8** %1, i8*** %6
store i32 %2, i32* %7
%12 = load i32, i32* %7
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %3
store i32 0, i32* %4
br label %53
15: ; preds = %3
%16 = load i8*, i8** %5
%17 = call i32 @strlen(i8* %16)
store i32 %17, i32* %9
%18 = load i32, i32* %7
%19 = sext i32 %18 to i64
%20 = mul i64 %19, 4
%21 = trunc i64 %20 to i32
%22 = call i32* @malloc(i32 %21)
store i32* %22, i32** %10
store i32 0, i32* %8
br label %23
23: ; preds = %38, %15
%24 = load i32, i32* %8
%25 = load i32, i32* %7
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %41
27: ; preds = %23
%28 = load i8**, i8*** %6
%29 = load i32, i32* %8
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8*, i8** %28, i64 %30
%32 = load i8*, i8** %31
%33 = call i32 @strlen(i8* %32)
%34 = load i32*, i32** %10
%35 = load i32, i32* %8
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i32, i32* %34, i64 %36
store i32 %33, i32* %37
br label %38
38: ; preds = %27
%39 = load i32, i32* %8
%40 = add nsw i32 %39, 1
store i32 %40, i32* %8
br label %23
41: ; preds = %23
%42 = load i32, i32* %9
%43 = call i32* @malloc(i32 %42)
store i32* %43, i32** %11
%44 = load i32*, i32** %11
%45 = load i32, i32* %9
%46 = call i32 @memset(i32* %44, i32 1, i32 %45)
%47 = load i8*, i8** %5
%48 = load i8**, i8*** %6
%49 = load i32*, i32** %10
%50 = load i32, i32* %7
%51 = load i32*, i32** %11
%52 = call i32 @dfs(i8* %47, i8** %48, i32* %49, i32 %50, i32* %51, i32 0)
store i32 %52, i32* %4
br label %53
53: ; preds = %41, %14
%54 = load i32, i32* %4
ret i32 %54
}

LLVM IR (-O2):
define i32 @wordBreak(i8* %0, i8** %1, i32 %2) {
%4 = icmp eq i32 %2, 0
br i1 %4, label %24, label %5
5: ; preds = %3
%6 = tail call i32 @strlen(i8* %0)
%7 = shl i32 %2, 2
%8 = tail call i32* @malloc(i32 %7)
%9 = icmp sgt i32 %2, 0
br i1 %9, label %10, label %20
10: ; preds = %5
%11 = zext i32 %2 to i64
br label %12
12: ; preds = %10, %12
%13 = phi i64 [ 0, %10 ], [ %18, %12 ]
%14 = getelementptr inbounds i8*, i8** %1, i64 %13
%15 = load i8*, i8** %14
%16 = tail call i32 @strlen(i8* %15)
%17 = getelementptr inbounds i32, i32* %8, i64 %13
store i32 %16, i32* %17
%18 = add nuw nsw i64 %13, 1
%19 = icmp eq i64 %18, %11
br i1 %19, label %20, label %12
20: ; preds = %12, %5
%21 = tail call i32* @malloc(i32 %6)
%22 = tail call i32 @memset(i32* %21, i32 1, i32 %6)
%23 = tail call i32 @dfs(i8* %0, i8** %1, i32* %8, i32 %2, i32* %21, i32 0)
br label %24
24: ; preds = %3, %20
%25 = phi i32 [ %23, %20 ], [ 0, %3 ]
ret i32 %25
}