#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 */
int /*<<< orphan*/ isspace(int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *inistrcrop(char *s) {
  static char l[1024 + 1];
  char *last;
  if (s == NULL)
    return NULL;
  memset(l, 0, 1024 + 1);
  strcpy(l, s);
  last = l + strlen(l);
  while (last > l) {
    if (!isspace((int)*(last - 1)))
      break;
    last--;
  }
  *last = (char)0;
  return l;
}


x86 assembly (clang, -O0):
<inistrcrop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1164 <inistrcrop+0x24>
movq   $0x0,-0x8(%rbp)
jmp    11f3 <inistrcrop+0xb3>
lea    0x2ee5(%rip),%rdi
xor    %esi,%esi
mov    $0x401,%edx
call   1050 <memset@plt>
mov    -0x10(%rbp),%rsi
lea    0x2ece(%rip),%rdi
call   1030 <strcpy@plt>
lea    0x2ec2(%rip),%rdi
call   1040 <strlen@plt>
movslq %eax,%rcx
lea    0x2eb3(%rip),%rax
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
lea    0x2ea5(%rip),%rax
cmp    %rax,-0x18(%rbp)
jbe    11e1 <inistrcrop+0xa1>
mov    -0x18(%rbp),%rax
movsbl -0x1(%rax),%edi
call   1060 <isspace@plt>
cmp    $0x0,%eax
jne    11d0 <inistrcrop+0x90>
jmp    11e1 <inistrcrop+0xa1>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    11a4 <inistrcrop+0x64>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
lea    0x2e61(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inistrcrop>:
push   %r15
push   %r14
push   %rbx
test   %rdi,%rdi
je     119e <inistrcrop+0x5e>
mov    %rdi,%r14
lea    0x2efc(%rip),%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x401,%edx
call   1050 <memset@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    %r15,%rdi
call   1040 <strlen@plt>
movslq %eax,%r14
add    %r15,%r14
nopl   0x0(%rax)
mov    %r14,%rbx
cmp    %r15,%r14
jbe    1199 <inistrcrop+0x59>
lea    -0x1(%rbx),%r14
movsbl -0x1(%rbx),%edi
call   1060 <isspace@plt>
test   %eax,%eax
jne    1180 <inistrcrop+0x40>
movb   $0x0,(%rbx)
jmp    11a1 <inistrcrop+0x61>
xor    %r15d,%r15d
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@inistrcrop.l = internal global [1025 x i8] zeroinitializer
define i8* @inistrcrop(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %8
7: ; preds = %1
store i8* null, i8** %2
br label %31
8: ; preds = %1
%9 = call i32 @memset(i8* getelementptr inbounds ([1025 x i8], [1025 x i8]* @inistrcrop.l, i64 0, i64 0), i32 0, i32 1025)
%10 = load i8*, i8** %3
%11 = call i32 @strcpy(i8* getelementptr inbounds ([1025 x i8], [1025 x i8]* @inistrcrop.l, i64 0, i64 0), i8* %10)
%12 = call i32 @strlen(i8* getelementptr inbounds ([1025 x i8], [1025 x i8]* @inistrcrop.l, i64 0, i64 0))
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* getelementptr inbounds ([1025 x i8], [1025 x i8]* @inistrcrop.l, i64 0, i64 0), i64 %13
store i8* %14, i8** %4
br label %15
15: ; preds = %26, %8
%16 = load i8*, i8** %4
%17 = icmp ugt i8* %16, getelementptr inbounds ([1025 x i8], [1025 x i8]* @inistrcrop.l, i64 0, i64 0)
br i1 %17, label %18, label %29
18: ; preds = %15
%19 = load i8*, i8** %4
%20 = getelementptr inbounds i8, i8* %19, i64 -1
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = call i32 @isspace(i32 %22)
%24 = icmp ne i32 %23, 0
br i1 %24, label %26, label %25
25: ; preds = %18
br label %29
26: ; preds = %18
%27 = load i8*, i8** %4
%28 = getelementptr inbounds i8, i8* %27, i32 -1
store i8* %28, i8** %4
br label %15
29: ; preds = %25, %15
%30 = load i8*, i8** %4
store i8 0, i8* %30
store i8* getelementptr inbounds ([1025 x i8], [1025 x i8]* @inistrcrop.l, i64 0, i64 0), i8** %2
br label %31
31: ; preds = %29, %7
%32 = load i8*, i8** %2
ret i8* %32
}

LLVM IR (-O2):
@inistrcrop.l = internal global [1025 x i8] zeroinitializer
define i8* @inistrcrop(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %19, label %3
3: ; preds = %1
%4 = tail call i32 @memset(i8* getelementptr inbounds ([1025 x i8], [1025 x i8]* @inistrcrop.l, i64 0, i64 0), i32 0, i32 1025)
%5 = tail call i32 @strcpy(i8* getelementptr inbounds ([1025 x i8], [1025 x i8]* @inistrcrop.l, i64 0, i64 0), i8* %0)
%6 = tail call i32 @strlen(i8* getelementptr inbounds ([1025 x i8], [1025 x i8]* @inistrcrop.l, i64 0, i64 0))
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds [1025 x i8], [1025 x i8]* @inistrcrop.l, i64 0, i64 %7
br label %9
9: ; preds = %12, %3
%10 = phi i8* [ %8, %3 ], [ %13, %12 ]
%11 = icmp ugt i8* %10, getelementptr inbounds ([1025 x i8], [1025 x i8]* @inistrcrop.l, i64 0, i64 0)
br i1 %11, label %12, label %18
12: ; preds = %9
%13 = getelementptr inbounds i8, i8* %10, i64 -1
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = tail call i32 @isspace(i32 %15)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %9
18: ; preds = %12, %9
store i8 0, i8* %10
br label %19
19: ; preds = %1, %18
%20 = phi i8* [ getelementptr inbounds ([1025 x i8], [1025 x i8]* @inistrcrop.l, i64 0, i64 0), %18 ], [ null, %1 ]
ret i8* %20
}