#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 get_field_pos(char *, int, char const *, char const *, int *);
char *get_1st_field(char *str, int len, const char *prejumpset,
                    const char *delemiters, int *field_len) {
  int subpos = 0;
  int sublen = get_field_pos(str, len, prejumpset, delemiters, &subpos);
  if (field_len) {
    *field_len = sublen;
  }
  return sublen ? &str[subpos] : 0;
}


x86 assembly (clang, -O0):
<get_1st_field>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    -0x2c(%rbp),%r8
call   1030 <get_field_pos@plt>
mov    %eax,-0x30(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1161 <get_1st_field+0x51>
mov    -0x30(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
cmpl   $0x0,-0x30(%rbp)
je     117f <get_1st_field+0x6f>
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
jmp    118a <get_1st_field+0x7a>
xor    %eax,%eax
mov    %rax,-0x38(%rbp)
jmp    118a <get_1st_field+0x7a>
mov    -0x38(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_1st_field>:
push   %r14
push   %rbx
push   %rax
mov    %r8,%r14
mov    %rdi,%rbx
movl   $0x0,0x4(%rsp)
lea    0x4(%rsp),%r8
call   1030 <get_field_pos@plt>
test   %r14,%r14
je     1134 <get_1st_field+0x24>
mov    %eax,(%r14)
movslq 0x4(%rsp),%rcx
add    %rcx,%rbx
xor    %ecx,%ecx
test   %eax,%eax
cmovne %rbx,%rcx
mov    %rcx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @get_1st_field(i8* %0, i32 %1, i8* %2, i8* %3, i32* %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i32
store i8* %0, i8** %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i32* %4, i32** %10
store i32 0, i32* %11
%13 = load i8*, i8** %6
%14 = load i32, i32* %7
%15 = load i8*, i8** %8
%16 = load i8*, i8** %9
%17 = call i32 @get_field_pos(i8* %13, i32 %14, i8* %15, i8* %16, i32* %11)
store i32 %17, i32* %12
%18 = load i32*, i32** %10
%19 = icmp ne i32* %18, null
br i1 %19, label %20, label %23
20: ; preds = %5
%21 = load i32, i32* %12
%22 = load i32*, i32** %10
store i32 %21, i32* %22
br label %23
23: ; preds = %20, %5
%24 = load i32, i32* %12
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %31
26: ; preds = %23
%27 = load i8*, i8** %6
%28 = load i32, i32* %11
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
br label %32
31: ; preds = %23
br label %32
32: ; preds = %31, %26
%33 = phi i8* [ %30, %26 ], [ null, %31 ]
ret i8* %33
}

LLVM IR (-O2):
define i8* @get_1st_field(i8* %0, i32 %1, i8* %2, i8* %3, i32* writeonly %4) {
%6 = alloca i32
%7 = bitcast i32* %6 to i8*
store i32 0, i32* %6
%8 = call i32 @get_field_pos(i8* %0, i32 %1, i8* %2, i8* %3, i32* %6)
%9 = icmp eq i32* %4, null
br i1 %9, label %11, label %10
10: ; preds = %5
store i32 %8, i32* %4
br label %11
11: ; preds = %10, %5
%12 = icmp eq i32 %8, 0
%13 = load i32, i32* %6
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %0, i64 %14
%16 = select i1 %12, i8* null, i8* %15
ret i8* %16
}