#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ yaiv_show_usage();
void yaiv_panic(int code, char *extra_msg) {
  char *msg;
  if (extra_msg != NULL)
    fprintf(stderr, "%s: ", extra_msg);
  switch (code) {
  case 1:
    msg = "Malformed IPv4 address";
    break;
  case 2:
    msg = "Malformed IPv6 address";
    break;
  case 3:
    msg = "Address not specified";
    yaiv_show_usage();
    break;
  case 4:
    msg = "Unknown parameters";
    yaiv_show_usage();
    break;
  case 255:
    msg = "Unknown error";
    break;
  default:
    msg = "Unknown error";
    break;
  }
  fprintf(stderr, "%s\n", msg);
  exit(code);
}


x86 assembly (clang, -O0):
<yaiv_panic>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1163 <yaiv_panic+0x33>
mov    0x2e8f(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xea2(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x1,%eax
je     11bd <yaiv_panic+0x8d>
jmp    1177 <yaiv_panic+0x47>
mov    -0x1c(%rbp),%eax
sub    $0x2,%eax
je     11cd <yaiv_panic+0x9d>
jmp    1188 <yaiv_panic+0x58>
mov    -0x1c(%rbp),%eax
sub    $0x3,%eax
je     11dd <yaiv_panic+0xad>
jmp    1199 <yaiv_panic+0x69>
mov    -0x1c(%rbp),%eax
sub    $0x4,%eax
je     11f4 <yaiv_panic+0xc4>
jmp    11aa <yaiv_panic+0x7a>
mov    -0x1c(%rbp),%eax
sub    $0xff,%eax
je     120b <yaiv_panic+0xdb>
jmp    121b <yaiv_panic+0xeb>
lea    0xe41(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    1226 <yaiv_panic+0xf6>
lea    0xe48(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    1226 <yaiv_panic+0xf6>
lea    0xe4f(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1050 <yaiv_show_usage@plt>
jmp    1226 <yaiv_panic+0xf6>
lea    0xe4e(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1050 <yaiv_show_usage@plt>
jmp    1226 <yaiv_panic+0xf6>
lea    0xe4a(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    1226 <yaiv_panic+0xf6>
lea    0xe3a(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0x2db3(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe30(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x4(%rbp),%edi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<yaiv_panic>:
push   %rbx
mov    %edi,%ebx
test   %rsi,%rsi
je     1150 <yaiv_panic+0x20>
mov    %rsi,%rdx
mov    0x2e9e(%rip),%rax
mov    (%rax),%edi
lea    0xec5(%rip),%rsi
call   1030 <fprintf@plt>
lea    -0x1(%rbx),%eax
cmp    $0x3,%eax
ja     1178 <yaiv_panic+0x48>
lea    0xeb6(%rip),%rdx
lea    0xe9a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xeb6(%rip),%rdx
jmp    11a5 <yaiv_panic+0x75>
cmp    $0xff,%ebx
lea    0xee7(%rip),%rdx
jmp    11a5 <yaiv_panic+0x75>
xor    %eax,%eax
call   1050 <yaiv_show_usage@plt>
lea    0xeae(%rip),%rdx
jmp    11a5 <yaiv_panic+0x75>
xor    %eax,%eax
call   1050 <yaiv_show_usage@plt>
lea    0xeb4(%rip),%rdx
mov    0x2e34(%rip),%rax
mov    (%rax),%edi
lea    0xec5(%rip),%rsi
call   1030 <fprintf@plt>
mov    %ebx,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [5 x i8] c"%s: \00"
@.str.1 = [23 x i8] c"Malformed IPv4 address\00"
@.str.2 = [23 x i8] c"Malformed IPv6 address\00"
@.str.3 = [22 x i8] c"Address not specified\00"
@.str.4 = [19 x i8] c"Unknown parameters\00"
@.str.5 = [14 x i8] c"Unknown error\00"
@.str.6 = [4 x i8] c"%s\0A\00"
define void @yaiv_panic(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
store i32 %0, i32* %3
store i8* %1, i8** %4
%6 = load i8*, i8** %4
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = load i8*, i8** %4
%11 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %10)
br label %12
12: ; preds = %8, %2
%13 = load i32, i32* %3
switch i32 %13, label %21 [
i32 1, label %14
i32 2, label %15
i32 3, label %16
i32 4, label %18
i32 255, label %20
]
14: ; preds = %12
store i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8** %5
br label %22
15: ; preds = %12
store i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8** %5
br label %22
16: ; preds = %12
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8** %5
%17 = call i32 (...) @yaiv_show_usage()
br label %22
18: ; preds = %12
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8** %5
%19 = call i32 (...) @yaiv_show_usage()
br label %22
20: ; preds = %12
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8** %5
br label %22
21: ; preds = %12
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8** %5
br label %22
22: ; preds = %21, %20, %18, %16, %15, %14
%23 = load i32, i32* @stderr
%24 = load i8*, i8** %5
%25 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %24)
%26 = load i32, i32* %3
%27 = call i32 @exit(i32 %26)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [5 x i8] c"%s: \00"
@.str.1 = [23 x i8] c"Malformed IPv4 address\00"
@.str.2 = [23 x i8] c"Malformed IPv6 address\00"
@.str.3 = [22 x i8] c"Address not specified\00"
@.str.4 = [19 x i8] c"Unknown parameters\00"
@.str.5 = [14 x i8] c"Unknown error\00"
@.str.6 = [4 x i8] c"%s\0A\00"
define void @yaiv_panic(i32 %0, i8* %1) {
%3 = icmp eq i8* %1, null
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %1)
br label %7
7: ; preds = %4, %2
switch i32 %0, label %14 [
i32 1, label %15
i32 2, label %8
i32 3, label %9
i32 4, label %11
i32 255, label %13
]
8: ; preds = %7
br label %15
9: ; preds = %7
%10 = tail call i32 (...) @yaiv_show_usage()
br label %15
11: ; preds = %7
%12 = tail call i32 (...) @yaiv_show_usage()
br label %15
13: ; preds = %7
br label %15
14: ; preds = %7
br label %15
15: ; preds = %7, %14, %13, %11, %9, %8
%16 = phi i8* [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), %14 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), %13 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), %11 ], [ getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), %9 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), %8 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), %7 ]
%17 = load i32, i32* @stderr
%18 = tail call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %16)
%19 = tail call i32 @exit(i32 %0)
unreachable
}