#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 klogctl(int, int /*<<< orphan*/ *, int);
int sockerror(int, char *);
int sockprint(int, char *, int);
int set_dmesg_loglevel(int fd, int level) {
  if (klogctl(8, NULL, level) == -1)
    return sockerror(fd, "klogctl(8)");
  return sockprint(fd, "dmesg loglevel set to %d\r\n", level);
}


x86 assembly (clang, -O0):
<set_dmesg_loglevel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%edx
mov    $0x8,%edi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <klogctl@plt>
cmp    $0xffffffff,%eax
jne    116f <set_dmesg_loglevel+0x3f>
mov    -0x8(%rbp),%edi
lea    0xe9e(%rip),%rsi
call   1050 <sockerror@plt>
mov    %eax,-0x4(%rbp)
jmp    1184 <set_dmesg_loglevel+0x54>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%edx
lea    0xe8f(%rip),%rsi
call   1040 <sockprint@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_dmesg_loglevel>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
mov    $0x8,%edi
xor    %esi,%esi
mov    %ebx,%edx
call   1030 <klogctl@plt>
cmp    $0xffffffff,%eax
je     1160 <set_dmesg_loglevel+0x30>
lea    0xeba(%rip),%rsi
mov    %ebp,%edi
mov    %ebx,%edx
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <sockprint@plt>
lea    0xe99(%rip),%rsi
mov    %ebp,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <sockerror@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"klogctl(8)\00"
@.str.1 = [27 x i8] c"dmesg loglevel set to %d\0D\0A\00"
define i32 @set_dmesg_loglevel(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%6 = load i32, i32* %5
%7 = call i32 @klogctl(i32 8, i32* null, i32 %6)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i32, i32* %4
%11 = call i32 @sockerror(i32 %10, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
store i32 %11, i32* %3
br label %16
12: ; preds = %2
%13 = load i32, i32* %4
%14 = load i32, i32* %5
%15 = call i32 @sockprint(i32 %13, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %14)
store i32 %15, i32* %3
br label %16
16: ; preds = %12, %9
%17 = load i32, i32* %3
ret i32 %17
}

LLVM IR (-O2):
@.str = [11 x i8] c"klogctl(8)\00"
@.str.1 = [27 x i8] c"dmesg loglevel set to %d\0D\0A\00"
define i32 @set_dmesg_loglevel(i32 %0, i32 %1) {
%3 = tail call i32 @klogctl(i32 8, i32* null, i32 %1)
%4 = icmp eq i32 %3, -1
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @sockerror(i32 %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %9
7: ; preds = %2
%8 = tail call i32 @sockprint(i32 %0, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %1)
br label %9
9: ; preds = %7, %5
%10 = phi i32 [ %6, %5 ], [ %8, %7 ]
ret i32 %10
}