#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*/ link_update(struct udev_device *, char const *,
                               int /*<<< orphan*/);
scalar_t__ strcmp(char const *, char const *);
struct udev_list_entry *
udev_device_get_devlinks_list_entry(struct udev_device *);
int /*<<< orphan*/ 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 *,
                                 int /*<<< orphan*/);
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;
  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;
    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));
    link_update(dev, name, 0);
  }
}


x86 assembly (clang, -O0):
<udev_node_update_old_links>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <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     1287 <udev_node_update_old_links+0x107>
mov    -0x20(%rbp),%rdi
call   1090 <udev_list_entry_get_name@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <udev_device_get_devlinks_list_entry@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     1228 <udev_node_update_old_links+0xa8>
mov    -0x30(%rbp),%rdi
call   1090 <udev_list_entry_get_name@plt>
mov    %rax,-0x40(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1211 <udev_node_update_old_links+0x91>
movl   $0x1,-0x34(%rbp)
jmp    1228 <udev_node_update_old_links+0xa8>
jmp    1216 <udev_node_update_old_links+0x96>
mov    -0x30(%rbp),%rdi
call   1080 <udev_list_entry_get_next@plt>
mov    %rax,-0x30(%rbp)
jmp    11d6 <udev_node_update_old_links+0x56>
cmpl   $0x0,-0x34(%rbp)
je     1237 <udev_node_update_old_links+0xb7>
jmp    1275 <udev_node_update_old_links+0xf5>
mov    -0x18(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x8(%rbp),%rdi
call   10a0 <udev_device_get_devpath@plt>
mov    -0x50(%rbp),%rdi
mov    -0x48(%rbp),%rdx
mov    %eax,%ecx
lea    0xd9f(%rip),%rsi
call   1050 <udev_log_null@plt>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rsi
xor    %edx,%edx
call   1030 <link_update@plt>
mov    -0x20(%rbp),%rdi
call   1080 <udev_list_entry_get_next@plt>
mov    %rax,-0x20(%rbp)
jmp    11aa <udev_node_update_old_links+0x2a>
add    $0x50,%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,%r15
call   1040 <udev_device_get_udev@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1060 <udev_device_get_devlinks_list_entry@plt>
test   %rax,%rax
je     123a <udev_node_update_old_links+0xba>
mov    %rax,%r13
lea    0xe4c(%rip),%r12
jmp    11f5 <udev_node_update_old_links+0x75>
cs nopw 0x0(%rax,%rax,1)
mov    %r15,%rdi
call   10a0 <udev_device_get_devpath@plt>
mov    %r14,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
mov    %eax,%ecx
call   1050 <udev_log_null@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %edx,%edx
call   1030 <link_update@plt>
mov    %r13,%rdi
call   1080 <udev_list_entry_get_next@plt>
mov    %rax,%r13
test   %rax,%rax
je     123a <udev_node_update_old_links+0xba>
mov    %r13,%rdi
call   1090 <udev_list_entry_get_name@plt>
mov    %rax,%rbx
mov    %r15,%rdi
call   1060 <udev_device_get_devlinks_list_entry@plt>
test   %rax,%rax
je     11c0 <udev_node_update_old_links+0x40>
mov    %rax,%rbp
mov    %rbp,%rdi
call   1090 <udev_list_entry_get_name@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     11e5 <udev_node_update_old_links+0x65>
mov    %rbp,%rdi
call   1080 <udev_list_entry_get_next@plt>
mov    %rax,%rbp
test   %rax,%rax
jne    1210 <udev_node_update_old_links+0x90>
jmp    11c0 <udev_node_update_old_links+0x40>
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"
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 %struct.udev_list_entry*
%9 = alloca i32
%10 = alloca i8*
store %struct.udev_device* %0, %struct.udev_device** %3
store %struct.udev_device* %1, %struct.udev_device** %4
%11 = load %struct.udev_device*, %struct.udev_device** %3
%12 = call %struct.udev* @udev_device_get_udev(%struct.udev_device* %11)
store %struct.udev* %12, %struct.udev** %5
%13 = load %struct.udev_device*, %struct.udev_device** %4
%14 = call %struct.udev_list_entry* @udev_device_get_devlinks_list_entry(%struct.udev_device* %13)
store %struct.udev_list_entry* %14, %struct.udev_list_entry** %6
br label %15
15: ; preds = %51, %2
%16 = load %struct.udev_list_entry*, %struct.udev_list_entry** %6
%17 = icmp ne %struct.udev_list_entry* %16, null
br i1 %17, label %18, label %54
18: ; preds = %15
%19 = load %struct.udev_list_entry*, %struct.udev_list_entry** %6
%20 = call i8* @udev_list_entry_get_name(%struct.udev_list_entry* %19)
store i8* %20, i8** %7
store i32 0, i32* %9
%21 = load %struct.udev_device*, %struct.udev_device** %3
%22 = call %struct.udev_list_entry* @udev_device_get_devlinks_list_entry(%struct.udev_device* %21)
store %struct.udev_list_entry* %22, %struct.udev_list_entry** %8
br label %23
23: ; preds = %35, %18
%24 = load %struct.udev_list_entry*, %struct.udev_list_entry** %8
%25 = icmp ne %struct.udev_list_entry* %24, null
br i1 %25, label %26, label %38
26: ; preds = %23
%27 = load %struct.udev_list_entry*, %struct.udev_list_entry** %8
%28 = call i8* @udev_list_entry_get_name(%struct.udev_list_entry* %27)
store i8* %28, i8** %10
%29 = load i8*, i8** %7
%30 = load i8*, i8** %10
%31 = call i64 @strcmp(i8* %29, i8* %30)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %26
store i32 1, i32* %9
br label %38
34: ; preds = %26
br label %35
35: ; preds = %34
%36 = load %struct.udev_list_entry*, %struct.udev_list_entry** %8
%37 = call %struct.udev_list_entry* @udev_list_entry_get_next(%struct.udev_list_entry* %36)
store %struct.udev_list_entry* %37, %struct.udev_list_entry** %8
br label %23
38: ; preds = %33, %23
%39 = load i32, i32* %9
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %42
41: ; preds = %38
br label %51
42: ; preds = %38
%43 = load %struct.udev*, %struct.udev** %5
%44 = load i8*, i8** %7
%45 = load %struct.udev_device*, %struct.udev_device** %3
%46 = call i32 @udev_device_get_devpath(%struct.udev_device* %45)
%47 = call i32 @udev_log_null(%struct.udev* %43, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i8* %44, i32 %46)
%48 = load %struct.udev_device*, %struct.udev_device** %3
%49 = load i8*, i8** %7
%50 = call i32 @link_update(%struct.udev_device* %48, i8* %49, i32 0)
br label %51
51: ; preds = %42, %41
%52 = load %struct.udev_list_entry*, %struct.udev_list_entry** %6
%53 = call %struct.udev_list_entry* @udev_list_entry_get_next(%struct.udev_list_entry* %52)
store %struct.udev_list_entry* %53, %struct.udev_list_entry** %6
br label %15
54: ; preds = %15
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"
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 %26, label %6
6: ; preds = %2, %23
%7 = phi %struct.udev_list_entry* [ %24, %23 ], [ %4, %2 ]
%8 = tail call i8* @udev_list_entry_get_name(%struct.udev_list_entry* %7)
%9 = tail call %struct.udev_list_entry* @udev_device_get_devlinks_list_entry(%struct.udev_device* %0)
%10 = icmp eq %struct.udev_list_entry* %9, null
br i1 %10, label %19, label %11
11: ; preds = %6, %16
%12 = phi %struct.udev_list_entry* [ %17, %16 ], [ %9, %6 ]
%13 = tail call i8* @udev_list_entry_get_name(%struct.udev_list_entry* %12)
%14 = tail call i64 @strcmp(i8* %8, i8* %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %23, label %16
16: ; preds = %11
%17 = tail call %struct.udev_list_entry* @udev_list_entry_get_next(%struct.udev_list_entry* %12)
%18 = icmp eq %struct.udev_list_entry* %17, null
br i1 %18, label %19, label %11
19: ; preds = %16, %6
%20 = tail call i32 @udev_device_get_devpath(%struct.udev_device* %0)
%21 = 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, i32 %20)
%22 = tail call i32 @link_update(%struct.udev_device* %0, i8* %8, i32 0)
br label %23
23: ; preds = %11, %19
%24 = tail call %struct.udev_list_entry* @udev_list_entry_get_next(%struct.udev_list_entry* %7)
%25 = icmp eq %struct.udev_list_entry* %24, null
br i1 %25, label %26, label %6
26: ; preds = %23, %2
ret void
}