#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(char);
char *skip_over_blank(char *);
int strlen(char *);
char *strip_line(char *line) {
  char *p;
  line = skip_over_blank(line);
  p = line + strlen(line) - 1;
  while (*line) {
    if (isspace(*p))
      *p-- = '\0';
    else
      break;
  }
  return line;
}


x86 assembly (clang, -O0):
<strip_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <skip_over_blank@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     11b2 <strip_line+0x82>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
je     11a8 <strip_line+0x78>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x0,(%rax)
jmp    11ad <strip_line+0x7d>
jmp    11b2 <strip_line+0x82>
jmp    116e <strip_line+0x3e>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strip_line>:
push   %r14
push   %rbx
push   %rax
call   1050 <skip_over_blank@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1030 <strlen@plt>
cmpb   $0x0,(%r14)
je     117a <strip_line+0x4a>
cltq
lea    (%rax,%r14,1),%rbx
add    $0xffffffffffffffff,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl (%rbx),%edi
call   1040 <isspace@plt>
test   %rax,%rax
je     117a <strip_line+0x4a>
movb   $0x0,(%rbx)
add    $0xffffffffffffffff,%rbx
cmpb   $0x0,(%r14)
jne    1160 <strip_line+0x30>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @strip_line(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i8* @skip_over_blank(i8* %4)
store i8* %5, i8** %2
%6 = load i8*, i8** %2
%7 = load i8*, i8** %2
%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** %3
br label %12
12: ; preds = %25, %1
%13 = load i8*, i8** %2
%14 = load i8, i8* %13
%15 = icmp ne i8 %14, 0
br i1 %15, label %16, label %26
16: ; preds = %12
%17 = load i8*, i8** %3
%18 = load i8, i8* %17
%19 = call i64 @isspace(i8 signext %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %16
%22 = load i8*, i8** %3
%23 = getelementptr inbounds i8, i8* %22, i32 -1
store i8* %23, i8** %3
store i8 0, i8* %22
br label %25
24: ; preds = %16
br label %26
25: ; preds = %21
br label %12
26: ; preds = %24, %12
%27 = load i8*, i8** %2
ret i8* %27
}

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