#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 *);
int /*<<< orphan*/ substring(char *, int, int, char *);
int main(void) {
  char result[81];
  substring("character", 4, 3, result);
  printf("%s\n", result);
  substring("two words", 4, 20, result);
  printf("%s\n", result);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x60(%rbp),%rcx
lea    0xec6(%rip),%rdi
mov    $0x4,%esi
mov    $0x3,%edx
call   1040 <substring@plt>
lea    -0x60(%rbp),%rsi
lea    0xeb6(%rip),%rdi
call   1030 <printf@plt>
lea    -0x60(%rbp),%rcx
lea    0xeaa(%rip),%rdi
mov    $0x4,%esi
mov    $0x14,%edx
call   1040 <substring@plt>
lea    -0x60(%rbp),%rsi
lea    0xe8c(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x58,%rsp
lea    0xed2(%rip),%rdi
mov    %rsp,%rbx
mov    $0x4,%esi
mov    $0x3,%edx
mov    %rbx,%rcx
call   1040 <substring@plt>
lea    0xec0(%rip),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
lea    0xeb2(%rip),%rdi
mov    $0x4,%esi
mov    $0x14,%edx
mov    %rbx,%rcx
call   1040 <substring@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [10 x i8] c"character\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [10 x i8] c"two words\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [81 x i8]
store i32 0, i32* %1
%3 = getelementptr inbounds [81 x i8], [81 x i8]* %2, i64 0, i64 0
%4 = call i32 @substring(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 4, i32 3, i8* %3)
%5 = getelementptr inbounds [81 x i8], [81 x i8]* %2, i64 0, i64 0
%6 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%7 = getelementptr inbounds [81 x i8], [81 x i8]* %2, i64 0, i64 0
%8 = call i32 @substring(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 4, i32 20, i8* %7)
%9 = getelementptr inbounds [81 x i8], [81 x i8]* %2, i64 0, i64 0
%10 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %9)
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"character\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [10 x i8] c"two words\00"
define i32 @main() {
%1 = alloca [81 x i8]
%2 = getelementptr inbounds [81 x i8], [81 x i8]* %1, i64 0, i64 0
%3 = call i32 @substring(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 4, i32 3, i8* %2)
%4 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%5 = call i32 @substring(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 4, i32 20, i8* %2)
%6 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %2)
ret i32 0
}