#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 *);
int /*<<< orphan*/ test_trim(char *, int);
int main(void) {
  printf("\n\t\tNull Source\n");
  test_trim(NULL, 14);
  printf("\n\t\tWorking\n");
  test_trim("asdfasdf\n"
            "asdfasdf\n"
            "1 3 5 2 6\n"
            "\n"
            "2\n"
            "2223232323\0",
            3);
  printf("\n\t\tZero Offset\n");
  test_trim("asdfasdf\n"
            "asdfasdf\n"
            "1 3 5 2 6\n"
            "\n"
            "2\n"
            "2223232323\0",
            0);
  printf("\n\t\t14 Offset\n");
  test_trim("asdfasdf\n"
            "asdfasdf\n"
            "1 3 5 2 6\n"
            "\n"
            "2\n"
            "2223232342342342323\0",
            14);
  printf("\n\t\tOne Line\n");
  test_trim("Hi! Test line!\n", 3);
  printf("\n\t\tAnother Test\n");
  test_trim("1234567890\n"
            "1234567890\n"
            "12345678901\n"
            "123456789\n",
            10);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
lea    0xed5(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
mov    $0xe,%esi
call   1040 <test_trim@plt>
lea    0xecb(%rip),%rdi
call   1030 <printf@plt>
lea    0xf44(%rip),%rdi
mov    $0x3,%esi
call   1040 <test_trim@plt>
lea    0xeba(%rip),%rdi
call   1030 <printf@plt>
lea    0xf27(%rip),%rdi
xor    %esi,%esi
call   1040 <test_trim@plt>
lea    0xeb0(%rip),%rdi
call   1030 <printf@plt>
lea    0xf38(%rip),%rdi
mov    $0xe,%esi
call   1040 <test_trim@plt>
lea    0xea1(%rip),%rdi
call   1030 <printf@plt>
lea    0xea2(%rip),%rdi
mov    $0x3,%esi
call   1040 <test_trim@plt>
lea    0xea1(%rip),%rdi
call   1030 <printf@plt>
lea    0xea6(%rip),%rdi
mov    $0xa,%esi
call   1040 <test_trim@plt>
xor    %eax,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xf74(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
mov    $0xe,%esi
call   1040 <test_trim@plt>
lea    0xf6b(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb4(%rip),%rbx
mov    %rbx,%rdi
mov    $0x3,%esi
call   1040 <test_trim@plt>
lea    0xf56(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <test_trim@plt>
lea    0xf4f(%rip),%rdi
call   1030 <puts@plt>
lea    0xea9(%rip),%rdi
mov    $0xe,%esi
call   1040 <test_trim@plt>
lea    0xf3f(%rip),%rdi
call   1030 <puts@plt>
lea    0xec0(%rip),%rdi
mov    $0x3,%esi
call   1040 <test_trim@plt>
lea    0xf2e(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb3(%rip),%rdi
mov    $0xa,%esi
call   1040 <test_trim@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [16 x i8] c"\0A\09\09Null Source\0A\00"
@.str.1 = [12 x i8] c"\0A\09\09Working\0A\00"
@.str.2 = [43 x i8] c"asdfasdf\0Aasdfasdf\0A1 3 5 2 6\0A\0A2\0A2223232323\00\00"
@.str.3 = [16 x i8] c"\0A\09\09Zero Offset\0A\00"
@.str.4 = [14 x i8] c"\0A\09\0914 Offset\0A\00"
@.str.5 = [52 x i8] c"asdfasdf\0Aasdfasdf\0A1 3 5 2 6\0A\0A2\0A2223232342342342323\00\00"
@.str.6 = [13 x i8] c"\0A\09\09One Line\0A\00"
@.str.7 = [16 x i8] c"Hi! Test line!\0A\00"
@.str.8 = [17 x i8] c"\0A\09\09Another Test\0A\00"
@.str.9 = [45 x i8] c"1234567890\0A1234567890\0A12345678901\0A123456789\0A\00"
define i32 @main() {
%1 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%2 = call i32 @test_trim(i8* null, i32 14)
%3 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 @test_trim(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i32 3)
%5 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%6 = call i32 @test_trim(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i32 0)
%7 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%8 = call i32 @test_trim(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.5, i64 0, i64 0), i32 14)
%9 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0))
%10 = call i32 @test_trim(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i32 3)
%11 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0))
%12 = call i32 @test_trim(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.9, i64 0, i64 0), i32 10)
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [43 x i8] c"asdfasdf\0Aasdfasdf\0A1 3 5 2 6\0A\0A2\0A2223232323\00\00"
@.str.5 = [52 x i8] c"asdfasdf\0Aasdfasdf\0A1 3 5 2 6\0A\0A2\0A2223232342342342323\00\00"
@.str.7 = [16 x i8] c"Hi! Test line!\0A\00"
@.str.9 = [45 x i8] c"1234567890\0A1234567890\0A12345678901\0A123456789\0A\00"
@str = [15 x i8] c"\0A\09\09Null Source\00"
@str.10 = [11 x i8] c"\0A\09\09Working\00"
@str.11 = [15 x i8] c"\0A\09\09Zero Offset\00"
@str.12 = [13 x i8] c"\0A\09\0914 Offset\00"
@str.13 = [12 x i8] c"\0A\09\09One Line\00"
@str.14 = [16 x i8] c"\0A\09\09Another Test\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @test_trim(i8* null, i32 14)
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.10, i64 0, i64 0))
%4 = tail call i32 @test_trim(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i32 3)
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.11, i64 0, i64 0))
%6 = tail call i32 @test_trim(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i32 0)
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.12, i64 0, i64 0))
%8 = tail call i32 @test_trim(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.5, i64 0, i64 0), i32 14)
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.13, i64 0, i64 0))
%10 = tail call i32 @test_trim(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i32 3)
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.14, i64 0, i64 0))
%12 = tail call i32 @test_trim(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.9, i64 0, i64 0), i32 10)
ret i32 0
}