#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*/ error(int, int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
void bug(char *msg, int fatal) {
  error(1, 0, "Internal error: %s.", msg);
  if (fatal) {
    fprintf(stderr, "Emergency stop.\n\n");
    exit(3);
  }
  fprintf(stderr, "Trying to continue...\n");
}


x86 assembly (clang, -O0):
<bug>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rcx
mov    $0x1,%edi
xor    %esi,%esi
lea    0xeaf(%rip),%rdx
call   1040 <error@plt>
cmpl   $0x0,-0xc(%rbp)
je     117f <bug+0x4f>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
lea    0xea4(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x3,%edi
call   1050 <exit@plt>
mov    0x2e5a(%rip),%rax
mov    (%rax),%edi
lea    0xe97(%rip),%rsi
call   1030 <fprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bug>:
push   %rbx
mov    %esi,%ebx
mov    %rdi,%rcx
lea    0xec3(%rip),%rdx
mov    $0x1,%edi
xor    %esi,%esi
call   1040 <error@plt>
mov    0x2e90(%rip),%rax
mov    (%rax),%edi
test   %ebx,%ebx
jne    1163 <bug+0x33>
lea    0xec9(%rip),%rsi
pop    %rbx
jmp    1030 <fprintf@plt>
lea    0xeaa(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x3,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [20 x i8] c"Internal error: %s.\00"
@stderr = global i32 0
@.str.1 = [18 x i8] c"Emergency stop.\0A\0A\00"
@.str.2 = [23 x i8] c"Trying to continue...\0A\00"
define void @bug(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%5 = load i8*, i8** %3
%6 = call i32 @error(i32 1, i32 0, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @exit(i32 3)
unreachable
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"Internal error: %s.\00"
@stderr = global i32 0
@.str.1 = [18 x i8] c"Emergency stop.\0A\0A\00"
@.str.2 = [23 x i8] c"Trying to continue...\0A\00"
define void @bug(i8* %0, i32 %1) {
%3 = tail call i32 @error(i32 1, i32 0, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %0)
%4 = icmp eq i32 %1, 0
%5 = load i32, i32* @stderr
br i1 %4, label %9, label %6
6: ; preds = %2
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%8 = tail call i32 @exit(i32 3)
unreachable
9: ; preds = %2
%10 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
ret void
}