#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*/ errno;
int /*<<< orphan*/ lprintf(char *, char const *, ...);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
void lperror(const char *s) {
  if ((s == NULL) || (*s == '\0'))
    lprintf("%s\n", strerror(errno));
  else
    lprintf("%s: %s\n", s, strerror(errno));
  return;
}


x86 assembly (clang, -O0):
<lperror>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1147 <lperror+0x27>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    116b <lperror+0x4b>
mov    0x2e92(%rip),%rax
mov    (%rax),%edi
call   1040 <strerror@plt>
movslq %eax,%rsi
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <lprintf@plt>
jmp    1195 <lperror+0x75>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    0x2e66(%rip),%rax
mov    (%rax),%edi
call   1040 <strerror@plt>
mov    -0x10(%rbp),%rsi
mov    %eax,%edx
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1030 <lprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lperror>:
push   %rbx
test   %rdi,%rdi
je     1150 <lperror+0x30>
mov    %rdi,%rbx
cmpb   $0x0,(%rdi)
je     1150 <lperror+0x30>
mov    0x2eab(%rip),%rax
mov    (%rax),%edi
call   1040 <strerror@plt>
lea    0xebd(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
pop    %rbx
jmp    1030 <lprintf@plt>
mov    0x2e89(%rip),%rax
mov    (%rax),%edi
call   1040 <strerror@plt>
movslq %eax,%rsi
lea    0xe9c(%rip),%rdi
xor    %eax,%eax
pop    %rbx
jmp    1030 <lprintf@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
@errno = global i32 0
@.str.1 = [8 x i8] c"%s: %s\0A\00"
define void @lperror(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = icmp eq i8* %3, null
br i1 %4, label %10, label %5
5: ; preds = %1
%6 = load i8*, i8** %2
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %16
10: ; preds = %5, %1
%11 = load i32, i32* @errno
%12 = call i32 @strerror(i32 %11)
%13 = sext i32 %12 to i64
%14 = inttoptr i64 %13 to i8*
%15 = call i32 (i8*, i8*, ...) @lprintf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %14)
br label %21
16: ; preds = %5
%17 = load i8*, i8** %2
%18 = load i32, i32* @errno
%19 = call i32 @strerror(i32 %18)
%20 = call i32 (i8*, i8*, ...) @lprintf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %17, i32 %19)
br label %21
21: ; preds = %16, %10
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
@errno = global i32 0
@.str.1 = [8 x i8] c"%s: %s\0A\00"
define void @lperror(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %6, label %3
3: ; preds = %1
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %6, label %12
6: ; preds = %3, %1
%7 = load i32, i32* @errno
%8 = tail call i32 @strerror(i32 %7)
%9 = sext i32 %8 to i64
%10 = inttoptr i64 %9 to i8*
%11 = tail call i32 (i8*, i8*, ...) @lprintf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %10)
br label %16
12: ; preds = %3
%13 = load i32, i32* @errno
%14 = tail call i32 @strerror(i32 %13)
%15 = tail call i32 (i8*, i8*, ...) @lprintf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32 %14)
br label %16
16: ; preds = %12, %6
ret void
}