#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 */
struct udev_ctrl {
  int dummy;
};
struct udev {
  int dummy;
};
struct option {
  char *member_0;
  char member_3;
  int /*<<< orphan*/ *member_2;
  int /*<<< orphan*/ const member_1;
};

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int getopt_long(int, char **, char *, struct option const *,
                int /*<<< orphan*/ *);
scalar_t__ getuid();
#define no_argument 129
char *optarg;
size_t optind;
int /*<<< orphan*/ print_help();
#define required_argument 128
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *strchr(char *, char);
int strtoul(char *, char **, int /*<<< orphan*/);
struct udev_ctrl *udev_ctrl_new(struct udev *);
int /*<<< orphan*/ udev_ctrl_send_exit(struct udev_ctrl *, int);
int /*<<< orphan*/ udev_ctrl_send_reload_rules(struct udev_ctrl *, int);
int /*<<< orphan*/ udev_ctrl_send_set_children_max(struct udev_ctrl *, int,
                                                   int);
int /*<<< orphan*/ udev_ctrl_send_set_env(struct udev_ctrl *, char *, int);
int /*<<< orphan*/ udev_ctrl_send_set_log_level(struct udev_ctrl *, int, int);
int /*<<< orphan*/ udev_ctrl_send_start_exec_queue(struct udev_ctrl *, int);
int /*<<< orphan*/ udev_ctrl_send_stop_exec_queue(struct udev_ctrl *, int);
int /*<<< orphan*/ udev_ctrl_unref(struct udev_ctrl *);
int util_log_priority(char *);
int adm_control(struct udev *udev, int argc, char *argv[]) {
  struct udev_ctrl *uctrl = NULL;
  int timeout = 60;
  int rc = 1;
  static const struct option options[] = {
      {"exit", no_argument, NULL, 'e'},
      {"log-priority", required_argument, NULL, 'l'},
      {"stop-exec-queue", no_argument, NULL, 's'},
      {"start-exec-queue", no_argument, NULL, 'S'},
      {"reload-rules", no_argument, NULL, 'R'},
      {"property", required_argument, NULL, 'p'},
      {"env", required_argument, NULL, 'p'},
      {"children-max", required_argument, NULL, 'm'},
      {"timeout", required_argument, NULL, 't'},
      {"help", no_argument, NULL, 'h'},
      {}};
  if (getuid() != 0) {
    fprintf(stderr, "root privileges required\n");
    return 1;
  }
  uctrl = udev_ctrl_new(udev);
  if (uctrl == NULL)
    return 2;
  for (;;) {
    int option;
    option = getopt_long(argc, argv, "el:sSRp:m:h", options, NULL);
    if (option == -1)
      break;
    switch (option) {
    case 'e':
      if (udev_ctrl_send_exit(uctrl, timeout) < 0)
        rc = 2;
      else
        rc = 0;
      break;
    case 'l': {
      int i;
      i = util_log_priority(optarg);
      if (i < 0) {
        fprintf(stderr, "invalid number '%s'\n", optarg);
        goto out;
      }
      if (udev_ctrl_send_set_log_level(uctrl, util_log_priority(optarg),
                                       timeout) < 0)
        rc = 2;
      else
        rc = 0;
      break;
    }
    case 's':
      if (udev_ctrl_send_stop_exec_queue(uctrl, timeout) < 0)
        rc = 2;
      else
        rc = 0;
      break;
    case 'S':
      if (udev_ctrl_send_start_exec_queue(uctrl, timeout) < 0)
        rc = 2;
      else
        rc = 0;
      break;
    case 'R':
      if (udev_ctrl_send_reload_rules(uctrl, timeout) < 0)
        rc = 2;
      else
        rc = 0;
      break;
    case 'p':
      if (strchr(optarg, '=') == NULL) {
        fprintf(stderr, "expect <KEY>=<value> instead of '%s'\n", optarg);
        goto out;
      }
      if (udev_ctrl_send_set_env(uctrl, optarg, timeout) < 0)
        rc = 2;
      else
        rc = 0;
      break;
    case 'm': {
      char *endp;
      int i;
      i = strtoul(optarg, &endp, 0);
      if (endp[0] != '\0' || i < 1) {
        fprintf(stderr, "invalid number '%s'\n", optarg);
        goto out;
      }
      if (udev_ctrl_send_set_children_max(uctrl, i, timeout) < 0)
        rc = 2;
      else
        rc = 0;
      break;
    }
    case 't': {
      int seconds;
      seconds = atoi(optarg);
      if (seconds >= 0)
        timeout = seconds;
      else
        fprintf(stderr, "invalid timeout value\n");
      break;
    }
    case 'h':
      print_help();
      rc = 0;
      break;
    }
  }
  if (argv[optind] != NULL)
    fprintf(stderr, "unknown option\n");
  else if (optind == 1)
    fprintf(stderr, "missing option\n");
out:
  udev_ctrl_unref(uctrl);
  return rc;
}


