#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*/ TIPC_CMD_GET_MAX_PORTS;
int /*<<< orphan*/ TIPC_CMD_SET_MAX_PORTS;
int do_get_unsigned(int /*<<< orphan*/);
int /*<<< orphan*/ do_set_unsigned(char *, int /*<<< orphan*/, char *, char *);
char *for_dest();
int /*<<< orphan*/ printf(char *, char *, int);
void set_max_ports(char *args) {
  if (!*args)
    printf("maximum allowed ports%s: %u\n", for_dest(),
           do_get_unsigned(TIPC_CMD_GET_MAX_PORTS));
  else
    do_set_unsigned(args, TIPC_CMD_SET_MAX_PORTS, "max ports",
                    " (this will restart TIPC)");
}


x86 assembly (clang, -O0):
<set_max_ports>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1189 <set_max_ports+0x49>
mov    $0x0,%al
call   1040 <for_dest@plt>
mov    %rax,-0x10(%rbp)
mov    0x2e6d(%rip),%rax
mov    (%rax),%edi
call   1060 <do_get_unsigned@plt>
mov    -0x10(%rbp),%rsi
mov    %eax,%edx
lea    0xe81(%rip),%rdi
call   1030 <printf@plt>
jmp    11a9 <set_max_ports+0x69>
mov    -0x8(%rbp),%rdi
mov    0x2e54(%rip),%rax
mov    (%rax),%esi
lea    0xe80(%rip),%rdx
lea    0xe83(%rip),%rcx
call   1050 <do_set_unsigned@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_max_ports>:
push   %rbx
cmpb   $0x0,(%rdi)
je     1163 <set_max_ports+0x23>
mov    0x2e9b(%rip),%rax
mov    (%rax),%esi
lea    0xec7(%rip),%rdx
lea    0xeca(%rip),%rcx
pop    %rbx
jmp    1050 <do_set_unsigned@plt>
xor    %eax,%eax
call   1040 <for_dest@plt>
mov    %rax,%rbx
mov    0x2e64(%rip),%rax
mov    (%rax),%edi
call   1060 <do_get_unsigned@plt>
lea    0xe7e(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
pop    %rbx
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [29 x i8] c"maximum allowed ports%s: %u\0A\00"
@TIPC_CMD_GET_MAX_PORTS = global i32 0
@TIPC_CMD_SET_MAX_PORTS = global i32 0
@.str.1 = [10 x i8] c"max ports\00"
@.str.2 = [26 x i8] c" (this will restart TIPC)\00"
define void @set_max_ports(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = load i8, i8* %3
%5 = icmp ne i8 %4, 0
br i1 %5, label %11, label %6
6: ; preds = %1
%7 = call i8* (...) @for_dest()
%8 = load i32, i32* @TIPC_CMD_GET_MAX_PORTS
%9 = call i32 @do_get_unsigned(i32 %8)
%10 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %7, i32 %9)
br label %15
11: ; preds = %1
%12 = load i8*, i8** %2
%13 = load i32, i32* @TIPC_CMD_SET_MAX_PORTS
%14 = call i32 @do_set_unsigned(i8* %12, i32 %13, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %15
15: ; preds = %11, %6
ret void
}

LLVM IR (-O2):
@.str = [29 x i8] c"maximum allowed ports%s: %u\0A\00"
@TIPC_CMD_GET_MAX_PORTS = global i32 0
@TIPC_CMD_SET_MAX_PORTS = global i32 0
@.str.1 = [10 x i8] c"max ports\00"
@.str.2 = [26 x i8] c" (this will restart TIPC)\00"
define void @set_max_ports(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %4, label %9
4: ; preds = %1
%5 = tail call i8* (...) @for_dest()
%6 = load i32, i32* @TIPC_CMD_GET_MAX_PORTS
%7 = tail call i32 @do_get_unsigned(i32 %6)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %5, i32 %7)
br label %12
9: ; preds = %1
%10 = load i32, i32* @TIPC_CMD_SET_MAX_PORTS
%11 = tail call i32 @do_set_unsigned(i8* %0, i32 %10, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %12
12: ; preds = %9, %4
ret void
}