#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*/ bail(char *);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ sprintf(char *, char *, char const *, char const *);
int system(char *);
int remove_from_hosts(const char *path, const char *hostname) {
  int retval = -1;
  char *command = (char *)malloc(sizeof(char) * 1024);
  sprintf(command, "sed -i '/%s/d' %s", hostname, path);
  retval = system(command);
  if (retval != -1) {
    retval = 0;
  } else {
    retval = -1;
    bail("Error reconfiguring hosts file");
  }
  free(command);
  return retval;
}


x86 assembly (clang, -O0):
<remove_from_hosts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xffffffff,-0x14(%rbp)
mov    $0x400,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x8(%rbp),%rcx
lea    0xe78(%rip),%rsi
call   1070 <sprintf@plt>
mov    -0x20(%rbp),%rdi
call   1040 <system@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
je     11af <remove_from_hosts+0x5f>
movl   $0x0,-0x14(%rbp)
jmp    11c2 <remove_from_hosts+0x72>
movl   $0xffffffff,-0x14(%rbp)
lea    0xe55(%rip),%rdi
call   1060 <bail@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remove_from_hosts>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbp
mov    %rdi,%r14
mov    $0x400,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
lea    0xe92(%rip),%rsi
mov    %rax,%rdi
mov    %rbp,%rdx
mov    %r14,%rcx
call   1070 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
xor    %ebp,%ebp
cmp    $0xffffffff,%eax
jne    119c <remove_from_hosts+0x4c>
lea    0xe80(%rip),%rdi
call   1060 <bail@plt>
mov    $0xffffffff,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"sed -i '/%s/d' %s\00"
@.str.1 = [31 x i8] c"Error reconfiguring hosts file\00"
define i32 @remove_from_hosts(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 -1, i32* %5
%7 = call i64 @malloc(i32 1024)
%8 = inttoptr i64 %7 to i8*
store i8* %8, i8** %6
%9 = load i8*, i8** %6
%10 = load i8*, i8** %4
%11 = load i8*, i8** %3
%12 = call i32 @sprintf(i8* %9, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %10, i8* %11)
%13 = load i8*, i8** %6
%14 = call i32 @system(i8* %13)
store i32 %14, i32* %5
%15 = load i32, i32* %5
%16 = icmp ne i32 %15, -1
br i1 %16, label %17, label %18
17: ; preds = %2
store i32 0, i32* %5
br label %20
18: ; preds = %2
store i32 -1, i32* %5
%19 = call i32 @bail(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
br label %20
20: ; preds = %18, %17
%21 = load i8*, i8** %6
%22 = call i32 @free(i8* %21)
%23 = load i32, i32* %5
ret i32 %23
}

LLVM IR (-O2):
@.str = [18 x i8] c"sed -i '/%s/d' %s\00"
@.str.1 = [31 x i8] c"Error reconfiguring hosts file\00"
define i32 @remove_from_hosts(i8* %0, i8* %1) {
%3 = tail call i64 @malloc(i32 1024)
%4 = inttoptr i64 %3 to i8*
%5 = tail call i32 @sprintf(i8* dereferenceable(1) %4, i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %0)
%6 = tail call i32 @system(i8* %4)
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = tail call i32 @bail(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
br label %10
10: ; preds = %2, %8
%11 = phi i32 [ -1, %8 ], [ 0, %2 ]
%12 = tail call i32 @free(i8* %4)
ret i32 %11
}