#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 */
scalar_t__ ENOENT;
int /*<<< orphan*/ LOG_ERR;
int /*<<< orphan*/ LOG_INFO;
scalar_t__ errno;
scalar_t__ remove(char *);
scalar_t__ symlink(char *, char *);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, ...);
void fix_symlink() {
  syslog(LOG_INFO, "Restoring symlink to %s", "/run/resolvconf/resolv.conf");
  if (remove("/etc/resolv.conf"))
    if (errno != ENOENT)
      syslog(LOG_ERR, "Failed to remove existing file resolv.conf");
  if (symlink("/run/resolvconf/resolv.conf", "/etc/resolv.conf"))
    syslog(LOG_ERR, "Failed to create symlink to dynamic resolv.conf");
}


x86 assembly (clang, -O0):
<fix_symlink>:
push   %rbp
mov    %rsp,%rbp
mov    0x2e9d(%rip),%rax
mov    (%rax),%edi
lea    0xebc(%rip),%rsi
lea    0xecd(%rip),%rdx
mov    $0x0,%al
call   1050 <syslog@plt>
lea    0xedb(%rip),%rdi
call   1030 <remove@plt>
cmp    $0x0,%rax
je     119e <fix_symlink+0x6e>
mov    0x2e71(%rip),%rax
mov    (%rax),%rax
mov    0x2e4f(%rip),%rcx
cmp    (%rcx),%rax
je     1199 <fix_symlink+0x69>
mov    0x2e37(%rip),%rax
mov    (%rax),%edi
lea    0xeb3(%rip),%rsi
mov    $0x0,%al
call   1050 <syslog@plt>
jmp    119e <fix_symlink+0x6e>
lea    0xe73(%rip),%rdi
lea    0xe88(%rip),%rsi
call   1040 <symlink@plt>
cmp    $0x0,%rax
je     11d2 <fix_symlink+0xa2>
mov    0x2dfe(%rip),%rax
mov    (%rax),%edi
lea    0xea5(%rip),%rsi
mov    $0x0,%al
call   1050 <syslog@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<fix_symlink>:
push   %rax
mov    0x2ea0(%rip),%rax
mov    (%rax),%edi
lea    0xebf(%rip),%rsi
lea    0xed0(%rip),%rdx
xor    %eax,%eax
call   1050 <syslog@plt>
lea    0xede(%rip),%rdi
call   1030 <remove@plt>
test   %rax,%rax
je     118d <fix_symlink+0x5d>
mov    0x2e79(%rip),%rax
mov    (%rax),%rax
mov    0x2e57(%rip),%rcx
cmp    (%rcx),%rax
je     118d <fix_symlink+0x5d>
mov    0x2e43(%rip),%rax
mov    (%rax),%edi
lea    0xebf(%rip),%rsi
xor    %eax,%eax
call   1050 <syslog@plt>
lea    0xe84(%rip),%rdi
lea    0xe99(%rip),%rsi
call   1040 <symlink@plt>
test   %rax,%rax
je     11bd <fix_symlink+0x8d>
mov    0x2e14(%rip),%rax
mov    (%rax),%edi
lea    0xebb(%rip),%rsi
xor    %eax,%eax
pop    %rcx
jmp    1050 <syslog@plt>
pop    %rax
ret

LLVM IR (-O0):
@LOG_INFO = global i32 0
@.str = [24 x i8] c"Restoring symlink to %s\00"
@.str.1 = [28 x i8] c"/run/resolvconf/resolv.conf\00"
@.str.2 = [17 x i8] c"/etc/resolv.conf\00"
@errno = global i64 0
@ENOENT = global i64 0
@LOG_ERR = global i32 0
@.str.3 = [43 x i8] c"Failed to remove existing file resolv.conf\00"
@.str.4 = [48 x i8] c"Failed to create symlink to dynamic resolv.conf\00"
define void @fix_symlink() {
%1 = load i32, i32* @LOG_INFO
%2 = call i32 (i32, i8*, ...) @syslog(i32 %1, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%3 = call i64 @remove(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%4 = icmp ne i64 %3, 0
br i1 %4, label %5, label %13
5: ; preds = %0
%6 = load i64, i64* @errno
%7 = load i64, i64* @ENOENT
%8 = icmp ne i64 %6, %7
br i1 %8, label %9, label %12
9: ; preds = %5
%10 = load i32, i32* @LOG_ERR
%11 = call i32 (i32, i8*, ...) @syslog(i32 %10, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0))
br label %12
12: ; preds = %9, %5
br label %13
13: ; preds = %12, %0
%14 = call i64 @symlink(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = load i32, i32* @LOG_ERR
%18 = call i32 (i32, i8*, ...) @syslog(i32 %17, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0))
br label %19
19: ; preds = %16, %13
ret void
}

LLVM IR (-O2):
@LOG_INFO = global i32 0
@.str = [24 x i8] c"Restoring symlink to %s\00"
@.str.1 = [28 x i8] c"/run/resolvconf/resolv.conf\00"
@.str.2 = [17 x i8] c"/etc/resolv.conf\00"
@errno = global i64 0
@ENOENT = global i64 0
@LOG_ERR = global i32 0
@.str.3 = [43 x i8] c"Failed to remove existing file resolv.conf\00"
@.str.4 = [48 x i8] c"Failed to create symlink to dynamic resolv.conf\00"
define void @fix_symlink() {
%1 = load i32, i32* @LOG_INFO
%2 = tail call i32 (i32, i8*, ...) @syslog(i32 %1, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i64 @remove(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%4 = icmp eq i64 %3, 0
br i1 %4, label %12, label %5
5: ; preds = %0
%6 = load i64, i64* @errno
%7 = load i64, i64* @ENOENT
%8 = icmp eq i64 %6, %7
br i1 %8, label %12, label %9
9: ; preds = %5
%10 = load i32, i32* @LOG_ERR
%11 = tail call i32 (i32, i8*, ...) @syslog(i32 %10, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0))
br label %12
12: ; preds = %5, %9, %0
%13 = tail call i64 @symlink(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %12
%16 = load i32, i32* @LOG_ERR
%17 = tail call i32 (i32, i8*, ...) @syslog(i32 %16, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0))
br label %18
18: ; preds = %15, %12
ret void
}