#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*/ STDERR_FILENO;
int /*<<< orphan*/ errno;
int my_strlen(char const *);
char *strerror(int /*<<< orphan*/);
int /*<<< orphan*/ xwrite(int /*<<< orphan*/, char const *, int);
void print_errno(const char *msg) {
  char *err;
  xwrite(STDERR_FILENO, "minishell: ", 11);
  xwrite(STDERR_FILENO, msg, my_strlen(msg));
  xwrite(STDERR_FILENO, ": ", 2);
  err = strerror(errno);
  xwrite(STDERR_FILENO, err, my_strlen(err));
  xwrite(STDERR_FILENO, "\n", 1);
}


x86 assembly (clang, -O0):
<print_errno>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e95(%rip),%rax
mov    (%rax),%edi
lea    0xeb4(%rip),%rsi
mov    $0xb,%edx
call   1040 <xwrite@plt>
mov    0x2e7b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <my_strlen@plt>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
call   1040 <xwrite@plt>
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
lea    0xe78(%rip),%rsi
mov    $0x2,%edx
call   1040 <xwrite@plt>
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    %rax,-0x10(%rbp)
mov    0x2e24(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <my_strlen@plt>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    %eax,%edx
call   1040 <xwrite@plt>
mov    0x2df9(%rip),%rax
mov    (%rax),%edi
lea    0xe24(%rip),%rsi
mov    $0x1,%edx
call   1040 <xwrite@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_errno>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
mov    0x2e9a(%rip),%r14
mov    (%r14),%edi
lea    0xeb8(%rip),%rsi
mov    $0xb,%edx
call   1040 <xwrite@plt>
mov    (%r14),%ebp
mov    %rbx,%rdi
call   1030 <my_strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <xwrite@plt>
mov    (%r14),%edi
lea    0xe96(%rip),%rsi
mov    $0x2,%edx
call   1040 <xwrite@plt>
mov    0x2e5c(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    %rax,%rbx
mov    (%r14),%ebp
mov    %rax,%rdi
call   1030 <my_strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <xwrite@plt>
mov    (%r14),%edi
lea    0xe5d(%rip),%rsi
mov    $0x1,%edx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <xwrite@plt>

LLVM IR (-O0):
@STDERR_FILENO = global i32 0
@.str = [12 x i8] c"minishell: \00"
@.str.1 = [3 x i8] c": \00"
@errno = global i32 0
@.str.2 = [2 x i8] c"\0A\00"
define void @print_errno(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i32, i32* @STDERR_FILENO
%5 = call i32 @xwrite(i32 %4, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 11)
%6 = load i32, i32* @STDERR_FILENO
%7 = load i8*, i8** %2
%8 = load i8*, i8** %2
%9 = call i32 @my_strlen(i8* %8)
%10 = call i32 @xwrite(i32 %6, i8* %7, i32 %9)
%11 = load i32, i32* @STDERR_FILENO
%12 = call i32 @xwrite(i32 %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
%13 = load i32, i32* @errno
%14 = call i8* @strerror(i32 %13)
store i8* %14, i8** %3
%15 = load i32, i32* @STDERR_FILENO
%16 = load i8*, i8** %3
%17 = load i8*, i8** %3
%18 = call i32 @my_strlen(i8* %17)
%19 = call i32 @xwrite(i32 %15, i8* %16, i32 %18)
%20 = load i32, i32* @STDERR_FILENO
%21 = call i32 @xwrite(i32 %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 1)
ret void
}

LLVM IR (-O2):
@STDERR_FILENO = global i32 0
@.str = [12 x i8] c"minishell: \00"
@.str.1 = [3 x i8] c": \00"
@errno = global i32 0
@.str.2 = [2 x i8] c"\0A\00"
define void @print_errno(i8* %0) {
%2 = load i32, i32* @STDERR_FILENO
%3 = tail call i32 @xwrite(i32 %2, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 11)
%4 = load i32, i32* @STDERR_FILENO
%5 = tail call i32 @my_strlen(i8* %0)
%6 = tail call i32 @xwrite(i32 %4, i8* %0, i32 %5)
%7 = load i32, i32* @STDERR_FILENO
%8 = tail call i32 @xwrite(i32 %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
%9 = load i32, i32* @errno
%10 = tail call i8* @strerror(i32 %9)
%11 = load i32, i32* @STDERR_FILENO
%12 = tail call i32 @my_strlen(i8* %10)
%13 = tail call i32 @xwrite(i32 %11, i8* %10, i32 %12)
%14 = load i32, i32* @STDERR_FILENO
%15 = tail call i32 @xwrite(i32 %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 1)
ret void
}