#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__ strcmp(char *, char *);
char *strdup(char *);
char *strtok(char *, char *);
char *parse_section_name(char *str) {
  char *name = strtok(str, " \t");
  if (name != NULL) {
    char *delim = strtok(NULL, " \n");
    if (delim != NULL && strcmp(delim, "{") == 0) {
      return strdup(name);
    }
  }
  return NULL;
}


x86 assembly (clang, -O0):
<parse_section_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeb9(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11ab <parse_section_name+0x7b>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe9d(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11a6 <parse_section_name+0x76>
mov    -0x20(%rbp),%rdi
lea    0xe81(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11a6 <parse_section_name+0x76>
mov    -0x18(%rbp),%rdi
call   1050 <strdup@plt>
mov    %rax,-0x8(%rbp)
jmp    11b3 <parse_section_name+0x83>
jmp    11ab <parse_section_name+0x7b>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_section_name>:
push   %rbx
lea    0xec8(%rip),%rsi
call   1040 <strtok@plt>
test   %rax,%rax
je     116c <parse_section_name+0x3c>
mov    %rax,%rbx
lea    0xeb7(%rip),%rsi
xor    %edi,%edi
call   1040 <strtok@plt>
test   %rax,%rax
je     116c <parse_section_name+0x3c>
lea    0xea7(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1170 <parse_section_name+0x40>
xor    %eax,%eax
pop    %rbx
ret
mov    %rbx,%rdi
pop    %rbx
jmp    1050 <strdup@plt>

LLVM IR (-O0):
@.str = [3 x i8] c" \09\00"
@.str.1 = [3 x i8] c" \0A\00"
@.str.2 = [2 x i8] c"{\00"
define i8* @parse_section_name(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i8* @strtok(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %7, i8** %4
%8 = load i8*, i8** %4
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %22
10: ; preds = %1
%11 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i8* %11, i8** %5
%12 = load i8*, i8** %5
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %21
14: ; preds = %10
%15 = load i8*, i8** %5
%16 = call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %14
%19 = load i8*, i8** %4
%20 = call i8* @strdup(i8* %19)
store i8* %20, i8** %2
br label %23
21: ; preds = %14, %10
br label %22
22: ; preds = %21, %1
store i8* null, i8** %2
br label %23
23: ; preds = %22, %18
%24 = load i8*, i8** %2
ret i8* %24
}

LLVM IR (-O2):
@.str = [3 x i8] c" \09\00"
@.str.1 = [3 x i8] c" \0A\00"
@.str.2 = [2 x i8] c"{\00"
define noalias i8* @parse_section_name(i8* %0) {
%2 = tail call i8* @strtok(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i8* %2, null
br i1 %3, label %12, label %4
4: ; preds = %1
%5 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i8* %5, null
br i1 %6, label %12, label %7
7: ; preds = %4
%8 = tail call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = tail call i8* @strdup(i8* %2)
br label %12
12: ; preds = %4, %7, %1, %10
%13 = phi i8* [ %11, %10 ], [ null, %1 ], [ null, %7 ], [ null, %4 ]
ret i8* %13
}