#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 */
typedef int /*<<< orphan*/ desc;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ librpipErrorGetDescription(char *, int);
int librpipErrorGetSeverity();
int /*<<< orphan*/ stderr;
void librpipErrorPrint(void) {
  char desc[300] = {0};
  if (librpipErrorGetDescription(&desc[0], sizeof(desc))) {
    switch (librpipErrorGetSeverity()) {
    case 1:
      fprintf(stderr, "[librpip INFO   ] %s\n", desc);
      break;
    case 2:
      fprintf(stderr, "[librpip WARNING] %s\n", desc);
      break;
    case 3:
      fprintf(stderr, "[librpip ERROR  ] %s\n", desc);
      break;
    }
  }
}


x86 assembly (clang, -O0):
<librpipErrorPrint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
lea    -0x130(%rbp),%rdi
xor    %esi,%esi
mov    $0x12c,%edx
call   1040 <memset@plt>
lea    -0x130(%rbp),%rdi
mov    $0x12c,%esi
call   1050 <librpipErrorGetDescription@plt>
cmp    $0x0,%rax
je     1221 <librpipErrorPrint+0xe1>
xor    %eax,%eax
call   1030 <librpipErrorGetSeverity@plt>
mov    %eax,%ecx
mov    %ecx,-0x134(%rbp)
sub    $0x1,%eax
je     11be <librpipErrorPrint+0x7e>
jmp    1196 <librpipErrorPrint+0x56>
mov    -0x134(%rbp),%eax
sub    $0x2,%eax
je     11df <librpipErrorPrint+0x9f>
jmp    11aa <librpipErrorPrint+0x6a>
mov    -0x134(%rbp),%eax
sub    $0x3,%eax
je     1200 <librpipErrorPrint+0xc0>
jmp    121c <librpipErrorPrint+0xdc>
mov    0x2e1b(%rip),%rax
mov    (%rax),%edi
lea    -0x130(%rbp),%rdx
lea    0xe2b(%rip),%rsi
call   1060 <fprintf@plt>
jmp    121c <librpipErrorPrint+0xdc>
mov    0x2dfa(%rip),%rax
mov    (%rax),%edi
lea    -0x130(%rbp),%rdx
lea    0xe20(%rip),%rsi
call   1060 <fprintf@plt>
jmp    121c <librpipErrorPrint+0xdc>
mov    0x2dd9(%rip),%rax
mov    (%rax),%edi
lea    -0x130(%rbp),%rdx
lea    0xe15(%rip),%rsi
call   1060 <fprintf@plt>
jmp    1221 <librpipErrorPrint+0xe1>
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<librpipErrorPrint>:
push   %rbx
sub    $0x130,%rsp
mov    %rsp,%rbx
mov    $0x12c,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
mov    %rbx,%rdi
mov    $0x12c,%esi
call   1050 <librpipErrorGetDescription@plt>
test   %rax,%rax
je     119c <librpipErrorPrint+0x5c>
xor    %eax,%eax
call   1030 <librpipErrorGetSeverity@plt>
add    $0xffffffff,%eax
cmp    $0x2,%eax
ja     119c <librpipErrorPrint+0x5c>
cltq
lea    0xec0(%rip),%rcx
movslq (%rcx,%rax,4),%rsi
add    %rcx,%rsi
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rdx
call   1060 <fprintf@plt>
add    $0x130,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [22 x i8] c"[librpip INFO ] %s\0A\00"
@.str.1 = [22 x i8] c"[librpip WARNING] %s\0A\00"
@.str.2 = [22 x i8] c"[librpip ERROR ] %s\0A\00"
define void @librpipErrorPrint() {
%1 = alloca [300 x i8]
%2 = bitcast [300 x i8]* %1 to i8*
%3 = getelementptr inbounds [300 x i8], [300 x i8]* %1, i64 0, i64 0
%4 = call i64 @librpipErrorGetDescription(i8* %3, i32 300)
%5 = icmp ne i64 %4, 0
br i1 %5, label %6, label %21
6: ; preds = %0
%7 = call i32 (...) @librpipErrorGetSeverity()
switch i32 %7, label %20 [
i32 1, label %8
i32 2, label %12
i32 3, label %16
]
8: ; preds = %6
%9 = load i32, i32* @stderr
%10 = getelementptr inbounds [300 x i8], [300 x i8]* %1, i64 0, i64 0
%11 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %10)
br label %20
12: ; preds = %6
%13 = load i32, i32* @stderr
%14 = getelementptr inbounds [300 x i8], [300 x i8]* %1, i64 0, i64 0
%15 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %14)
br label %20
16: ; preds = %6
%17 = load i32, i32* @stderr
%18 = getelementptr inbounds [300 x i8], [300 x i8]* %1, i64 0, i64 0
%19 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %18)
br label %20
20: ; preds = %6, %16, %12, %8
br label %21
21: ; preds = %20, %0
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [22 x i8] c"[librpip INFO ] %s\0A\00"
@.str.1 = [22 x i8] c"[librpip WARNING] %s\0A\00"
@.str.2 = [22 x i8] c"[librpip ERROR ] %s\0A\00"
@reltable.librpipErrorPrint = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([22 x i8]* @.str to i64), i64 ptrtoint ([3 x i32]* @reltable.librpipErrorPrint to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([22 x i8]* @.str.1 to i64), i64 ptrtoint ([3 x i32]* @reltable.librpipErrorPrint to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([22 x i8]* @.str.2 to i64), i64 ptrtoint ([3 x i32]* @reltable.librpipErrorPrint to i64)) to i32)]
define void @librpipErrorPrint() {
%1 = alloca [300 x i8]
%2 = getelementptr inbounds [300 x i8], [300 x i8]* %1, i64 0, i64 0
%3 = call i64 @librpipErrorGetDescription(i8* %2, i32 300)
%4 = icmp eq i64 %3, 0
br i1 %4, label %15, label %5
5: ; preds = %0
%6 = call i32 (...) @librpipErrorGetSeverity()
%7 = add i32 %6, -1
%8 = icmp ult i32 %7, 3
br i1 %8, label %9, label %15
9: ; preds = %5
%10 = sext i32 %7 to i64
%11 = shl i64 %10, 2
%12 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.librpipErrorPrint to i8*), i64 %11)
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* %12, i8* %2)
br label %15
15: ; preds = %5, %9, %0
ret void
}