#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*/ uid_t;
struct udev_list_entry {
  int dummy;
};
struct udev_device {
  int dummy;
};
struct udev {
  int dummy;
};
typedef int /*<<< orphan*/ partitionname;
typedef int /*<<< orphan*/ mode_t;
typedef int /*<<< orphan*/ gid_t;
typedef int /*<<< orphan*/ dev_t;

/* Variables and functions */
int /*<<< orphan*/ major(int /*<<< orphan*/);
int /*<<< orphan*/ makedev(int /*<<< orphan*/, scalar_t__);
scalar_t__ minor(int /*<<< orphan*/);
int /*<<< orphan*/ name_index(struct udev *, int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, int);
struct udev_list_entry *
udev_device_get_devlinks_list_entry(struct udev_device *);
char *udev_device_get_devnode(struct udev_device *);
int /*<<< orphan*/ udev_device_get_devnum(struct udev_device *);
int /*<<< orphan*/ udev_device_get_devpath(struct udev_device *);
int udev_device_get_num_fake_partitions(struct udev_device *);
struct udev *udev_device_get_udev(struct udev_device *);
char *udev_list_entry_get_name(struct udev_list_entry *);
struct udev_list_entry *udev_list_entry_get_next(struct udev_list_entry *);
int /*<<< orphan*/ udev_log_null(struct udev *, char *, char *, int, ...);
scalar_t__ udev_node_mknod(struct udev_device *, char *, int /*<<< orphan*/,
                           int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/);
int /*<<< orphan*/ update_link(struct udev_device *, char *);
int /*<<< orphan*/ util_create_path(struct udev *, char *);
int udev_node_add(struct udev_device *dev, mode_t mode, uid_t uid, gid_t gid) {
  struct udev *udev = udev_device_get_udev(dev);
  int i;
  int num;
  struct udev_list_entry *list_entry;
  int err = 0;
  udev_log_null(
      udev,
      "creating device node '%s', devnum=%d:%d, mode=%#o, uid=%d, gid=%d\n",
      udev_device_get_devnode(dev), major(udev_device_get_devnum(dev)),
      minor(udev_device_get_devnum(dev)), mode, uid, gid);
  util_create_path(udev, udev_device_get_devnode(dev));
  if (udev_node_mknod(dev, NULL, makedev(0, 0), mode, uid, gid) != 0) {
    err = -1;
    goto exit;
  }
  num = udev_device_get_num_fake_partitions(dev);
  if (num > 0) {
    udev_log_null(udev, "creating device partition nodes '%s[1-%i]'\n",
                  udev_device_get_devnode(dev), num);
    for (i = 1; i <= num; i++) {
      char partitionname[1024];
      dev_t part_devnum;
      snprintf(partitionname, sizeof(partitionname), "%s%d",
               udev_device_get_devnode(dev), i);
      partitionname[sizeof(partitionname) - 1] = '\0';
      part_devnum = makedev(major(udev_device_get_devnum(dev)),
                            minor(udev_device_get_devnum(dev)) + i);
      udev_node_mknod(dev, partitionname, part_devnum, mode, uid, gid);
    }
  }
  name_index(udev, udev_device_get_devpath(dev), udev_device_get_devnode(dev),
             1);
  for (list_entry = udev_device_get_devlinks_list_entry(dev);
       list_entry != NULL; list_entry = udev_list_entry_get_next(list_entry)) {
    name_index(udev, udev_device_get_devpath(dev),
               udev_list_entry_get_name(list_entry), 1);
    update_link(dev, udev_list_entry_get_name(list_entry));
  }
exit:
  return err;
}


