#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(unsigned char);
int /*<<< orphan*/ memmove(unsigned char *, unsigned char *, int);
int strlen(char const *);
void postprocess_field(unsigned char *src, int strip_strings) {
  if (strip_strings) {
    unsigned char *begin = src;
    unsigned char *end = src + strlen((const char *)src);
    while (isspace(*begin))
      ++begin;
    while (begin < end && isspace(*(end - 1)))
      --end;
    if (begin < end) {
      memmove(src, begin, end - begin);
      src[end - begin] = 0;
    } else {
      src[0] = 0;
    }
  }
}


x86 assembly (clang, -O0):
<postprocess_field>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1235 <postprocess_field+0x105>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movzbl (%rax),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
je     1199 <postprocess_field+0x69>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1172 <postprocess_field+0x42>
jmp    119e <postprocess_field+0x6e>
mov    -0x18(%rbp),%rcx
xor    %eax,%eax
cmp    -0x20(%rbp),%rcx
mov    %al,-0x29(%rbp)
jae    11c8 <postprocess_field+0x98>
mov    -0x20(%rbp),%rax
movzbl -0x1(%rax),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    11d8 <postprocess_field+0xa8>
jmp    11e9 <postprocess_field+0xb9>
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
jmp    119e <postprocess_field+0x6e>
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    1229 <postprocess_field+0xf9>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
call   1050 <memmove@plt>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%rdx
sub    %rdx,%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    1230 <postprocess_field+0x100>
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
jmp    1235 <postprocess_field+0x105>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<postprocess_field>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
je     11b7 <postprocess_field+0x87>
mov    %rdi,%r14
call   1030 <strlen@plt>
movslq %eax,%r12
xor    %ebx,%ebx
nopl   0x0(%rax)
movzbl (%r14,%rbx,1),%edi
call   1040 <isspace@plt>
add    $0x1,%rbx
test   %rax,%rax
jne    1150 <postprocess_field+0x20>
lea    (%r14,%r12,1),%rbp
sub    %ebx,%r12d
add    $0x2,%r12d
mov    %rbp,%r13
sub    %rbx,%r13
add    $0x2,%r13
lea    (%r14,%rbx,1),%r15
add    $0xffffffffffffffff,%r15
cmp    %rbp,%r15
jae    11af <postprocess_field+0x7f>
movzbl -0x1(%rbp),%edi
add    $0xffffffffffffffff,%rbp
call   1040 <isspace@plt>
add    $0xffffffffffffffff,%r13
add    $0xffffffff,%r12d
test   %rax,%rax
jne    1180 <postprocess_field+0x50>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12d,%edx
call   1050 <memmove@plt>
jmp    11b2 <postprocess_field+0x82>
mov    %r14,%r13
movb   $0x0,0x0(%r13)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @postprocess_field(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %65
9: ; preds = %2
%10 = load i8*, i8** %3
store i8* %10, i8** %5
%11 = load i8*, i8** %3
%12 = load i8*, i8** %3
%13 = call i32 @strlen(i8* %12)
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %11, i64 %14
store i8* %15, i8** %6
br label %16
16: ; preds = %21, %9
%17 = load i8*, i8** %5
%18 = load i8, i8* %17
%19 = call i64 @isspace(i8 zeroext %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %16
%22 = load i8*, i8** %5
%23 = getelementptr inbounds i8, i8* %22, i32 1
store i8* %23, i8** %5
br label %16
24: ; preds = %16
br label %25
25: ; preds = %37, %24
%26 = load i8*, i8** %5
%27 = load i8*, i8** %6
%28 = icmp ult i8* %26, %27
br i1 %28, label %29, label %35
29: ; preds = %25
%30 = load i8*, i8** %6
%31 = getelementptr inbounds i8, i8* %30, i64 -1
%32 = load i8, i8* %31
%33 = call i64 @isspace(i8 zeroext %32)
%34 = icmp ne i64 %33, 0
br label %35
35: ; preds = %29, %25
%36 = phi i1 [ false, %25 ], [ %34, %29 ]
br i1 %36, label %37, label %40
37: ; preds = %35
%38 = load i8*, i8** %6
%39 = getelementptr inbounds i8, i8* %38, i32 -1
store i8* %39, i8** %6
br label %25
40: ; preds = %35
%41 = load i8*, i8** %5
%42 = load i8*, i8** %6
%43 = icmp ult i8* %41, %42
br i1 %43, label %44, label %61
44: ; preds = %40
%45 = load i8*, i8** %3
%46 = load i8*, i8** %5
%47 = load i8*, i8** %6
%48 = load i8*, i8** %5
%49 = ptrtoint i8* %47 to i64
%50 = ptrtoint i8* %48 to i64
%51 = sub i64 %49, %50
%52 = trunc i64 %51 to i32
%53 = call i32 @memmove(i8* %45, i8* %46, i32 %52)
%54 = load i8*, i8** %3
%55 = load i8*, i8** %6
%56 = load i8*, i8** %5
%57 = ptrtoint i8* %55 to i64
%58 = ptrtoint i8* %56 to i64
%59 = sub i64 %57, %58
%60 = getelementptr inbounds i8, i8* %54, i64 %59
store i8 0, i8* %60
br label %64
61: ; preds = %40
%62 = load i8*, i8** %3
%63 = getelementptr inbounds i8, i8* %62, i64 0
store i8 0, i8* %63
br label %64
64: ; preds = %61, %44
br label %65
65: ; preds = %64, %2
ret void
}

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