#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 errno;
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
char *strerror(int);
void c_strerror() {
  char *p = strerror(errno);
  fprintf(stdout, " System error: %d, %s\n", errno, p);
  fprintf(stderr, " System error: %d, %s\n", errno, p);
  fflush(stdout);
  fflush(stderr);
}


x86 assembly (clang, -O0):
<c_strerror>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e99(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    %rax,-0x8(%rbp)
mov    0x2e7f(%rip),%rax
mov    (%rax),%edi
mov    0x2e7e(%rip),%rax
mov    (%rax),%edx
mov    -0x8(%rbp),%rcx
lea    0xe99(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e6d(%rip),%rax
mov    (%rax),%edi
mov    0x2e5c(%rip),%rax
mov    (%rax),%edx
mov    -0x8(%rbp),%rcx
lea    0xe77(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e3b(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
mov    0x2e3d(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<c_strerror>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    0x2e98(%rip),%r15
mov    (%r15),%edi
call   1050 <strerror@plt>
mov    %rax,%rbx
mov    0x2e7e(%rip),%r12
mov    (%r12),%edi
mov    (%r15),%edx
lea    0xea0(%rip),%r14
mov    %r14,%rsi
mov    %rax,%rcx
call   1030 <fprintf@plt>
mov    0x2e6e(%rip),%r13
mov    0x0(%r13),%edi
mov    (%r15),%edx
mov    %r14,%rsi
mov    %rbx,%rcx
call   1030 <fprintf@plt>
mov    (%r12),%edi
call   1040 <fflush@plt>
mov    0x0(%r13),%edi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1040 <fflush@plt>

LLVM IR (-O0):
@errno = global i32 0
@stdout = global i32 0
@.str = [23 x i8] c" System error: %d, %s\0A\00"
@stderr = global i32 0
define void @c_strerror() {
%1 = alloca i8*
%2 = load i32, i32* @errno
%3 = call i8* @strerror(i32 %2)
store i8* %3, i8** %1
%4 = load i32, i32* @stdout
%5 = load i32, i32* @errno
%6 = load i8*, i8** %1
%7 = call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %5, i8* %6)
%8 = load i32, i32* @stderr
%9 = load i32, i32* @errno
%10 = load i8*, i8** %1
%11 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %9, i8* %10)
%12 = load i32, i32* @stdout
%13 = call i32 @fflush(i32 %12)
%14 = load i32, i32* @stderr
%15 = call i32 @fflush(i32 %14)
ret void
}

LLVM IR (-O2):
@errno = global i32 0
@stdout = global i32 0
@.str = [23 x i8] c" System error: %d, %s\0A\00"
@stderr = global i32 0
define void @c_strerror() {
%1 = load i32, i32* @errno
%2 = tail call i8* @strerror(i32 %1)
%3 = load i32, i32* @stdout
%4 = load i32, i32* @errno
%5 = tail call i32 @fprintf(i32 %3, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %4, i8* %2)
%6 = load i32, i32* @stderr
%7 = load i32, i32* @errno
%8 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %7, i8* %2)
%9 = load i32, i32* @stdout
%10 = tail call i32 @fflush(i32 %9)
%11 = load i32, i32* @stderr
%12 = tail call i32 @fflush(i32 %11)
ret void
}