#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*/ fprintf(int /*<<< orphan*/, char *, ...);
char *getenv(char *);
int /*<<< orphan*/ i0(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *);
int /*<<< orphan*/ stderr;
void bss_log(char *calling_fcn, char *command, int return_code) {
  char bss_command[1024];
  char bss_results[1024];
  sprintf(bss_command, "perror");
  i0(bss_command, bss_results);
  fprintf(stderr, "Calling function [%s]\n\n", calling_fcn);
  if (return_code < 0) {
    fprintf(stderr, "There was an ERROR executing the command:\n\n");
  } else {
    fprintf(stderr, "There was a WARNING executing the command:\n\n");
  }
  fprintf(stderr, "%s\n\n", command);
  fprintf(stderr, "BSS error: [%s] (%d)\n", bss_results, return_code);
  fprintf(stderr, "BSS_PARMPATH = [%s]\n", getenv("BSS_PARMPATH"));
}


x86 assembly (clang, -O0):
<bss_log>:
push   %rbp
mov    %rsp,%rbp
sub    $0x830,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
lea    -0x420(%rbp),%rdi
lea    0xe9c(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x420(%rbp),%rdi
lea    -0x820(%rbp),%rsi
call   1060 <i0@plt>
mov    0x2e5d(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe77(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
cmpl   $0x0,-0x14(%rbp)
jge    11bd <bss_log+0x7d>
mov    0x2e38(%rip),%rax
mov    (%rax),%edi
lea    0xe6e(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    11d4 <bss_log+0x94>
mov    0x2e1c(%rip),%rax
mov    (%rax),%edi
lea    0xe7e(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e05(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe90(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2dea(%rip),%rax
mov    (%rax),%edi
lea    -0x820(%rbp),%rdx
mov    -0x14(%rbp),%ecx
lea    0xe74(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2dc9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x824(%rbp)
lea    0xe82(%rip),%rdi
call   1030 <getenv@plt>
mov    -0x824(%rbp),%edi
mov    %rax,%rdx
lea    0xe58(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
add    $0x830,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bss_log>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x800,%rsp
mov    %edx,%r12d
mov    %rsi,%r15
mov    %rdi,%rbx
movl   $0x72726570,(%rsp)
movl   $0x726f72,0x3(%rsp)
mov    %rsp,%rdi
lea    0x400(%rsp),%r14
mov    %r14,%rsi
call   1050 <i0@plt>
mov    0x2e6f(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xe8c(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
test   %r12d,%r12d
mov    0x0(%rbp),%edi
lea    0xe8d(%rip),%rax
lea    0xeb2(%rip),%rsi
cmovs  %rax,%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xeca(%rip),%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xebb(%rip),%rsi
mov    %r14,%rdx
mov    %r12d,%ecx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x0(%rbp),%ebx
lea    0xecf(%rip),%rdi
call   1030 <getenv@plt>
lea    0xeae(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
add    $0x800,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"perror\00"
@stderr = global i32 0
@.str.1 = [24 x i8] c"Calling function [%s]\0A\0A\00"
@.str.2 = [44 x i8] c"There was an ERROR executing the command:\0A\0A\00"
@.str.3 = [45 x i8] c"There was a WARNING executing the command:\0A\0A\00"
@.str.4 = [5 x i8] c"%s\0A\0A\00"
@.str.5 = [22 x i8] c"BSS error: [%s] (%d)\0A\00"
@.str.6 = [21 x i8] c"BSS_PARMPATH = [%s]\0A\00"
@.str.7 = [13 x i8] c"BSS_PARMPATH\00"
define void @bss_log(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca [1024 x i8]
%8 = alloca [1024 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%10 = call i32 @sprintf(i8* %9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%13 = call i32 @i0(i8* %11, i8* %12)
%14 = load i32, i32* @stderr
%15 = load i8*, i8** %4
%16 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%17 = load i32, i32* %6
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %3
%20 = load i32, i32* @stderr
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0))
br label %25
22: ; preds = %3
%23 = load i32, i32* @stderr
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0))
br label %25
25: ; preds = %22, %19
%26 = load i32, i32* @stderr
%27 = load i8*, i8** %5
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %27)
%29 = load i32, i32* @stderr
%30 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%31 = load i32, i32* %6
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i8* %30, i32 %31)
%33 = load i32, i32* @stderr
%34 = call i8* @getenv(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i8* %34)
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"perror\00"
@stderr = global i32 0
@.str.1 = [24 x i8] c"Calling function [%s]\0A\0A\00"
@.str.2 = [44 x i8] c"There was an ERROR executing the command:\0A\0A\00"
@.str.3 = [45 x i8] c"There was a WARNING executing the command:\0A\0A\00"
@.str.4 = [5 x i8] c"%s\0A\0A\00"
@.str.5 = [22 x i8] c"BSS error: [%s] (%d)\0A\00"
@.str.6 = [21 x i8] c"BSS_PARMPATH = [%s]\0A\00"
@.str.7 = [13 x i8] c"BSS_PARMPATH\00"
define void @bss_log(i8* %0, i8* %1, i32 %2) {
%4 = alloca [1024 x i8]
%5 = alloca [1024 x i8]
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%8 = call i32 @i0(i8* %6, i8* %7)
%9 = load i32, i32* @stderr
%10 = call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%11 = icmp slt i32 %2, 0
%12 = load i32, i32* @stderr
%13 = select i1 %11, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0)
%14 = call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* %13)
%15 = load i32, i32* @stderr
%16 = call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %1)
%17 = load i32, i32* @stderr
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i8* %7, i32 %2)
%19 = load i32, i32* @stderr
%20 = call i8* @getenv(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i8* %20)
ret void
}