#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*/ va_list;
struct katcl_line {
  int dummy;
};

/* Variables and functions */
int vlog_message_katcl(struct katcl_line *, unsigned int, char *, char *,
                       int /*<<< orphan*/);
int check_log_message_katcp(struct katcl_line *l, int sum, unsigned int limit,
                            unsigned int level, char *name, char *fmt,
                            va_list args) {
  int result;
  if (level < limit) {
    return 0;
  }
  result = vlog_message_katcl(l, level, name, fmt, args);
  if (sum < 0) {
    return sum;
  }
  if (result < 0) {
    return result;
  }
  return sum + result;
}


x86 assembly (clang, -O0):
<check_log_message_katcp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jae    1148 <check_log_message_katcp+0x38>
movl   $0x0,-0x4(%rbp)
jmp    1196 <check_log_message_katcp+0x86>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    0x10(%rbp),%r8d
call   1030 <vlog_message_katcl@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    1178 <check_log_message_katcp+0x68>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1196 <check_log_message_katcp+0x86>
cmpl   $0x0,-0x34(%rbp)
jge    118d <check_log_message_katcp+0x7d>
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1196 <check_log_message_katcp+0x86>
mov    -0x14(%rbp),%eax
add    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_log_message_katcp>:
push   %rbx
xor    %eax,%eax
cmp    %edx,%ecx
jb     113c <check_log_message_katcp+0x2c>
mov    %esi,%ebx
mov    0x10(%rsp),%eax
mov    %ecx,%esi
mov    %r8,%rdx
mov    %r9,%rcx
mov    %eax,%r8d
call   1030 <vlog_message_katcl@plt>
test   %ebx,%ebx
js     113a <check_log_message_katcp+0x2a>
xor    %ecx,%ecx
test   %eax,%eax
cmovs  %ecx,%ebx
add    %eax,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.katcl_line = type { i32 }
define i32 @check_log_message_katcp(%struct.katcl_line* %0, i32 %1, i32 %2, i32 %3, i8* %4, i8* %5, i32 %6) {
%8 = alloca i32
%9 = alloca %struct.katcl_line*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i32
%16 = alloca i32
store %struct.katcl_line* %0, %struct.katcl_line** %9
store i32 %1, i32* %10
store i32 %2, i32* %11
store i32 %3, i32* %12
store i8* %4, i8** %13
store i8* %5, i8** %14
store i32 %6, i32* %15
%17 = load i32, i32* %12
%18 = load i32, i32* %11
%19 = icmp ult i32 %17, %18
br i1 %19, label %20, label %21
20: ; preds = %7
store i32 0, i32* %8
br label %41
21: ; preds = %7
%22 = load %struct.katcl_line*, %struct.katcl_line** %9
%23 = load i32, i32* %12
%24 = load i8*, i8** %13
%25 = load i8*, i8** %14
%26 = load i32, i32* %15
%27 = call i32 @vlog_message_katcl(%struct.katcl_line* %22, i32 %23, i8* %24, i8* %25, i32 %26)
store i32 %27, i32* %16
%28 = load i32, i32* %10
%29 = icmp slt i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %21
%31 = load i32, i32* %10
store i32 %31, i32* %8
br label %41
32: ; preds = %21
%33 = load i32, i32* %16
%34 = icmp slt i32 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %32
%36 = load i32, i32* %16
store i32 %36, i32* %8
br label %41
37: ; preds = %32
%38 = load i32, i32* %10
%39 = load i32, i32* %16
%40 = add nsw i32 %38, %39
store i32 %40, i32* %8
br label %41
41: ; preds = %37, %35, %30, %20
%42 = load i32, i32* %8
ret i32 %42
}

LLVM IR (-O2):
%struct.katcl_line = type { i32 }
define i32 @check_log_message_katcp(%struct.katcl_line* %0, i32 %1, i32 %2, i32 %3, i8* %4, i8* %5, i32 %6) {
%8 = icmp ult i32 %3, %2
br i1 %8, label %16, label %9
9: ; preds = %7
%10 = tail call i32 @vlog_message_katcl(%struct.katcl_line* %0, i32 %3, i8* %4, i8* %5, i32 %6)
%11 = icmp slt i32 %1, 0
br i1 %11, label %16, label %12
12: ; preds = %9
%13 = icmp slt i32 %10, 0
%14 = select i1 %13, i32 0, i32 %1
%15 = add nsw i32 %14, %10
br label %16
16: ; preds = %12, %9, %7
%17 = phi i32 [ 0, %7 ], [ %1, %9 ], [ %15, %12 ]
ret i32 %17
}