#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 my_strlen(char *);
char *my_substr(char *s, int start, int length) {
  char *c = "";
  int i = 0;
  int end = start + length;
  if (end > my_strlen(s)) {
    end = my_strlen(s);
  }
  while (*s) {
    if (i >= start && i < end) {
    }
    s++;
  }
  return c;
}


x86 assembly (clang, -O0):
<my_substr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
lea    0xed7(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <my_strlen@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
cmp    %ecx,%eax
jle    1165 <my_substr+0x55>
mov    -0x8(%rbp),%rdi
call   1030 <my_strlen@plt>
mov    %eax,-0x20(%rbp)
jmp    116a <my_substr+0x5a>
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     11a5 <my_substr+0x95>
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jl     1194 <my_substr+0x84>
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1194 <my_substr+0x84>
jmp    1194 <my_substr+0x84>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    116a <my_substr+0x5a>
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_substr>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
add    %edx,%ebp
call   1030 <my_strlen@plt>
cmp    %eax,%ebp
jle    112b <my_substr+0x1b>
mov    %rbx,%rdi
call   1030 <my_strlen@plt>
lea    0xece(%rip),%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
define i8* @my_substr(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %7
store i32 0, i32* %8
%10 = load i32, i32* %5
%11 = load i32, i32* %6
%12 = add nsw i32 %10, %11
store i32 %12, i32* %9
%13 = load i32, i32* %9
%14 = load i8*, i8** %4
%15 = call i32 @my_strlen(i8* %14)
%16 = icmp sgt i32 %13, %15
br i1 %16, label %17, label %20
17: ; preds = %3
%18 = load i8*, i8** %4
%19 = call i32 @my_strlen(i8* %18)
store i32 %19, i32* %9
br label %20
20: ; preds = %17, %3
br label %21
21: ; preds = %34, %20
%22 = load i8*, i8** %4
%23 = load i8, i8* %22
%24 = icmp ne i8 %23, 0
br i1 %24, label %25, label %37
25: ; preds = %21
%26 = load i32, i32* %8
%27 = load i32, i32* %5
%28 = icmp sge i32 %26, %27
br i1 %28, label %29, label %34
29: ; preds = %25
%30 = load i32, i32* %8
%31 = load i32, i32* %9
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %34
33: ; preds = %29
br label %34
34: ; preds = %33, %29, %25
%35 = load i8*, i8** %4
%36 = getelementptr inbounds i8, i8* %35, i32 1
store i8* %36, i8** %4
br label %21
37: ; preds = %21
%38 = load i8*, i8** %7
ret i8* %38
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
define i8* @my_substr(i8* %0, i32 %1, i32 %2) {
%4 = add nsw i32 %2, %1
%5 = tail call i32 @my_strlen(i8* %0)
%6 = icmp sgt i32 %4, %5
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = tail call i32 @my_strlen(i8* %0)
br label %9
9: ; preds = %7, %3
ret i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0)
}