#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 StripTrailingWhitespace(char *String) {
  int count, len;
  len = (String ? strlen(String) : 0);
  if (len == 0)
    return;
  for (count = len - 1; (count > -1) && isspace(String[count]); count--)
    String[count] = 0;
}


x86 assembly (clang, -O0):
<StripTrailingWhitespace>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1148 <StripTrailingWhitespace+0x28>
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
jmp    1152 <StripTrailingWhitespace+0x32>
xor    %eax,%eax
mov    %eax,-0x14(%rbp)
jmp    1152 <StripTrailingWhitespace+0x32>
mov    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    1167 <StripTrailingWhitespace+0x47>
jmp    11c4 <StripTrailingWhitespace+0xa4>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0xc(%rbp)
xor    %eax,%eax
cmpl   $0xffffffff,-0xc(%rbp)
mov    %al,-0x15(%rbp)
jle    119a <StripTrailingWhitespace+0x7a>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    11aa <StripTrailingWhitespace+0x8a>
jmp    11c4 <StripTrailingWhitespace+0xa4>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1170 <StripTrailingWhitespace+0x50>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<StripTrailingWhitespace>:
push   %r15
push   %r14
push   %rbx
test   %rdi,%rdi
je     1162 <StripTrailingWhitespace+0x42>
mov    %rdi,%r14
call   1030 <strlen@plt>
test   %eax,%eax
jle    1162 <StripTrailingWhitespace+0x42>
mov    %eax,%ebx
add    $0x1,%rbx
nopl   0x0(%rax)
lea    -0x2(%rbx),%r15d
movsbl (%r14,%r15,1),%edi
call   1040 <isspace@plt>
test   %rax,%rax
je     1162 <StripTrailingWhitespace+0x42>
movb   $0x0,(%r14,%r15,1)
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
ja     1140 <StripTrailingWhitespace+0x20>
pop    %rbx
pop    %r14
pop    %r15
ret

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

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