#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*/ execl(char *, char *, char *, char *, char *, char *,
                         int /*<<< orphan*/ *);
scalar_t__ fork();
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ wait(int /*<<< orphan*/ *);
int shred(char *filename, int upToByte) {
  if (fork() == 0) {
    char bytes[10];
    sprintf(bytes, "%u", upToByte);
    execl("/usr/bin/shred", "/usr/bin/shred", filename, "-z", "-s", bytes,
          NULL);
  } else {
    wait(NULL);
    return 0;
  }
}


x86 assembly (clang, -O0):
<shred>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    $0x0,%al
call   1060 <fork@plt>
cmp    $0x0,%rax
jne    11a7 <shred+0x67>
lea    -0x1e(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xe92(%rip),%rsi
call   1030 <sprintf@plt>
mov    -0x10(%rbp),%rdx
lea    -0x1e(%rbp),%r9
lea    0xe81(%rip),%rsi
lea    0xe89(%rip),%rcx
lea    0xe85(%rip),%r8
xor    %eax,%eax
mov    %rsi,%rdi
movq   $0x0,(%rsp)
call   1040 <execl@plt>
jmp    11b7 <shred+0x77>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <wait@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shred>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %esi,%ebp
mov    %rdi,%rbx
xor    %eax,%eax
call   1060 <fork@plt>
test   %rax,%rax
je     1162 <shred+0x22>
xor    %edi,%edi
call   1050 <wait@plt>
jmp    11a3 <shred+0x63>
lea    0xe97(%rip),%rsi
lea    0x16(%rsp),%r14
mov    %r14,%rdi
mov    %ebp,%edx
call   1030 <sprintf@plt>
movq   $0x0,(%rsp)
lea    0xe7c(%rip),%rdi
lea    0xe84(%rip),%rcx
lea    0xe80(%rip),%r8
mov    %rdi,%rsi
mov    %rbx,%rdx
mov    %r14,%r9
call   1040 <execl@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%u\00"
@.str.1 = [15 x i8] c"/usr/bin/shred\00"
@.str.2 = [3 x i8] c"-z\00"
@.str.3 = [3 x i8] c"-s\00"
define i32 @shred(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca [10 x i8]
store i8* %0, i8** %4
store i32 %1, i32* %5
%7 = call i64 (...) @fork()
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %16
9: ; preds = %2
%10 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%11 = load i32, i32* %5
%12 = call i32 @sprintf(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = load i8*, i8** %4
%14 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%15 = call i32 @execl(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %14, i32* null)
br label %18
16: ; preds = %2
%17 = call i32 @wait(i32* null)
store i32 0, i32* %3
br label %18
18: ; preds = %16, %9
%19 = load i32, i32* %3
ret i32 %19
}

LLVM IR (-O2):
@.str = [3 x i8] c"%u\00"
@.str.1 = [15 x i8] c"/usr/bin/shred\00"
@.str.2 = [3 x i8] c"-z\00"
@.str.3 = [3 x i8] c"-s\00"
define i32 @shred(i8* %0, i32 %1) {
%3 = alloca [10 x i8]
%4 = tail call i64 (...) @fork()
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%8 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %1)
%9 = call i32 @execl(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %7, i32* null)
br label %12
10: ; preds = %2
%11 = tail call i32 @wait(i32* null)
br label %12
12: ; preds = %10, %6
ret i32 0
}