#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 *__strerror_r(int /*<<< orphan*/, char *, int);
char *_buf();
char *clnt_sperrno(int);
TYPE_2__ rpc_createerr;
int sprintf(char *, char *, char const *);
char *stpcpy(char *, char *);
char *clnt_spcreateerror(const char *msg) {
  char buf[1024];
  char *str = _buf();
  char *cp;
  int len;
  if (str == NULL)
    return NULL;
  len = sprintf(str, "%s: ", msg);
  cp = str + len;
  cp = stpcpy(cp, clnt_sperrno(rpc_createerr.cf_stat));
  switch (rpc_createerr.cf_stat) {
  case RPC_PMAPFAILURE:
    cp = stpcpy(stpcpy(cp, " - "),
                clnt_sperrno(rpc_createerr.cf_error.re_status));
    break;
  case RPC_SYSTEMERROR:
    cp = stpcpy(stpcpy(cp, " - "),
                __strerror_r(rpc_createerr.cf_error.re_errno, buf, sizeof buf));
    break;
  default:
    break;
  }
  *cp = '\n';
  *++cp = '\0';
  return str;
}


x86 assembly (clang, -O0):
<clnt_spcreateerror>:
push   %rbp
mov    %rsp,%rbp
sub    $0x450,%rsp
mov    %rdi,-0x10(%rbp)
mov    $0x0,%al
call   1070 <_buf@plt>
mov    %rax,-0x418(%rbp)
cmpq   $0x0,-0x418(%rbp)
jne    1188 <clnt_spcreateerror+0x38>
movq   $0x0,-0x8(%rbp)
jmp    12f5 <clnt_spcreateerror+0x1a5>
mov    -0x418(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe66(%rip),%rsi
call   1050 <sprintf@plt>
mov    %eax,-0x424(%rbp)
mov    -0x418(%rbp),%rax
movslq -0x424(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x420(%rbp)
mov    -0x420(%rbp),%rax
mov    %rax,-0x438(%rbp)
mov    0x2e1e(%rip),%rax
mov    %rax,-0x430(%rbp)
mov    (%rax),%edi
call   1040 <clnt_sperrno@plt>
mov    -0x438(%rbp),%rdi
mov    %rax,%rsi
call   1030 <stpcpy@plt>
mov    %rax,%rcx
mov    -0x430(%rbp),%rax
mov    %rcx,-0x420(%rbp)
mov    (%rax),%eax
mov    %eax,-0x428(%rbp)
sub    $0x80,%eax
je     1272 <clnt_spcreateerror+0x122>
jmp    1218 <clnt_spcreateerror+0xc8>
mov    -0x428(%rbp),%eax
sub    $0x81,%eax
jne    12c2 <clnt_spcreateerror+0x172>
jmp    122e <clnt_spcreateerror+0xde>
mov    -0x420(%rbp),%rdi
lea    0xdc9(%rip),%rsi
call   1030 <stpcpy@plt>
mov    %rax,-0x440(%rbp)
mov    0x2da1(%rip),%rax
mov    0x4(%rax),%edi
call   1040 <clnt_sperrno@plt>
mov    -0x440(%rbp),%rdi
mov    %rax,%rsi
call   1030 <stpcpy@plt>
mov    %rax,-0x420(%rbp)
jmp    12c7 <clnt_spcreateerror+0x177>
mov    -0x420(%rbp),%rdi
lea    0xd85(%rip),%rsi
call   1030 <stpcpy@plt>
mov    %rax,-0x448(%rbp)
mov    0x2d5d(%rip),%rax
mov    0x8(%rax),%edi
lea    -0x410(%rbp),%rsi
mov    $0x400,%edx
call   1060 <__strerror_r@plt>
mov    -0x448(%rbp),%rdi
mov    %rax,%rsi
call   1030 <stpcpy@plt>
mov    %rax,-0x420(%rbp)
jmp    12c7 <clnt_spcreateerror+0x177>
jmp    12c7 <clnt_spcreateerror+0x177>
mov    -0x420(%rbp),%rax
movb   $0xa,(%rax)
mov    -0x420(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x420(%rbp)
movb   $0x0,0x1(%rax)
mov    -0x418(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x450,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clnt_spcreateerror>:
push   %r15
push   %r14
push   %rbx
sub    $0x400,%rsp
mov    %rdi,%rbx
xor    %eax,%eax
call   1070 <_buf@plt>
mov    %rax,%r14
test   %rax,%rax
je     11ff <clnt_spcreateerror+0xaf>
lea    0xe87(%rip),%rsi
mov    %r14,%rdi
mov    %rbx,%rdx
call   1050 <sprintf@plt>
cltq
mov    %r14,%rbx
add    %rax,%rbx
mov    0x2e5d(%rip),%r15
mov    (%r15),%edi
call   1040 <clnt_sperrno@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1030 <stpcpy@plt>
mov    (%r15),%ecx
cmp    $0x80,%ecx
je     11d1 <clnt_spcreateerror+0x81>
cmp    $0x81,%ecx
jne    11fa <clnt_spcreateerror+0xaa>
mov    %rax,%rbx
add    $0x3,%rbx
movl   $0x202d20,(%rax)
mov    0x4(%r15),%edi
call   1040 <clnt_sperrno@plt>
jmp    11ef <clnt_spcreateerror+0x9f>
mov    %rax,%rbx
add    $0x3,%rbx
movl   $0x202d20,(%rax)
mov    0x8(%r15),%edi
mov    %rsp,%rsi
mov    $0x400,%edx
call   1060 <__strerror_r@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1030 <stpcpy@plt>
movw   $0xa,(%rax)
mov    %r14,%rax
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
%struct.TYPE_4__ = type { i32, %struct.TYPE_3__ }
%struct.TYPE_3__ = type { i32, i32 }
@.str = [5 x i8] c"%s: \00"
@rpc_createerr = global %struct.TYPE_4__ zeroinitializer
define i8* @clnt_spcreateerror(i8* %0) {
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%4 = tail call i8* (...) @_buf()
%5 = icmp eq i8* %4, null
br i1 %5, label %29, label %6
6: ; preds = %1
%7 = tail call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %0)
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %4, i64 %8
%10 = load i32, i32* getelementptr inbounds (%struct.TYPE_4__, %struct.TYPE_4__* @rpc_createerr, i64 0, i32 0)
%11 = tail call i8* @clnt_sperrno(i32 %10)
%12 = tail call i8* @stpcpy(i8* %9, i8* %11)
%13 = load i32, i32* getelementptr inbounds (%struct.TYPE_4__, %struct.TYPE_4__* @rpc_createerr, i64 0, i32 0)
switch i32 %13, label %26 [
i32 129, label %14
i32 128, label %20
]
14: ; preds = %6
%15 = getelementptr i8, i8* %12, i64 3
%16 = bitcast i8* %12 to i32*
store i32 2108704, i32* %16
%17 = load i32, i32* getelementptr inbounds (%struct.TYPE_4__, %struct.TYPE_4__* @rpc_createerr, i64 0, i32 1, i32 0)
%18 = tail call i8* @clnt_sperrno(i32 %17)
%19 = tail call i8* @stpcpy(i8* %15, i8* %18)
br label %26
20: ; preds = %6
%21 = getelementptr i8, i8* %12, i64 3
%22 = bitcast i8* %12 to i32*
store i32 2108704, i32* %22
%23 = load i32, i32* getelementptr inbounds (%struct.TYPE_4__, %struct.TYPE_4__* @rpc_createerr, i64 0, i32 1, i32 1)
%24 = call i8* @__strerror_r(i32 %23, i8* %3, i32 1024)
%25 = call i8* @stpcpy(i8* %21, i8* %24)
br label %26
26: ; preds = %6, %20, %14
%27 = phi i8* [ %12, %6 ], [ %25, %20 ], [ %19, %14 ]
store i8 10, i8* %27
%28 = getelementptr inbounds i8, i8* %27, i64 1
store i8 0, i8* %28
br label %29
29: ; preds = %1, %26
ret i8* %4
}