#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*/ pid_t;

/* Variables and functions */
int /*<<< orphan*/ bandwidth_pid(int /*<<< orphan*/, char const *, char const *,
                                 int, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ name2pid(char const *, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
scalar_t__ strlen(char const *);
void bandwidth_name(const char *name, const char *command, const char *dev,
                    int down, int up) {
  if (!name || strlen(name) == 0) {
    fprintf(stderr, "Error: invalid sandbox name\n");
    exit(1);
  }
  pid_t pid;
  if (name2pid(name, &pid)) {
    fprintf(stderr, "Error: cannot find sandbox %s\n", name);
    exit(1);
  }
  bandwidth_pid(pid, command, dev, down, up);
}


x86 assembly (clang, -O0):
<bandwidth_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1189 <bandwidth_name+0x39>
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%rax
jne    11aa <bandwidth_name+0x5a>
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
lea    0xe67(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x8(%rbp),%rdi
lea    -0x24(%rbp),%rsi
call   1070 <name2pid@plt>
cmp    $0x0,%rax
je     11e6 <bandwidth_name+0x96>
mov    0x2e18(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe48(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x24(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
call   1040 <bandwidth_pid@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bandwidth_name>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
test   %rdi,%rdi
je     1199 <bandwidth_name+0x59>
mov    %rdi,%rbx
cmpb   $0x0,(%rdi)
je     1199 <bandwidth_name+0x59>
mov    %r8d,%r14d
mov    %ecx,%r15d
mov    %rdx,%r12
mov    %rsi,%rbp
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <name2pid@plt>
test   %rax,%rax
jne    11ba <bandwidth_name+0x7a>
mov    0xc(%rsp),%edi
mov    %rbp,%rsi
mov    %r12,%rdx
mov    %r15d,%ecx
mov    %r14d,%r8d
call   1030 <bandwidth_pid@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2e40(%rip),%rax
mov    (%rax),%edi
lea    0xe57(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    0x2e1f(%rip),%rax
mov    (%rax),%edi
lea    0xe53(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [29 x i8] c"Error: invalid sandbox name\0A\00"
@.str.1 = [31 x i8] c"Error: cannot find sandbox %s\0A\00"
define void @bandwidth_name(i8* %0, i8* %1, i8* %2, i32 %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%12 = load i8*, i8** %6
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %18
14: ; preds = %5
%15 = load i8*, i8** %6
%16 = call i64 @strlen(i8* %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %14, %5
%19 = load i32, i32* @stderr
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%21 = call i32 @exit(i32 1)
unreachable
22: ; preds = %14
%23 = load i8*, i8** %6
%24 = call i64 @name2pid(i8* %23, i32* %11)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %31
26: ; preds = %22
%27 = load i32, i32* @stderr
%28 = load i8*, i8** %6
%29 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %28)
%30 = call i32 @exit(i32 1)
unreachable
31: ; preds = %22
%32 = load i32, i32* %11
%33 = load i8*, i8** %7
%34 = load i8*, i8** %8
%35 = load i32, i32* %9
%36 = load i32, i32* %10
%37 = call i32 @bandwidth_pid(i32 %32, i8* %33, i8* %34, i32 %35, i32 %36)
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [29 x i8] c"Error: invalid sandbox name\0A\00"
@.str.1 = [31 x i8] c"Error: cannot find sandbox %s\0A\00"
define void @bandwidth_name(i8* %0, i8* %1, i8* %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = icmp eq i8* %0, null
br i1 %7, label %11, label %8
8: ; preds = %5
%9 = load i8, i8* %0
%10 = icmp eq i8 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %8, %5
%12 = load i32, i32* @stderr
%13 = tail call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%14 = tail call i32 @exit(i32 1)
unreachable
15: ; preds = %8
%16 = bitcast i32* %6 to i8*
%17 = call i64 @name2pid(i8* %0, i32* %6)
%18 = icmp eq i64 %17, 0
br i1 %18, label %23, label %19
19: ; preds = %15
%20 = load i32, i32* @stderr
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %15
%24 = load i32, i32* %6
%25 = call i32 @bandwidth_pid(i32 %24, i8* %1, i8* %2, i32 %3, i32 %4)
ret void
}