#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 */
scalar_t__ errno;
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ perror(char const *);
int /*<<< orphan*/ stamp(int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
void warn(const char *msg) {
  stamp(stderr);
  fprintf(stderr, "WARN\t");
  if (errno)
    perror(msg);
  else
    fprintf(stderr, "WARN: %s\n", msg);
  fflush(stderr);
}


x86 assembly (clang, -O0):
<warn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e8d(%rip),%rax
mov    (%rax),%edi
call   1040 <stamp@plt>
mov    0x2e7f(%rip),%rax
mov    (%rax),%edi
lea    0xe96(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e60(%rip),%rax
cmpq   $0x0,(%rax)
je     1190 <warn+0x50>
mov    -0x8(%rbp),%rdi
call   1060 <perror@plt>
jmp    11ab <warn+0x6b>
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe62(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e2e(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<warn>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    0x2e92(%rip),%rbx
mov    (%rbx),%edi
call   1040 <stamp@plt>
mov    (%rbx),%edi
lea    0xea2(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    0x2e6c(%rip),%rax
cmpq   $0x0,(%rax)
jne    1193 <warn+0x53>
mov    (%rbx),%edi
lea    0xe8b(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%rbx),%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <fflush@plt>
mov    %r14,%rdi
call   1060 <perror@plt>
jmp    1185 <warn+0x45>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [6 x i8] c"WARN\09\00"
@errno = global i64 0
@.str.1 = [10 x i8] c"WARN: %s\0A\00"
define void @warn(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i32, i32* @stderr
%4 = call i32 @stamp(i32 %3)
%5 = load i32, i32* @stderr
%6 = call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%7 = load i64, i64* @errno
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = load i8*, i8** %2
%11 = call i32 @perror(i8* %10)
br label %16
12: ; preds = %1
%13 = load i32, i32* @stderr
%14 = load i8*, i8** %2
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %14)
br label %16
16: ; preds = %12, %9
%17 = load i32, i32* @stderr
%18 = call i32 @fflush(i32 %17)
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [6 x i8] c"WARN\09\00"
@errno = global i64 0
@.str.1 = [10 x i8] c"WARN: %s\0A\00"
define void @warn(i8* %0) {
%2 = load i32, i32* @stderr
%3 = tail call i32 @stamp(i32 %2)
%4 = load i32, i32* @stderr
%5 = tail call i32 (i32, i8*, ...) @fprintf(i32 %4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%6 = load i64, i64* @errno
%7 = icmp eq i64 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %1
%9 = tail call i32 @perror(i8* %0)
br label %13
10: ; preds = %1
%11 = load i32, i32* @stderr
%12 = tail call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %13
13: ; preds = %10, %8
%14 = load i32, i32* @stderr
%15 = tail call i32 @fflush(i32 %14)
ret void
}