#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ EOF;
int /*<<< orphan*/ category_file();
int /*<<< orphan*/ errf(int /*<<< orphan*/);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fputc(char, int /*<<< orphan*/ *);
scalar_t__ fputs(char const *, int /*<<< orphan*/ *);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int /*<<< orphan*/ unlink(int /*<<< orphan*/);
int putl_category(const char *s, FILE *f) {
  if (s && fputs(s, f) == EOF) {
    (void)fclose(f);
    (void)unlink(category_file());
    errf(strerror(errno));
    return (EOF);
  }
  if (fputc('\n', f) == EOF) {
    (void)fclose(f);
    (void)unlink(category_file());
    errf(strerror(errno));
    return (EOF);
  }
  return (0);
}


x86 assembly (clang, -O0):
<putl_category>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11e6 <putl_category+0x76>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <fputs@plt>
mov    0x2e49(%rip),%rcx
cmp    (%rcx),%rax
jne    11e6 <putl_category+0x76>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    $0x0,%al
call   1060 <category_file@plt>
mov    %eax,%edi
call   1030 <unlink@plt>
mov    0x2e12(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    %eax,%edi
call   1080 <errf@plt>
mov    0x2e0d(%rip),%rax
mov    (%rax),%rax
mov    %eax,-0x4(%rbp)
jmp    1249 <putl_category+0xd9>
mov    -0x18(%rbp),%rsi
mov    $0xa,%edi
call   1070 <fputc@plt>
mov    0x2ded(%rip),%rcx
cmp    (%rcx),%rax
jne    1242 <putl_category+0xd2>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    $0x0,%al
call   1060 <category_file@plt>
mov    %eax,%edi
call   1030 <unlink@plt>
mov    0x2db6(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    %eax,%edi
call   1080 <errf@plt>
mov    0x2db1(%rip),%rax
mov    (%rax),%rax
mov    %eax,-0x4(%rbp)
jmp    1249 <putl_category+0xd9>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<putl_category>:
push   %rbx
mov    %rsi,%rbx
test   %rdi,%rdi
je     118d <putl_category+0x1d>
mov    %rbx,%rsi
call   1050 <fputs@plt>
mov    0x2e60(%rip),%rcx
cmp    (%rcx),%rax
je     11ab <putl_category+0x3b>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1070 <fputc@plt>
mov    %rax,%rcx
mov    0x2e44(%rip),%rdx
xor    %eax,%eax
cmp    (%rdx),%rcx
jne    11df <putl_category+0x6f>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
call   1060 <category_file@plt>
mov    %eax,%edi
call   1030 <unlink@plt>
mov    0x2e10(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    %eax,%edi
call   1080 <errf@plt>
mov    0x2e0b(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret

LLVM IR (-O0):
@EOF = global i64 0
@errno = global i32 0
define i32 @putl_category(i8* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32*
store i8* %0, i8** %4
store i32* %1, i32** %5
%6 = load i8*, i8** %4
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %24
8: ; preds = %2
%9 = load i8*, i8** %4
%10 = load i32*, i32** %5
%11 = call i64 @fputs(i8* %9, i32* %10)
%12 = load i64, i64* @EOF
%13 = icmp eq i64 %11, %12
br i1 %13, label %14, label %24
14: ; preds = %8
%15 = load i32*, i32** %5
%16 = call i32 @fclose(i32* %15)
%17 = call i32 (...) @category_file()
%18 = call i32 @unlink(i32 %17)
%19 = load i32, i32* @errno
%20 = call i32 @strerror(i32 %19)
%21 = call i32 @errf(i32 %20)
%22 = load i64, i64* @EOF
%23 = trunc i64 %22 to i32
store i32 %23, i32* %3
br label %40
24: ; preds = %8, %2
%25 = load i32*, i32** %5
%26 = call i64 @fputc(i8 signext 10, i32* %25)
%27 = load i64, i64* @EOF
%28 = icmp eq i64 %26, %27
br i1 %28, label %29, label %39
29: ; preds = %24
%30 = load i32*, i32** %5
%31 = call i32 @fclose(i32* %30)
%32 = call i32 (...) @category_file()
%33 = call i32 @unlink(i32 %32)
%34 = load i32, i32* @errno
%35 = call i32 @strerror(i32 %34)
%36 = call i32 @errf(i32 %35)
%37 = load i64, i64* @EOF
%38 = trunc i64 %37 to i32
store i32 %38, i32* %3
br label %40
39: ; preds = %24
store i32 0, i32* %3
br label %40
40: ; preds = %39, %29, %14
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
@EOF = global i64 0
@errno = global i32 0
define i32 @putl_category(i8* %0, i32* nocapture %1) {
%3 = icmp eq i8* %0, null
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = tail call i64 @fputs(i8* %0, i32* %1)
%6 = load i64, i64* @EOF
%7 = icmp eq i64 %5, %6
br i1 %7, label %12, label %8
8: ; preds = %4, %2
%9 = tail call i64 @fputc(i8 signext 10, i32* %1)
%10 = load i64, i64* @EOF
%11 = icmp eq i64 %9, %10
br i1 %11, label %12, label %21
12: ; preds = %8, %4
%13 = tail call i32 @fclose(i32* %1)
%14 = tail call i32 (...) @category_file()
%15 = tail call i32 @unlink(i32 %14)
%16 = load i32, i32* @errno
%17 = tail call i32 @strerror(i32 %16)
%18 = tail call i32 @errf(i32 %17)
%19 = load i64, i64* @EOF
%20 = trunc i64 %19 to i32
br label %21
21: ; preds = %12, %8
%22 = phi i32 [ 0, %8 ], [ %20, %12 ]
ret i32 %22
}