#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 */
scalar_t__ run_exec_process(char *const *);
int format_ext2_device(const char *device) {
  char *const mke2fs[] = {"/sbin/mke2fs", device, NULL};
  if (run_exec_process(mke2fs))
    return -1;
  char *const tune2fs[] = {"/sbin/tune2fs", "-C", "1", device, NULL};
  if (run_exec_process(tune2fs))
    return -1;
  char *const e2fsck[] = {"/sbin/e2fsck", "-fy", device, NULL};
  if (run_exec_process(e2fsck))
    return -1;
  return 0;
}


x86 assembly (clang, -O0):
<format_ext2_device>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xeda(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x20(%rbp)
lea    -0x30(%rbp),%rdi
call   1030 <run_exec_process@plt>
cmp    $0x0,%rax
je     1159 <format_ext2_device+0x49>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f5 <format_ext2_device+0xe5>
lea    0xead(%rip),%rax
mov    %rax,-0x60(%rbp)
lea    0xeb0(%rip),%rax
mov    %rax,-0x58(%rbp)
lea    0xea8(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x48(%rbp)
movq   $0x0,-0x40(%rbp)
lea    -0x60(%rbp),%rdi
call   1030 <run_exec_process@plt>
cmp    $0x0,%rax
je     11a9 <format_ext2_device+0x99>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f5 <format_ext2_device+0xe5>
lea    0xe70(%rip),%rax
mov    %rax,-0x80(%rbp)
lea    0xe72(%rip),%rax
mov    %rax,-0x78(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x70(%rbp)
movq   $0x0,-0x68(%rbp)
lea    -0x80(%rbp),%rdi
call   1030 <run_exec_process@plt>
cmp    $0x0,%rax
je     11ee <format_ext2_device+0xde>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f5 <format_ext2_device+0xe5>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<format_ext2_device>:
push   %rbx
sub    $0x70,%rsp
mov    %rdi,%rbx
lea    0xee1(%rip),%rax
mov    %rax,(%rsp)
mov    %rdi,0x8(%rsp)
movq   $0x0,0x10(%rsp)
mov    %rsp,%rdi
call   1030 <run_exec_process@plt>
mov    %rax,%rcx
mov    $0xffffffff,%eax
test   %rcx,%rcx
jne    11c4 <format_ext2_device+0xb4>
lea    0xec0(%rip),%rax
mov    %rax,0x40(%rsp)
lea    0xec2(%rip),%rax
mov    %rax,0x48(%rsp)
lea    0xeb9(%rip),%rax
mov    %rax,0x50(%rsp)
mov    %rbx,0x58(%rsp)
movq   $0x0,0x60(%rsp)
lea    0x40(%rsp),%rdi
call   1030 <run_exec_process@plt>
mov    %rax,%rcx
mov    $0xffffffff,%eax
test   %rcx,%rcx
jne    11c4 <format_ext2_device+0xb4>
lea    0xe8a(%rip),%rax
mov    %rax,0x20(%rsp)
lea    0xe8b(%rip),%rax
mov    %rax,0x28(%rsp)
mov    %rbx,0x30(%rsp)
movq   $0x0,0x38(%rsp)
lea    0x20(%rsp),%rdi
call   1030 <run_exec_process@plt>
neg    %rax
sbb    %eax,%eax
add    $0x70,%rsp
pop    %rbx
ret

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

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