#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 *);
void sub_string(char *s, char *new, int len) {
  if (len == 0)
    return;
  if (*s == '\0')
    return;
  else {
    *new = *s;
    sub_string(s + 1, new + 1, len - 1);
    printf("\n %s", new);
  }
}


x86 assembly (clang, -O0):
<sub_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1142 <sub_string+0x22>
jmp    118e <sub_string+0x6e>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1157 <sub_string+0x37>
jmp    118e <sub_string+0x6e>
mov    -0x8(%rbp),%rax
mov    (%rax),%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x8(%rbp),%rdi
add    $0x1,%rdi
mov    -0x10(%rbp),%rsi
add    $0x1,%rsi
mov    -0x14(%rbp),%edx
sub    $0x1,%edx
call   1040 <sub_string@plt>
mov    -0x10(%rbp),%rsi
lea    0xe77(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sub_string>:
push   %rbx
test   %edx,%edx
je     1150 <sub_string+0x30>
mov    (%rdi),%al
test   %al,%al
je     1150 <sub_string+0x30>
mov    %rsi,%rbx
mov    %al,(%rsi)
add    $0x1,%rdi
add    $0x1,%rsi
add    $0xffffffff,%edx
call   1040 <sub_string@plt>
lea    0xeb9(%rip),%rdi
mov    %rbx,%rsi
pop    %rbx
jmp    1030 <printf@plt>
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c"\0A %s\00"
define void @sub_string(i8* nocapture %0, i8* %1, i32 %2) {
%4 = icmp eq i32 %2, 0
br i1 %4, label %8, label %5
5: ; preds = %3
%6 = load i8, i8* %0
%7 = icmp eq i8 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %3, %5, %9
ret void
9: ; preds = %5
store i8 %6, i8* %1
%10 = getelementptr inbounds i8, i8* %0, i64 1
%11 = getelementptr inbounds i8, i8* %1, i64 1
%12 = add nsw i32 %2, -1
tail call void @sub_string(i8* %10, i8* %11, i32 %12)
%13 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %1)
br label %8
}