#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 */
typedef struct TYPE_4__ TYPE_2__;
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  int re_status;
  int /*<<< orphan*/ re_errno;
};
struct TYPE_4__ {
  int cf_stat;
  TYPE_1__ cf_error;
};

/* Variables and functions */
#define RPC_PMAPFAILURE 129
#define RPC_SYSTEMERROR 128
char *_buf();
char *clnt_sperrno(int);
TYPE_2__ rpc_createerr;
int /*<<< orphan*/ snprintf(char *, int, char *, char const *, char *, ...);
char *strerror(int /*<<< orphan*/);
char *clnt_spcreateerror(const char *s) {
  char *str = _buf();
  if (str == 0)
    return (0);
  switch (rpc_createerr.cf_stat) {
  case RPC_PMAPFAILURE:
    (void)snprintf(str, 256, "%s: %s - %s\n", s,
                   clnt_sperrno(rpc_createerr.cf_stat),
                   clnt_sperrno(rpc_createerr.cf_error.re_status));
    break;
  case RPC_SYSTEMERROR:
    (void)snprintf(str, 256, "%s: %s - %s\n", s,
                   clnt_sperrno(rpc_createerr.cf_stat),
                   strerror(rpc_createerr.cf_error.re_errno));
    break;
  default:
    (void)snprintf(str, 256, "%s: %s\n", s,
                   clnt_sperrno(rpc_createerr.cf_stat));
    break;
  }
  str[256 - 2] = '\n';
  str[256 - 1] = '\0';
  return (str);
}


