int str$$rzerotrim(struct dsc$descriptor_s *sd1, long *exp) {
  int i, status;
  char *s1_ptr;
  unsigned short s1_len;
  status = str$analyze_sdesc(sd1, &s1_len, &s1_ptr);
  i = s1_len - 1;
  while ((s1_ptr[i] == '0') && (i > 0)) {
    if (s1_ptr[i] == '0') {
      s1_ptr[i] = ' ';
      (*exp)++;
      s1_len--;
    }
    i--;
  }
  status = str$get1_dx(&s1_len, sd1);
  str$analyze_sdesc(sd1, &s1_len, &s1_ptr);
  return status;
}


x86 assembly (clang, -O0):
<str$$rzerotrim>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x22(%rbp),%rsi
lea    -0x20(%rbp),%rdx
mov    $0x0,%al
call   1030 <str$analyze_sdesc@plt>
mov    %eax,-0x18(%rbp)
movzwl -0x22(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x30,%ecx
mov    %al,-0x23(%rbp)
jne    1174 <str$$rzerotrim+0x54>
cmpl   $0x0,-0x14(%rbp)
setg   %al
mov    %al,-0x23(%rbp)
mov    -0x23(%rbp),%al
test   $0x1,%al
jne    1184 <str$$rzerotrim+0x64>
jmp    11cd <str$$rzerotrim+0xad>
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x30,%eax
jne    11bf <str$$rzerotrim+0x9f>
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x20,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
mov    -0x22(%rbp),%ax
add    $0xffff,%ax
mov    %ax,-0x22(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1150 <str$$rzerotrim+0x30>
mov    -0x8(%rbp),%rsi
lea    -0x22(%rbp),%rdi
mov    $0x0,%al
call   1040 <str$get1_dx@plt>
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x22(%rbp),%rsi
lea    -0x20(%rbp),%rdx
mov    $0x0,%al
call   1030 <str$analyze_sdesc@plt>
mov    -0x18(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str$$rzerotrim>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0x6(%rsp),%rsi
lea    0x8(%rsp),%rdx
xor    %eax,%eax
call   1030 <str$analyze_sdesc@plt>
movzwl 0x6(%rsp),%edx
movzwl %dx,%eax
mov    0x8(%rsp),%rcx
cmpb   $0x30,-0x1(%rax,%rcx,1)
jne    1199 <str$$rzerotrim+0x79>
cmp    $0x2,%dx
jb     1199 <str$$rzerotrim+0x79>
add    %rax,%rcx
add    $0xffffffffffffffff,%rcx
add    $0xfffffffffffffffe,%rax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movb   $0x20,(%rcx)
addq   $0x1,(%rbx)
addw   $0xffff,0x6(%rsp)
mov    0x8(%rsp),%rcx
cmpb   $0x30,(%rcx,%rax,1)
jne    1199 <str$$rzerotrim+0x79>
lea    0x1(%rax),%rdx
add    %rax,%rcx
add    $0xffffffffffffffff,%rax
cmp    $0x1,%rdx
ja     1170 <str$$rzerotrim+0x50>
lea    0x6(%rsp),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <str$get1_dx@plt>
mov    %eax,%ebp
lea    0x8(%rsp),%rdx
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <str$analyze_sdesc@plt>
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%"struct.dsc$descriptor_s" = type opaque
define i32 @"str$$rzerotrim"(%"struct.dsc$descriptor_s"* %0, i64* %1) {
%3 = alloca %"struct.dsc$descriptor_s"*
%4 = alloca i64*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i16
store %"struct.dsc$descriptor_s"* %0, %"struct.dsc$descriptor_s"** %3
store i64* %1, i64** %4
%9 = load %"struct.dsc$descriptor_s"*, %"struct.dsc$descriptor_s"** %3
%10 = call i32 (%"struct.dsc$descriptor_s"*, i16*, i8**, ...) bitcast (i32 (...)* @"str$analyze_sdesc" to i32 (%"struct.dsc$descriptor_s"*, i16*, i8**, ...)*)(%"struct.dsc$descriptor_s"* %9, i16* %8, i8** %7)
store i32 %10, i32* %6
%11 = load i16, i16* %8
%12 = zext i16 %11 to i32
%13 = sub nsw i32 %12, 1
store i32 %13, i32* %5
br label %14
14: ; preds = %45, %2
%15 = load i8*, i8** %7
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 48
br i1 %21, label %22, label %25
22: ; preds = %14
%23 = load i32, i32* %5
%24 = icmp sgt i32 %23, 0
br label %25
25: ; preds = %22, %14
%26 = phi i1 [ false, %14 ], [ %24, %22 ]
br i1 %26, label %27, label %48
27: ; preds = %25
%28 = load i8*, i8** %7
%29 = load i32, i32* %5
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %28, i64 %30
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 48
br i1 %34, label %35, label %45
35: ; preds = %27
%36 = load i8*, i8** %7
%37 = load i32, i32* %5
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %36, i64 %38
store i8 32, i8* %39
%40 = load i64*, i64** %4
%41 = load i64, i64* %40
%42 = add nsw i64 %41, 1
store i64 %42, i64* %40
%43 = load i16, i16* %8
%44 = add i16 %43, -1
store i16 %44, i16* %8
br label %45
45: ; preds = %35, %27
%46 = load i32, i32* %5
%47 = add nsw i32 %46, -1
store i32 %47, i32* %5
br label %14
48: ; preds = %25
%49 = load %"struct.dsc$descriptor_s"*, %"struct.dsc$descriptor_s"** %3
%50 = call i32 (i16*, %"struct.dsc$descriptor_s"*, ...) bitcast (i32 (...)* @"str$get1_dx" to i32 (i16*, %"struct.dsc$descriptor_s"*, ...)*)(i16* %8, %"struct.dsc$descriptor_s"* %49)
store i32 %50, i32* %6
%51 = load %"struct.dsc$descriptor_s"*, %"struct.dsc$descriptor_s"** %3
%52 = call i32 (%"struct.dsc$descriptor_s"*, i16*, i8**, ...) bitcast (i32 (...)* @"str$analyze_sdesc" to i32 (%"struct.dsc$descriptor_s"*, i16*, i8**, ...)*)(%"struct.dsc$descriptor_s"* %51, i16* %8, i8** %7)
%53 = load i32, i32* %6
ret i32 %53
}

LLVM IR (-O2):
%"struct.dsc$descriptor_s" = type opaque
define i32 @"str$$rzerotrim"(%"struct.dsc$descriptor_s"* %0, i64* nocapture %1) {
%3 = alloca i8*
%4 = alloca i16
%5 = bitcast i8** %3 to i8*
%6 = bitcast i16* %4 to i8*
%7 = call i32 (%"struct.dsc$descriptor_s"*, i16*, i8**, ...) bitcast (i32 (...)* @"str$analyze_sdesc" to i32 (%"struct.dsc$descriptor_s"*, i16*, i8**, ...)*)(%"struct.dsc$descriptor_s"* %0, i16* %4, i8** %3)
%8 = load i16, i16* %4
%9 = zext i16 %8 to i64
%10 = add nsw i64 %9, -1
%11 = load i8*, i8** %3
%12 = getelementptr inbounds i8, i8* %11, i64 %10
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 48
%15 = icmp ugt i16 %8, 1
%16 = select i1 %14, i1 %15, i1 false
br i1 %16, label %17, label %34
17: ; preds = %2
%18 = zext i16 %8 to i64
%19 = add nsw i64 %18, -1
br label %20
20: ; preds = %17, %20
%21 = phi i64 [ %19, %17 ], [ %27, %20 ]
%22 = phi i8* [ %12, %17 ], [ %29, %20 ]
store i8 32, i8* %22
%23 = load i64, i64* %1
%24 = add nsw i64 %23, 1
store i64 %24, i64* %1
%25 = load i16, i16* %4
%26 = add i16 %25, -1
store i16 %26, i16* %4
%27 = add nsw i64 %21, -1
%28 = load i8*, i8** %3
%29 = getelementptr inbounds i8, i8* %28, i64 %27
%30 = load i8, i8* %29
%31 = icmp eq i8 %30, 48
%32 = icmp ugt i64 %21, 1
%33 = select i1 %31, i1 %32, i1 false
br i1 %33, label %20, label %34
34: ; preds = %20, %2
%35 = call i32 (i16*, %"struct.dsc$descriptor_s"*, ...) bitcast (i32 (...)* @"str$get1_dx" to i32 (i16*, %"struct.dsc$descriptor_s"*, ...)*)(i16* %4, %"struct.dsc$descriptor_s"* %0)
%36 = call i32 (%"struct.dsc$descriptor_s"*, i16*, i8**, ...) bitcast (i32 (...)* @"str$analyze_sdesc" to i32 (%"struct.dsc$descriptor_s"*, i16*, i8**, ...)*)(%"struct.dsc$descriptor_s"* %0, i16* %4, i8** %3)
ret i32 %35
}