#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*/ printf(char *);
int system(char *);
int uninstall() {
  printf("Restoring original boot manager...\n");
  int res;
  res = system("MOUNTVOL T: /S");
  if (res) {
    printf("Could not mount ESP volume!\n");
    return 1;
  }
  res = system("MOVE /Y T:\\EFI\\Microsoft\\Boot\\bootmgfw.orig.efi "
               "T:\\EFI\\Microsoft\\Boot\\bootmgfw.efi");
  if (res) {
    printf("Warning: No boot manager backup detected! Will attempt to write "
           "new one...\n");
    res = system("COPY /Y %SYSTEMROOT%\\Boot\\EFI\\bootmgfw.efi "
                 "T:\\EFI\\Microsoft\\Boot\\bootmgfw.efi");
    if (res) {
      printf("That failed too! This is bad.\n");
    }
  }
  res = system("DEL T:\\EFI\\Microsoft\\Boot\\slic.bin");
  if (res) {
    printf("Failed to delete SLIC.\n");
  }
  res = system("MOUNTVOL T: /D");
  return 0;
}


x86 assembly (clang, -O0):
<uninstall>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
call   1040 <printf@plt>
lea    0xee9(%rip),%rdi
call   1030 <system@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1165 <uninstall+0x45>
lea    0xedf(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11ef <uninstall+0xcf>
lea    0xee4(%rip),%rdi
call   1030 <system@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     11b4 <uninstall+0x94>
lea    0xf1e(%rip),%rdi
call   1040 <printf@plt>
lea    0xf5e(%rip),%rdi
call   1030 <system@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     11af <uninstall+0x8f>
lea    0xf93(%rip),%rdi
call   1040 <printf@plt>
jmp    11b4 <uninstall+0x94>
lea    0xfa1(%rip),%rdi
call   1030 <system@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     11d9 <uninstall+0xb9>
lea    0xfab(%rip),%rdi
call   1040 <printf@plt>
lea    0xfb7(%rip),%rdi
call   1030 <system@plt>
mov    %eax,-0x8(%rbp)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uninstall>:
push   %rax
lea    0xfba(%rip),%rdi
call   1030 <puts@plt>
lea    0xecc(%rip),%rdi
call   1040 <system@plt>
test   %eax,%eax
je     1150 <uninstall+0x30>
lea    0x1041(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
pop    %rcx
ret
lea    0xeb8(%rip),%rdi
call   1040 <system@plt>
test   %eax,%eax
je     1188 <uninstall+0x68>
lea    0xfb5(%rip),%rdi
call   1030 <puts@plt>
lea    0xeef(%rip),%rdi
call   1040 <system@plt>
test   %eax,%eax
je     1188 <uninstall+0x68>
lea    0xfe4(%rip),%rdi
call   1030 <puts@plt>
lea    0xf21(%rip),%rdi
call   1040 <system@plt>
test   %eax,%eax
je     11a4 <uninstall+0x84>
lea    0xf66(%rip),%rdi
call   1030 <puts@plt>
lea    0xf28(%rip),%rdi
call   1040 <system@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [36 x i8] c"Restoring original boot manager...\0A\00"
@.str.1 = [15 x i8] c"MOUNTVOL T: /S\00"
@.str.2 = [29 x i8] c"Could not mount ESP volume!\0A\00"
@.str.3 = [83 x i8] c"MOVE /Y T:\\EFI\\Microsoft\\Boot\\bootmgfw.orig.efi T:\\EFI\\Microsoft\\Boot\\bootmgfw.efi\00"
@.str.4 = [76 x i8] c"Warning: No boot manager backup detected! Will attempt to write new one...\0A\00"
@.str.5 = [78 x i8] c"COPY /Y %SYSTEMROOT%\\Boot\\EFI\\bootmgfw.efi T:\\EFI\\Microsoft\\Boot\\bootmgfw.efi\00"
@.str.6 = [31 x i8] c"That failed too! This is bad.\0A\00"
@.str.7 = [35 x i8] c"DEL T:\\EFI\\Microsoft\\Boot\\slic.bin\00"
@.str.8 = [24 x i8] c"Failed to delete SLIC.\0A\00"
@.str.9 = [15 x i8] c"MOUNTVOL T: /D\00"
define i32 @uninstall() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @system(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
store i32 %4, i32* %2
%5 = load i32, i32* %2
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %1
br label %29
9: ; preds = %0
%10 = call i32 @system(i8* getelementptr inbounds ([83 x i8], [83 x i8]* @.str.3, i64 0, i64 0))
store i32 %10, i32* %2
%11 = load i32, i32* %2
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %21
13: ; preds = %9
%14 = call i32 @printf(i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str.4, i64 0, i64 0))
%15 = call i32 @system(i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str.5, i64 0, i64 0))
store i32 %15, i32* %2
%16 = load i32, i32* %2
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0))
br label %20
20: ; preds = %18, %13
br label %21
21: ; preds = %20, %9
%22 = call i32 @system(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.7, i64 0, i64 0))
store i32 %22, i32* %2
%23 = load i32, i32* %2
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0))
br label %27
27: ; preds = %25, %21
%28 = call i32 @system(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0))
store i32 %28, i32* %2
store i32 0, i32* %1
br label %29
29: ; preds = %27, %7
%30 = load i32, i32* %1
ret i32 %30
}

LLVM IR (-O2):
@.str.1 = [15 x i8] c"MOUNTVOL T: /S\00"
@.str.3 = [83 x i8] c"MOVE /Y T:\\EFI\\Microsoft\\Boot\\bootmgfw.orig.efi T:\\EFI\\Microsoft\\Boot\\bootmgfw.efi\00"
@.str.5 = [78 x i8] c"COPY /Y %SYSTEMROOT%\\Boot\\EFI\\bootmgfw.efi T:\\EFI\\Microsoft\\Boot\\bootmgfw.efi\00"
@.str.7 = [35 x i8] c"DEL T:\\EFI\\Microsoft\\Boot\\slic.bin\00"
@.str.9 = [15 x i8] c"MOUNTVOL T: /D\00"
@str = [35 x i8] c"Restoring original boot manager...\00"
@str.10 = [23 x i8] c"Failed to delete SLIC.\00"
@str.11 = [75 x i8] c"Warning: No boot manager backup detected! Will attempt to write new one...\00"
@str.12 = [30 x i8] c"That failed too! This is bad.\00"
@str.13 = [28 x i8] c"Could not mount ESP volume!\00"
define i32 @uninstall() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @system(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp eq i32 %2, 0
br i1 %3, label %6, label %4
4: ; preds = %0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.13, i64 0, i64 0))
br label %22
6: ; preds = %0
%7 = tail call i32 @system(i8* getelementptr inbounds ([83 x i8], [83 x i8]* @.str.3, i64 0, i64 0))
%8 = icmp eq i32 %7, 0
br i1 %8, label %15, label %9
9: ; preds = %6
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([75 x i8], [75 x i8]* @str.11, i64 0, i64 0))
%11 = tail call i32 @system(i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str.5, i64 0, i64 0))
%12 = icmp eq i32 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %9
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.12, i64 0, i64 0))
br label %15
15: ; preds = %9, %13, %6
%16 = tail call i32 @system(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.7, i64 0, i64 0))
%17 = icmp eq i32 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %15
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.10, i64 0, i64 0))
br label %20
20: ; preds = %18, %15
%21 = tail call i32 @system(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0))
br label %22
22: ; preds = %20, %4
%23 = phi i32 [ 1, %4 ], [ 0, %20 ]
ret i32 %23
}