#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 */
char *concat(char const *, char *, char const *, char *, char const *,
             char const *, char *, char const *, int /*<<< orphan*/ *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ sprintf(char *, char *, unsigned int);
char const *strerror(int /*<<< orphan*/);
char *mkreason(const char *what, const char *pathname, unsigned int lineno,
               const char *why) {
  char buf[sizeof(unsigned int) * 3 + 1];
  const char *at_line = (lineno ? " at line " : "");
  const char *at_num = (lineno ? buf : "");
  if (lineno)
    sprintf(buf, "%u", lineno);
  return concat(what, " \"", pathname, "\"", at_line, at_num, ": ",
                (why ? why : strerror(errno)), NULL);
}


x86 assembly (clang, -O0):
<mkreason>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x14(%rbp),%edx
lea    0xebe(%rip),%rax
lea    0xea5(%rip),%rcx
cmp    $0x0,%edx
cmovne %rcx,%rax
mov    %rax,-0x38(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     117d <mkreason+0x4d>
lea    -0x2d(%rbp),%rax
mov    %rax,-0x48(%rbp)
jmp    118d <mkreason+0x5d>
lea    0xe8e(%rip),%rax
mov    %rax,-0x48(%rbp)
jmp    118d <mkreason+0x5d>
mov    -0x48(%rbp),%rax
mov    %rax,-0x40(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11b2 <mkreason+0x82>
lea    -0x2d(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xe5d(%rip),%rsi
call   1040 <sprintf@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11ea <mkreason+0xba>
mov    -0x20(%rbp),%rax
mov    %rax,-0x70(%rbp)
jmp    11fc <mkreason+0xcc>
mov    0x2def(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    %rax,-0x70(%rbp)
mov    -0x50(%rbp),%r9
mov    -0x58(%rbp),%r8
mov    -0x60(%rbp),%rdx
mov    -0x68(%rbp),%rdi
mov    -0x70(%rbp),%rax
lea    0xdf6(%rip),%rsi
lea    0xdf0(%rip),%rcx
lea    0xdeb(%rip),%r10
xor    %r11d,%r11d
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
movq   $0x0,0x10(%rsp)
call   1030 <concat@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mkreason>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%rbx
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%r15
test   %edx,%edx
je     115c <mkreason+0x2c>
lea    0xeba(%rip),%rsi
lea    0xb(%rsp),%rdi
mov    %ebp,%edx
call   1040 <sprintf@plt>
test   %rbx,%rbx
jne    1172 <mkreason+0x42>
mov    0x2e78(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    %rax,%rbx
test   %ebp,%ebp
lea    0xe97(%rip),%rax
lea    0xb(%rsp),%r9
cmove  %rax,%r9
lea    0xe75(%rip),%r8
cmove  %rax,%r8
sub    $0x8,%rsp
lea    0xe76(%rip),%rax
lea    0xe6c(%rip),%rsi
lea    0xe66(%rip),%rcx
mov    %r15,%rdi
mov    %r14,%rdx
push   $0x0
push   %rbx
push   %rax
call   1030 <concat@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c" at line \00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [3 x i8] c"%u\00"
@.str.3 = [3 x i8] c" \22\00"
@.str.4 = [2 x i8] c"\22\00"
@.str.5 = [3 x i8] c": \00"
@errno = global i32 0
define i8* @mkreason(i8* %0, i8* %1, i32 %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca [13 x i8]
%10 = alloca i8*
%11 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i8* %3, i8** %8
%12 = load i32, i32* %7
%13 = icmp ne i32 %12, 0
%14 = zext i1 %13 to i64
%15 = select i1 %13, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0)
store i8* %15, i8** %10
%16 = load i32, i32* %7
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %4
%19 = getelementptr inbounds [13 x i8], [13 x i8]* %9, i64 0, i64 0
br label %21
20: ; preds = %4
br label %21
21: ; preds = %20, %18
%22 = phi i8* [ %19, %18 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), %20 ]
store i8* %22, i8** %11
%23 = load i32, i32* %7
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %21
%26 = getelementptr inbounds [13 x i8], [13 x i8]* %9, i64 0, i64 0
%27 = load i32, i32* %7
%28 = call i32 @sprintf(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %25, %21
%30 = load i8*, i8** %5
%31 = load i8*, i8** %6
%32 = load i8*, i8** %10
%33 = load i8*, i8** %11
%34 = load i8*, i8** %8
%35 = icmp ne i8* %34, null
br i1 %35, label %36, label %38
36: ; preds = %29
%37 = load i8*, i8** %8
br label %41
38: ; preds = %29
%39 = load i32, i32* @errno
%40 = call i8* @strerror(i32 %39)
br label %41
41: ; preds = %38, %36
%42 = phi i8* [ %37, %36 ], [ %40, %38 ]
%43 = call i8* @concat(i8* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* %32, i8* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %42, i32* null)
ret i8* %43
}

LLVM IR (-O2):
@.str = [10 x i8] c" at line \00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [3 x i8] c"%u\00"
@.str.3 = [3 x i8] c" \22\00"
@.str.4 = [2 x i8] c"\22\00"
@.str.5 = [3 x i8] c": \00"
@errno = global i32 0
define i8* @mkreason(i8* %0, i8* %1, i32 %2, i8* %3) {
%5 = alloca [13 x i8]
%6 = getelementptr inbounds [13 x i8], [13 x i8]* %5, i64 0, i64 0
%7 = icmp eq i32 %2, 0
br i1 %7, label %10, label %8
8: ; preds = %4
%9 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %2)
br label %10
10: ; preds = %8, %4
%11 = icmp eq i8* %3, null
br i1 %11, label %12, label %15
12: ; preds = %10
%13 = load i32, i32* @errno
%14 = tail call i8* @strerror(i32 %13)
br label %15
15: ; preds = %10, %12
%16 = phi i8* [ %14, %12 ], [ %3, %10 ]
%17 = select i1 %7, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* %6
%18 = select i1 %7, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0)
%19 = call i8* @concat(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* %18, i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %16, i32* null)
ret i8* %19
}