#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*/ printf(char *, char *);
unsigned int strlen(char *);
void sequences(char *cs, char *buf, unsigned k, unsigned j) {
  if (j == k) {
    buf[k] = '\0';
    printf("%s\n", buf);
  } else {
    for (unsigned i = 0; i < strlen(cs); i++) {
      buf[j] = cs[i];
      sequences(cs, buf, k, j + 1);
    }
  }
}


x86 assembly (clang, -O0):
<sequences>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jne    1172 <sequences+0x42>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rsi
lea    0xe98(%rip),%rdi
call   1050 <printf@plt>
jmp    11d2 <sequences+0xa2>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cmp    %ecx,%eax
jae    11cd <sequences+0x9d>
mov    -0x8(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    (%rax,%rcx,1),%dl
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
call   1030 <sequences@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1179 <sequences+0x49>
jmp    11d2 <sequences+0xa2>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sequences>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r15d
mov    %rsi,%r13
cmp    %edx,%ecx
jne    116b <sequences+0x3b>
mov    %r15d,%eax
movb   $0x0,0x0(%r13,%rax,1)
lea    0xeab(%rip),%rdi
mov    %r13,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <printf@plt>
mov    %edx,%r14d
mov    %rdi,%rbp
call   1040 <strlen@plt>
test   %eax,%eax
je     11be <sequences+0x8e>
mov    %r15d,%r12d
add    $0x1,%r15d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl 0x0(%rbp,%rbx,1),%eax
mov    %al,0x0(%r13,%r12,1)
mov    %rbp,%rdi
mov    %r13,%rsi
mov    %r14d,%edx
mov    %r15d,%ecx
call   1030 <sequences@plt>
add    $0x1,%rbx
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %eax,%eax
cmp    %rax,%rbx
jb     1190 <sequences+0x60>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
define void @sequences(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = load i32, i32* %8
%11 = load i32, i32* %7
%12 = icmp eq i32 %10, %11
br i1 %12, label %13, label %20
13: ; preds = %4
%14 = load i8*, i8** %6
%15 = load i32, i32* %7
%16 = zext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
store i8 0, i8* %17
%18 = load i8*, i8** %6
%19 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %18)
br label %45
20: ; preds = %4
store i32 0, i32* %9
br label %21
21: ; preds = %41, %20
%22 = load i32, i32* %9
%23 = load i8*, i8** %5
%24 = call i32 @strlen(i8* %23)
%25 = icmp ult i32 %22, %24
br i1 %25, label %26, label %44
26: ; preds = %21
%27 = load i8*, i8** %5
%28 = load i32, i32* %9
%29 = zext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
%31 = load i8, i8* %30
%32 = load i8*, i8** %6
%33 = load i32, i32* %8
%34 = zext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
store i8 %31, i8* %35
%36 = load i8*, i8** %5
%37 = load i8*, i8** %6
%38 = load i32, i32* %7
%39 = load i32, i32* %8
%40 = add i32 %39, 1
br label %41
41: ; preds = %26
%42 = load i32, i32* %9
%43 = add i32 %42, 1
store i32 %43, i32* %9
br label %21
44: ; preds = %21
br label %45
45: ; preds = %44, %13
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
define void @sequences(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = icmp eq i32 %3, %2
br i1 %5, label %13, label %6
6: ; preds = %4
%7 = tail call i32 @strlen(i8* %0)
%8 = icmp eq i32 %7, 0
br i1 %8, label %25, label %9
9: ; preds = %6
%10 = zext i32 %3 to i64
%11 = getelementptr inbounds i8, i8* %1, i64 %10
%12 = add i32 %3, 1
br label %17
13: ; preds = %4
%14 = zext i32 %3 to i64
%15 = getelementptr inbounds i8, i8* %1, i64 %14
store i8 0, i8* %15
%16 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %1)
br label %25
17: ; preds = %9, %17
%18 = phi i64 [ 0, %9 ], [ %21, %17 ]
%19 = getelementptr inbounds i8, i8* %0, i64 %18
%20 = load i8, i8* %19
store i8 %20, i8* %11
tail call void @sequences(i8* %0, i8* %1, i32 %2, i32 %12)
%21 = add nuw nsw i64 %18, 1
%22 = tail call i32 @strlen(i8* %0)
%23 = zext i32 %22 to i64
%24 = icmp ult i64 %21, %23
br i1 %24, label %17, label %25
25: ; preds = %17, %6, %13
ret void
}