#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 */
char *get_error();
char *gettext(char *);
int /*<<< orphan*/ printf(char *, ...);
int nagios_result(int ok, int nagios_mode, int nagios_exit_code,
                  double avg_httping_time, double nagios_warn,
                  double nagios_crit) {
  if (nagios_mode == 1) {
    if (ok == 0) {
      printf(gettext("CRITICAL - connecting failed: %s"), get_error());
      return 2;
    } else if (avg_httping_time >= nagios_crit) {
      printf(gettext("CRITICAL - average httping-time is %.1f\n"),
             avg_httping_time);
      return 2;
    } else if (avg_httping_time >= nagios_warn) {
      printf(gettext("WARNING - average httping-time is %.1f\n"),
             avg_httping_time);
      return 1;
    }
    printf(gettext("OK - average httping-time is %.1f (%s)|ping=%f\n"),
           avg_httping_time, get_error(), avg_httping_time);
    return 0;
  } else if (nagios_mode == 2) {
    const char *err = get_error();
    if (ok && err[0] == 0x00) {
      printf(gettext("OK - all fine, avg httping time is %.1f|ping=%f\n"),
             avg_httping_time, avg_httping_time);
      return 0;
    }
    printf(gettext("%s: - failed: %s"),
           nagios_exit_code == 1
               ? "WARNING"
               : (nagios_exit_code == 2 ? "CRITICAL" : "ERROR"),
           err);
    return nagios_exit_code;
  }
  return -1;
}


