#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 */
scalar_t__ isspace(int);
int strlen(char *);
void trimLine(char *line) {
  char *str;
  str = line;
  char *strEnd;
  for (strEnd = str + strlen(str) - 1; strEnd >= str && isspace((int)(*strEnd));
       strEnd--)
    ;
  *(strEnd + 1) = 0;
}


x86 assembly (clang, -O0):
<trimLine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rcx
xor    %eax,%eax
cmp    -0x10(%rbp),%rcx
mov    %al,-0x21(%rbp)
jb     1182 <trimLine+0x62>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1192 <trimLine+0x72>
jmp    11a8 <trimLine+0x88>
jmp    1197 <trimLine+0x77>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    1159 <trimLine+0x39>
mov    -0x18(%rbp),%rax
movb   $0x0,0x1(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<trimLine>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1030 <strlen@plt>
cltq
lea    (%rax,%r14,1),%rcx
add    $0xffffffffffffffff,%rcx
cs nopw 0x0(%rax,%rax,1)
mov    %rcx,%rbx
cmp    %r14,%rcx
jb     1159 <trimLine+0x39>
movsbl (%rbx),%edi
call   1040 <isspace@plt>
lea    -0x1(%rbx),%rcx
test   %rax,%rax
jne    1140 <trimLine+0x20>
movb   $0x0,0x1(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @trimLine(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
store i8* %5, i8** %3
%6 = load i8*, i8** %3
%7 = load i8*, i8** %3
%8 = call i32 @strlen(i8* %7)
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %6, i64 %9
%11 = getelementptr inbounds i8, i8* %10, i64 -1
store i8* %11, i8** %4
br label %12
12: ; preds = %25, %1
%13 = load i8*, i8** %4
%14 = load i8*, i8** %3
%15 = icmp uge i8* %13, %14
br i1 %15, label %16, label %22
16: ; preds = %12
%17 = load i8*, i8** %4
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = call i64 @isspace(i32 %19)
%21 = icmp ne i64 %20, 0
br label %22
22: ; preds = %16, %12
%23 = phi i1 [ false, %12 ], [ %21, %16 ]
br i1 %23, label %24, label %28
24: ; preds = %22
br label %25
25: ; preds = %24
%26 = load i8*, i8** %4
%27 = getelementptr inbounds i8, i8* %26, i32 -1
store i8* %27, i8** %4
br label %12
28: ; preds = %22
%29 = load i8*, i8** %4
%30 = getelementptr inbounds i8, i8* %29, i64 1
store i8 0, i8* %30
ret void
}

LLVM IR (-O2):
define void @trimLine(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = sext i32 %2 to i64
%4 = getelementptr inbounds i8, i8* %0, i64 %3
br label %5
5: ; preds = %9, %1
%6 = phi i8* [ %4, %1 ], [ %7, %9 ]
%7 = getelementptr inbounds i8, i8* %6, i64 -1
%8 = icmp ult i8* %7, %0
br i1 %8, label %14, label %9
9: ; preds = %5
%10 = load i8, i8* %7
%11 = sext i8 %10 to i32
%12 = tail call i64 @isspace(i32 %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %5
14: ; preds = %5, %9
store i8 0, i8* %6
ret void
}