#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 */
typedef int /*<<< orphan*/ argv;

/* Variables and functions */
int /*<<< orphan*/ my_printf(char *, char *);
scalar_t__ optind;
scalar_t__ rm_main(int, char **);
int rm_rootfs(char *directory, int quiet, int no_write) {
  optind = 0;
  char *argv[] = {"rm", "-r", "-f", directory, NULL};
  int argc = (int)(sizeof(argv) / sizeof(argv[0])) - 1;
  if (!quiet)
    my_printf("Delete rootfs: rm -r -f %s\n", directory);
  if (!no_write)
    if (rm_main(argc, argv) != 0)
      return 0;
  return 1;
}


x86 assembly (clang, -O0):
<rm_rootfs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    0x2eaf(%rip),%rax
movq   $0x0,(%rax)
lea    0xeb9(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0xeb1(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    0xea9(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x4,-0x44(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1192 <rm_rootfs+0x72>
mov    -0x10(%rbp),%rsi
lea    0xe7c(%rip),%rdi
call   1030 <my_printf@plt>
cmpl   $0x0,-0x18(%rbp)
jne    11c3 <rm_rootfs+0xa3>
mov    -0x44(%rbp),%edi
lea    -0x40(%rbp),%rsi
call   1040 <rm_main@plt>
cmp    $0x0,%rax
je     11be <rm_rootfs+0x9e>
movl   $0x0,-0x4(%rbp)
jmp    11ca <rm_rootfs+0xaa>
jmp    11c3 <rm_rootfs+0xa3>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rm_rootfs>:
push   %rbx
sub    $0x30,%rsp
mov    %edx,%ebx
mov    0x2eba(%rip),%rcx
movq   $0x0,(%rcx)
lea    0xec4(%rip),%rcx
mov    %rcx,(%rsp)
lea    0xebc(%rip),%rcx
mov    %rcx,0x8(%rsp)
lea    0xeb3(%rip),%rcx
mov    %rcx,0x10(%rsp)
mov    %rdi,0x18(%rsp)
movq   $0x0,0x20(%rsp)
test   %esi,%esi
je     1170 <rm_rootfs+0x50>
test   %ebx,%ebx
jne    119d <rm_rootfs+0x7d>
jmp    1186 <rm_rootfs+0x66>
mov    %rdi,%rax
lea    0xe8f(%rip),%rdi
mov    %rax,%rsi
call   1030 <my_printf@plt>
test   %ebx,%ebx
jne    119d <rm_rootfs+0x7d>
mov    %rsp,%rsi
mov    $0x4,%edi
call   1040 <rm_main@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jne    11a2 <rm_rootfs+0x82>
mov    $0x1,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@optind = global i64 0
@.str = [3 x i8] c"rm\00"
@.str.1 = [3 x i8] c"-r\00"
@.str.2 = [3 x i8] c"-f\00"
@.str.3 = [28 x i8] c"Delete rootfs: rm -r -f %s\0A\00"
define i32 @rm_rootfs(i8* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca [5 x i8*]
%9 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i64 0, i64* @optind
%10 = getelementptr inbounds [5 x i8*], [5 x i8*]* %8, i64 0, i64 0
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %10
%11 = getelementptr inbounds i8*, i8** %10, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %11
%12 = getelementptr inbounds i8*, i8** %11, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, 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
store i32 4, i32* %9
%16 = load i32, i32* %6
%17 = icmp ne i32 %16, 0
br i1 %17, label %21, label %18
18: ; preds = %3
%19 = load i8*, i8** %5
%20 = call i32 @my_printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* %19)
br label %21
21: ; preds = %18, %3
%22 = load i32, i32* %7
%23 = icmp ne i32 %22, 0
br i1 %23, label %31, label %24
24: ; preds = %21
%25 = load i32, i32* %9
%26 = getelementptr inbounds [5 x i8*], [5 x i8*]* %8, i64 0, i64 0
%27 = call i64 @rm_main(i32 %25, i8** %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %24
store i32 0, i32* %4
br label %32
30: ; preds = %24
br label %31
31: ; preds = %30, %21
store i32 1, i32* %4
br label %32
32: ; preds = %31, %29
%33 = load i32, i32* %4
ret i32 %33
}

LLVM IR (-O2):
@optind = global i64 0
@.str = [3 x i8] c"rm\00"
@.str.1 = [3 x i8] c"-r\00"
@.str.2 = [3 x i8] c"-f\00"
@.str.3 = [28 x i8] c"Delete rootfs: rm -r -f %s\0A\00"
define i32 @rm_rootfs(i8* %0, i32 %1, i32 %2) {
%4 = alloca [5 x i8*]
store i64 0, i64* @optind
%5 = bitcast [5 x i8*]* %4 to i8*
%6 = getelementptr inbounds [5 x i8*], [5 x i8*]* %4, i64 0, i64 0
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %6
%7 = getelementptr inbounds [5 x i8*], [5 x i8*]* %4, i64 0, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %7
%8 = getelementptr inbounds [5 x i8*], [5 x i8*]* %4, i64 0, i64 2
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** %8
%9 = getelementptr inbounds [5 x i8*], [5 x i8*]* %4, i64 0, i64 3
store i8* %0, i8** %9
%10 = getelementptr inbounds [5 x i8*], [5 x i8*]* %4, i64 0, i64 4
store i8* null, i8** %10
%11 = icmp eq i32 %1, 0
br i1 %11, label %12, label %14
12: ; preds = %3
%13 = tail call i32 @my_printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* %0)
br label %14
14: ; preds = %12, %3
%15 = icmp eq i32 %2, 0
br i1 %15, label %16, label %19
16: ; preds = %14
%17 = call i64 @rm_main(i32 4, i8** %6)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %16, %14
br label %20
20: ; preds = %16, %19
%21 = phi i32 [ 1, %19 ], [ 0, %16 ]
ret i32 %21
}