#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 *, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ stdout;
void handle_error(char *msg, char *error) {
  if (error) {
    fprintf(stdout, "%s: %s", msg, error);
    free(error);
  } else {
    fprintf(stdout, "%s: %s", msg, "unknown error");
  }
}


x86 assembly (clang, -O0):
<handle_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1166 <handle_error+0x46>
mov    0x2e9e(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xead(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
jmp    1186 <handle_error+0x66>
mov    0x2e73(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe86(%rip),%rsi
lea    0xe86(%rip),%rcx
call   1040 <fprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handle_error>:
push   %rbx
mov    %rdi,%rdx
mov    0x2eb5(%rip),%rax
mov    (%rax),%edi
test   %rsi,%rsi
je     114d <handle_error+0x2d>
mov    %rsi,%rbx
lea    0xec4(%rip),%rsi
mov    %rbx,%rcx
call   1040 <fprintf@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1030 <free@plt>
lea    0xeac(%rip),%rsi
lea    0xeac(%rip),%rcx
pop    %rbx
jmp    1040 <fprintf@plt>

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

LLVM IR (-O2):
@stdout = global i32 0
@.str = [7 x i8] c"%s: %s\00"
@.str.1 = [14 x i8] c"unknown error\00"
define void @handle_error(i8* %0, i8* %1) {
%3 = icmp eq i8* %1, null
%4 = load i32, i32* @stdout
br i1 %3, label %8, label %5
5: ; preds = %2
%6 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
%7 = tail call i32 @free(i8* %1)
br label %10
8: ; preds = %2
%9 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %0, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %10
10: ; preds = %8, %5
ret void
}