x86 assembly (clang, -O0):
<nagios_result>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
movsd  %xmm2,-0x28(%rbp)
cmpl   $0x1,-0xc(%rbp)
jne    1252 <nagios_result+0x122>
cmpl   $0x0,-0x8(%rbp)
jne    1195 <nagios_result+0x65>
lea    0xe95(%rip),%rdi
call   1030 <gettext@plt>
mov    %rax,-0x38(%rbp)
mov    $0x0,%al
call   1050 <get_error@plt>
mov    -0x38(%rbp),%rdi
mov    %rax,%rsi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x2,-0x4(%rbp)
jmp    131d <nagios_result+0x1ed>
movsd  -0x18(%rbp),%xmm0
ucomisd -0x28(%rbp),%xmm0
jb     11cc <nagios_result+0x9c>
lea    0xe75(%rip),%rdi
call   1030 <gettext@plt>
mov    %rax,%rdi
movsd  -0x18(%rbp),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
movl   $0x2,-0x4(%rbp)
jmp    131d <nagios_result+0x1ed>
movsd  -0x18(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jb     1203 <nagios_result+0xd3>
lea    0xe67(%rip),%rdi
call   1030 <gettext@plt>
mov    %rax,%rdi
movsd  -0x18(%rbp),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    131d <nagios_result+0x1ed>
jmp    1208 <nagios_result+0xd8>
jmp    120d <nagios_result+0xdd>
lea    0xe5e(%rip),%rdi
call   1030 <gettext@plt>
mov    %rax,-0x48(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    $0x0,%al
call   1050 <get_error@plt>
mov    -0x48(%rbp),%rdi
movsd  -0x40(%rbp),%xmm0
mov    %rax,%rsi
movsd  -0x18(%rbp),%xmm1
mov    $0x2,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    131d <nagios_result+0x1ed>
cmpl   $0x2,-0xc(%rbp)
jne    1311 <nagios_result+0x1e1>
mov    $0x0,%al
call   1050 <get_error@plt>
mov    %rax,-0x30(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     12ad <nagios_result+0x17d>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    12ad <nagios_result+0x17d>
lea    0xe1a(%rip),%rdi
call   1030 <gettext@plt>
mov    %rax,%rdi
movsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
mov    $0x2,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    131d <nagios_result+0x1ed>
lea    0xe1f(%rip),%rdi
call   1030 <gettext@plt>
mov    %rax,-0x50(%rbp)
cmpl   $0x1,-0x10(%rbp)
jne    12d7 <nagios_result+0x1a7>
lea    0xe16(%rip),%rax
mov    %rax,-0x58(%rbp)
jmp    12f3 <nagios_result+0x1c3>
mov    -0x10(%rbp),%edx
lea    0xe14(%rip),%rax
lea    0xe04(%rip),%rcx
cmp    $0x2,%edx
cmove  %rcx,%rax
mov    %rax,-0x58(%rbp)
mov    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    131d <nagios_result+0x1ed>
jmp    1316 <nagios_result+0x1e6>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nagios_result>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebp
cmp    $0x2,%esi
je     11a3 <nagios_result+0x73>
mov    $0xffffffff,%ebx
cmp    $0x1,%esi
jne    1296 <nagios_result+0x166>
test   %ebp,%ebp
je     1204 <nagios_result+0xd4>
ucomisd %xmm2,%xmm0
movsd  %xmm0,0x8(%rsp)
jae    122e <nagios_result+0xfe>
ucomisd %xmm1,%xmm0
jae    1275 <nagios_result+0x145>
lea    0xefc(%rip),%rdi
call   1030 <gettext@plt>
mov    %rax,%rbp
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <get_error@plt>
mov    %rbp,%rdi
movsd  0x8(%rsp),%xmm0
mov    %rax,%rsi
movapd %xmm0,%xmm1
mov    $0x2,%al
call   1040 <printf@plt>
jmp    1296 <nagios_result+0x166>
mov    %edx,%ebx
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1050 <get_error@plt>
mov    %rax,%r14
test   %ebp,%ebp
je     11c3 <nagios_result+0x93>
cmpb   $0x0,(%r14)
je     1251 <nagios_result+0x121>
lea    0xf09(%rip),%rdi
call   1030 <gettext@plt>
cmp    $0x2,%ebx
lea    0xf13(%rip),%rcx
lea    0xf15(%rip),%rdx
cmove  %rcx,%rdx
cmp    $0x1,%ebx
lea    0xef6(%rip),%rsi
cmovne %rdx,%rsi
mov    %rax,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1296 <nagios_result+0x166>
lea    0xdf5(%rip),%rdi
call   1030 <gettext@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1050 <get_error@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x2,%ebx
jmp    1296 <nagios_result+0x166>
lea    0xdec(%rip),%rdi
call   1030 <gettext@plt>
mov    %rax,%rdi
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
mov    $0x2,%ebx
jmp    1296 <nagios_result+0x166>
lea    0xe4a(%rip),%rdi
call   1030 <gettext@plt>
mov    %rax,%rdi
movsd  0x8(%rsp),%xmm0
movapd %xmm0,%xmm1
mov    $0x2,%al
call   1040 <printf@plt>
xor    %ebx,%ebx
jmp    1296 <nagios_result+0x166>
lea    0xdce(%rip),%rdi
call   1030 <gettext@plt>
mov    %rax,%rdi
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"CRITICAL - connecting failed: %s\00"
@.str.1 = [41 x i8] c"CRITICAL - average httping-time is %.1f\0A\00"
@.str.2 = [40 x i8] c"WARNING - average httping-time is %.1f\0A\00"
@.str.3 = [48 x i8] c"OK - average httping-time is %.1f (%s)|ping=%f\0A\00"
@.str.4 = [49 x i8] c"OK - all fine, avg httping time is %.1f|ping=%f\0A\00"
@.str.5 = [17 x i8] c"%s: - failed: %s\00"
@.str.6 = [8 x i8] c"WARNING\00"
@.str.7 = [9 x i8] c"CRITICAL\00"
@.str.8 = [6 x i8] c"ERROR\00"
define i32 @nagios_result(i32 %0, i32 %1, i32 %2, double %3, double %4, double %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca i8*
store i32 %0, i32* %8
store i32 %1, i32* %9
store i32 %2, i32* %10
store double %3, double* %11
store double %4, double* %12
store double %5, double* %13
%15 = load i32, i32* %9
%16 = icmp eq i32 %15, 1
br i1 %16, label %17, label %48
17: ; preds = %6
%18 = load i32, i32* %8
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %17
%21 = call i8* @gettext(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%22 = call i8* (...) @get_error()
%23 = call i32 (i8*, ...) @printf(i8* %21, i8* %22)
store i32 2, i32* %7
br label %83
24: ; preds = %17
%25 = load double, double* %11
%26 = load double, double* %13
%27 = fcmp oge double %25, %26
br i1 %27, label %28, label %32
28: ; preds = %24
%29 = call i8* @gettext(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
%30 = load double, double* %11
%31 = call i32 (i8*, ...) @printf(i8* %29, double %30)
store i32 2, i32* %7
br label %83
32: ; preds = %24
%33 = load double, double* %11
%34 = load double, double* %12
%35 = fcmp oge double %33, %34
br i1 %35, label %36, label %40
36: ; preds = %32
%37 = call i8* @gettext(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
%38 = load double, double* %11
%39 = call i32 (i8*, ...) @printf(i8* %37, double %38)
store i32 1, i32* %7
br label %83
40: ; preds = %32
br label %41
41: ; preds = %40
br label %42
42: ; preds = %41
%43 = call i8* @gettext(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0))
%44 = load double, double* %11
%45 = call i8* (...) @get_error()
%46 = load double, double* %11
%47 = call i32 (i8*, ...) @printf(i8* %43, double %44, i8* %45, double %46)
store i32 0, i32* %7
br label %83
48: ; preds = %6
%49 = load i32, i32* %9
%50 = icmp eq i32 %49, 2
br i1 %50, label %51, label %81
51: ; preds = %48
%52 = call i8* (...) @get_error()
store i8* %52, i8** %14
%53 = load i32, i32* %8
%54 = icmp ne i32 %53, 0
br i1 %54, label %55, label %66
55: ; preds = %51
%56 = load i8*, i8** %14
%57 = getelementptr inbounds i8, i8* %56, i64 0
%58 = load i8, i8* %57
%59 = sext i8 %58 to i32
%60 = icmp eq i32 %59, 0
br i1 %60, label %61, label %66
61: ; preds = %55
%62 = call i8* @gettext(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.4, i64 0, i64 0))
%63 = load double, double* %11
%64 = load double, double* %11
%65 = call i32 (i8*, ...) @printf(i8* %62, double %63, double %64)
store i32 0, i32* %7
br label %83
66: ; preds = %55, %51
%67 = call i8* @gettext(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
%68 = load i32, i32* %10
%69 = icmp eq i32 %68, 1
br i1 %69, label %70, label %71
70: ; preds = %66
br label %76
71: ; preds = %66
%72 = load i32, i32* %10
%73 = icmp eq i32 %72, 2
%74 = zext i1 %73 to i64
%75 = select i1 %73, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0)
br label %76
76: ; preds = %71, %70
%77 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), %70 ], [ %75, %71 ]
%78 = load i8*, i8** %14
%79 = call i32 (i8*, ...) @printf(i8* %67, i8* %77, i8* %78)
%80 = load i32, i32* %10
store i32 %80, i32* %7
br label %83
81: ; preds = %48
br label %82
82: ; preds = %81
store i32 -1, i32* %7
br label %83
83: ; preds = %82, %76, %61, %42, %36, %28, %20
%84 = load i32, i32* %7
ret i32 %84
}

LLVM IR (-O2):
@.str = [33 x i8] c"CRITICAL - connecting failed: %s\00"
@.str.1 = [41 x i8] c"CRITICAL - average httping-time is %.1f\0A\00"
@.str.2 = [40 x i8] c"WARNING - average httping-time is %.1f\0A\00"
@.str.3 = [48 x i8] c"OK - average httping-time is %.1f (%s)|ping=%f\0A\00"
@.str.4 = [49 x i8] c"OK - all fine, avg httping time is %.1f|ping=%f\0A\00"
@.str.5 = [17 x i8] c"%s: - failed: %s\00"
@.str.6 = [8 x i8] c"WARNING\00"
@.str.7 = [9 x i8] c"CRITICAL\00"
@.str.8 = [6 x i8] c"ERROR\00"
define i32 @nagios_result(i32 %0, i32 %1, i32 %2, double %3, double %4, double %5) {
switch i32 %1, label %43 [
i32 1, label %7
i32 2, label %27
]
7: ; preds = %6
%8 = icmp eq i32 %0, 0
br i1 %8, label %9, label %13
9: ; preds = %7
%10 = tail call i8* @gettext(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%11 = tail call i8* (...) @get_error()
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %10, i8* %11)
br label %43
13: ; preds = %7
%14 = fcmp ult double %3, %5
br i1 %14, label %18, label %15
15: ; preds = %13
%16 = tail call i8* @gettext(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %16, double %3)
br label %43
18: ; preds = %13
%19 = fcmp ult double %3, %4
br i1 %19, label %23, label %20
20: ; preds = %18
%21 = tail call i8* @gettext(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %21, double %3)
br label %43
23: ; preds = %18
%24 = tail call i8* @gettext(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0))
%25 = tail call i8* (...) @get_error()
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %24, double %3, i8* %25, double %3)
br label %43
27: ; preds = %6
%28 = tail call i8* (...) @get_error()
%29 = icmp eq i32 %0, 0
br i1 %29, label %36, label %30
30: ; preds = %27
%31 = load i8, i8* %28
%32 = icmp eq i8 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %30
%34 = tail call i8* @gettext(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.4, i64 0, i64 0))
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %34, double %3, double %3)
br label %43
36: ; preds = %30, %27
%37 = tail call i8* @gettext(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
%38 = icmp eq i32 %2, 1
%39 = icmp eq i32 %2, 2
%40 = select i1 %39, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0)
%41 = select i1 %38, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i8* %40
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %37, i8* %41, i8* %28)
br label %43
43: ; preds = %6, %33, %36, %23, %20, %15, %9
%44 = phi i32 [ 2, %9 ], [ 2, %15 ], [ 1, %20 ], [ 0, %23 ], [ 0, %33 ], [ %2, %36 ], [ -1, %6 ]
ret i32 %44
}