#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 */
char *memory_Malloc(int);
int /*<<< orphan*/ strcpy(char *, char const *);
char *string_EmptyString();
int strlen(char const *);
char *string_Suffix(const char *s, int i) {
  int l;
  char *dst;
  l = strlen(s);
  if (i >= l)
    return string_EmptyString();
  dst = memory_Malloc(l - i + 1);
  strcpy(dst, s + i);
  return dst;
}


x86 assembly (clang, -O0):
<string_Suffix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jl     1177 <string_Suffix+0x37>
mov    $0x0,%al
call   1050 <string_EmptyString@plt>
mov    %rax,-0x8(%rbp)
jmp    11a5 <string_Suffix+0x65>
mov    -0x18(%rbp),%edi
sub    -0x14(%rbp),%edi
add    $0x1,%edi
call   1030 <memory_Malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movslq -0x14(%rbp),%rax
add    %rax,%rsi
call   1040 <strcpy@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<string_Suffix>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %rdi,%rbx
call   1060 <strlen@plt>
sub    %ebp,%eax
jle    1178 <string_Suffix+0x38>
add    $0x1,%eax
mov    %eax,%edi
call   1030 <memory_Malloc@plt>
mov    %rax,%r14
movslq %ebp,%rax
add    %rax,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <string_EmptyString@plt>

LLVM IR (-O0):
define i8* @string_Suffix(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
store i8* %0, i8** %4
store i32 %1, i32* %5
%8 = load i8*, i8** %4
%9 = call i32 @strlen(i8* %8)
store i32 %9, i32* %6
%10 = load i32, i32* %5
%11 = load i32, i32* %6
%12 = icmp sge i32 %10, %11
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = call i8* (...) @string_EmptyString()
store i8* %14, i8** %3
br label %28
15: ; preds = %2
%16 = load i32, i32* %6
%17 = load i32, i32* %5
%18 = sub nsw i32 %16, %17
%19 = add nsw i32 %18, 1
%20 = call i8* @memory_Malloc(i32 %19)
store i8* %20, i8** %7
%21 = load i8*, i8** %7
%22 = load i8*, i8** %4
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
%26 = call i32 @strcpy(i8* %21, i8* %25)
%27 = load i8*, i8** %7
store i8* %27, i8** %3
br label %28
28: ; preds = %15, %13
%29 = load i8*, i8** %3
ret i8* %29
}

LLVM IR (-O2):
define i8* @string_Suffix(i8* %0, i32 %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = icmp sgt i32 %3, %1
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = tail call i8* (...) @string_EmptyString()
br label %14
7: ; preds = %2
%8 = sub i32 1, %1
%9 = add i32 %8, %3
%10 = tail call i8* @memory_Malloc(i32 %9)
%11 = sext i32 %1 to i64
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = tail call i32 @strcpy(i8* %10, i8* %12)
br label %14
14: ; preds = %7, %5
%15 = phi i8* [ %6, %5 ], [ %10, %7 ]
ret i8* %15
}