#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*/ memcpy(char *, char *, size_t);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, char *);
size_t strlen(char *);
char *strstr(char *, char *);
void word_break(char *sentence, char *dict[], char *buf) {
  if (*sentence == 0) {
    printf("sentence : %s\n", buf);
    memset(buf, 0, 32);
    return;
  }
  int i = 0;
  for (i = 0; dict[i] != NULL; i++) {
    if (strstr(sentence, dict[i]) == sentence) {
      memcpy(&buf[strlen(buf)], dict[i], strlen(dict[i]));
      buf[strlen(buf)] = ' ';
      buf[strlen(buf) + 1] = 0;
      word_break(&sentence[strlen(dict[i])], dict, buf);
    }
  }
}


x86 assembly (clang, -O0):
<word_break>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11a9 <word_break+0x49>
mov    -0x18(%rbp),%rsi
lea    0xe71(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1050 <memset@plt>
jmp    12b2 <word_break+0x152>
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     12b2 <word_break+0x152>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1080 <strstr@plt>
cmp    -0x8(%rbp),%rax
jne    129f <word_break+0x13f>
mov    -0x18(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x50(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <strlen@plt>
mov    -0x48(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    %rax,%rdx
call   1060 <memcpy@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
movb   $0x20,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
movb   $0x0,0x1(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <strlen@plt>
mov    -0x28(%rbp),%rdi
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1070 <word_break@plt>
jmp    12a4 <word_break+0x144>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11b7 <word_break+0x57>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<word_break>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r12
cmpb   $0x0,(%rdi)
je     121d <word_break+0xbd>
mov    %rsi,%r14
mov    (%rsi),%rbx
test   %rbx,%rbx
je     120e <word_break+0xae>
mov    %rdi,%r15
lea    0x8(%r14),%rbp
jmp    119d <word_break+0x3d>
nop
mov    0x0(%rbp),%rbx
add    $0x8,%rbp
test   %rbx,%rbx
je     120e <word_break+0xae>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1030 <strncmp@plt>
test   %eax,%eax
jne    1190 <word_break+0x30>
mov    %r12,%rdi
call   1040 <strlen@plt>
lea    (%rax,%r12,1),%r13
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1070 <memcpy@plt>
mov    %r12,%rdi
call   1040 <strlen@plt>
movb   $0x20,(%r12,%rax,1)
mov    %r12,%rdi
call   1040 <strlen@plt>
movb   $0x0,0x1(%rax,%r12,1)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
lea    (%rax,%r15,1),%rdi
mov    %r14,%rsi
mov    %r12,%rdx
call   1080 <word_break@plt>
jmp    1190 <word_break+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xddc(%rip),%rdi
mov    %r12,%rsi
call   1050 <printf@plt>
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x20,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <memset@plt>

LLVM IR (-O0):
@.str = [15 x i8] c"sentence : %s\0A\00"
define void @word_break(i8* %0, i8** %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i8* %2, i8** %6
%8 = load i8*, i8** %4
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %17
12: ; preds = %3
%13 = load i8*, i8** %6
%14 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = load i8*, i8** %6
%16 = call i32 @memset(i8* %15, i32 0, i32 32)
br label %75
17: ; preds = %3
store i32 0, i32* %7
store i32 0, i32* %7
br label %18
18: ; preds = %72, %17
%19 = load i8**, i8*** %5
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8*, i8** %19, i64 %21
%23 = load i8*, i8** %22
%24 = icmp ne i8* %23, null
br i1 %24, label %25, label %75
25: ; preds = %18
%26 = load i8*, i8** %4
%27 = load i8**, i8*** %5
%28 = load i32, i32* %7
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %27, i64 %29
%31 = load i8*, i8** %30
%32 = call i8* @strstr(i8* %26, i8* %31)
%33 = load i8*, i8** %4
%34 = icmp eq i8* %32, %33
br i1 %34, label %35, label %71
35: ; preds = %25
%36 = load i8*, i8** %6
%37 = load i8*, i8** %6
%38 = call i64 @strlen(i8* %37)
%39 = getelementptr inbounds i8, i8* %36, i64 %38
%40 = load i8**, i8*** %5
%41 = load i32, i32* %7
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8*, i8** %40, i64 %42
%44 = load i8*, i8** %43
%45 = load i8**, i8*** %5
%46 = load i32, i32* %7
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8*, i8** %45, i64 %47
%49 = load i8*, i8** %48
%50 = call i64 @strlen(i8* %49)
%51 = call i32 @memcpy(i8* %39, i8* %44, i64 %50)
%52 = load i8*, i8** %6
%53 = load i8*, i8** %6
%54 = call i64 @strlen(i8* %53)
%55 = getelementptr inbounds i8, i8* %52, i64 %54
store i8 32, i8* %55
%56 = load i8*, i8** %6
%57 = load i8*, i8** %6
%58 = call i64 @strlen(i8* %57)
%59 = add i64 %58, 1
%60 = getelementptr inbounds i8, i8* %56, i64 %59
store i8 0, i8* %60
%61 = load i8*, i8** %4
%62 = load i8**, i8*** %5
%63 = load i32, i32* %7
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i8*, i8** %62, i64 %64
%66 = load i8*, i8** %65
%67 = call i64 @strlen(i8* %66)
%68 = getelementptr inbounds i8, i8* %61, i64 %67
%69 = load i8**, i8*** %5
%70 = load i8*, i8** %6
br label %71
71: ; preds = %35, %25
br label %72
72: ; preds = %71
%73 = load i32, i32* %7
%74 = add nsw i32 %73, 1
store i32 %74, i32* %7
br label %18
75: ; preds = %12, %18
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"sentence : %s\0A\00"
define void @word_break(i8* nocapture %0, i8** nocapture %1, i8* %2) {
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %3
%7 = load i8*, i8** %1
%8 = icmp eq i8* %7, null
br i1 %8, label %37, label %12
9: ; preds = %3
%10 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %2)
%11 = tail call i32 @memset(i8* %2, i32 0, i32 32)
br label %37
12: ; preds = %6, %32
%13 = phi i64 [ %33, %32 ], [ 0, %6 ]
%14 = phi i8* [ %35, %32 ], [ %7, %6 ]
%15 = phi i8** [ %34, %32 ], [ %1, %6 ]
%16 = tail call i64 @strlen(i8* %14)
%17 = tail call i32 @strncmp(i8* %0, i8* %14, i64 %16)
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %32
19: ; preds = %12
%20 = tail call i64 @strlen(i8* dereferenceable(1) %2)
%21 = getelementptr inbounds i8, i8* %2, i64 %20
%22 = tail call i64 @strlen(i8* %14)
%23 = tail call i32 @memcpy(i8* %21, i8* %14, i64 %22)
%24 = tail call i64 @strlen(i8* dereferenceable(1) %2)
%25 = getelementptr inbounds i8, i8* %2, i64 %24
store i8 32, i8* %25
%26 = tail call i64 @strlen(i8* dereferenceable(1) %2)
%27 = add i64 %26, 1
%28 = getelementptr inbounds i8, i8* %2, i64 %27
store i8 0, i8* %28
%29 = load i8*, i8** %15
%30 = tail call i64 @strlen(i8* dereferenceable(1) %29)
%31 = getelementptr inbounds i8, i8* %0, i64 %30
tail call void @word_break(i8* %31, i8** %1, i8* %2)
br label %32
32: ; preds = %12, %19
%33 = add nuw i64 %13, 1
%34 = getelementptr inbounds i8*, i8** %1, i64 %33
%35 = load i8*, i8** %34
%36 = icmp eq i8* %35, null
br i1 %36, label %37, label %12
37: ; preds = %32, %6, %9
ret void
}