#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 /*<<< orphan*/);
int strlen(char *);
char *get_carrot_data_fieldname(char *input_buffer) {
  static char data_fieldname[4096] = {0};
  char *end_pointer = input_buffer + strlen(input_buffer);
  int first_time = 1;
  while (end_pointer > input_buffer) {
    if (*end_pointer == '^') {
      if (first_time) {
        first_time = 0;
      } else {
        piece(data_fieldname, '^', end_pointer + 1, 0);
        break;
      }
    }
    end_pointer--;
  }
  return data_fieldname;
}


x86 assembly (clang, -O0):
<get_carrot_data_fieldname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x8(%rbp),%rax
jbe    11be <get_carrot_data_fieldname+0x9e>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5e,%eax
jne    11ad <get_carrot_data_fieldname+0x8d>
cmpl   $0x0,-0x14(%rbp)
je     1188 <get_carrot_data_fieldname+0x68>
movl   $0x0,-0x14(%rbp)
jmp    11a8 <get_carrot_data_fieldname+0x88>
mov    -0x10(%rbp),%rdx
add    $0x1,%rdx
lea    0x2ea9(%rip),%rdi
mov    $0x5e,%esi
xor    %ecx,%ecx
call   1040 <piece@plt>
jmp    11be <get_carrot_data_fieldname+0x9e>
jmp    11ad <get_carrot_data_fieldname+0x8d>
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
jmp    1154 <get_carrot_data_fieldname+0x34>
lea    0x2e7b(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_carrot_data_fieldname>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
test   %eax,%eax
jle    116e <get_carrot_data_fieldname+0x4e>
mov    %eax,%edx
add    %rbx,%rdx
mov    $0x1,%eax
jmp    1149 <get_carrot_data_fieldname+0x29>
nopl   0x0(%rax)
add    $0xffffffffffffffff,%rdx
cmp    %rbx,%rdx
jbe    116e <get_carrot_data_fieldname+0x4e>
cmpb   $0x5e,(%rdx)
jne    1140 <get_carrot_data_fieldname+0x20>
test   %eax,%eax
mov    $0x0,%eax
jne    1140 <get_carrot_data_fieldname+0x20>
add    $0x1,%rdx
lea    0x2ede(%rip),%rdi
mov    $0x5e,%esi
xor    %ecx,%ecx
call   1040 <piece@plt>
lea    0x2ecb(%rip),%rax
pop    %rbx
ret

LLVM IR (-O0):
@get_carrot_data_fieldname.data_fieldname = internal global [4096 x i8] zeroinitializer
define i8* @get_carrot_data_fieldname(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = load i8*, i8** %2
%7 = call i32 @strlen(i8* %6)
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %5, i64 %8
store i8* %9, i8** %3
store i32 1, i32* %4
br label %10
10: ; preds = %28, %1
%11 = load i8*, i8** %3
%12 = load i8*, i8** %2
%13 = icmp ugt i8* %11, %12
br i1 %13, label %14, label %31
14: ; preds = %10
%15 = load i8*, i8** %3
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 94
br i1 %18, label %19, label %28
19: ; preds = %14
%20 = load i32, i32* %4
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %19
store i32 0, i32* %4
br label %27
23: ; preds = %19
%24 = load i8*, i8** %3
%25 = getelementptr inbounds i8, i8* %24, i64 1
%26 = call i32 @piece(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @get_carrot_data_fieldname.data_fieldname, i64 0, i64 0), i8 signext 94, i8* %25, i32 0)
br label %31
27: ; preds = %22
br label %28
28: ; preds = %27, %14
%29 = load i8*, i8** %3
%30 = getelementptr inbounds i8, i8* %29, i32 -1
store i8* %30, i8** %3
br label %10
31: ; preds = %23, %10
ret i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @get_carrot_data_fieldname.data_fieldname, i64 0, i64 0)
}

LLVM IR (-O2):
@get_carrot_data_fieldname.data_fieldname = internal global [4096 x i8] zeroinitializer
define i8* @get_carrot_data_fieldname(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %21
4: ; preds = %1
%5 = zext i32 %2 to i64
%6 = getelementptr inbounds i8, i8* %0, i64 %5
br label %7
7: ; preds = %4, %17
%8 = phi i32 [ %18, %17 ], [ 1, %4 ]
%9 = phi i8* [ %19, %17 ], [ %6, %4 ]
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 94
br i1 %11, label %12, label %17
12: ; preds = %7
%13 = icmp eq i32 %8, 0
br i1 %13, label %14, label %17
14: ; preds = %12
%15 = getelementptr inbounds i8, i8* %9, i64 1
%16 = tail call i32 @piece(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @get_carrot_data_fieldname.data_fieldname, i64 0, i64 0), i8 signext 94, i8* %15, i32 0)
br label %21
17: ; preds = %12, %7
%18 = phi i32 [ %8, %7 ], [ 0, %12 ]
%19 = getelementptr inbounds i8, i8* %9, i64 -1
%20 = icmp ugt i8* %19, %0
br i1 %20, label %7, label %21
21: ; preds = %17, %1, %14
ret i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @get_carrot_data_fieldname.data_fieldname, i64 0, i64 0)
}