#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*/ assert(int);
int /*<<< orphan*/ strchr(char *, char);
int mysave(char const *recp, int reclen, char *buf, int bufsize,
           char const *udata, int uleng) {
  (void)recp, (void)reclen, (void)udata, (void)uleng;
  assert(!buf || bufsize > 0);
  int ret = 0;
  assert(ret >= 0);
  assert(!buf || !(ret < bufsize ? buf[ret] : buf[bufsize - 1]));
  assert(!strchr(buf, '\n'));
  return ret;
}


x86 assembly (clang, -O0):
<mysave>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
mov    $0x1,%al
cmpq   $0x0,-0x18(%rbp)
mov    %al,-0x31(%rbp)
je     1158 <mysave+0x38>
cmpl   $0x0,-0x1c(%rbp)
setg   %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movl   $0x0,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
setge  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    $0x1,%al
cmpq   $0x0,-0x18(%rbp)
mov    %al,-0x32(%rbp)
je     11cf <mysave+0xaf>
mov    -0x30(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11ad <mysave+0x8d>
mov    -0x18(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x38(%rbp)
jmp    11c1 <mysave+0xa1>
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x32(%rbp)
mov    -0x32(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x18(%rbp),%rdi
mov    $0xa,%esi
call   1030 <strchr@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x30(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mysave>:
push   %rbp
push   %r14
push   %rbx
mov    %ecx,%r14d
mov    %rdx,%rbx
test   %rdx,%rdx
sete   %al
test   %ecx,%ecx
setg   %cl
or     %al,%cl
movzbl %cl,%edi
call   1040 <assert@plt>
mov    $0x1,%ebp
mov    $0x1,%edi
call   1040 <assert@plt>
test   %rbx,%rbx
je     116c <mysave+0x4c>
lea    -0x1(%r14),%eax
xor    %ecx,%ecx
test   %r14d,%r14d
cmovle %eax,%ecx
movslq %ecx,%rax
xor    %ebp,%ebp
cmpb   $0x0,(%rbx,%rax,1)
sete   %bpl
mov    %ebp,%edi
call   1040 <assert@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1030 <strchr@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1040 <assert@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @mysave(i8* %0, i32 %1, i8* %2, i32 %3, i8* %4, i32 %5) {
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
store i8* %0, i8** %7
store i32 %1, i32* %8
store i8* %2, i8** %9
store i32 %3, i32* %10
store i8* %4, i8** %11
store i32 %5, i32* %12
%14 = load i8*, i8** %7
%15 = load i32, i32* %8
%16 = load i8*, i8** %11
%17 = load i32, i32* %12
%18 = load i8*, i8** %9
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %23
20: ; preds = %6
%21 = load i32, i32* %10
%22 = icmp sgt i32 %21, 0
br label %23
23: ; preds = %20, %6
%24 = phi i1 [ true, %6 ], [ %22, %20 ]
%25 = zext i1 %24 to i32
%26 = call i32 @assert(i32 %25)
store i32 0, i32* %13
%27 = load i32, i32* %13
%28 = icmp sge i32 %27, 0
%29 = zext i1 %28 to i32
%30 = call i32 @assert(i32 %29)
%31 = load i8*, i8** %9
%32 = icmp ne i8* %31, null
br i1 %32, label %33, label %56
33: ; preds = %23
%34 = load i32, i32* %13
%35 = load i32, i32* %10
%36 = icmp slt i32 %34, %35
br i1 %36, label %37, label %44
37: ; preds = %33
%38 = load i8*, i8** %9
%39 = load i32, i32* %13
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %38, i64 %40
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
br label %52
44: ; preds = %33
%45 = load i8*, i8** %9
%46 = load i32, i32* %10
%47 = sub nsw i32 %46, 1
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* %45, i64 %48
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
br label %52
52: ; preds = %44, %37
%53 = phi i32 [ %43, %37 ], [ %51, %44 ]
%54 = icmp ne i32 %53, 0
%55 = xor i1 %54, true
br label %56
56: ; preds = %52, %23
%57 = phi i1 [ true, %23 ], [ %55, %52 ]
%58 = zext i1 %57 to i32
%59 = call i32 @assert(i32 %58)
%60 = load i8*, i8** %9
%61 = call i32 @strchr(i8* %60, i8 signext 10)
%62 = icmp ne i32 %61, 0
%63 = xor i1 %62, true
%64 = zext i1 %63 to i32
%65 = call i32 @assert(i32 %64)
%66 = load i32, i32* %13
ret i32 %66
}

LLVM IR (-O2):
define i32 @mysave(i8* nocapture readnone %0, i32 %1, i8* %2, i32 %3, i8* nocapture readnone %4, i32 %5) {
%7 = icmp eq i8* %2, null
%8 = icmp sgt i32 %3, 0
%9 = or i1 %7, %8
%10 = zext i1 %9 to i32
%11 = tail call i32 @assert(i32 %10)
%12 = tail call i32 @assert(i32 1)
br i1 %7, label %21, label %13
13: ; preds = %6
%14 = add nsw i32 %3, -1
%15 = select i1 %8, i32 0, i32 %14
%16 = sext i32 %15 to i64
%17 = getelementptr i8, i8* %2, i64 %16
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 0
%20 = zext i1 %19 to i32
br label %21
21: ; preds = %13, %6
%22 = phi i32 [ 1, %6 ], [ %20, %13 ]
%23 = tail call i32 @assert(i32 %22)
%24 = tail call i32 @strchr(i8* %2, i8 signext 10)
%25 = icmp eq i32 %24, 0
%26 = zext i1 %25 to i32
%27 = tail call i32 @assert(i32 %26)
ret i32 0
}