#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);
int strlen(char *);
void parse_input_buffer(char *station, char *datatype, char *units,
                        char *agency, char *input_buffer) {
  char piece_buffer[128];
  piece(station, '^', input_buffer, 0);
  piece(piece_buffer, '[', input_buffer, 0);
  piece(datatype, '^', piece_buffer, 1);
  piece(piece_buffer, '[', input_buffer, 1);
  piece(units, '-', piece_buffer, 0);
  piece(agency, '-', piece_buffer, 2);
  *(agency + (strlen(agency) - 1)) = '\0';
}


x86 assembly (clang, -O0):
<parse_input_buffer>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    $0x5e,%esi
xor    %ecx,%ecx
call   1040 <piece@plt>
lea    -0xb0(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    $0x5b,%esi
xor    %ecx,%ecx
call   1040 <piece@plt>
mov    -0x10(%rbp),%rdi
lea    -0xb0(%rbp),%rdx
mov    $0x5e,%esi
mov    $0x1,%ecx
call   1040 <piece@plt>
lea    -0xb0(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    $0x5b,%esi
mov    $0x1,%ecx
call   1040 <piece@plt>
mov    -0x18(%rbp),%rdi
lea    -0xb0(%rbp),%rdx
mov    $0x2d,%esi
xor    %ecx,%ecx
call   1040 <piece@plt>
mov    -0x20(%rbp),%rdi
lea    -0xb0(%rbp),%rdx
mov    $0x2d,%esi
mov    $0x2,%ecx
call   1040 <piece@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0xb8(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0xb8(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_input_buffer>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x80,%rsp
mov    %r8,%rbx
mov    %rcx,%r15
mov    %rdx,%r14
mov    %rsi,%r13
mov    $0x5e,%esi
mov    %r8,%rdx
xor    %ecx,%ecx
call   1040 <piece@plt>
mov    %rsp,%r12
mov    %r12,%rdi
mov    $0x5b,%esi
mov    %rbx,%rdx
xor    %ecx,%ecx
call   1040 <piece@plt>
mov    %r13,%rdi
mov    $0x5e,%esi
mov    %r12,%rdx
mov    $0x1,%ecx
call   1040 <piece@plt>
mov    %r12,%rdi
mov    $0x5b,%esi
mov    %rbx,%rdx
mov    $0x1,%ecx
call   1040 <piece@plt>
mov    %r14,%rdi
mov    $0x2d,%esi
mov    %r12,%rdx
xor    %ecx,%ecx
call   1040 <piece@plt>
mov    %r15,%rdi
mov    $0x2d,%esi
mov    %r12,%rdx
mov    $0x2,%ecx
call   1040 <piece@plt>
mov    %r15,%rdi
call   1030 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%r15,1)
add    $0x80,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @parse_input_buffer(i8* %0, i8* %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca [128 x i8]
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i8* %4, i8** %10
%12 = load i8*, i8** %6
%13 = load i8*, i8** %10
%14 = call i32 @piece(i8* %12, i8 signext 94, i8* %13, i32 0)
%15 = getelementptr inbounds [128 x i8], [128 x i8]* %11, i64 0, i64 0
%16 = load i8*, i8** %10
%17 = call i32 @piece(i8* %15, i8 signext 91, i8* %16, i32 0)
%18 = load i8*, i8** %7
%19 = getelementptr inbounds [128 x i8], [128 x i8]* %11, i64 0, i64 0
%20 = call i32 @piece(i8* %18, i8 signext 94, i8* %19, i32 1)
%21 = getelementptr inbounds [128 x i8], [128 x i8]* %11, i64 0, i64 0
%22 = load i8*, i8** %10
%23 = call i32 @piece(i8* %21, i8 signext 91, i8* %22, i32 1)
%24 = load i8*, i8** %8
%25 = getelementptr inbounds [128 x i8], [128 x i8]* %11, i64 0, i64 0
%26 = call i32 @piece(i8* %24, i8 signext 45, i8* %25, i32 0)
%27 = load i8*, i8** %9
%28 = getelementptr inbounds [128 x i8], [128 x i8]* %11, i64 0, i64 0
%29 = call i32 @piece(i8* %27, i8 signext 45, i8* %28, i32 2)
%30 = load i8*, i8** %9
%31 = load i8*, i8** %9
%32 = call i32 @strlen(i8* %31)
%33 = sub nsw i32 %32, 1
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %30, i64 %34
store i8 0, i8* %35
ret void
}

LLVM IR (-O2):
define void @parse_input_buffer(i8* %0, i8* %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca [128 x i8]
%7 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%8 = tail call i32 @piece(i8* %0, i8 signext 94, i8* %4, i32 0)
%9 = call i32 @piece(i8* %7, i8 signext 91, i8* %4, i32 0)
%10 = call i32 @piece(i8* %1, i8 signext 94, i8* %7, i32 1)
%11 = call i32 @piece(i8* %7, i8 signext 91, i8* %4, i32 1)
%12 = call i32 @piece(i8* %2, i8 signext 45, i8* %7, i32 0)
%13 = call i32 @piece(i8* %3, i8 signext 45, i8* %7, i32 2)
%14 = call i32 @strlen(i8* %3)
%15 = add nsw i32 %14, -1
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %3, i64 %16
store i8 0, i8* %17
ret void
}