#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_list_entry {
  int dummy;
};
struct udev_device {
  int dummy;
};
struct udev {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ name_index(struct udev *, char const *, char const *,
                              int /*<<< orphan*/);
scalar_t__ strcmp(char const *, char const *);
struct udev_list_entry *
udev_device_get_devlinks_list_entry(struct udev_device *);
char const *udev_device_get_devnode(struct udev_device *);
char const *udev_device_get_devpath(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 const *,
                                 char const *);
int /*<<< orphan*/ update_link(struct udev_device *, char const *);
void udev_node_update_old_links(struct udev_device *dev,
                                struct udev_device *dev_old) {
  struct udev *udev = udev_device_get_udev(dev);
  struct udev_list_entry *list_entry;
  const char *devnode_old;
  for (list_entry = udev_device_get_devlinks_list_entry(dev_old);
       list_entry != NULL; list_entry = udev_list_entry_get_next(list_entry)) {
    const char *name = udev_list_entry_get_name(list_entry);
    struct udev_list_entry *list_entry_current;
    int found;
    if (strcmp(name, udev_device_get_devnode(dev)) == 0)
      continue;
    found = 0;
    for (list_entry_current = udev_device_get_devlinks_list_entry(dev);
         list_entry_current != NULL;
         list_entry_current = udev_list_entry_get_next(list_entry_current)) {
      const char *name_current = udev_list_entry_get_name(list_entry_current);
      if (strcmp(name, name_current) == 0) {
        found = 1;
        break;
      }
    }
    if (found)
      continue;
    udev_log_null(udev, "update old name, '%s' no longer belonging to '%s'\n",
                  name, udev_device_get_devpath(dev));
    name_index(udev, udev_device_get_devpath(dev), name, 0);
    update_link(dev, name);
  }
  devnode_old = udev_device_get_devnode(dev_old);
  if (devnode_old != NULL) {
    const char *devnode = udev_device_get_devnode(dev);
    if (devnode != NULL && strcmp(devnode_old, devnode) != 0) {
      udev_log_null(udev, "node has changed from '%s' to '%s'\n", devnode_old,
                    devnode);
      name_index(udev, udev_device_get_devpath(dev), devnode_old, 0);
      update_link(dev, devnode_old);
    }
  }
}


x86 assembly (clang, -O0):
<udev_node_update_old_links>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <udev_device_get_udev@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <udev_device_get_devlinks_list_entry@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     12f8 <udev_node_update_old_links+0x158>
mov    -0x20(%rbp),%rdi
call   1090 <udev_list_entry_get_name@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x8(%rbp),%rdi
call   10a0 <udev_device_get_devnode@plt>
mov    -0x58(%rbp),%rdi
mov    %rax,%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1211 <udev_node_update_old_links+0x71>
jmp    12e6 <udev_node_update_old_links+0x146>
movl   $0x0,-0x3c(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <udev_device_get_devlinks_list_entry@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     1277 <udev_node_update_old_links+0xd7>
mov    -0x38(%rbp),%rdi
call   1090 <udev_list_entry_get_name@plt>
mov    %rax,-0x48(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x48(%rbp),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1260 <udev_node_update_old_links+0xc0>
movl   $0x1,-0x3c(%rbp)
jmp    1277 <udev_node_update_old_links+0xd7>
jmp    1265 <udev_node_update_old_links+0xc5>
mov    -0x38(%rbp),%rdi
call   1080 <udev_list_entry_get_next@plt>
mov    %rax,-0x38(%rbp)
jmp    1225 <udev_node_update_old_links+0x85>
cmpl   $0x0,-0x3c(%rbp)
je     1286 <udev_node_update_old_links+0xe6>
jmp    12e6 <udev_node_update_old_links+0x146>
mov    -0x18(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x8(%rbp),%rdi
call   10b0 <udev_device_get_devpath@plt>
mov    -0x70(%rbp),%rdi
mov    -0x68(%rbp),%rdx
mov    %rax,%rcx
lea    0xd4f(%rip),%rsi
call   1040 <udev_log_null@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x8(%rbp),%rdi
call   10b0 <udev_device_get_devpath@plt>
mov    -0x60(%rbp),%rdi
mov    %rax,%rsi
mov    -0x30(%rbp),%rdx
xor    %ecx,%ecx
call   10c0 <name_index@plt>
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1050 <update_link@plt>
mov    -0x20(%rbp),%rdi
call   1080 <udev_list_entry_get_next@plt>
mov    %rax,-0x20(%rbp)
jmp    11cd <udev_node_update_old_links+0x2d>
mov    -0x10(%rbp),%rdi
call   10a0 <udev_device_get_devnode@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     138c <udev_node_update_old_links+0x1ec>
mov    -0x8(%rbp),%rdi
call   10a0 <udev_device_get_devnode@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
je     1387 <udev_node_update_old_links+0x1e7>
mov    -0x28(%rbp),%rdi
mov    -0x50(%rbp),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     1387 <udev_node_update_old_links+0x1e7>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x50(%rbp),%rcx
lea    0xce1(%rip),%rsi
call   1040 <udev_log_null@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x8(%rbp),%rdi
call   10b0 <udev_device_get_devpath@plt>
mov    -0x78(%rbp),%rdi
mov    %rax,%rsi
mov    -0x28(%rbp),%rdx
xor    %ecx,%ecx
call   10c0 <name_index@plt>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1050 <update_link@plt>
jmp    138c <udev_node_update_old_links+0x1ec>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<udev_node_update_old_links>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r12
call   1030 <udev_device_get_udev@plt>
mov    %rax,%r14
mov    %rbx,(%rsp)
mov    %rbx,%rdi
call   1060 <udev_device_get_devlinks_list_entry@plt>
test   %rax,%rax
je     128d <udev_node_update_old_links+0xed>
mov    %rax,%rbx
lea    0xe28(%rip),%r13
jmp    122c <udev_node_update_old_links+0x8c>
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
call   10b0 <udev_device_get_devpath@plt>
mov    %r14,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
mov    %rax,%rcx
call   1040 <udev_log_null@plt>
mov    %r12,%rdi
call   10b0 <udev_device_get_devpath@plt>
mov    %r14,%rdi
mov    %rax,%rsi
mov    %rbp,%rdx
xor    %ecx,%ecx
call   10c0 <name_index@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
call   1050 <update_link@plt>
mov    %rbx,%rdi
call   1080 <udev_list_entry_get_next@plt>
mov    %rax,%rbx
test   %rax,%rax
je     128d <udev_node_update_old_links+0xed>
mov    %rbx,%rdi
call   1090 <udev_list_entry_get_name@plt>
mov    %rax,%rbp
mov    %r12,%rdi
call   10a0 <udev_device_get_devnode@plt>
mov    %rbp,%rdi
mov    %rax,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     121c <udev_node_update_old_links+0x7c>
mov    %r12,%rdi
call   1060 <udev_device_get_devlinks_list_entry@plt>
test   %rax,%rax
je     11e0 <udev_node_update_old_links+0x40>
mov    %rax,%r15
nop
mov    %r15,%rdi
call   1090 <udev_list_entry_get_name@plt>
mov    %rbp,%rdi
mov    %rax,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     121c <udev_node_update_old_links+0x7c>
mov    %r15,%rdi
call   1080 <udev_list_entry_get_next@plt>
mov    %rax,%r15
test   %rax,%rax
jne    1260 <udev_node_update_old_links+0xc0>
jmp    11e0 <udev_node_update_old_links+0x40>
mov    (%rsp),%rdi
call   10a0 <udev_device_get_devnode@plt>
test   %rax,%rax
je     1304 <udev_node_update_old_links+0x164>
mov    %rax,%rbx
mov    %r12,%rdi
call   10a0 <udev_device_get_devnode@plt>
test   %rax,%rax
je     1304 <udev_node_update_old_links+0x164>
mov    %rax,%rbp
mov    %rbx,%rdi
mov    %rax,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1304 <udev_node_update_old_links+0x164>
lea    0xd6e(%rip),%rsi
mov    %r14,%rdi
mov    %rbx,%rdx
mov    %rbp,%rcx
call   1040 <udev_log_null@plt>
mov    %r12,%rdi
call   10b0 <udev_device_get_devpath@plt>
mov    %r14,%rdi
mov    %rax,%rsi
mov    %rbx,%rdx
xor    %ecx,%ecx
call   10c0 <name_index@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <update_link@plt>
add    $0x8,%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 = [51 x i8] c"update old name, '%s' no longer belonging to '%s'\0A\00"
@.str.1 = [36 x i8] c"node has changed from '%s' to '%s'\0A\00"
define void @udev_node_update_old_links(%struct.udev_device* %0, %struct.udev_device* %1) {
%3 = alloca %struct.udev_device*
%4 = alloca %struct.udev_device*
%5 = alloca %struct.udev*
%6 = alloca %struct.udev_list_entry*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca %struct.udev_list_entry*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8*
store %struct.udev_device* %0, %struct.udev_device** %3
store %struct.udev_device* %1, %struct.udev_device** %4
%13 = load %struct.udev_device*, %struct.udev_device** %3
%14 = call %struct.udev* @udev_device_get_udev(%struct.udev_device* %13)
store %struct.udev* %14, %struct.udev** %5
%15 = load %struct.udev_device*, %struct.udev_device** %4
%16 = call %struct.udev_list_entry* @udev_device_get_devlinks_list_entry(%struct.udev_device* %15)
store %struct.udev_list_entry* %16, %struct.udev_list_entry** %6
br label %17
17: ; preds = %65, %2
%18 = load %struct.udev_list_entry*, %struct.udev_list_entry** %6
%19 = icmp ne %struct.udev_list_entry* %18, null
br i1 %19, label %20, label %68
20: ; preds = %17
%21 = load %struct.udev_list_entry*, %struct.udev_list_entry** %6
%22 = call i8* @udev_list_entry_get_name(%struct.udev_list_entry* %21)
store i8* %22, i8** %8
%23 = load i8*, i8** %8
%24 = load %struct.udev_device*, %struct.udev_device** %3
%25 = call i8* @udev_device_get_devnode(%struct.udev_device* %24)
%26 = call i64 @strcmp(i8* %23, i8* %25)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %20
br label %65
29: ; preds = %20
store i32 0, i32* %10
%30 = load %struct.udev_device*, %struct.udev_device** %3
%31 = call %struct.udev_list_entry* @udev_device_get_devlinks_list_entry(%struct.udev_device* %30)
store %struct.udev_list_entry* %31, %struct.udev_list_entry** %9
br label %32
32: ; preds = %44, %29
%33 = load %struct.udev_list_entry*, %struct.udev_list_entry** %9
%34 = icmp ne %struct.udev_list_entry* %33, null
br i1 %34, label %35, label %47
35: ; preds = %32
%36 = load %struct.udev_list_entry*, %struct.udev_list_entry** %9
%37 = call i8* @udev_list_entry_get_name(%struct.udev_list_entry* %36)
store i8* %37, i8** %11
%38 = load i8*, i8** %8
%39 = load i8*, i8** %11
%40 = call i64 @strcmp(i8* %38, i8* %39)
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %43
42: ; preds = %35
store i32 1, i32* %10
br label %47
43: ; preds = %35
br label %44
44: ; preds = %43
%45 = load %struct.udev_list_entry*, %struct.udev_list_entry** %9
%46 = call %struct.udev_list_entry* @udev_list_entry_get_next(%struct.udev_list_entry* %45)
store %struct.udev_list_entry* %46, %struct.udev_list_entry** %9
br label %32
47: ; preds = %42, %32
%48 = load i32, i32* %10
%49 = icmp ne i32 %48, 0
br i1 %49, label %50, label %51
50: ; preds = %47
br label %65
51: ; preds = %47
%52 = load %struct.udev*, %struct.udev** %5
%53 = load i8*, i8** %8
%54 = load %struct.udev_device*, %struct.udev_device** %3
%55 = call i8* @udev_device_get_devpath(%struct.udev_device* %54)
%56 = call i32 @udev_log_null(%struct.udev* %52, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i8* %53, i8* %55)
%57 = load %struct.udev*, %struct.udev** %5
%58 = load %struct.udev_device*, %struct.udev_device** %3
%59 = call i8* @udev_device_get_devpath(%struct.udev_device* %58)
%60 = load i8*, i8** %8
%61 = call i32 @name_index(%struct.udev* %57, i8* %59, i8* %60, i32 0)
%62 = load %struct.udev_device*, %struct.udev_device** %3
%63 = load i8*, i8** %8
%64 = call i32 @update_link(%struct.udev_device* %62, i8* %63)
br label %65
65: ; preds = %51, %50, %28
%66 = load %struct.udev_list_entry*, %struct.udev_list_entry** %6
%67 = call %struct.udev_list_entry* @udev_list_entry_get_next(%struct.udev_list_entry* %66)
store %struct.udev_list_entry* %67, %struct.udev_list_entry** %6
br label %17
68: ; preds = %17
%69 = load %struct.udev_device*, %struct.udev_device** %4
%70 = call i8* @udev_device_get_devnode(%struct.udev_device* %69)
store i8* %70, i8** %7
%71 = load i8*, i8** %7
%72 = icmp ne i8* %71, null
br i1 %72, label %73, label %97
73: ; preds = %68
%74 = load %struct.udev_device*, %struct.udev_device** %3
%75 = call i8* @udev_device_get_devnode(%struct.udev_device* %74)
store i8* %75, i8** %12
%76 = load i8*, i8** %12
%77 = icmp ne i8* %76, null
br i1 %77, label %78, label %96
78: ; preds = %73
%79 = load i8*, i8** %7
%80 = load i8*, i8** %12
%81 = call i64 @strcmp(i8* %79, i8* %80)
%82 = icmp ne i64 %81, 0
br i1 %82, label %83, label %96
83: ; preds = %78
%84 = load %struct.udev*, %struct.udev** %5
%85 = load i8*, i8** %7
%86 = load i8*, i8** %12
%87 = call i32 @udev_log_null(%struct.udev* %84, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i8* %85, i8* %86)
%88 = load %struct.udev*, %struct.udev** %5
%89 = load %struct.udev_device*, %struct.udev_device** %3
%90 = call i8* @udev_device_get_devpath(%struct.udev_device* %89)
%91 = load i8*, i8** %7
%92 = call i32 @name_index(%struct.udev* %88, i8* %90, i8* %91, i32 0)
%93 = load %struct.udev_device*, %struct.udev_device** %3
%94 = load i8*, i8** %7
%95 = call i32 @update_link(%struct.udev_device* %93, i8* %94)
br label %96
96: ; preds = %83, %78, %73
br label %97
97: ; preds = %96, %68
ret void
}

LLVM IR (-O2):
%struct.udev_device = type { i32 }
%struct.udev = type { i32 }
%struct.udev_list_entry = type { i32 }
@.str = [51 x i8] c"update old name, '%s' no longer belonging to '%s'\0A\00"
@.str.1 = [36 x i8] c"node has changed from '%s' to '%s'\0A\00"
define void @udev_node_update_old_links(%struct.udev_device* %0, %struct.udev_device* %1) {
%3 = tail call %struct.udev* @udev_device_get_udev(%struct.udev_device* %0)
%4 = tail call %struct.udev_list_entry* @udev_device_get_devlinks_list_entry(%struct.udev_device* %1)
%5 = icmp eq %struct.udev_list_entry* %4, null
br i1 %5, label %32, label %6
6: ; preds = %2, %29
%7 = phi %struct.udev_list_entry* [ %30, %29 ], [ %4, %2 ]
%8 = tail call i8* @udev_list_entry_get_name(%struct.udev_list_entry* %7)
%9 = tail call i8* @udev_device_get_devnode(%struct.udev_device* %0)
%10 = tail call i64 @strcmp(i8* %8, i8* %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %29, label %12
12: ; preds = %6
%13 = tail call %struct.udev_list_entry* @udev_device_get_devlinks_list_entry(%struct.udev_device* %0)
%14 = icmp eq %struct.udev_list_entry* %13, null
br i1 %14, label %23, label %15
15: ; preds = %12, %20
%16 = phi %struct.udev_list_entry* [ %21, %20 ], [ %13, %12 ]
%17 = tail call i8* @udev_list_entry_get_name(%struct.udev_list_entry* %16)
%18 = tail call i64 @strcmp(i8* %8, i8* %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %29, label %20
20: ; preds = %15
%21 = tail call %struct.udev_list_entry* @udev_list_entry_get_next(%struct.udev_list_entry* %16)
%22 = icmp eq %struct.udev_list_entry* %21, null
br i1 %22, label %23, label %15
23: ; preds = %20, %12
%24 = tail call i8* @udev_device_get_devpath(%struct.udev_device* %0)
%25 = tail call i32 @udev_log_null(%struct.udev* %3, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i8* %8, i8* %24)
%26 = tail call i8* @udev_device_get_devpath(%struct.udev_device* %0)
%27 = tail call i32 @name_index(%struct.udev* %3, i8* %26, i8* %8, i32 0)
%28 = tail call i32 @update_link(%struct.udev_device* %0, i8* %8)
br label %29
29: ; preds = %15, %6, %23
%30 = tail call %struct.udev_list_entry* @udev_list_entry_get_next(%struct.udev_list_entry* %7)
%31 = icmp eq %struct.udev_list_entry* %30, null
br i1 %31, label %32, label %6
32: ; preds = %29, %2
%33 = tail call i8* @udev_device_get_devnode(%struct.udev_device* %1)
%34 = icmp eq i8* %33, null
br i1 %34, label %46, label %35
35: ; preds = %32
%36 = tail call i8* @udev_device_get_devnode(%struct.udev_device* %0)
%37 = icmp eq i8* %36, null
br i1 %37, label %46, label %38
38: ; preds = %35
%39 = tail call i64 @strcmp(i8* %33, i8* %36)
%40 = icmp eq i64 %39, 0
br i1 %40, label %46, label %41
41: ; preds = %38
%42 = tail call i32 @udev_log_null(%struct.udev* %3, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i8* %33, i8* %36)
%43 = tail call i8* @udev_device_get_devpath(%struct.udev_device* %0)
%44 = tail call i32 @name_index(%struct.udev* %3, i8* %43, i8* %33, i32 0)
%45 = tail call i32 @update_link(%struct.udev_device* %0, i8* %33)
br label %46
46: ; preds = %35, %38, %41, %32
ret void
}