#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 getend(char *, int, int);
int getstart(char *, int, int);
int /*<<< orphan*/ strncpy(char *, char *, int);
void getkey(char *orig, int start, int end, int separator, char *key) {
  int num = getend(orig, end, separator) - getstart(orig, start, separator) - 1;
  strncpy(key, (char *)(orig + getstart(orig, start, separator)), num);
  key[num] = '\0';
}


x86 assembly (clang, -O0):
<getkey>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1050 <getend@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1040 <getstart@plt>
mov    %eax,%ecx
mov    -0x3c(%rbp),%eax
sub    %ecx,%eax
sub    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1040 <getstart@plt>
mov    -0x38(%rbp),%rsi
mov    -0x30(%rbp),%rdi
cltq
add    %rax,%rsi
mov    -0x24(%rbp),%edx
call   1030 <strncpy@plt>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getkey>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%r14
mov    %ecx,%r13d
mov    %esi,%r15d
mov    %rdi,%rbx
mov    %edx,%esi
mov    %ecx,%edx
call   1050 <getend@plt>
mov    %eax,%r12d
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %r13d,%edx
call   1040 <getstart@plt>
mov    %eax,%ebp
not    %ebp
add    %r12d,%ebp
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %r13d,%edx
call   1040 <getstart@plt>
movslq %eax,%rsi
add    %rbx,%rsi
mov    %r14,%rdi
mov    %ebp,%edx
call   1030 <strncpy@plt>
movslq %ebp,%rax
movb   $0x0,(%r14,%rax,1)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @getkey(i8* %0, i32 %1, i32 %2, i32 %3, i8* %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
store i8* %0, i8** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i8* %4, i8** %10
%12 = load i8*, i8** %6
%13 = load i32, i32* %8
%14 = load i32, i32* %9
%15 = call i32 @getend(i8* %12, i32 %13, i32 %14)
%16 = load i8*, i8** %6
%17 = load i32, i32* %7
%18 = load i32, i32* %9
%19 = call i32 @getstart(i8* %16, i32 %17, i32 %18)
%20 = sub nsw i32 %15, %19
%21 = sub nsw i32 %20, 1
store i32 %21, i32* %11
%22 = load i8*, i8** %10
%23 = load i8*, i8** %6
%24 = load i8*, i8** %6
%25 = load i32, i32* %7
%26 = load i32, i32* %9
%27 = call i32 @getstart(i8* %24, i32 %25, i32 %26)
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %23, i64 %28
%30 = load i32, i32* %11
%31 = call i32 @strncpy(i8* %22, i8* %29, i32 %30)
%32 = load i8*, i8** %10
%33 = load i32, i32* %11
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
store i8 0, i8* %35
ret void
}

LLVM IR (-O2):
define void @getkey(i8* %0, i32 %1, i32 %2, i32 %3, i8* %4) {
%6 = tail call i32 @getend(i8* %0, i32 %2, i32 %3)
%7 = tail call i32 @getstart(i8* %0, i32 %1, i32 %3)
%8 = xor i32 %7, -1
%9 = add i32 %6, %8
%10 = tail call i32 @getstart(i8* %0, i32 %1, i32 %3)
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = tail call i32 @strncpy(i8* %4, i8* %12, i32 %9)
%14 = sext i32 %9 to i64
%15 = getelementptr inbounds i8, i8* %4, i64 %14
store i8 0, i8* %15
ret void
}