x86 assembly (clang, -O0):
<udev_node_add>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4c0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <udev_device_get_udev@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x470(%rbp)
mov    -0x8(%rbp),%rdi
call   1110 <udev_device_get_devnode@plt>
mov    %rax,-0x468(%rbp)
mov    -0x8(%rbp),%rdi
call   10d0 <udev_device_get_devnum@plt>
mov    %eax,%edi
call   1080 <major@plt>
mov    %eax,-0x45c(%rbp)
mov    -0x8(%rbp),%rdi
call   10d0 <udev_device_get_devnum@plt>
mov    %eax,%edi
call   1050 <minor@plt>
mov    -0x470(%rbp),%rdi
mov    -0x468(%rbp),%rdx
mov    -0x45c(%rbp),%ecx
mov    %rax,%r8
mov    -0xc(%rbp),%r9d
mov    -0x10(%rbp),%r10d
mov    -0x14(%rbp),%eax
lea    0xd5a(%rip),%rsi
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
mov    $0x0,%al
call   1040 <udev_log_null@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x458(%rbp)
mov    -0x8(%rbp),%rdi
call   1110 <udev_device_get_devnode@plt>
mov    -0x458(%rbp),%rdi
mov    %rax,%rsi
call   10a0 <util_create_path@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x450(%rbp)
xor    %edi,%edi
xor    %eax,%eax
mov    %eax,%esi
call   10f0 <makedev@plt>
mov    -0x450(%rbp),%rdi
mov    %eax,%edx
mov    -0xc(%rbp),%ecx
mov    -0x10(%rbp),%r8d
mov    -0x14(%rbp),%r9d
xor    %eax,%eax
mov    %eax,%esi
call   10b0 <udev_node_mknod@plt>
cmp    $0x0,%rax
je     1321 <udev_node_add+0x111>
movl   $0xffffffff,-0x34(%rbp)
jmp    14f4 <udev_node_add+0x2e4>
mov    -0x8(%rbp),%rdi
call   10e0 <udev_device_get_num_fake_partitions@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jle    1428 <udev_node_add+0x218>
mov    -0x20(%rbp),%rax
mov    %rax,-0x478(%rbp)
mov    -0x8(%rbp),%rdi
call   1110 <udev_device_get_devnode@plt>
mov    -0x478(%rbp),%rdi
mov    %rax,%rdx
mov    -0x28(%rbp),%ecx
lea    0xce4(%rip),%rsi
mov    $0x0,%al
call   1040 <udev_log_null@plt>
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
jg     1423 <udev_node_add+0x213>
lea    -0x440(%rbp),%rax
mov    %rax,-0x488(%rbp)
mov    -0x8(%rbp),%rdi
call   1110 <udev_device_get_devnode@plt>
mov    -0x488(%rbp),%rdi
mov    %rax,%rcx
mov    -0x24(%rbp),%r8d
mov    $0x400,%esi
lea    0xcc5(%rip),%rdx
call   1060 <snprintf@plt>
movb   $0x0,-0x41(%rbp)
mov    -0x8(%rbp),%rdi
call   10d0 <udev_device_get_devnum@plt>
mov    %eax,%edi
call   1080 <major@plt>
mov    %eax,-0x47c(%rbp)
mov    -0x8(%rbp),%rdi
call   10d0 <udev_device_get_devnum@plt>
mov    %eax,%edi
call   1050 <minor@plt>
mov    -0x47c(%rbp),%edi
mov    %rax,%rsi
movslq -0x24(%rbp),%rax
add    %rax,%rsi
call   10f0 <makedev@plt>
mov    %eax,-0x444(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x440(%rbp),%rsi
mov    -0x444(%rbp),%edx
mov    -0xc(%rbp),%ecx
mov    -0x10(%rbp),%r8d
mov    -0x14(%rbp),%r9d
call   10b0 <udev_node_mknod@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    136d <udev_node_add+0x15d>
jmp    1428 <udev_node_add+0x218>
mov    -0x20(%rbp),%rax
mov    %rax,-0x498(%rbp)
mov    -0x8(%rbp),%rdi
call   1120 <udev_device_get_devpath@plt>
mov    %eax,-0x48c(%rbp)
mov    -0x8(%rbp),%rdi
call   1110 <udev_device_get_devnode@plt>
mov    -0x498(%rbp),%rdi
mov    -0x48c(%rbp),%esi
mov    %rax,%rdx
mov    $0x1,%ecx
call   1130 <name_index@plt>
mov    -0x8(%rbp),%rdi
call   1090 <udev_device_get_devlinks_list_entry@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     14ef <udev_node_add+0x2df>
mov    -0x20(%rbp),%rax
mov    %rax,-0x4b0(%rbp)
mov    -0x8(%rbp),%rdi
call   1120 <udev_device_get_devpath@plt>
mov    %eax,-0x4a4(%rbp)
mov    -0x30(%rbp),%rdi
call   1100 <udev_list_entry_get_name@plt>
mov    -0x4b0(%rbp),%rdi
mov    -0x4a4(%rbp),%esi
mov    %rax,%rdx
mov    $0x1,%ecx
call   1130 <name_index@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x4a0(%rbp)
mov    -0x30(%rbp),%rdi
call   1100 <udev_list_entry_get_name@plt>
mov    -0x4a0(%rbp),%rdi
mov    %rax,%rsi
call   1070 <update_link@plt>
mov    -0x30(%rbp),%rdi
call   10c0 <udev_list_entry_get_next@plt>
mov    %rax,-0x30(%rbp)
jmp    1472 <udev_node_add+0x262>
jmp    14f4 <udev_node_add+0x2e4>
mov    -0x34(%rbp),%eax
add    $0x4c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<udev_node_add>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x428,%rsp
mov    %ecx,%ebx
mov    %edx,%ebp
mov    %esi,0xc(%rsp)
mov    %rdi,%r13
call   1030 <udev_device_get_udev@plt>
mov    %rax,%r15
mov    %r13,%rdi
call   1110 <udev_device_get_devnode@plt>
mov    %rax,%r14
mov    %r13,%rdi
call   10d0 <udev_device_get_devnum@plt>
mov    %eax,%edi
call   1080 <major@plt>
mov    %eax,%r12d
mov    %r13,%rdi
call   10d0 <udev_device_get_devnum@plt>
mov    %eax,%edi
call   1050 <minor@plt>
lea    0xd99(%rip),%rsi
mov    %r15,%rdi
mov    %r14,%rdx
mov    %r12d,%ecx
mov    0xc(%rsp),%r12d
mov    %rax,%r8
mov    %r12d,%r9d
xor    %eax,%eax
push   %rbx
push   %rbp
call   1040 <udev_log_null@plt>
add    $0x10,%rsp
mov    %r13,%rdi
call   1110 <udev_device_get_devnode@plt>
mov    %r15,%rdi
mov    %rax,%rsi
call   10a0 <util_create_path@plt>
xor    %edi,%edi
xor    %esi,%esi
call   10f0 <makedev@plt>
mov    %r13,%rdi
xor    %esi,%esi
mov    %eax,%edx
mov    %r12d,%ecx
mov    %ebp,%r8d
mov    %ebx,%r9d
call   10b0 <udev_node_mknod@plt>
mov    $0xffffffff,%r14d
test   %rax,%rax
jne    1427 <udev_node_add+0x217>
mov    %r15,0x10(%rsp)
mov    %r13,%rdi
call   10e0 <udev_device_get_num_fake_partitions@plt>
test   %eax,%eax
jle    1396 <udev_node_add+0x186>
mov    %rax,%r14
mov    %r13,%rdi
call   1110 <udev_device_get_devnode@plt>
lea    0xd54(%rip),%rsi
mov    0x10(%rsp),%rdi
mov    %rax,%rdx
mov    %r14d,%ecx
xor    %eax,%eax
call   1040 <udev_log_null@plt>
add    $0x1,%r14d
mov    %r14,0x18(%rsp)
mov    $0x1,%r14d
mov    %r13,%rdi
call   1110 <udev_device_get_devnode@plt>
lea    0x20(%rsp),%rdi
mov    $0x400,%esi
lea    0xd46(%rip),%rdx
mov    %rax,%rcx
mov    %r14d,%r8d
call   1060 <snprintf@plt>
movb   $0x0,0x41f(%rsp)
mov    %r13,%rdi
call   10d0 <udev_device_get_devnum@plt>
mov    %eax,%edi
call   1080 <major@plt>
mov    %r12d,%r15d
mov    %eax,%r12d
mov    %r13,%rdi
call   10d0 <udev_device_get_devnum@plt>
mov    %eax,%edi
call   1050 <minor@plt>
lea    (%rax,%r14,1),%rsi
mov    %r12d,%edi
mov    %r15d,%r12d
call   10f0 <makedev@plt>
mov    %r13,%rdi
lea    0x20(%rsp),%rsi
mov    %eax,%edx
mov    %r15d,%ecx
mov    %ebp,%r8d
mov    %ebx,%r9d
call   10b0 <udev_node_mknod@plt>
add    $0x1,%r14
cmp    %r14,0x18(%rsp)
jne    1310 <udev_node_add+0x100>
mov    %r13,%rdi
call   1120 <udev_device_get_devpath@plt>
mov    %eax,%ebp
mov    %r13,%rdi
call   1110 <udev_device_get_devnode@plt>
mov    0x10(%rsp),%r15
mov    %r15,%rdi
mov    %ebp,%esi
mov    %rax,%rdx
mov    $0x1,%ecx
call   1130 <name_index@plt>
mov    %r13,%rdi
call   1090 <udev_device_get_devlinks_list_entry@plt>
xor    %r14d,%r14d
test   %rax,%rax
je     1427 <udev_node_add+0x217>
mov    %rax,%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r13,%rdi
call   1120 <udev_device_get_devpath@plt>
mov    %eax,%ebx
mov    %rbp,%rdi
call   1100 <udev_list_entry_get_name@plt>
mov    %r15,%rdi
mov    %ebx,%esi
mov    %rax,%rdx
mov    $0x1,%ecx
call   1130 <name_index@plt>
mov    %rbp,%rdi
call   1100 <udev_list_entry_get_name@plt>
mov    %r13,%rdi
mov    %rax,%rsi
call   1070 <update_link@plt>
mov    %rbp,%rdi
call   10c0 <udev_list_entry_get_next@plt>
mov    %rax,%rbp
test   %rax,%rax
jne    13e0 <udev_node_add+0x1d0>
mov    %r14d,%eax
add    $0x428,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.udev_device = type { i32 }
%struct.udev = type { i32 }
%struct.udev_list_entry = type { i32 }
@.str = [67 x i8] c"creating device node '%s', devnum=%d:%d, mode=%#o, uid=%d, gid=%d\0A\00"
@.str.1 = [44 x i8] c"creating device partition nodes '%s[1-%i]'\0A\00"
@.str.2 = [5 x i8] c"%s%d\00"
define i32 @udev_node_add(%struct.udev_device* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca %struct.udev_device*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca %struct.udev*
%10 = alloca i32
%11 = alloca i32
%12 = alloca %struct.udev_list_entry*
%13 = alloca i32
%14 = alloca [1024 x i8]
%15 = alloca i32
store %struct.udev_device* %0, %struct.udev_device** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%16 = load %struct.udev_device*, %struct.udev_device** %5
%17 = call %struct.udev* @udev_device_get_udev(%struct.udev_device* %16)
store %struct.udev* %17, %struct.udev** %9
store i32 0, i32* %13
%18 = load %struct.udev*, %struct.udev** %9
%19 = load %struct.udev_device*, %struct.udev_device** %5
%20 = call i8* @udev_device_get_devnode(%struct.udev_device* %19)
%21 = load %struct.udev_device*, %struct.udev_device** %5
%22 = call i32 @udev_device_get_devnum(%struct.udev_device* %21)
%23 = call i32 @major(i32 %22)
%24 = load %struct.udev_device*, %struct.udev_device** %5
%25 = call i32 @udev_device_get_devnum(%struct.udev_device* %24)
%26 = call i64 @minor(i32 %25)
%27 = load i32, i32* %6
%28 = load i32, i32* %7
%29 = load i32, i32* %8
%30 = call i32 (%struct.udev*, i8*, i8*, i32, ...) @udev_log_null(%struct.udev* %18, i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str, i64 0, i64 0), i8* %20, i32 %23, i64 %26, i32 %27, i32 %28, i32 %29)
%31 = load %struct.udev*, %struct.udev** %9
%32 = load %struct.udev_device*, %struct.udev_device** %5
%33 = call i8* @udev_device_get_devnode(%struct.udev_device* %32)
%34 = call i32 @util_create_path(%struct.udev* %31, i8* %33)
%35 = load %struct.udev_device*, %struct.udev_device** %5
%36 = call i32 @makedev(i32 0, i64 0)
%37 = load i32, i32* %6
%38 = load i32, i32* %7
%39 = load i32, i32* %8
%40 = call i64 @udev_node_mknod(%struct.udev_device* %35, i8* null, i32 %36, i32 %37, i32 %38, i32 %39)
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %43
42: ; preds = %4
store i32 -1, i32* %13
br label %113
43: ; preds = %4
%44 = load %struct.udev_device*, %struct.udev_device** %5
%45 = call i32 @udev_device_get_num_fake_partitions(%struct.udev_device* %44)
store i32 %45, i32* %11
%46 = load i32, i32* %11
%47 = icmp sgt i32 %46, 0
br i1 %47, label %48, label %86
48: ; preds = %43
%49 = load %struct.udev*, %struct.udev** %9
%50 = load %struct.udev_device*, %struct.udev_device** %5
%51 = call i8* @udev_device_get_devnode(%struct.udev_device* %50)
%52 = load i32, i32* %11
%53 = call i32 (%struct.udev*, i8*, i8*, i32, ...) @udev_log_null(%struct.udev* %49, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i8* %51, i32 %52)
store i32 1, i32* %10
br label %54
54: ; preds = %82, %48
%55 = load i32, i32* %10
%56 = load i32, i32* %11
%57 = icmp sle i32 %55, %56
br i1 %57, label %58, label %85
58: ; preds = %54
%59 = getelementptr inbounds [1024 x i8], [1024 x i8]* %14, i64 0, i64 0
%60 = load %struct.udev_device*, %struct.udev_device** %5
%61 = call i8* @udev_device_get_devnode(%struct.udev_device* %60)
%62 = load i32, i32* %10
%63 = call i32 @snprintf(i8* %59, i32 1024, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %61, i32 %62)
%64 = getelementptr inbounds [1024 x i8], [1024 x i8]* %14, i64 0, i64 1023
store i8 0, i8* %64
%65 = load %struct.udev_device*, %struct.udev_device** %5
%66 = call i32 @udev_device_get_devnum(%struct.udev_device* %65)
%67 = call i32 @major(i32 %66)
%68 = load %struct.udev_device*, %struct.udev_device** %5
%69 = call i32 @udev_device_get_devnum(%struct.udev_device* %68)
%70 = call i64 @minor(i32 %69)
%71 = load i32, i32* %10
%72 = sext i32 %71 to i64
%73 = add nsw i64 %70, %72
%74 = call i32 @makedev(i32 %67, i64 %73)
store i32 %74, i32* %15
%75 = load %struct.udev_device*, %struct.udev_device** %5
%76 = getelementptr inbounds [1024 x i8], [1024 x i8]* %14, i64 0, i64 0
%77 = load i32, i32* %15
%78 = load i32, i32* %6
%79 = load i32, i32* %7
%80 = load i32, i32* %8
%81 = call i64 @udev_node_mknod(%struct.udev_device* %75, i8* %76, i32 %77, i32 %78, i32 %79, i32 %80)
br label %82
82: ; preds = %58
%83 = load i32, i32* %10
%84 = add nsw i32 %83, 1
store i32 %84, i32* %10
br label %54
85: ; preds = %54
br label %86
86: ; preds = %85, %43
%87 = load %struct.udev*, %struct.udev** %9
%88 = load %struct.udev_device*, %struct.udev_device** %5
%89 = call i32 @udev_device_get_devpath(%struct.udev_device* %88)
%90 = load %struct.udev_device*, %struct.udev_device** %5
%91 = call i8* @udev_device_get_devnode(%struct.udev_device* %90)
%92 = call i32 @name_index(%struct.udev* %87, i32 %89, i8* %91, i32 1)
%93 = load %struct.udev_device*, %struct.udev_device** %5
%94 = call %struct.udev_list_entry* @udev_device_get_devlinks_list_entry(%struct.udev_device* %93)
store %struct.udev_list_entry* %94, %struct.udev_list_entry** %12
br label %95
95: ; preds = %109, %86
%96 = load %struct.udev_list_entry*, %struct.udev_list_entry** %12
%97 = icmp ne %struct.udev_list_entry* %96, null
br i1 %97, label %98, label %112
98: ; preds = %95
%99 = load %struct.udev*, %struct.udev** %9
%100 = load %struct.udev_device*, %struct.udev_device** %5
%101 = call i32 @udev_device_get_devpath(%struct.udev_device* %100)
%102 = load %struct.udev_list_entry*, %struct.udev_list_entry** %12
%103 = call i8* @udev_list_entry_get_name(%struct.udev_list_entry* %102)
%104 = call i32 @name_index(%struct.udev* %99, i32 %101, i8* %103, i32 1)
%105 = load %struct.udev_device*, %struct.udev_device** %5
%106 = load %struct.udev_list_entry*, %struct.udev_list_entry** %12
%107 = call i8* @udev_list_entry_get_name(%struct.udev_list_entry* %106)
%108 = call i32 @update_link(%struct.udev_device* %105, i8* %107)
br label %109
109: ; preds = %98
%110 = load %struct.udev_list_entry*, %struct.udev_list_entry** %12
%111 = call %struct.udev_list_entry* @udev_list_entry_get_next(%struct.udev_list_entry* %110)
store %struct.udev_list_entry* %111, %struct.udev_list_entry** %12
br label %95
112: ; preds = %95
br label %113
113: ; preds = %112, %42
%114 = load i32, i32* %13
ret i32 %114
}

