#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 */
char *calloc(int, scalar_t__);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcat(char *, char const *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char const *);
int system(char *);
bool db_shred(const char *path) {
  char *command = "shred -f -z -u ";
  char *run = NULL;
  int ret = -1;
  run = calloc(1, (strlen(path) + strlen(command)) + 1);
  if (run == NULL) {
    fprintf(stderr, "Malloc failed.\n");
    return false;
  }
  strcpy(run, command);
  strcat(run, path);
  ret = system(run);
  if (ret != 0) {
    fprintf(stderr, "Unable to run command shred. Aborting.\n");
    free(run);
    return false;
  }
  free(run);
  return true;
}


x86 assembly (clang, -O0):
<db_shred>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xe7d(%rip),%rax
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0xffffffff,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x30(%rbp),%rsi
add    %rax,%rsi
add    $0x1,%rsi
mov    $0x1,%edi
call   1070 <calloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11f1 <db_shred+0x81>
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
lea    0xe30(%rip),%rsi
call   1080 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    125b <db_shred+0xeb>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1090 <strcat@plt>
mov    -0x20(%rbp),%rdi
call   1060 <system@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     124b <db_shred+0xdb>
mov    0x2db8(%rip),%rax
mov    (%rax),%edi
lea    0xdef(%rip),%rsi
call   1080 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
jmp    125b <db_shred+0xeb>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<db_shred>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1050 <strlen@plt>
lea    0x10(%rax),%rsi
mov    $0x1,%edi
call   1070 <calloc@plt>
test   %rax,%rax
je     11d9 <db_shred+0x69>
mov    %rax,%rbx
lea    0xe67(%rip),%rsi
mov    %rax,%rdi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1090 <strcat@plt>
mov    %rbx,%rdi
call   1060 <system@plt>
test   %eax,%eax
je     11f2 <db_shred+0x82>
mov    0x2e21(%rip),%rax
mov    (%rax),%edi
lea    0xe58(%rip),%rsi
call   1080 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
jmp    11ff <db_shred+0x8f>
mov    0x2e00(%rip),%rax
mov    (%rax),%edi
lea    0xe27(%rip),%rsi
call   1080 <fprintf@plt>
xor    %eax,%eax
jmp    11ff <db_shred+0x8f>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [16 x i8] c"shred -f -z -u \00"
@stderr = global i32 0
@.str.1 = [16 x i8] c"Malloc failed.\0A\00"
@.str.2 = [40 x i8] c"Unable to run command shred. Aborting.\0A\00"
define i32 @db_shred(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %3
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8** %4
store i8* null, i8** %5
store i32 -1, i32* %6
%7 = load i8*, i8** %3
%8 = call i64 @strlen(i8* %7)
%9 = load i8*, i8** %4
%10 = call i64 @strlen(i8* %9)
%11 = add nsw i64 %8, %10
%12 = add nsw i64 %11, 1
%13 = call i8* @calloc(i32 1, i64 %12)
store i8* %13, i8** %5
%14 = load i8*, i8** %5
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %19
16: ; preds = %1
%17 = load i32, i32* @stderr
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %2
br label %38
19: ; preds = %1
%20 = load i8*, i8** %5
%21 = load i8*, i8** %4
%22 = call i32 @strcpy(i8* %20, i8* %21)
%23 = load i8*, i8** %5
%24 = load i8*, i8** %3
%25 = call i32 @strcat(i8* %23, i8* %24)
%26 = load i8*, i8** %5
%27 = call i32 @system(i8* %26)
store i32 %27, i32* %6
%28 = load i32, i32* %6
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %35
30: ; preds = %19
%31 = load i32, i32* @stderr
%32 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
%33 = load i8*, i8** %5
%34 = call i32 @free(i8* %33)
store i32 0, i32* %2
br label %38
35: ; preds = %19
%36 = load i8*, i8** %5
%37 = call i32 @free(i8* %36)
store i32 1, i32* %2
br label %38
38: ; preds = %35, %30, %16
%39 = load i32, i32* %2
ret i32 %39
}

LLVM IR (-O2):
@.str = [16 x i8] c"shred -f -z -u \00"
@stderr = global i32 0
@.str.1 = [16 x i8] c"Malloc failed.\0A\00"
@.str.2 = [40 x i8] c"Unable to run command shred. Aborting.\0A\00"
define i32 @db_shred(i8* %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = add nsw i64 %2, 16
%4 = tail call i8* @calloc(i32 1, i64 %3)
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %9
6: ; preds = %1
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
br label %20
9: ; preds = %1
%10 = tail call i32 @strcpy(i8* %4, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%11 = tail call i32 @strcat(i8* %4, i8* %0)
%12 = tail call i32 @system(i8* %4)
%13 = icmp eq i32 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %9
%15 = load i32, i32* @stderr
%16 = tail call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0))
%17 = tail call i32 @free(i8* %4)
br label %20
18: ; preds = %9
%19 = tail call i32 @free(i8* %4)
br label %20
20: ; preds = %18, %14, %6
%21 = phi i32 [ 0, %6 ], [ 0, %14 ], [ 1, %18 ]
ret i32 %21
}