#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*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int ser_putc(int, char);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int strlen(char *);
int write(int, char *, int);
int ser_println(int f, char *b) {
  int l = strlen(b);
  if (write(f, b, l) == -1) {
    fprintf(stderr, "%s\n", strerror(errno));
    return -1;
  }
  if (ser_putc(f, '\n') == -1) {
    fprintf(stderr, "%s\n", strerror(errno));
    return -1;
  }
  return 1;
}


x86 assembly (clang, -O0):
<ser_println>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <write@plt>
cmp    $0xffffffff,%eax
jne    11bb <ser_println+0x6b>
mov    0x2e56(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    0x2e42(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0x18(%rbp),%edi
mov    %rax,%rdx
lea    0xe56(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1210 <ser_println+0xc0>
mov    -0x8(%rbp),%edi
mov    $0xa,%esi
call   1040 <ser_putc@plt>
cmp    $0xffffffff,%eax
jne    1209 <ser_println+0xb9>
mov    0x2e08(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2df4(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0x1c(%rbp),%edi
mov    %rax,%rdx
lea    0xe08(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1210 <ser_println+0xc0>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ser_println>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
mov    %rsi,%rdi
call   1050 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write@plt>
cmp    $0xffffffff,%eax
je     1189 <ser_println+0x39>
mov    %ebp,%edi
mov    $0xa,%esi
call   1040 <ser_putc@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    $0xffffffff,%ecx
jne    11b6 <ser_println+0x66>
mov    0x2e50(%rip),%rax
mov    (%rax),%ebx
mov    0x2e3f(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
lea    0xe59(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1060 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [4 x i8] c"%s\0A\00"
@errno = global i32 0
define i32 @ser_println(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
%7 = load i8*, i8** %5
%8 = call i32 @strlen(i8* %7)
store i32 %8, i32* %6
%9 = load i32, i32* %4
%10 = load i8*, i8** %5
%11 = load i32, i32* %6
%12 = call i32 @write(i32 %9, i8* %10, i32 %11)
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %19
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = load i32, i32* @errno
%17 = call i8* @strerror(i32 %16)
%18 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %17)
store i32 -1, i32* %3
br label %29
19: ; preds = %2
%20 = load i32, i32* %4
%21 = call i32 @ser_putc(i32 %20, i8 signext 10)
%22 = icmp eq i32 %21, -1
br i1 %22, label %23, label %28
23: ; preds = %19
%24 = load i32, i32* @stderr
%25 = load i32, i32* @errno
%26 = call i8* @strerror(i32 %25)
%27 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %26)
store i32 -1, i32* %3
br label %29
28: ; preds = %19
store i32 1, i32* %3
br label %29
29: ; preds = %28, %23, %14
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [4 x i8] c"%s\0A\00"
@errno = global i32 0
define i32 @ser_println(i32 %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %1)
%4 = tail call i32 @write(i32 %0, i8* %1, i32 %3)
%5 = icmp eq i32 %4, -1
br i1 %5, label %9, label %6
6: ; preds = %2
%7 = tail call i32 @ser_putc(i32 %0, i8 signext 10)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %14
9: ; preds = %6, %2
%10 = load i32, i32* @stderr
%11 = load i32, i32* @errno
%12 = tail call i8* @strerror(i32 %11)
%13 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %12)
br label %14
14: ; preds = %9, %6
%15 = phi i32 [ 1, %6 ], [ -1, %9 ]
ret i32 %15
}