x86 assembly (clang, -O0):
<adm_control>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movl   $0x3c,-0x2c(%rbp)
movl   $0x1,-0x30(%rbp)
mov    $0x0,%al
call   1050 <getuid@plt>
cmp    $0x0,%rax
je     126d <adm_control+0x5d>
mov    0x2d77(%rip),%rax
mov    (%rax),%edi
lea    0xe99(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    15fb <adm_control+0x3eb>
mov    -0x10(%rbp),%rdi
call   10b0 <udev_ctrl_new@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1291 <adm_control+0x81>
movl   $0x2,-0x4(%rbp)
jmp    15fb <adm_control+0x3eb>
jmp    1296 <adm_control+0x86>
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%rsi
lea    0xe69(%rip),%rdx
lea    0x29f5(%rip),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1060 <getopt_long@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0xffffffff,-0x34(%rbp)
jne    12c7 <adm_control+0xb7>
jmp    1585 <adm_control+0x375>
mov    -0x34(%rbp),%eax
add    $0xffffffae,%eax
mov    %eax,%ecx
mov    %rcx,-0x50(%rbp)
sub    $0x22,%eax
ja     1580 <adm_control+0x370>
mov    -0x50(%rbp),%rax
lea    0xd19(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x28(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   10e0 <udev_ctrl_send_exit@plt>
cmp    $0x0,%eax
jge    1311 <adm_control+0x101>
movl   $0x2,-0x30(%rbp)
jmp    1318 <adm_control+0x108>
movl   $0x0,-0x30(%rbp)
jmp    1580 <adm_control+0x370>
mov    0x2ccc(%rip),%rax
mov    (%rax),%rdi
call   1040 <util_log_priority@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x0,-0x38(%rbp)
jge    135f <adm_control+0x14f>
mov    0x2c88(%rip),%rax
mov    (%rax),%edi
mov    0x2ca7(%rip),%rax
mov    (%rax),%rdx
lea    0xdc6(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    15ec <adm_control+0x3dc>
mov    -0x28(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    0x2c82(%rip),%rax
mov    (%rax),%rdi
call   1040 <util_log_priority@plt>
mov    -0x58(%rbp),%rdi
mov    %eax,%esi
mov    -0x2c(%rbp),%edx
call   1030 <udev_ctrl_send_set_log_level@plt>
cmp    $0x0,%eax
jge    1399 <adm_control+0x189>
movl   $0x2,-0x30(%rbp)
jmp    13a0 <adm_control+0x190>
movl   $0x0,-0x30(%rbp)
jmp    1580 <adm_control+0x370>
mov    -0x28(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   10d0 <udev_ctrl_send_stop_exec_queue@plt>
cmp    $0x0,%eax
jge    13c6 <adm_control+0x1b6>
movl   $0x2,-0x30(%rbp)
jmp    13cd <adm_control+0x1bd>
movl   $0x0,-0x30(%rbp)
jmp    1580 <adm_control+0x370>
mov    -0x28(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   10f0 <udev_ctrl_send_start_exec_queue@plt>
cmp    $0x0,%eax
jge    13f3 <adm_control+0x1e3>
movl   $0x2,-0x30(%rbp)
jmp    13fa <adm_control+0x1ea>
movl   $0x0,-0x30(%rbp)
jmp    1580 <adm_control+0x370>
mov    -0x28(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   10c0 <udev_ctrl_send_reload_rules@plt>
cmp    $0x0,%eax
jge    1420 <adm_control+0x210>
movl   $0x2,-0x30(%rbp)
jmp    1427 <adm_control+0x217>
movl   $0x0,-0x30(%rbp)
jmp    1580 <adm_control+0x370>
mov    0x2bbd(%rip),%rax
mov    (%rax),%rdi
mov    $0x3d,%esi
call   1070 <strchr@plt>
cmp    $0x0,%rax
jne    1470 <adm_control+0x260>
mov    0x2b77(%rip),%rax
mov    (%rax),%edi
mov    0x2b96(%rip),%rax
mov    (%rax),%rdx
lea    0xcca(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    15ec <adm_control+0x3dc>
mov    -0x28(%rbp),%rdi
mov    0x2b75(%rip),%rax
mov    (%rax),%rsi
mov    -0x2c(%rbp),%edx
call   10a0 <udev_ctrl_send_set_env@plt>
cmp    $0x0,%eax
jge    149b <adm_control+0x28b>
movl   $0x2,-0x30(%rbp)
jmp    14a2 <adm_control+0x292>
movl   $0x0,-0x30(%rbp)
jmp    1580 <adm_control+0x370>
mov    0x2b42(%rip),%rax
mov    (%rax),%rdi
lea    -0x40(%rbp),%rsi
xor    %edx,%edx
call   1100 <strtoul@plt>
mov    %eax,-0x44(%rbp)
mov    -0x40(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    14d9 <adm_control+0x2c9>
cmpl   $0x1,-0x44(%rbp)
jge    14ff <adm_control+0x2ef>
mov    0x2ae8(%rip),%rax
mov    (%rax),%edi
mov    0x2b07(%rip),%rax
mov    (%rax),%rdx
lea    0xc26(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    15ec <adm_control+0x3dc>
mov    -0x28(%rbp),%rdi
mov    -0x44(%rbp),%esi
mov    -0x2c(%rbp),%edx
call   1080 <udev_ctrl_send_set_children_max@plt>
cmp    $0x0,%eax
jge    1523 <adm_control+0x313>
movl   $0x2,-0x30(%rbp)
jmp    152a <adm_control+0x31a>
movl   $0x0,-0x30(%rbp)
jmp    1580 <adm_control+0x370>
mov    0x2aba(%rip),%rax
mov    (%rax),%rdi
call   1110 <atoi@plt>
mov    %eax,-0x48(%rbp)
cmpl   $0x0,-0x48(%rbp)
jl     1556 <adm_control+0x346>
mov    -0x48(%rbp),%eax
mov    %eax,-0x2c(%rbp)
jmp    156d <adm_control+0x35d>
mov    0x2a6b(%rip),%rax
mov    (%rax),%edi
lea    0xbee(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    1580 <adm_control+0x370>
mov    $0x0,%al
call   1120 <print_help@plt>
movl   $0x0,-0x30(%rbp)
jmp    1296 <adm_control+0x86>
mov    -0x20(%rbp),%rax
mov    0x2a48(%rip),%rcx
mov    (%rcx),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     15ba <adm_control+0x3aa>
mov    0x2a23(%rip),%rax
mov    (%rax),%edi
lea    0xbbd(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    15e7 <adm_control+0x3d7>
mov    0x2a17(%rip),%rax
cmpq   $0x1,(%rax)
jne    15e2 <adm_control+0x3d2>
mov    0x29f6(%rip),%rax
mov    (%rax),%edi
lea    0xba0(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    15e7 <adm_control+0x3d7>
jmp    15ec <adm_control+0x3dc>
mov    -0x28(%rbp),%rdi
call   1130 <udev_ctrl_unref@plt>
mov    -0x30(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<adm_control>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r14
mov    %esi,%r15d
mov    %rdi,%rbp
xor    %eax,%eax
call   1050 <getuid@plt>
test   %rax,%rax
je     1254 <adm_control+0x44>
mov    0x2d8e(%rip),%rax
mov    (%rax),%edi
lea    0xeb0(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x1,%ebp
jmp    1482 <adm_control+0x272>
mov    %rbp,%rdi
call   10b0 <udev_ctrl_new@plt>
mov    %rax,(%rsp)
test   %rax,%rax
je     142e <adm_control+0x21e>
mov    $0x3c,%eax
mov    $0x1,%ebp
lea    0xe93(%rip),%rbx
lea    0xd7f(%rip),%r13
mov    %r14,0x8(%rsp)
jmp    129f <adm_control+0x8f>
mov    (%rsp),%rdi
mov    %r12d,%esi
call   10e0 <udev_ctrl_send_exit@plt>
mov    %eax,%ebp
shr    $0x1e,%ebp
and    $0xfffffffe,%ebp
mov    %r12d,%eax
mov    %eax,%r12d
mov    %r15d,%edi
mov    %r14,%rsi
mov    %rbx,%rdx
lea    0x29ee(%rip),%rcx
xor    %r8d,%r8d
call   1060 <getopt_long@plt>
mov    %eax,%ecx
lea    -0x52(%rcx),%eax
cmp    $0x22,%eax
ja     13ff <adm_control+0x1ef>
movslq 0x0(%r13,%rax,4),%rcx
add    %r13,%rcx
mov    %r12d,%eax
jmp    *%rcx
mov    (%rsp),%rdi
mov    %r12d,%esi
call   10c0 <udev_ctrl_send_reload_rules@plt>
jmp    1294 <adm_control+0x84>
mov    (%rsp),%rdi
mov    %r12d,%esi
call   10f0 <udev_ctrl_send_start_exec_queue@plt>
jmp    1294 <adm_control+0x84>
xor    %ebp,%ebp
xor    %eax,%eax
call   1120 <print_help@plt>
mov    %r12d,%eax
jmp    129f <adm_control+0x8f>
mov    (%rsp),%r14
mov    0x2ce6(%rip),%rbx
mov    (%rbx),%rdi
call   1040 <util_log_priority@plt>
test   %eax,%eax
js     1435 <adm_control+0x225>
mov    (%rbx),%rdi
call   1040 <util_log_priority@plt>
mov    %r14,%rdi
mov    %eax,%esi
mov    %r12d,%edx
call   1030 <udev_ctrl_send_set_log_level@plt>
jmp    139c <adm_control+0x18c>
mov    0x2cb8(%rip),%rax
mov    (%rax),%rdi
lea    0x10(%rsp),%rsi
xor    %edx,%edx
call   1100 <strtoul@plt>
mov    0x10(%rsp),%rcx
cmpb   $0x0,(%rcx)
jne    1443 <adm_control+0x233>
test   %eax,%eax
jle    1443 <adm_control+0x233>
mov    (%rsp),%rdi
mov    %eax,%esi
mov    %r12d,%edx
call   1080 <udev_ctrl_send_set_children_max@plt>
jmp    1294 <adm_control+0x84>
mov    0x2c79(%rip),%r14
mov    (%r14),%rdi
mov    $0x3d,%esi
call   1070 <strchr@plt>
test   %rax,%rax
je     145f <adm_control+0x24f>
mov    (%r14),%rsi
mov    (%rsp),%rdi
mov    %r12d,%edx
call   10a0 <udev_ctrl_send_set_env@plt>
mov    %eax,%ebp
shr    $0x1e,%ebp
and    $0xfffffffe,%ebp
mov    %r12d,%eax
mov    0x8(%rsp),%r14
lea    0xd5a(%rip),%rbx
jmp    129f <adm_control+0x8f>
mov    (%rsp),%rdi
mov    %r12d,%esi
call   10d0 <udev_ctrl_send_stop_exec_queue@plt>
jmp    1294 <adm_control+0x84>
mov    0x2c20(%rip),%rax
mov    (%rax),%rdi
call   1110 <atoi@plt>
test   %eax,%eax
jns    129f <adm_control+0x8f>
mov    0x2be1(%rip),%rax
mov    (%rax),%edi
lea    0xd64(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    %r12d,%eax
jmp    129f <adm_control+0x8f>
mov    %r12d,%eax
cmp    $0xffffffff,%ecx
jne    129f <adm_control+0x8f>
mov    0x2bc6(%rip),%rax
mov    (%rax),%rax
cmpq   $0x0,(%r14,%rax,8)
je     1493 <adm_control+0x283>
mov    0x2ba5(%rip),%rax
mov    (%rax),%edi
lea    0xd3f(%rip),%rsi
jmp    14a9 <adm_control+0x299>
mov    $0x2,%ebp
jmp    1482 <adm_control+0x272>
mov    0x2b8c(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
jmp    1456 <adm_control+0x246>
mov    0x2b7e(%rip),%rax
mov    (%rax),%edi
mov    0x2b9d(%rip),%rax
mov    (%rax),%rdx
lea    0xcbc(%rip),%rsi
jmp    1472 <adm_control+0x262>
mov    0x2b62(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xcbc(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    (%rsp),%rdi
call   1130 <udev_ctrl_unref@plt>
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
cmp    $0x1,%rax
jne    1479 <adm_control+0x269>
mov    0x2b28(%rip),%rax
mov    (%rax),%edi
lea    0xcd2(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
jmp    1479 <adm_control+0x269>

LLVM IR (-O0):
%struct.option = type { i8*, i8, i32*, i32 }
%struct.udev = type { i32 }
%struct.udev_ctrl = type { i32 }
@adm_control.options = internal constant [11 x %struct.option] [%struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8 -127, i32* null, i32 101 }, %struct.option { i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i32 0, i32 0), i8 -128, i32* null, i32 108 }, %struct.option { i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i32 0, i32 0), i8 -127, i32* null, i32 115 }, %struct.option { i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i32 0, i32 0), i8 -127, i32* null, i32 83 }, %struct.option { i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i32 0, i32 0), i8 -127, i32* null, i32 82 }, %struct.option { i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i32 0, i32 0), i8 -128, i32* null, i32 112 }, %struct.option { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i32 0, i32 0), i8 -128, i32* null, i32 112 }, %struct.option { i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i32 0, i32 0), i8 -128, i32* null, i32 109 }, %struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i32 0, i32 0), i8 -128, i32* null, i32 116 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i32 0, i32 0), i8 -127, i32* null, i32 104 }, %struct.option zeroinitializer]
@.str = [5 x i8] c"exit\00"
@.str.1 = [13 x i8] c"log-priority\00"
@.str.2 = [16 x i8] c"stop-exec-queue\00"
@.str.3 = [17 x i8] c"start-exec-queue\00"
@.str.4 = [13 x i8] c"reload-rules\00"
@.str.5 = [9 x i8] c"property\00"
@.str.6 = [4 x i8] c"env\00"
@.str.7 = [13 x i8] c"children-max\00"
@.str.8 = [8 x i8] c"timeout\00"
@.str.9 = [5 x i8] c"help\00"
@stderr = global i32 0
@.str.10 = [26 x i8] c"root privileges required\0A\00"
@.str.11 = [12 x i8] c"el:sSRp:m:h\00"
@optarg = global i8* null
@.str.12 = [21 x i8] c"invalid number '%s'\0A\00"
@.str.13 = [38 x i8] c"expect <KEY>=<value> instead of '%s'\0A\00"
@.str.14 = [23 x i8] c"invalid timeout value\0A\00"
@optind = global i64 0
@.str.15 = [16 x i8] c"unknown option\0A\00"
@.str.16 = [16 x i8] c"missing option\0A\00"
define i32 @adm_control(%struct.udev* %0, i32 %1, i8** %2) {
%4 = alloca i32
%5 = alloca %struct.udev*
%6 = alloca i32
%7 = alloca i8**
%8 = alloca %struct.udev_ctrl*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i32
%15 = alloca i32
store %struct.udev* %0, %struct.udev** %5
store i32 %1, i32* %6
store i8** %2, i8*** %7
store %struct.udev_ctrl* null, %struct.udev_ctrl** %8
store i32 60, i32* %9
store i32 1, i32* %10
%16 = call i64 (...) @getuid()
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %3
%19 = load i32, i32* @stderr
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0))
store i32 1, i32* %4
br label %164
21: ; preds = %3
%22 = load %struct.udev*, %struct.udev** %5
%23 = call %struct.udev_ctrl* @udev_ctrl_new(%struct.udev* %22)
store %struct.udev_ctrl* %23, %struct.udev_ctrl** %8
%24 = load %struct.udev_ctrl*, %struct.udev_ctrl** %8
%25 = icmp eq %struct.udev_ctrl* %24, null
br i1 %25, label %26, label %27
26: ; preds = %21
store i32 2, i32* %4
br label %164
27: ; preds = %21
br label %28
28: ; preds = %142, %27
%29 = load i32, i32* %6
%30 = load i8**, i8*** %7
%31 = call i32 @getopt_long(i32 %29, i8** %30, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0), %struct.option* getelementptr inbounds ([11 x %struct.option], [11 x %struct.option]* @adm_control.options, i64 0, i64 0), i32* null)
store i32 %31, i32* %11
%32 = load i32, i32* %11
%33 = icmp eq i32 %32, -1
br i1 %33, label %34, label %35
34: ; preds = %28
br label %143
35: ; preds = %28
%36 = load i32, i32* %11
switch i32 %36, label %142 [
i32 101, label %37
i32 108, label %45
i32 115, label %64
i32 83, label %72
i32 82, label %80
i32 112, label %88
i32 109, label %105
i32 116, label %129
i32 104, label %140
]
37: ; preds = %35
%38 = load %struct.udev_ctrl*, %struct.udev_ctrl** %8
%39 = load i32, i32* %9
%40 = call i32 @udev_ctrl_send_exit(%struct.udev_ctrl* %38, i32 %39)
%41 = icmp slt i32 %40, 0
br i1 %41, label %42, label %43
42: ; preds = %37
store i32 2, i32* %10
br label %44
43: ; preds = %37
store i32 0, i32* %10
br label %44
44: ; preds = %43, %42
br label %142
45: ; preds = %35
%46 = load i8*, i8** @optarg
%47 = call i32 @util_log_priority(i8* %46)
store i32 %47, i32* %12
%48 = load i32, i32* %12
%49 = icmp slt i32 %48, 0
br i1 %49, label %50, label %54
50: ; preds = %45
%51 = load i32, i32* @stderr
%52 = load i8*, i8** @optarg
%53 = call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.12, i64 0, i64 0), i8* %52)
br label %160
54: ; preds = %45
%55 = load %struct.udev_ctrl*, %struct.udev_ctrl** %8
%56 = load i8*, i8** @optarg
%57 = call i32 @util_log_priority(i8* %56)
%58 = load i32, i32* %9
%59 = call i32 @udev_ctrl_send_set_log_level(%struct.udev_ctrl* %55, i32 %57, i32 %58)
%60 = icmp slt i32 %59, 0
br i1 %60, label %61, label %62
61: ; preds = %54
store i32 2, i32* %10
br label %63
62: ; preds = %54
store i32 0, i32* %10
br label %63
63: ; preds = %62, %61
br label %142
64: ; preds = %35
%65 = load %struct.udev_ctrl*, %struct.udev_ctrl** %8
%66 = load i32, i32* %9
%67 = call i32 @udev_ctrl_send_stop_exec_queue(%struct.udev_ctrl* %65, i32 %66)
%68 = icmp slt i32 %67, 0
br i1 %68, label %69, label %70
69: ; preds = %64
store i32 2, i32* %10
br label %71
70: ; preds = %64
store i32 0, i32* %10
br label %71
71: ; preds = %70, %69
br label %142
72: ; preds = %35
%73 = load %struct.udev_ctrl*, %struct.udev_ctrl** %8
%74 = load i32, i32* %9
%75 = call i32 @udev_ctrl_send_start_exec_queue(%struct.udev_ctrl* %73, i32 %74)
%76 = icmp slt i32 %75, 0
br i1 %76, label %77, label %78
77: ; preds = %72
store i32 2, i32* %10
br label %79
78: ; preds = %72
store i32 0, i32* %10
br label %79
79: ; preds = %78, %77
br label %142
80: ; preds = %35
%81 = load %struct.udev_ctrl*, %struct.udev_ctrl** %8
%82 = load i32, i32* %9
%83 = call i32 @udev_ctrl_send_reload_rules(%struct.udev_ctrl* %81, i32 %82)
%84 = icmp slt i32 %83, 0
br i1 %84, label %85, label %86
85: ; preds = %80
store i32 2, i32* %10
br label %87
86: ; preds = %80
store i32 0, i32* %10
br label %87
87: ; preds = %86, %85
br label %142
88: ; preds = %35
%89 = load i8*, i8** @optarg
%90 = call i32* @strchr(i8* %89, i8 signext 61)
%91 = icmp eq i32* %90, null
br i1 %91, label %92, label %96
92: ; preds = %88
%93 = load i32, i32* @stderr
%94 = load i8*, i8** @optarg
%95 = call i32 (i32, i8*, ...) @fprintf(i32 %93, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.13, i64 0, i64 0), i8* %94)
br label %160
96: ; preds = %88
%97 = load %struct.udev_ctrl*, %struct.udev_ctrl** %8
%98 = load i8*, i8** @optarg
%99 = load i32, i32* %9
%100 = call i32 @udev_ctrl_send_set_env(%struct.udev_ctrl* %97, i8* %98, i32 %99)
%101 = icmp slt i32 %100, 0
br i1 %101, label %102, label %103
102: ; preds = %96
store i32 2, i32* %10
br label %104
103: ; preds = %96
store i32 0, i32* %10
br label %104
104: ; preds = %103, %102
br label %142
105: ; preds = %35
%106 = load i8*, i8** @optarg
%107 = call i32 @strtoul(i8* %106, i8** %13, i32 0)
store i32 %107, i32* %14
%108 = load i8*, i8** %13
%109 = getelementptr inbounds i8, i8* %108, i64 0
%110 = load i8, i8* %109
%111 = sext i8 %110 to i32
%112 = icmp ne i32 %111, 0
br i1 %112, label %116, label %113
113: ; preds = %105
%114 = load i32, i32* %14
%115 = icmp slt i32 %114, 1
br i1 %115, label %116, label %120
116: ; preds = %113, %105
%117 = load i32, i32* @stderr
%118 = load i8*, i8** @optarg
%119 = call i32 (i32, i8*, ...) @fprintf(i32 %117, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.12, i64 0, i64 0), i8* %118)
br label %160
120: ; preds = %113
%121 = load %struct.udev_ctrl*, %struct.udev_ctrl** %8
%122 = load i32, i32* %14
%123 = load i32, i32* %9
%124 = call i32 @udev_ctrl_send_set_children_max(%struct.udev_ctrl* %121, i32 %122, i32 %123)
%125 = icmp slt i32 %124, 0
br i1 %125, label %126, label %127
126: ; preds = %120
store i32 2, i32* %10
br label %128
127: ; preds = %120
store i32 0, i32* %10
br label %128
128: ; preds = %127, %126
br label %142
129: ; preds = %35
%130 = load i8*, i8** @optarg
%131 = call i32 @atoi(i8* %130)
store i32 %131, i32* %15
%132 = load i32, i32* %15
%133 = icmp sge i32 %132, 0
br i1 %133, label %134, label %136
134: ; preds = %129
%135 = load i32, i32* %15
store i32 %135, i32* %9
br label %139
136: ; preds = %129
%137 = load i32, i32* @stderr
%138 = call i32 (i32, i8*, ...) @fprintf(i32 %137, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.14, i64 0, i64 0))
br label %139
139: ; preds = %136, %134
br label %142
140: ; preds = %35
%141 = call i32 (...) @print_help()
store i32 0, i32* %10
br label %142
142: ; preds = %35, %140, %139, %128, %104, %87, %79, %71, %63, %44
br label %28
143: ; preds = %34
%144 = load i8**, i8*** %7
%145 = load i64, i64* @optind
%146 = getelementptr inbounds i8*, i8** %144, i64 %145
%147 = load i8*, i8** %146
%148 = icmp ne i8* %147, null
br i1 %148, label %149, label %152
149: ; preds = %143
%150 = load i32, i32* @stderr
%151 = call i32 (i32, i8*, ...) @fprintf(i32 %150, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.15, i64 0, i64 0))
br label %159
152: ; preds = %143
%153 = load i64, i64* @optind
%154 = icmp eq i64 %153, 1
br i1 %154, label %155, label %158
155: ; preds = %152
%156 = load i32, i32* @stderr
%157 = call i32 (i32, i8*, ...) @fprintf(i32 %156, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.16, i64 0, i64 0))
br label %158
158: ; preds = %155, %152
br label %159
159: ; preds = %158, %149
br label %160
160: ; preds = %159, %116, %92, %50
%161 = load %struct.udev_ctrl*, %struct.udev_ctrl** %8
%162 = call i32 @udev_ctrl_unref(%struct.udev_ctrl* %161)
%163 = load i32, i32* %10
store i32 %163, i32* %4
br label %164
164: ; preds = %160, %26, %18
%165 = load i32, i32* %4
ret i32 %165
}

