#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);
char *strrchr(char *, char);
int /*<<< orphan*/ truncsp(char *);
char *section_name(char *p) {
  char *tp;
  while (*(p) && isspace((unsigned char)*(p)))
    (p)++;
  ;
  if (*p != '[')
    return (NULL);
  p++;
  while (*(p) && isspace((unsigned char)*(p)))
    (p)++;
  ;
  tp = strrchr(p, ']');
  if (tp == NULL)
    return (NULL);
  *tp = 0;
  truncsp(p);
  return (p);
}


x86 assembly (clang, -O0):
<section_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x19(%rbp)
je     1167 <section_name+0x37>
mov    -0x10(%rbp),%rax
movzbl (%rax),%edi
call   1050 <isspace@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1177 <section_name+0x47>
jmp    1188 <section_name+0x58>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    113c <section_name+0xc>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5b,%eax
je     11a5 <section_name+0x75>
movq   $0x0,-0x8(%rbp)
jmp    123f <section_name+0x10f>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x1a(%rbp)
je     11dc <section_name+0xac>
mov    -0x10(%rbp),%rax
movzbl (%rax),%edi
call   1050 <isspace@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x1a(%rbp)
mov    -0x1a(%rbp),%al
test   $0x1,%al
jne    11ec <section_name+0xbc>
jmp    11fd <section_name+0xcd>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11b1 <section_name+0x81>
mov    -0x10(%rbp),%rdi
mov    $0x5d,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1227 <section_name+0xf7>
movq   $0x0,-0x8(%rbp)
jmp    123f <section_name+0x10f>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
call   1030 <truncsp@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<section_name>:
push   %r14
push   %rbx
push   %rax
mov    (%rdi),%al
test   %al,%al
je     11aa <section_name+0x7a>
mov    %rdi,%rbx
add    $0x1,%rbx
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl %al,%edi
call   1050 <isspace@plt>
test   %rax,%rax
je     116a <section_name+0x3a>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1150 <section_name+0x20>
jmp    11ad <section_name+0x7d>
cmpb   $0x5b,-0x1(%rbx)
jne    11aa <section_name+0x7a>
mov    %rbx,%r14
movzbl (%rbx),%eax
test   %al,%al
je     118b <section_name+0x5b>
movzbl %al,%edi
call   1050 <isspace@plt>
lea    0x1(%r14),%rbx
test   %rax,%rax
jne    1170 <section_name+0x40>
mov    %r14,%rdi
mov    $0x5d,%esi
call   1040 <strrchr@plt>
test   %rax,%rax
je     11aa <section_name+0x7a>
movb   $0x0,(%rax)
mov    %r14,%rdi
call   1030 <truncsp@plt>
jmp    11ad <section_name+0x7d>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @section_name(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
br label %5
5: ; preds = %17, %1
%6 = load i8*, i8** %3
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %5
%11 = load i8*, i8** %3
%12 = load i8, i8* %11
%13 = call i64 @isspace(i8 zeroext %12)
%14 = icmp ne i64 %13, 0
br label %15
15: ; preds = %10, %5
%16 = phi i1 [ false, %5 ], [ %14, %10 ]
br i1 %16, label %17, label %20
17: ; preds = %15
%18 = load i8*, i8** %3
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %3
br label %5
20: ; preds = %15
%21 = load i8*, i8** %3
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp ne i32 %23, 91
br i1 %24, label %25, label %26
25: ; preds = %20
store i8* null, i8** %2
br label %55
26: ; preds = %20
%27 = load i8*, i8** %3
%28 = getelementptr inbounds i8, i8* %27, i32 1
store i8* %28, i8** %3
br label %29
29: ; preds = %41, %26
%30 = load i8*, i8** %3
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %39
34: ; preds = %29
%35 = load i8*, i8** %3
%36 = load i8, i8* %35
%37 = call i64 @isspace(i8 zeroext %36)
%38 = icmp ne i64 %37, 0
br label %39
39: ; preds = %34, %29
%40 = phi i1 [ false, %29 ], [ %38, %34 ]
br i1 %40, label %41, label %44
41: ; preds = %39
%42 = load i8*, i8** %3
%43 = getelementptr inbounds i8, i8* %42, i32 1
store i8* %43, i8** %3
br label %29
44: ; preds = %39
%45 = load i8*, i8** %3
%46 = call i8* @strrchr(i8* %45, i8 signext 93)
store i8* %46, i8** %4
%47 = load i8*, i8** %4
%48 = icmp eq i8* %47, null
br i1 %48, label %49, label %50
49: ; preds = %44
store i8* null, i8** %2
br label %55
50: ; preds = %44
%51 = load i8*, i8** %4
store i8 0, i8* %51
%52 = load i8*, i8** %3
%53 = call i32 @truncsp(i8* %52)
%54 = load i8*, i8** %3
store i8* %54, i8** %2
br label %55
55: ; preds = %50, %49, %25
%56 = load i8*, i8** %2
ret i8* %56
}

LLVM IR (-O2):
define i8* @section_name(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %29, label %4
4: ; preds = %1, %9
%5 = phi i8 [ %11, %9 ], [ %2, %1 ]
%6 = phi i8* [ %10, %9 ], [ %0, %1 ]
%7 = tail call i64 @isspace(i8 zeroext %5)
%8 = icmp eq i64 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %4
%10 = getelementptr inbounds i8, i8* %6, i64 1
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 0
br i1 %12, label %29, label %4
13: ; preds = %4
%14 = load i8, i8* %6
%15 = icmp eq i8 %14, 91
br i1 %15, label %16, label %29
16: ; preds = %13, %21
%17 = phi i8* [ %18, %21 ], [ %6, %13 ]
%18 = getelementptr inbounds i8, i8* %17, i64 1
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 0
br i1 %20, label %24, label %21
21: ; preds = %16
%22 = tail call i64 @isspace(i8 zeroext %19)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %16
24: ; preds = %16, %21
%25 = tail call i8* @strrchr(i8* %18, i8 signext 93)
%26 = icmp eq i8* %25, null
br i1 %26, label %29, label %27
27: ; preds = %24
store i8 0, i8* %25
%28 = tail call i32 @truncsp(i8* %18)
br label %29
29: ; preds = %9, %1, %24, %13, %27
%30 = phi i8* [ %18, %27 ], [ null, %13 ], [ null, %24 ], [ null, %1 ], [ null, %9 ]
ret i8* %30
}