#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 */
char *strchr(int /*<<< orphan*/, char);
int /*<<< orphan*/ strcpy(char *, char const *);
int strlen(char const *);
int load(char *recp, int recsize, char const *buf, char const *udata,
         int uleng) {
  (void)udata, (void)uleng;
  int buflen = strlen(buf) + 1;
  if (buflen <= recsize) {
    char *valpos = strchr(strcpy(recp, buf), '\t');
    if (valpos)
      *valpos = 0;
  }
  return buflen;
}


x86 assembly (clang, -O0):
<load>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     119a <load+0x6a>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
mov    %eax,%edi
mov    $0x9,%esi
call   1050 <strchr@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     1195 <load+0x65>
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
jmp    119a <load+0x6a>
mov    -0x28(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %esi,%ebp
mov    %rdi,%r15
mov    %rdx,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebx
cmp    %ebp,%eax
jge    116c <load+0x3c>
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    %eax,%edi
mov    $0x9,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     116c <load+0x3c>
movb   $0x0,(%rax)
add    $0x1,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @load(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 i8*
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
%13 = load i8*, i8** %9
%14 = load i32, i32* %10
%15 = load i8*, i8** %8
%16 = call i32 @strlen(i8* %15)
%17 = add nsw i32 %16, 1
store i32 %17, i32* %11
%18 = load i32, i32* %11
%19 = load i32, i32* %7
%20 = icmp sle i32 %18, %19
br i1 %20, label %21, label %31
21: ; preds = %5
%22 = load i8*, i8** %6
%23 = load i8*, i8** %8
%24 = call i32 @strcpy(i8* %22, i8* %23)
%25 = call i8* @strchr(i32 %24, i8 signext 9)
store i8* %25, i8** %12
%26 = load i8*, i8** %12
%27 = icmp ne i8* %26, null
br i1 %27, label %28, label %30
28: ; preds = %21
%29 = load i8*, i8** %12
store i8 0, i8* %29
br label %30
30: ; preds = %28, %21
br label %31
31: ; preds = %30, %5
%32 = load i32, i32* %11
ret i32 %32
}

LLVM IR (-O2):
define i32 @load(i8* %0, i32 %1, i8* %2, i8* nocapture readnone %3, i32 %4) {
%6 = tail call i32 @strlen(i8* %2)
%7 = icmp slt i32 %6, %1
br i1 %7, label %8, label %13
8: ; preds = %5
%9 = tail call i32 @strcpy(i8* %0, i8* %2)
%10 = tail call i8* @strchr(i32 %9, i8 signext 9)
%11 = icmp eq i8* %10, null
br i1 %11, label %13, label %12
12: ; preds = %8
store i8 0, i8* %10
br label %13
13: ; preds = %8, %12, %5
%14 = add nsw i32 %6, 1
ret i32 %14
}