#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*/ assert(int);
int mx_log_level_get();
int mx_log_level_set(int);
int test_mx_log();
int test_mx_log_shortname();
int test_mx_log_level(int level) {
  int x;
  int curr;
  curr = mx_log_level_get();
  assert(mx_log_level_set(level) == curr);
  assert(mx_log_level_get() == level);
  assert(test_mx_log_shortname() == level + (level > 0));
  assert((x = test_mx_log()) == level);
  return x;
}


x86 assembly (clang, -O0):
<test_mx_log_level>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x0,%al
call   1040 <mx_log_level_get@plt>
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <mx_log_level_set@plt>
cmp    -0xc(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    $0x0,%al
call   1040 <mx_log_level_get@plt>
cmp    -0x4(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    $0x0,%al
call   1070 <test_mx_log_shortname@plt>
mov    -0x4(%rbp),%ecx
cmpl   $0x0,-0x4(%rbp)
setg   %dl
and    $0x1,%dl
movzbl %dl,%edx
add    %edx,%ecx
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    $0x0,%al
call   1050 <test_mx_log@plt>
mov    %eax,-0x8(%rbp)
cmp    -0x4(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_mx_log_level>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
xor    %eax,%eax
call   1040 <mx_log_level_get@plt>
mov    %eax,%ebp
mov    %ebx,%edi
call   1030 <mx_log_level_set@plt>
xor    %edi,%edi
cmp    %ebp,%eax
sete   %dil
call   1060 <assert@plt>
xor    %eax,%eax
call   1040 <mx_log_level_get@plt>
xor    %edi,%edi
cmp    %ebx,%eax
sete   %dil
call   1060 <assert@plt>
xor    %eax,%eax
call   1070 <test_mx_log_shortname@plt>
xor    %ecx,%ecx
test   %ebx,%ebx
setg   %cl
add    %ebx,%ecx
xor    %edi,%edi
cmp    %ecx,%eax
sete   %dil
call   1060 <assert@plt>
xor    %eax,%eax
call   1050 <test_mx_log@plt>
mov    %eax,%ebp
xor    %edi,%edi
cmp    %ebx,%eax
sete   %dil
call   1060 <assert@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @test_mx_log_level(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
%5 = call i32 (...) @mx_log_level_get()
store i32 %5, i32* %4
%6 = load i32, i32* %2
%7 = call i32 @mx_log_level_set(i32 %6)
%8 = load i32, i32* %4
%9 = icmp eq i32 %7, %8
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = call i32 (...) @mx_log_level_get()
%13 = load i32, i32* %2
%14 = icmp eq i32 %12, %13
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
%17 = call i32 (...) @test_mx_log_shortname()
%18 = load i32, i32* %2
%19 = load i32, i32* %2
%20 = icmp sgt i32 %19, 0
%21 = zext i1 %20 to i32
%22 = add nsw i32 %18, %21
%23 = icmp eq i32 %17, %22
%24 = zext i1 %23 to i32
%25 = call i32 @assert(i32 %24)
%26 = call i32 (...) @test_mx_log()
store i32 %26, i32* %3
%27 = load i32, i32* %2
%28 = icmp eq i32 %26, %27
%29 = zext i1 %28 to i32
%30 = call i32 @assert(i32 %29)
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
define i32 @test_mx_log_level(i32 %0) {
%2 = tail call i32 (...) @mx_log_level_get()
%3 = tail call i32 @mx_log_level_set(i32 %0)
%4 = icmp eq i32 %3, %2
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
%7 = tail call i32 (...) @mx_log_level_get()
%8 = icmp eq i32 %7, %0
%9 = zext i1 %8 to i32
%10 = tail call i32 @assert(i32 %9)
%11 = tail call i32 (...) @test_mx_log_shortname()
%12 = icmp sgt i32 %0, 0
%13 = zext i1 %12 to i32
%14 = add nsw i32 %13, %0
%15 = icmp eq i32 %11, %14
%16 = zext i1 %15 to i32
%17 = tail call i32 @assert(i32 %16)
%18 = tail call i32 (...) @test_mx_log()
%19 = icmp eq i32 %18, %0
%20 = zext i1 %19 to i32
%21 = tail call i32 @assert(i32 %20)
ret i32 %18
}