#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 */
int /*<<< orphan*/ run(char const *const *);
void reset_diversion(const char *package, const char *file,
                     const char *distrib) {
  const char *const remove_old_diversion[] = {
      "dpkg-divert", "--package", "bash", "--remove", file, NULL};
  const char *const new_diversion[] = {"dpkg-divert", "--package", package,
                                       "--divert",    distrib,     "--add",
                                       file,          NULL};
  run(remove_old_diversion);
  run(new_diversion);
}


x86 assembly (clang, -O0):
<reset_diversion>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    0xed2(%rip),%rax
mov    %rax,-0x50(%rbp)
lea    0xed3(%rip),%rax
mov    %rax,-0x48(%rbp)
lea    0xed2(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0xecc(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
movq   $0x0,-0x28(%rbp)
lea    0xe96(%rip),%rax
mov    %rax,-0x90(%rbp)
lea    0xe94(%rip),%rax
mov    %rax,-0x88(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x80(%rbp)
lea    0xe96(%rip),%rax
mov    %rax,-0x78(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x70(%rbp)
lea    0xe8c(%rip),%rax
mov    %rax,-0x68(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x60(%rbp)
movq   $0x0,-0x58(%rbp)
lea    -0x50(%rbp),%rdi
call   1030 <run@plt>
lea    -0x90(%rbp),%rdi
call   1030 <run@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reset_diversion>:
sub    $0x78,%rsp
lea    0xee5(%rip),%r8
mov    %r8,(%rsp)
lea    0xee6(%rip),%rcx
mov    %rcx,0x8(%rsp)
lea    0xee4(%rip),%rax
mov    %rax,0x10(%rsp)
lea    0xedd(%rip),%rax
mov    %rax,0x18(%rsp)
mov    %rsi,0x20(%rsp)
movq   $0x0,0x28(%rsp)
mov    %r8,0x30(%rsp)
mov    %rcx,0x38(%rsp)
mov    %rdi,0x40(%rsp)
lea    0xebd(%rip),%rax
mov    %rax,0x48(%rsp)
mov    %rdx,0x50(%rsp)
lea    0xeb5(%rip),%rax
mov    %rax,0x58(%rsp)
mov    %rsi,0x60(%rsp)
movq   $0x0,0x68(%rsp)
mov    %rsp,%rdi
call   1030 <run@plt>
lea    0x30(%rsp),%rdi
call   1030 <run@plt>
add    $0x78,%rsp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"dpkg-divert\00"
@.str.1 = [10 x i8] c"--package\00"
@.str.2 = [5 x i8] c"bash\00"
@.str.3 = [9 x i8] c"--remove\00"
@.str.4 = [9 x i8] c"--divert\00"
@.str.5 = [6 x i8] c"--add\00"
define void @reset_diversion(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca [6 x i8*]
%8 = alloca [8 x i8*]
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%9 = getelementptr inbounds [6 x i8*], [6 x i8*]* %7, i64 0, i64 0
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %9
%10 = getelementptr inbounds i8*, i8** %9, i64 1
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8** %10
%11 = getelementptr inbounds i8*, i8** %10, i64 1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %11
%12 = getelementptr inbounds i8*, i8** %11, i64 1
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8** %12
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %5
store i8* %14, i8** %13
%15 = getelementptr inbounds i8*, i8** %13, i64 1
store i8* null, i8** %15
%16 = getelementptr inbounds [8 x i8*], [8 x i8*]* %8, i64 0, i64 0
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %16
%17 = getelementptr inbounds i8*, i8** %16, i64 1
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8** %17
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %4
store i8* %19, i8** %18
%20 = getelementptr inbounds i8*, i8** %18, i64 1
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8** %20
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %6
store i8* %22, i8** %21
%23 = getelementptr inbounds i8*, i8** %21, i64 1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8** %23
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %5
store i8* %25, i8** %24
%26 = getelementptr inbounds i8*, i8** %24, i64 1
store i8* null, i8** %26
%27 = getelementptr inbounds [6 x i8*], [6 x i8*]* %7, i64 0, i64 0
%28 = call i32 @run(i8** %27)
%29 = getelementptr inbounds [8 x i8*], [8 x i8*]* %8, i64 0, i64 0
%30 = call i32 @run(i8** %29)
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"dpkg-divert\00"
@.str.1 = [10 x i8] c"--package\00"
@.str.2 = [5 x i8] c"bash\00"
@.str.3 = [9 x i8] c"--remove\00"
@.str.4 = [9 x i8] c"--divert\00"
@.str.5 = [6 x i8] c"--add\00"
define void @reset_diversion(i8* %0, i8* %1, i8* %2) {
%4 = alloca [6 x i8*]
%5 = alloca [8 x i8*]
%6 = bitcast [6 x i8*]* %4 to i8*
%7 = getelementptr inbounds [6 x i8*], [6 x i8*]* %4, i64 0, i64 0
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %7
%8 = getelementptr inbounds [6 x i8*], [6 x i8*]* %4, i64 0, i64 1
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8** %8
%9 = getelementptr inbounds [6 x i8*], [6 x i8*]* %4, i64 0, i64 2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %9
%10 = getelementptr inbounds [6 x i8*], [6 x i8*]* %4, i64 0, i64 3
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8** %10
%11 = getelementptr inbounds [6 x i8*], [6 x i8*]* %4, i64 0, i64 4
store i8* %1, i8** %11
%12 = getelementptr inbounds [6 x i8*], [6 x i8*]* %4, i64 0, i64 5
store i8* null, i8** %12
%13 = bitcast [8 x i8*]* %5 to i8*
%14 = getelementptr inbounds [8 x i8*], [8 x i8*]* %5, i64 0, i64 0
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %14
%15 = getelementptr inbounds [8 x i8*], [8 x i8*]* %5, i64 0, i64 1
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8** %15
%16 = getelementptr inbounds [8 x i8*], [8 x i8*]* %5, i64 0, i64 2
store i8* %0, i8** %16
%17 = getelementptr inbounds [8 x i8*], [8 x i8*]* %5, i64 0, i64 3
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8** %17
%18 = getelementptr inbounds [8 x i8*], [8 x i8*]* %5, i64 0, i64 4
store i8* %2, i8** %18
%19 = getelementptr inbounds [8 x i8*], [8 x i8*]* %5, i64 0, i64 5
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8** %19
%20 = getelementptr inbounds [8 x i8*], [8 x i8*]* %5, i64 0, i64 6
store i8* %1, i8** %20
%21 = getelementptr inbounds [8 x i8*], [8 x i8*]* %5, i64 0, i64 7
store i8* null, i8** %21
%22 = call i32 @run(i8** %7)
%23 = call i32 @run(i8** %14)
ret void
}