LLVM IR (-O2):
%struct.option = type { i8*, i8, i32*, i32 }
%struct.udev = type { i32 }
%struct.udev_ctrl = type { i32 }
@adm_control.options = internal constant [11 x %struct.option] [%struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8 -127, i32* null, i32 101 }, %struct.option { i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i32 0, i32 0), i8 -128, i32* null, i32 108 }, %struct.option { i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i32 0, i32 0), i8 -127, i32* null, i32 115 }, %struct.option { i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i32 0, i32 0), i8 -127, i32* null, i32 83 }, %struct.option { i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i32 0, i32 0), i8 -127, i32* null, i32 82 }, %struct.option { i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i32 0, i32 0), i8 -128, i32* null, i32 112 }, %struct.option { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i32 0, i32 0), i8 -128, i32* null, i32 112 }, %struct.option { i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i32 0, i32 0), i8 -128, i32* null, i32 109 }, %struct.option { i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i32 0, i32 0), i8 -128, i32* null, i32 116 }, %struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i32 0, i32 0), i8 -127, i32* null, i32 104 }, %struct.option zeroinitializer]
@.str = [5 x i8] c"exit\00"
@.str.1 = [13 x i8] c"log-priority\00"
@.str.2 = [16 x i8] c"stop-exec-queue\00"
@.str.3 = [17 x i8] c"start-exec-queue\00"
@.str.4 = [13 x i8] c"reload-rules\00"
@.str.5 = [9 x i8] c"property\00"
@.str.6 = [4 x i8] c"env\00"
@.str.7 = [13 x i8] c"children-max\00"
@.str.8 = [8 x i8] c"timeout\00"
@.str.9 = [5 x i8] c"help\00"
@stderr = global i32 0
@.str.10 = [26 x i8] c"root privileges required\0A\00"
@.str.11 = [12 x i8] c"el:sSRp:m:h\00"
@optarg = global i8* null
@.str.12 = [21 x i8] c"invalid number '%s'\0A\00"
@.str.13 = [38 x i8] c"expect <KEY>=<value> instead of '%s'\0A\00"
@.str.14 = [23 x i8] c"invalid timeout value\0A\00"
@optind = global i64 0
@.str.15 = [16 x i8] c"unknown option\0A\00"
@.str.16 = [16 x i8] c"missing option\0A\00"
define i32 @adm_control(%struct.udev* %0, i32 %1, i8** %2) {
%4 = alloca i8*
%5 = tail call i64 (...) @getuid()
%6 = icmp eq i64 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %3
%8 = load i32, i32* @stderr
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0))
br label %105
10: ; preds = %3
%11 = tail call %struct.udev_ctrl* @udev_ctrl_new(%struct.udev* %0)
%12 = icmp eq %struct.udev_ctrl* %11, null
br i1 %12, label %105, label %13
13: ; preds = %10
%14 = bitcast i8** %4 to i8*
br label %15
15: ; preds = %87, %13
%16 = phi i32 [ 1, %13 ], [ %88, %87 ]
%17 = phi i32 [ 60, %13 ], [ %89, %87 ]
%18 = tail call i32 @getopt_long(i32 %1, i8** %2, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0), %struct.option* getelementptr inbounds ([11 x %struct.option], [11 x %struct.option]* @adm_control.options, i64 0, i64 0), i32* null)
switch i32 %18, label %87 [
i32 -1, label %90
i32 101, label %19
i32 108, label %23
i32 115, label %37
i32 83, label %41
i32 82, label %45
i32 112, label %49
i32 109, label %62
i32 116, label %78
i32 104, label %85
]
19: ; preds = %15
%20 = tail call i32 @udev_ctrl_send_exit(%struct.udev_ctrl* %11, i32 %17)
%21 = lshr i32 %20, 30
%22 = and i32 %21, 2
br label %87
23: ; preds = %15
%24 = load i8*, i8** @optarg
%25 = tail call i32 @util_log_priority(i8* %24)
%26 = icmp slt i32 %25, 0
br i1 %26, label %27, label %31
27: ; preds = %23
%28 = load i32, i32* @stderr
%29 = load i8*, i8** @optarg
%30 = tail call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.12, i64 0, i64 0), i8* %29)
br label %103
31: ; preds = %23
%32 = load i8*, i8** @optarg
%33 = tail call i32 @util_log_priority(i8* %32)
%34 = tail call i32 @udev_ctrl_send_set_log_level(%struct.udev_ctrl* %11, i32 %33, i32 %17)
%35 = lshr i32 %34, 30
%36 = and i32 %35, 2
br label %87
37: ; preds = %15
%38 = tail call i32 @udev_ctrl_send_stop_exec_queue(%struct.udev_ctrl* %11, i32 %17)
%39 = lshr i32 %38, 30
%40 = and i32 %39, 2
br label %87
41: ; preds = %15
%42 = tail call i32 @udev_ctrl_send_start_exec_queue(%struct.udev_ctrl* %11, i32 %17)
%43 = lshr i32 %42, 30
%44 = and i32 %43, 2
br label %87
45: ; preds = %15
%46 = tail call i32 @udev_ctrl_send_reload_rules(%struct.udev_ctrl* %11, i32 %17)
%47 = lshr i32 %46, 30
%48 = and i32 %47, 2
br label %87
49: ; preds = %15
%50 = load i8*, i8** @optarg
%51 = tail call i32* @strchr(i8* %50, i8 signext 61)
%52 = icmp eq i32* %51, null
br i1 %52, label %53, label %57
53: ; preds = %49
%54 = load i32, i32* @stderr
%55 = load i8*, i8** @optarg
%56 = tail call i32 (i32, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.13, i64 0, i64 0), i8* %55)
br label %103
57: ; preds = %49
%58 = load i8*, i8** @optarg
%59 = tail call i32 @udev_ctrl_send_set_env(%struct.udev_ctrl* %11, i8* %58, i32 %17)
%60 = lshr i32 %59, 30
%61 = and i32 %60, 2
br label %87
62: ; preds = %15
%63 = load i8*, i8** @optarg
%64 = call i32 @strtoul(i8* %63, i8** %4, i32 0)
%65 = load i8*, i8** %4
%66 = load i8, i8* %65
%67 = icmp ne i8 %66, 0
%68 = icmp slt i32 %64, 1
%69 = select i1 %67, i1 true, i1 %68
br i1 %69, label %70, label %74
70: ; preds = %62
%71 = load i32, i32* @stderr
%72 = load i8*, i8** @optarg
%73 = tail call i32 (i32, i8*, ...) @fprintf(i32 %71, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.12, i64 0, i64 0), i8* %72)
br label %103
74: ; preds = %62
%75 = tail call i32 @udev_ctrl_send_set_children_max(%struct.udev_ctrl* %11, i32 %64, i32 %17)
%76 = lshr i32 %75, 30
%77 = and i32 %76, 2
br label %87
78: ; preds = %15
%79 = load i8*, i8** @optarg
%80 = tail call i32 @atoi(i8* %79)
%81 = icmp sgt i32 %80, -1
br i1 %81, label %87, label %82
82: ; preds = %78
%83 = load i32, i32* @stderr
%84 = tail call i32 (i32, i8*, ...) @fprintf(i32 %83, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.14, i64 0, i64 0))
br label %87
85: ; preds = %15
%86 = tail call i32 (...) @print_help()
br label %87
87: ; preds = %85, %15, %19, %37, %41, %45, %57, %78, %82, %31, %74
%88 = phi i32 [ 0, %85 ], [ %77, %74 ], [ %36, %31 ], [ %16, %15 ], [ %22, %19 ], [ %40, %37 ], [ %44, %41 ], [ %48, %45 ], [ %61, %57 ], [ %16, %78 ], [ %16, %82 ]
%89 = phi i32 [ %17, %85 ], [ %17, %74 ], [ %17, %31 ], [ %17, %15 ], [ %17, %19 ], [ %17, %37 ], [ %17, %41 ], [ %17, %45 ], [ %17, %57 ], [ %80, %78 ], [ %17, %82 ]
br label %15
90: ; preds = %15
%91 = load i64, i64* @optind
%92 = getelementptr inbounds i8*, i8** %2, i64 %91
%93 = load i8*, i8** %92
%94 = icmp eq i8* %93, null
br i1 %94, label %98, label %95
95: ; preds = %90
%96 = load i32, i32* @stderr
%97 = tail call i32 (i32, i8*, ...) @fprintf(i32 %96, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.15, i64 0, i64 0))
br label %103
98: ; preds = %90
%99 = icmp eq i64 %91, 1
br i1 %99, label %100, label %103
100: ; preds = %98
%101 = load i32, i32* @stderr
%102 = tail call i32 (i32, i8*, ...) @fprintf(i32 %101, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.16, i64 0, i64 0))
br label %103
103: ; preds = %70, %27, %53, %95, %100, %98
%104 = tail call i32 @udev_ctrl_unref(%struct.udev_ctrl* %11)
br label %105
105: ; preds = %10, %103, %7
%106 = phi i32 [ 1, %7 ], [ %16, %103 ], [ 2, %10 ]
ret i32 %106
}