#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*/ piece(char *, char, char *, int);
char *strdup(char *);
scalar_t__ timlib_character_exists(char *, char);
char *spreadsheet_units_label(char *spreadsheet_header_label) {
  char units_label[256];
  if (!spreadsheet_header_label || !*spreadsheet_header_label)
    return (char *)0;
  if (timlib_character_exists(spreadsheet_header_label, '(')) {
    char buffer[256];
    piece(buffer, '(', spreadsheet_header_label, 1);
    piece(units_label, ')', buffer, 0);
    return strdup(units_label);
  }
  return (char *)0;
}


x86 assembly (clang, -O0):
<spreadsheet_units_label>:
push   %rbp
mov    %rsp,%rbp
sub    $0x210,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1157 <spreadsheet_units_label+0x27>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1164 <spreadsheet_units_label+0x34>
movq   $0x0,-0x8(%rbp)
jmp    11cd <spreadsheet_units_label+0x9d>
mov    -0x10(%rbp),%rdi
mov    $0x28,%esi
call   1030 <timlib_character_exists@plt>
cmp    $0x0,%rax
je     11c5 <spreadsheet_units_label+0x95>
lea    -0x210(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x28,%esi
mov    $0x1,%ecx
call   1040 <piece@plt>
lea    -0x110(%rbp),%rdi
lea    -0x210(%rbp),%rdx
mov    $0x29,%esi
xor    %ecx,%ecx
call   1040 <piece@plt>
lea    -0x110(%rbp),%rdi
call   1050 <strdup@plt>
mov    %rax,-0x8(%rbp)
jmp    11cd <spreadsheet_units_label+0x9d>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x210,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<spreadsheet_units_label>:
push   %r14
push   %rbx
sub    $0x208,%rsp
test   %rdi,%rdi
je     1195 <spreadsheet_units_label+0x65>
mov    %rdi,%rbx
cmpb   $0x0,(%rdi)
je     1195 <spreadsheet_units_label+0x65>
mov    %rbx,%rdi
mov    $0x28,%esi
call   1030 <timlib_character_exists@plt>
test   %rax,%rax
je     1195 <spreadsheet_units_label+0x65>
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x28,%esi
mov    %rbx,%rdx
mov    $0x1,%ecx
call   1040 <piece@plt>
lea    0x100(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x29,%esi
mov    %r14,%rdx
xor    %ecx,%ecx
call   1040 <piece@plt>
mov    %rbx,%rdi
call   1050 <strdup@plt>
jmp    1197 <spreadsheet_units_label+0x67>
xor    %eax,%eax
add    $0x208,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @spreadsheet_units_label(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca [256 x i8]
%5 = alloca [256 x i8]
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %12
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = load i8, i8* %9
%11 = icmp ne i8 %10, 0
br i1 %11, label %13, label %12
12: ; preds = %8, %1
store i8* null, i8** %2
br label %27
13: ; preds = %8
%14 = load i8*, i8** %3
%15 = call i64 @timlib_character_exists(i8* %14, i8 signext 40)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %26
17: ; preds = %13
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%19 = load i8*, i8** %3
%20 = call i32 @piece(i8* %18, i8 signext 40, i8* %19, i32 1)
%21 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%22 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%23 = call i32 @piece(i8* %21, i8 signext 41, i8* %22, i32 0)
%24 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%25 = call i8* @strdup(i8* %24)
store i8* %25, i8** %2
br label %27
26: ; preds = %13
store i8* null, i8** %2
br label %27
27: ; preds = %26, %17, %12
%28 = load i8*, i8** %2
ret i8* %28
}

LLVM IR (-O2):
define noalias i8* @spreadsheet_units_label(i8* %0) {
%2 = alloca [256 x i8]
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%5 = icmp eq i8* %0, null
br i1 %5, label %17, label %6
6: ; preds = %1
%7 = load i8, i8* %0
%8 = icmp eq i8 %7, 0
br i1 %8, label %17, label %9
9: ; preds = %6
%10 = tail call i64 @timlib_character_exists(i8* %0, i8 signext 40)
%11 = icmp eq i64 %10, 0
br i1 %11, label %17, label %12
12: ; preds = %9
%13 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%14 = call i32 @piece(i8* %13, i8 signext 40, i8* %0, i32 1)
%15 = call i32 @piece(i8* %4, i8 signext 41, i8* %13, i32 0)
%16 = call i8* @strdup(i8* %4)
br label %17
17: ; preds = %9, %1, %6, %12
%18 = phi i8* [ %16, %12 ], [ null, %6 ], [ null, %1 ], [ null, %9 ]
ret i8* %18
}