LLVM IR (-O2):
%struct.udev_device = type { i32 }
%struct.udev = type { i32 }
%struct.udev_list_entry = type { i32 }
@.str = [67 x i8] c"creating device node '%s', devnum=%d:%d, mode=%#o, uid=%d, gid=%d\0A\00"
@.str.1 = [44 x i8] c"creating device partition nodes '%s[1-%i]'\0A\00"
@.str.2 = [5 x i8] c"%s%d\00"
define i32 @udev_node_add(%struct.udev_device* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca [1024 x i8]
%6 = tail call %struct.udev* @udev_device_get_udev(%struct.udev_device* %0)
%7 = tail call i8* @udev_device_get_devnode(%struct.udev_device* %0)
%8 = tail call i32 @udev_device_get_devnum(%struct.udev_device* %0)
%9 = tail call i32 @major(i32 %8)
%10 = tail call i32 @udev_device_get_devnum(%struct.udev_device* %0)
%11 = tail call i64 @minor(i32 %10)
%12 = tail call i32 (%struct.udev*, i8*, i8*, i32, ...) @udev_log_null(%struct.udev* %6, i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str, i64 0, i64 0), i8* %7, i32 %9, i64 %11, i32 %1, i32 %2, i32 %3)
%13 = tail call i8* @udev_device_get_devnode(%struct.udev_device* %0)
%14 = tail call i32 @util_create_path(%struct.udev* %6, i8* %13)
%15 = tail call i32 @makedev(i32 0, i64 0)
%16 = tail call i64 @udev_node_mknod(%struct.udev_device* %0, i8* null, i32 %15, i32 %1, i32 %2, i32 %3)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %57
18: ; preds = %4
%19 = tail call i32 @udev_device_get_num_fake_partitions(%struct.udev_device* %0)
%20 = icmp sgt i32 %19, 0
br i1 %20, label %21, label %42
21: ; preds = %18
%22 = tail call i8* @udev_device_get_devnode(%struct.udev_device* %0)
%23 = tail call i32 (%struct.udev*, i8*, i8*, i32, ...) @udev_log_null(%struct.udev* %6, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i8* %22, i32 %19)
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 1023
%26 = add nuw i32 %19, 1
%27 = zext i32 %26 to i64
br label %28
28: ; preds = %21, %28
%29 = phi i64 [ 1, %21 ], [ %40, %28 ]
%30 = call i8* @udev_device_get_devnode(%struct.udev_device* %0)
%31 = trunc i64 %29 to i32
%32 = call i32 @snprintf(i8* %24, i32 1024, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %30, i32 %31)
store i8 0, i8* %25
%33 = call i32 @udev_device_get_devnum(%struct.udev_device* %0)
%34 = call i32 @major(i32 %33)
%35 = call i32 @udev_device_get_devnum(%struct.udev_device* %0)
%36 = call i64 @minor(i32 %35)
%37 = add nsw i64 %36, %29
%38 = call i32 @makedev(i32 %34, i64 %37)
%39 = call i64 @udev_node_mknod(%struct.udev_device* %0, i8* %24, i32 %38, i32 %1, i32 %2, i32 %3)
%40 = add nuw nsw i64 %29, 1
%41 = icmp eq i64 %40, %27
br i1 %41, label %42, label %28
42: ; preds = %28, %18
%43 = call i32 @udev_device_get_devpath(%struct.udev_device* %0)
%44 = call i8* @udev_device_get_devnode(%struct.udev_device* %0)
%45 = call i32 @name_index(%struct.udev* %6, i32 %43, i8* %44, i32 1)
%46 = call %struct.udev_list_entry* @udev_device_get_devlinks_list_entry(%struct.udev_device* %0)
%47 = icmp eq %struct.udev_list_entry* %46, null
br i1 %47, label %57, label %48
48: ; preds = %42, %48
%49 = phi %struct.udev_list_entry* [ %55, %48 ], [ %46, %42 ]
%50 = call i32 @udev_device_get_devpath(%struct.udev_device* %0)
%51 = call i8* @udev_list_entry_get_name(%struct.udev_list_entry* %49)
%52 = call i32 @name_index(%struct.udev* %6, i32 %50, i8* %51, i32 1)
%53 = call i8* @udev_list_entry_get_name(%struct.udev_list_entry* %49)
%54 = call i32 @update_link(%struct.udev_device* %0, i8* %53)
%55 = call %struct.udev_list_entry* @udev_list_entry_get_next(%struct.udev_list_entry* %49)
%56 = icmp eq %struct.udev_list_entry* %55, null
br i1 %56, label %57, label %48
57: ; preds = %48, %42, %4
%58 = phi i32 [ -1, %4 ], [ 0, %42 ], [ 0, %48 ]
ret i32 %58
}