#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*/ init_bounds(char **, int *, int *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
void prepend_word(char *pass, int cnt, void **nxt_f) {
  char *words[] = {"Welcome ", NULL};
  static int num_words = 0, longest_word = 0;
  if (num_words == 0 || longest_word == 0)
    init_bounds(words, &num_words, &longest_word);
  int lpass = strlen(pass);
  char pass_new[lpass + longest_word + 1];
  strcpy(pass_new, pass);
  void (*func)(char *pass, int cnt, void **nxt_f) = *nxt_f;
  func(pass, 0, nxt_f + 1);
  int i;
  for (i = 0; i < num_words; i++) {
    sprintf(pass_new, "%s%s", words[i], pass);
    func(pass_new, 0, nxt_f + 1);
  }
}


x86 assembly (clang, -O0):
<prepend_word>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    0x2cb6(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2cb3(%rip),%rax
mov    %rax,-0x28(%rbp)
cmpl   $0x0,0x2ed4(%rip)
je     1183 <prepend_word+0x43>
cmpl   $0x0,0x2ecb(%rip)
jne    119a <prepend_word+0x5a>
lea    -0x30(%rbp),%rdi
lea    0x2eb6(%rip),%rsi
lea    0x2eb3(%rip),%rdx
call   1050 <init_bounds@plt>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%edx
mov    0x2e99(%rip),%eax
mov    %eax,%ecx
mov    %edx,%eax
lea    0x1(%rax,%rcx,1),%eax
mov    %rsp,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x60(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x48(%rbp)
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
add    $0x8,%rdx
xor    %esi,%esi
call   *%rax
movl   $0x0,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    0x2e32(%rip),%eax
jge    1257 <prepend_word+0x117>
mov    -0x60(%rbp),%rdi
movslq -0x54(%rbp),%rax
mov    -0x30(%rbp,%rax,8),%rdx
mov    -0x8(%rbp),%rcx
lea    0xdd9(%rip),%rsi
call   1060 <sprintf@plt>
mov    -0x60(%rbp),%rdi
mov    -0x50(%rbp),%rax
mov    -0x18(%rbp),%rdx
add    $0x8,%rdx
xor    %esi,%esi
call   *%rax
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1209 <prepend_word+0xc9>
mov    -0x40(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prepend_word>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r15
mov    %rdi,%r14
movaps 0x2cb2(%rip),%xmm0
movaps %xmm0,-0x40(%rbp)
cmpl   $0x0,0x2edb(%rip)
je     1174 <prepend_word+0x34>
cmpl   $0x0,0x2ed6(%rip)
jne    118b <prepend_word+0x4b>
lea    0x2ec9(%rip),%rsi
lea    0x2ec6(%rip),%rdx
lea    -0x40(%rbp),%rdi
call   1050 <init_bounds@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %rsp,-0x30(%rbp)
mov    0x2eab(%rip),%ecx
add    %ecx,%eax
add    $0x1,%eax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%rbx
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    (%r15),%r13
add    $0x8,%r15
mov    %r14,%rdi
xor    %esi,%esi
mov    %r15,%rdx
call   *%r13
cmpl   $0x0,0x2e6d(%rip)
jle    1212 <prepend_word+0xd2>
xor    %r12d,%r12d
nopl   0x0(%rax)
mov    -0x40(%rbp,%r12,8),%rdx
mov    %rbx,%rdi
lea    0xe1a(%rip),%rsi
mov    %r14,%rcx
call   1060 <sprintf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    %r15,%rdx
call   *%r13
add    $0x1,%r12
movslq 0x2e37(%rip),%rax
cmp    %rax,%r12
jl     11e0 <prepend_word+0xa0>
mov    -0x30(%rbp),%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [9 x i8] c"Welcome \00"
@__const.prepend_word.words = [2 x i8*] [i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i32 0, i32 0), i8* null]
@prepend_word.num_words = internal global i32 0
@prepend_word.longest_word = internal global i32 0
@.str.1 = [5 x i8] c"%s%s\00"
define void @prepend_word(i8* %0, i32 %1, i8** %2) {
%4 = alloca [2 x i8*]
%5 = bitcast [2 x i8*]* %4 to i8*
%6 = load i32, i32* @prepend_word.num_words
%7 = icmp eq i32 %6, 0
%8 = load i32, i32* @prepend_word.longest_word
%9 = icmp eq i32 %8, 0
%10 = select i1 %7, i1 true, i1 %9
br i1 %10, label %11, label %14
11: ; preds = %3
%12 = getelementptr inbounds [2 x i8*], [2 x i8*]* %4, i64 0, i64 0
%13 = call i32 @init_bounds(i8** %12, i32* @prepend_word.num_words, i32* @prepend_word.longest_word)
br label %14
14: ; preds = %3, %11
%15 = call i32 @strlen(i8* %0)
%16 = load i32, i32* @prepend_word.longest_word
%17 = add i32 %15, 1
%18 = add i32 %17, %16
%19 = zext i32 %18 to i64
%20 = call i8* @llvm.stacksave()
%21 = alloca i8, i64 %19
%22 = call i32 @strcpy(i8* %21, i8* %0)
%23 = bitcast i8** %2 to void (i8*, i32, i8**)**
%24 = load void (i8*, i32, i8**)*, void (i8*, i32, i8**)** %23
%25 = getelementptr inbounds i8*, i8** %2, i64 1
%26 = load i32, i32* @prepend_word.num_words
%27 = icmp sgt i32 %26, 0
br i1 %27, label %28, label %37
28: ; preds = %14, %28
%29 = phi i64 [ %33, %28 ], [ 0, %14 ]
%30 = getelementptr inbounds [2 x i8*], [2 x i8*]* %4, i64 0, i64 %29
%31 = load i8*, i8** %30
%32 = call i32 @sprintf(i8* %21, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %31, i8* %0)
%33 = add nuw nsw i64 %29, 1
%34 = load i32, i32* @prepend_word.num_words
%35 = sext i32 %34 to i64
%36 = icmp slt i64 %33, %35
br i1 %36, label %28, label %37
37: ; preds = %28, %14
ret void
}