#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 strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
void TrimCopy(char *Trim, char *Line, int n) {
  int l;
  char *s;
  l = strlen(Line);
  Line[--l] = 0;
  while (Line[l - 1] == ' ')
    Line[--l] = 0;
  s = Line;
  while (*s == ' ')
    ++s;
  strncpy(Trim, s, n);
}


x86 assembly (clang, -O0):
<TrimCopy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x18(%rbp)
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    1186 <TrimCopy+0x66>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x18(%rbp)
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    1153 <TrimCopy+0x33>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    11af <TrimCopy+0x8f>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    118e <TrimCopy+0x6e>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <strncpy@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TrimCopy>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %rsi,%rbp
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbp,1)
cmpb   $0x20,-0x2(%rax,%rbp,1)
jne    115d <TrimCopy+0x3d>
add    %rbp,%rax
add    $0xfffffffffffffffe,%rax
nopw   0x0(%rax,%rax,1)
movb   $0x0,(%rax)
cmpb   $0x20,-0x1(%rax)
lea    -0x1(%rax),%rax
je     1150 <TrimCopy+0x30>
add    $0xffffffffffffffff,%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmpb   $0x20,0x1(%rbp)
lea    0x1(%rbp),%rbp
je     1170 <TrimCopy+0x50>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r14d,%edx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <strncpy@plt>

LLVM IR (-O0):
define void @TrimCopy(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%9 = load i8*, i8** %5
%10 = call i32 @strlen(i8* %9)
store i32 %10, i32* %7
%11 = load i8*, i8** %5
%12 = load i32, i32* %7
%13 = add nsw i32 %12, -1
store i32 %13, i32* %7
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %11, i64 %14
store i8 0, i8* %15
br label %16
16: ; preds = %25, %3
%17 = load i8*, i8** %5
%18 = load i32, i32* %7
%19 = sub nsw i32 %18, 1
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %17, i64 %20
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 32
br i1 %24, label %25, label %31
25: ; preds = %16
%26 = load i8*, i8** %5
%27 = load i32, i32* %7
%28 = add nsw i32 %27, -1
store i32 %28, i32* %7
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %26, i64 %29
store i8 0, i8* %30
br label %16
31: ; preds = %16
%32 = load i8*, i8** %5
store i8* %32, i8** %8
br label %33
33: ; preds = %38, %31
%34 = load i8*, i8** %8
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 32
br i1 %37, label %38, label %41
38: ; preds = %33
%39 = load i8*, i8** %8
%40 = getelementptr inbounds i8, i8* %39, i32 1
store i8* %40, i8** %8
br label %33
41: ; preds = %33
%42 = load i8*, i8** %4
%43 = load i8*, i8** %8
%44 = load i32, i32* %6
%45 = call i32 @strncpy(i8* %42, i8* %43, i32 %44)
ret void
}

LLVM IR (-O2):
define void @TrimCopy(i8* %0, i8* %1, i32 %2) {
%4 = tail call i32 @strlen(i8* %1)
%5 = add nsw i32 %4, -1
%6 = sext i32 %5 to i64
%7 = getelementptr inbounds i8, i8* %1, i64 %6
store i8 0, i8* %7
%8 = add nsw i32 %4, -2
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %1, i64 %9
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 32
br i1 %12, label %13, label %20
13: ; preds = %3, %13
%14 = phi i64 [ %16, %13 ], [ %9, %3 ]
%15 = phi i8* [ %17, %13 ], [ %10, %3 ]
store i8 0, i8* %15
%16 = add i64 %14, -1
%17 = getelementptr inbounds i8, i8* %1, i64 %16
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 32
br i1 %19, label %13, label %20
20: ; preds = %13, %3
br label %21
21: ; preds = %20, %21
%22 = phi i8* [ %25, %21 ], [ %1, %20 ]
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 32
%25 = getelementptr inbounds i8, i8* %22, i64 1
br i1 %24, label %21, label %26
26: ; preds = %21
%27 = tail call i32 @strncpy(i8* %0, i8* %22, i32 %2)
ret void
}