x86 assembly (clang, -O0):
<clnt_spcreateerror>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    $0x0,%al
call   1050 <_buf@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    116f <clnt_spcreateerror+0x2f>
movq   $0x0,-0x8(%rbp)
jmp    12a8 <clnt_spcreateerror+0x168>
mov    0x2e7a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x80,%eax
je     11f6 <clnt_spcreateerror+0xb6>
jmp    118b <clnt_spcreateerror+0x4b>
mov    -0x1c(%rbp),%eax
sub    $0x81,%eax
jne    124e <clnt_spcreateerror+0x10e>
jmp    119e <clnt_spcreateerror+0x5e>
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    0x2e3b(%rip),%rax
mov    (%rax),%edi
call   1040 <clnt_sperrno@plt>
mov    %rax,-0x28(%rbp)
mov    0x2e29(%rip),%rax
mov    0x4(%rax),%edi
call   1040 <clnt_sperrno@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    %rax,%r9
mov    $0x100,%esi
lea    0xe16(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
jmp    128a <clnt_spcreateerror+0x14a>
mov    -0x18(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    0x2de3(%rip),%rax
mov    (%rax),%edi
call   1040 <clnt_sperrno@plt>
mov    %rax,-0x40(%rbp)
mov    0x2dd1(%rip),%rax
mov    0x8(%rax),%edi
call   1060 <strerror@plt>
mov    -0x50(%rbp),%rdi
mov    -0x48(%rbp),%rcx
mov    -0x40(%rbp),%r8
mov    %rax,%r9
mov    $0x100,%esi
lea    0xdbe(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
jmp    128a <clnt_spcreateerror+0x14a>
mov    -0x18(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    0x2d8b(%rip),%rax
mov    (%rax),%edi
call   1040 <clnt_sperrno@plt>
mov    -0x60(%rbp),%rdi
mov    -0x58(%rbp),%rcx
mov    %rax,%r8
mov    $0x100,%esi
lea    0xd8a(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
mov    -0x18(%rbp),%rax
movb   $0xa,0xfe(%rax)
mov    -0x18(%rbp),%rax
movb   $0x0,0xff(%rax)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clnt_spcreateerror>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %eax,%eax
call   1050 <_buf@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11f4 <clnt_spcreateerror+0xb4>
mov    0x2e8b(%rip),%r12
mov    (%r12),%edi
cmp    $0x80,%edi
je     1192 <clnt_spcreateerror+0x52>
cmp    $0x81,%edi
jne    11ca <clnt_spcreateerror+0x8a>
mov    $0x81,%edi
call   1040 <clnt_sperrno@plt>
mov    %rax,%r15
mov    0x4(%r12),%edi
call   1040 <clnt_sperrno@plt>
jmp    11a9 <clnt_spcreateerror+0x69>
mov    $0x80,%edi
call   1040 <clnt_sperrno@plt>
mov    %rax,%r15
mov    0x8(%r12),%edi
call   1060 <strerror@plt>
lea    0xe50(%rip),%rdx
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %r14,%rcx
mov    %r15,%r8
mov    %rax,%r9
xor    %eax,%eax
call   1030 <snprintf@plt>
jmp    11eb <clnt_spcreateerror+0xab>
call   1040 <clnt_sperrno@plt>
lea    0xe37(%rip),%rdx
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %r14,%rcx
mov    %rax,%r8
xor    %eax,%eax
call   1030 <snprintf@plt>
movw   $0xa,0xfe(%rbx)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.TYPE_4__ = type { i32, %struct.TYPE_3__ }
%struct.TYPE_3__ = type { i32, i32 }
@rpc_createerr = global %struct.TYPE_4__ zeroinitializer
@.str = [13 x i8] c"%s: %s - %s\0A\00"
@.str.1 = [8 x i8] c"%s: %s\0A\00"
define i8* @clnt_spcreateerror(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = call i8* (...) @_buf()
store i8* %5, i8** %4
%6 = load i8*, i8** %4
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %9
8: ; preds = %1
store i8* null, i8** %2
br label %39
9: ; preds = %1
%10 = load i32, i32* getelementptr inbounds (%struct.TYPE_4__, %struct.TYPE_4__* @rpc_createerr, i32 0, i32 0)
switch i32 %10, label %27 [
i32 129, label %11
i32 128, label %19
]
11: ; preds = %9
%12 = load i8*, i8** %4
%13 = load i8*, i8** %3
%14 = load i32, i32* getelementptr inbounds (%struct.TYPE_4__, %struct.TYPE_4__* @rpc_createerr, i32 0, i32 0)
%15 = call i8* @clnt_sperrno(i32 %14)
%16 = load i32, i32* getelementptr inbounds (%struct.TYPE_4__, %struct.TYPE_4__* @rpc_createerr, i32 0, i32 1, i32 0)
%17 = call i8* @clnt_sperrno(i32 %16)
%18 = call i32 (i8*, i32, i8*, i8*, i8*, ...) @snprintf(i8* %12, i32 256, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %13, i8* %15, i8* %17)
br label %33
19: ; preds = %9
%20 = load i8*, i8** %4
%21 = load i8*, i8** %3
%22 = load i32, i32* getelementptr inbounds (%struct.TYPE_4__, %struct.TYPE_4__* @rpc_createerr, i32 0, i32 0)
%23 = call i8* @clnt_sperrno(i32 %22)
%24 = load i32, i32* getelementptr inbounds (%struct.TYPE_4__, %struct.TYPE_4__* @rpc_createerr, i32 0, i32 1, i32 1)
%25 = call i8* @strerror(i32 %24)
%26 = call i32 (i8*, i32, i8*, i8*, i8*, ...) @snprintf(i8* %20, i32 256, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %21, i8* %23, i8* %25)
br label %33
27: ; preds = %9
%28 = load i8*, i8** %4
%29 = load i8*, i8** %3
%30 = load i32, i32* getelementptr inbounds (%struct.TYPE_4__, %struct.TYPE_4__* @rpc_createerr, i32 0, i32 0)
%31 = call i8* @clnt_sperrno(i32 %30)
%32 = call i32 (i8*, i32, i8*, i8*, i8*, ...) @snprintf(i8* %28, i32 256, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %29, i8* %31)
br label %33
33: ; preds = %27, %19, %11
%34 = load i8*, i8** %4
%35 = getelementptr inbounds i8, i8* %34, i64 254
store i8 10, i8* %35
%36 = load i8*, i8** %4
%37 = getelementptr inbounds i8, i8* %36, i64 255
store i8 0, i8* %37
%38 = load i8*, i8** %4
store i8* %38, i8** %2
br label %39
39: ; preds = %33, %8
%40 = load i8*, i8** %2
ret i8* %40
}

LLVM IR (-O2):
%struct.TYPE_4__ = type { i32, %struct.TYPE_3__ }
%struct.TYPE_3__ = type { i32, i32 }
@rpc_createerr = global %struct.TYPE_4__ zeroinitializer
@.str = [13 x i8] c"%s: %s - %s\0A\00"
@.str.1 = [8 x i8] c"%s: %s\0A\00"
define i8* @clnt_spcreateerror(i8* %0) {
%2 = tail call i8* (...) @_buf()
%3 = icmp eq i8* %2, null
br i1 %3, label %22, label %4
4: ; preds = %1
%5 = load i32, i32* getelementptr inbounds (%struct.TYPE_4__, %struct.TYPE_4__* @rpc_createerr, i64 0, i32 0)
switch i32 %5, label %16 [
i32 129, label %6
i32 128, label %11
]
6: ; preds = %4
%7 = tail call i8* @clnt_sperrno(i32 129)
%8 = load i32, i32* getelementptr inbounds (%struct.TYPE_4__, %struct.TYPE_4__* @rpc_createerr, i64 0, i32 1, i32 0)
%9 = tail call i8* @clnt_sperrno(i32 %8)
%10 = tail call i32 (i8*, i32, i8*, i8*, i8*, ...) @snprintf(i8* %2, i32 256, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %7, i8* %9)
br label %19
11: ; preds = %4
%12 = tail call i8* @clnt_sperrno(i32 128)
%13 = load i32, i32* getelementptr inbounds (%struct.TYPE_4__, %struct.TYPE_4__* @rpc_createerr, i64 0, i32 1, i32 1)
%14 = tail call i8* @strerror(i32 %13)
%15 = tail call i32 (i8*, i32, i8*, i8*, i8*, ...) @snprintf(i8* %2, i32 256, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %12, i8* %14)
br label %19
16: ; preds = %4
%17 = tail call i8* @clnt_sperrno(i32 %5)
%18 = tail call i32 (i8*, i32, i8*, i8*, i8*, ...) @snprintf(i8* %2, i32 256, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %17)
br label %19
19: ; preds = %16, %11, %6
%20 = getelementptr inbounds i8, i8* %2, i64 254
store i8 10, i8* %20
%21 = getelementptr inbounds i8, i8* %2, i64 255
store i8 0, i8* %21
br label %22
22: ; preds = %1, %19
ret i8* %2
}