#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 */
typedef int /*<<< orphan*/ l;

/* Variables and functions */
scalar_t__ isspace(int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *strstrip(char *s) {
  static char l[1024 + 1];
  char *last;
  if (s == NULL)
    return NULL;
  while (isspace((int)*s) && *s)
    s++;
  memset(l, 0, 1024 + 1);
  strncpy(l, s, sizeof(l) - 1);
  last = l + strlen(l);
  while (last > l) {
    if (!isspace((int)*(last - 1)))
      break;
    last--;
  }
  *last = (char)0;
  return (char *)l;
}


x86 assembly (clang, -O0):
<strstrip>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1164 <strstrip+0x24>
movq   $0x0,-0x8(%rbp)
jmp    124d <strstrip+0x10d>
jmp    1169 <strstrip+0x29>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1060 <isspace@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x19(%rbp)
je     1197 <strstrip+0x57>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    11a7 <strstrip+0x67>
jmp    11b8 <strstrip+0x78>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1169 <strstrip+0x29>
lea    0x2e91(%rip),%rdi
xor    %esi,%esi
mov    $0x401,%edx
call   1050 <memset@plt>
mov    -0x10(%rbp),%rsi
lea    0x2e7a(%rip),%rdi
mov    $0x400,%edx
call   1030 <strncpy@plt>
lea    0x2e69(%rip),%rdi
call   1040 <strlen@plt>
movslq %eax,%rcx
lea    0x2e5a(%rip),%rax
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
lea    0x2e4c(%rip),%rax
cmp    %rax,-0x18(%rbp)
jbe    123b <strstrip+0xfb>
mov    -0x18(%rbp),%rax
movsbl -0x1(%rax),%edi
call   1060 <isspace@plt>
cmp    $0x0,%rax
jne    122a <strstrip+0xea>
jmp    123b <strstrip+0xfb>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    11fd <strstrip+0xbd>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
lea    0x2e07(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strstrip>:
push   %r15
push   %r14
push   %rbx
test   %rdi,%rdi
je     11bf <strstrip+0x7f>
mov    %rdi,%rbx
movsbl (%rdi),%edi
call   1060 <isspace@plt>
test   %rax,%rax
je     1169 <strstrip+0x29>
cmpb   $0x0,(%rbx)
je     1169 <strstrip+0x29>
movsbl 0x1(%rbx),%edi
add    $0x1,%rbx
jmp    1150 <strstrip+0x10>
lea    0x2ee0(%rip),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x401,%edx
call   1050 <memset@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x400,%edx
call   1030 <strncpy@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
movslq %eax,%r15
add    %r14,%r15
nopl   (%rax)
mov    %r15,%rbx
cmp    %r14,%r15
jbe    11ba <strstrip+0x7a>
lea    -0x1(%rbx),%r15
movsbl -0x1(%rbx),%edi
call   1060 <isspace@plt>
test   %rax,%rax
jne    11a0 <strstrip+0x60>
movb   $0x0,(%rbx)
jmp    11c2 <strstrip+0x82>
xor    %r14d,%r14d
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@strstrip.l = internal global [1025 x i8] zeroinitializer
define i8* @strstrip(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 %48
8: ; preds = %1
br label %9
9: ; preds = %22, %8
%10 = load i8*, i8** %3
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = call i64 @isspace(i32 %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %9
%16 = load i8*, i8** %3
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 0
br label %20
20: ; preds = %15, %9
%21 = phi i1 [ false, %9 ], [ %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 %9
25: ; preds = %20
%26 = call i32 @memset(i8* getelementptr inbounds ([1025 x i8], [1025 x i8]* @strstrip.l, i64 0, i64 0), i32 0, i32 1025)
%27 = load i8*, i8** %3
%28 = call i32 @strncpy(i8* getelementptr inbounds ([1025 x i8], [1025 x i8]* @strstrip.l, i64 0, i64 0), i8* %27, i32 1024)
%29 = call i32 @strlen(i8* getelementptr inbounds ([1025 x i8], [1025 x i8]* @strstrip.l, i64 0, i64 0))
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* getelementptr inbounds ([1025 x i8], [1025 x i8]* @strstrip.l, i64 0, i64 0), i64 %30
store i8* %31, i8** %4
br label %32
32: ; preds = %43, %25
%33 = load i8*, i8** %4
%34 = icmp ugt i8* %33, getelementptr inbounds ([1025 x i8], [1025 x i8]* @strstrip.l, i64 0, i64 0)
br i1 %34, label %35, label %46
35: ; preds = %32
%36 = load i8*, i8** %4
%37 = getelementptr inbounds i8, i8* %36, i64 -1
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = call i64 @isspace(i32 %39)
%41 = icmp ne i64 %40, 0
br i1 %41, label %43, label %42
42: ; preds = %35
br label %46
43: ; preds = %35
%44 = load i8*, i8** %4
%45 = getelementptr inbounds i8, i8* %44, i32 -1
store i8* %45, i8** %4
br label %32
46: ; preds = %42, %32
%47 = load i8*, i8** %4
store i8 0, i8* %47
store i8* getelementptr inbounds ([1025 x i8], [1025 x i8]* @strstrip.l, i64 0, i64 0), i8** %2
br label %48
48: ; preds = %46, %7
%49 = load i8*, i8** %2
ret i8* %49
}

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