#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);
int strlen(char *);
void fixdesc(char *s) {
  char *e = s + strlen(s);
  --e;
  while (e >= s && isspace(*e)) {
    --e;
  }
  if (*e == '.') {
    *e = 0;
  }
}


x86 assembly (clang, -O0):
<fixdesc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-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
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rcx
xor    %eax,%eax
cmp    -0x8(%rbp),%rcx
mov    %al,-0x19(%rbp)
jb     1182 <fixdesc+0x62>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1192 <fixdesc+0x72>
jmp    11a3 <fixdesc+0x83>
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
jmp    1159 <fixdesc+0x39>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    11ba <fixdesc+0x9a>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fixdesc>:
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 <fixdesc+0x39>
movsbl (%rbx),%edi
call   1040 <isspace@plt>
lea    -0x1(%rbx),%rcx
test   %rax,%rax
jne    1140 <fixdesc+0x20>
cmpb   $0x2e,(%rbx)
jne    1161 <fixdesc+0x41>
movb   $0x0,(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define void @fixdesc(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 %13, label %9
9: ; preds = %5
%10 = load i8, i8* %7
%11 = tail call i64 @isspace(i8 signext %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %5
13: ; preds = %5, %9
%14 = load i8, i8* %7
%15 = icmp eq i8 %14, 46
br i1 %15, label %16, label %17
16: ; preds = %13
store i8 0, i8* %7
br label %17
17: ; preds = %16, %13
ret void
}