#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 *);
scalar_t__ run_exec_process(char *const *);
int format_ext3_device(const char *device) {
  char *const mke2fs[] = {"/sbin/mke2fs", "-j", "-q", device, NULL};
  char *const tune2fs[] = {"/sbin/tune2fs", "-C", "1", device, NULL};
  if (run_exec_process(mke2fs)) {
    printf("failure while running mke2fs\n");
    return -1;
  }
  if (run_exec_process(tune2fs)) {
    printf("failure while running mke2fs\n");
    return -1;
  }
  char *const e2fsck[] = {"/sbin/e2fsck", "-fy", device, NULL};
  if (run_exec_process(e2fsck)) {
    printf("failure while running e2fsck\n");
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<format_ext3_device>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xeca(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0xecc(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    0xec4(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x20(%rbp)
lea    0xeac(%rip),%rax
mov    %rax,-0x70(%rbp)
lea    0xeaf(%rip),%rax
mov    %rax,-0x68(%rbp)
lea    0xea7(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x58(%rbp)
movq   $0x0,-0x50(%rbp)
lea    -0x40(%rbp),%rdi
call   1030 <run_exec_process@plt>
cmp    $0x0,%rax
je     11bc <format_ext3_device+0x9c>
lea    0xe7b(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1248 <format_ext3_device+0x128>
lea    -0x70(%rbp),%rdi
call   1030 <run_exec_process@plt>
cmp    $0x0,%rax
je     11e7 <format_ext3_device+0xc7>
lea    0xe50(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1248 <format_ext3_device+0x128>
lea    0xe56(%rip),%rax
mov    %rax,-0x90(%rbp)
lea    0xe55(%rip),%rax
mov    %rax,-0x88(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x80(%rbp)
movq   $0x0,-0x78(%rbp)
lea    -0x90(%rbp),%rdi
call   1030 <run_exec_process@plt>
cmp    $0x0,%rax
je     1241 <format_ext3_device+0x121>
lea    0xe25(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1248 <format_ext3_device+0x128>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<format_ext3_device>:
push   %rbx
sub    $0x80,%rsp
mov    %rdi,%rbx
lea    0xece(%rip),%rax
mov    %rax,0x50(%rsp)
lea    0xecf(%rip),%rax
mov    %rax,0x58(%rsp)
lea    0xec6(%rip),%rax
mov    %rax,0x60(%rsp)
mov    %rdi,0x68(%rsp)
movq   $0x0,0x70(%rsp)
lea    0xeaf(%rip),%rax
mov    %rax,0x20(%rsp)
lea    0xeb1(%rip),%rax
mov    %rax,0x28(%rsp)
lea    0xea8(%rip),%rax
mov    %rax,0x30(%rsp)
mov    %rdi,0x38(%rsp)
movq   $0x0,0x40(%rsp)
lea    0x50(%rsp),%rdi
call   1040 <run_exec_process@plt>
test   %rax,%rax
jne    11ad <format_ext3_device+0x8d>
lea    0x20(%rsp),%rdi
call   1040 <run_exec_process@plt>
test   %rax,%rax
je     11c7 <format_ext3_device+0xa7>
lea    0xea0(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
add    $0x80,%rsp
pop    %rbx
ret
lea    0xe58(%rip),%rax
mov    %rax,(%rsp)
lea    0xe5a(%rip),%rax
mov    %rax,0x8(%rsp)
mov    %rbx,0x10(%rsp)
movq   $0x0,0x18(%rsp)
mov    %rsp,%rdi
call   1040 <run_exec_process@plt>
test   %rax,%rax
je     1202 <format_ext3_device+0xe2>
lea    0xe37(%rip),%rdi
jmp    11b4 <format_ext3_device+0x94>
xor    %eax,%eax
jmp    11be <format_ext3_device+0x9e>

LLVM IR (-O0):
@.str = [13 x i8] c"/sbin/mke2fs\00"
@.str.1 = [3 x i8] c"-j\00"
@.str.2 = [3 x i8] c"-q\00"
@.str.3 = [14 x i8] c"/sbin/tune2fs\00"
@.str.4 = [3 x i8] c"-C\00"
@.str.5 = [2 x i8] c"1\00"
@.str.6 = [30 x i8] c"failure while running mke2fs\0A\00"
@.str.7 = [13 x i8] c"/sbin/e2fsck\00"
@.str.8 = [4 x i8] c"-fy\00"
@.str.9 = [30 x i8] c"failure while running e2fsck\0A\00"
define i32 @format_ext3_device(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [5 x i8*]
%5 = alloca [5 x i8*]
%6 = alloca [4 x i8*]
store i8* %0, i8** %3
%7 = getelementptr inbounds [5 x i8*], [5 x i8*]* %4, i64 0, i64 0
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8** %7
%8 = getelementptr inbounds i8*, i8** %7, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %8
%9 = getelementptr inbounds i8*, i8** %8, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** %9
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %3
store i8* %11, i8** %10
%12 = getelementptr inbounds i8*, i8** %10, i64 1
store i8* null, i8** %12
%13 = getelementptr inbounds [5 x i8*], [5 x i8*]* %5, i64 0, i64 0
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8** %13
%14 = getelementptr inbounds i8*, i8** %13, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8** %14
%15 = getelementptr inbounds i8*, i8** %14, i64 1
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8** %15
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %3
store i8* %17, i8** %16
%18 = getelementptr inbounds i8*, i8** %16, i64 1
store i8* null, i8** %18
%19 = getelementptr inbounds [5 x i8*], [5 x i8*]* %4, i64 0, i64 0
%20 = call i64 @run_exec_process(i8** %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %1
%23 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0))
store i32 -1, i32* %2
br label %42
24: ; preds = %1
%25 = getelementptr inbounds [5 x i8*], [5 x i8*]* %5, i64 0, i64 0
%26 = call i64 @run_exec_process(i8** %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %24
%29 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0))
store i32 -1, i32* %2
br label %42
30: ; preds = %24
%31 = getelementptr inbounds [4 x i8*], [4 x i8*]* %6, i64 0, i64 0
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i8** %31
%32 = getelementptr inbounds i8*, i8** %31, i64 1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8** %32
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %3
store i8* %34, i8** %33
%35 = getelementptr inbounds i8*, i8** %33, i64 1
store i8* null, i8** %35
%36 = getelementptr inbounds [4 x i8*], [4 x i8*]* %6, i64 0, i64 0
%37 = call i64 @run_exec_process(i8** %36)
%38 = icmp ne i64 %37, 0
br i1 %38, label %39, label %41
39: ; preds = %30
%40 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.9, i64 0, i64 0))
store i32 -1, i32* %2
br label %42
41: ; preds = %30
store i32 0, i32* %2
br label %42
42: ; preds = %41, %39, %28, %22
%43 = load i32, i32* %2
ret i32 %43
}

LLVM IR (-O2):
@.str = [13 x i8] c"/sbin/mke2fs\00"
@.str.1 = [3 x i8] c"-j\00"
@.str.2 = [3 x i8] c"-q\00"
@.str.3 = [14 x i8] c"/sbin/tune2fs\00"
@.str.4 = [3 x i8] c"-C\00"
@.str.5 = [2 x i8] c"1\00"
@.str.7 = [13 x i8] c"/sbin/e2fsck\00"
@.str.8 = [4 x i8] c"-fy\00"
@str = [29 x i8] c"failure while running e2fsck\00"
@str.11 = [29 x i8] c"failure while running mke2fs\00"
define i32 @format_ext3_device(i8* %0) {
%2 = alloca [5 x i8*]
%3 = alloca [5 x i8*]
%4 = alloca [4 x i8*]
%5 = bitcast [5 x i8*]* %2 to i8*
%6 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 0
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8** %6
%7 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, 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*]* %2, 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*]* %2, i64 0, i64 3
store i8* %0, i8** %9
%10 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 4
store i8* null, i8** %10
%11 = bitcast [5 x i8*]* %3 to i8*
%12 = getelementptr inbounds [5 x i8*], [5 x i8*]* %3, i64 0, i64 0
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8** %12
%13 = getelementptr inbounds [5 x i8*], [5 x i8*]* %3, i64 0, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8** %13
%14 = getelementptr inbounds [5 x i8*], [5 x i8*]* %3, i64 0, i64 2
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8** %14
%15 = getelementptr inbounds [5 x i8*], [5 x i8*]* %3, i64 0, i64 3
store i8* %0, i8** %15
%16 = getelementptr inbounds [5 x i8*], [5 x i8*]* %3, i64 0, i64 4
store i8* null, i8** %16
%17 = call i64 @run_exec_process(i8** %6)
%18 = icmp eq i64 %17, 0
br i1 %18, label %21, label %19
19: ; preds = %1
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.11, i64 0, i64 0))
br label %38
21: ; preds = %1
%22 = call i64 @run_exec_process(i8** %12)
%23 = icmp eq i64 %22, 0
br i1 %23, label %26, label %24
24: ; preds = %21
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.11, i64 0, i64 0))
br label %38
26: ; preds = %21
%27 = bitcast [4 x i8*]* %4 to i8*
%28 = getelementptr inbounds [4 x i8*], [4 x i8*]* %4, i64 0, i64 0
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i8** %28
%29 = getelementptr inbounds [4 x i8*], [4 x i8*]* %4, i64 0, i64 1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8** %29
%30 = getelementptr inbounds [4 x i8*], [4 x i8*]* %4, i64 0, i64 2
store i8* %0, i8** %30
%31 = getelementptr inbounds [4 x i8*], [4 x i8*]* %4, i64 0, i64 3
store i8* null, i8** %31
%32 = call i64 @run_exec_process(i8** %28)
%33 = icmp eq i64 %32, 0
br i1 %33, label %36, label %34
34: ; preds = %26
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
br label %36
36: ; preds = %26, %34
%37 = phi i32 [ -1, %34 ], [ 0, %26 ]
br label %38
38: ; preds = %36, %24, %19
%39 = phi i32 [ -1, %19 ], [ -1, %24 ], [ %37, %36 ]
ret i32 %39
}