#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 execute(char *, char const *, ...);
int tc_attach_download_qdisc(const char dev[], const char ifb_dev[],
                             int download_limit) {
  int rc = 0;
  execute("tc qdisc del dev %s root", dev);
  rc |= execute("tc qdisc add dev %s root handle 1: hfsc default 2", dev);
  rc |= execute("tc class add dev %s parent 1: classid 1:1 hfsc sc rate %dkbit "
                "ul rate %dkbit",
                dev, download_limit, download_limit);
  rc |= execute("tc class add dev %s parent 1:1 classid 1:2 hfsc sc rate "
                "%dkbit ul rate %dkbit",
                dev, download_limit / 10, download_limit / 10);
  return rc;
}


x86 assembly (clang, -O0):
<tc_attach_download_qdisc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1030 <execute@plt>
mov    -0x8(%rbp),%rsi
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1030 <execute@plt>
or     -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xee6(%rip),%rdi
mov    $0x0,%al
call   1030 <execute@plt>
or     -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x1c(%rbp),%edx
mov    %eax,%ecx
lea    0xefd(%rip),%rdi
mov    $0x0,%al
call   1030 <execute@plt>
or     -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tc_attach_download_qdisc>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %rdi,%rbx
lea    0xedc(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <execute@plt>
lea    0xee4(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <execute@plt>
mov    %eax,%r14d
lea    0xf02(%rip),%rdi
mov    %rbx,%rsi
mov    %r15d,%edx
mov    %r15d,%ecx
xor    %eax,%eax
call   1030 <execute@plt>
mov    %eax,%ebp
or     %r14d,%ebp
movslq %r15d,%rax
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rax
shr    $0x3f,%rax
sar    $0x22,%rcx
add    %eax,%ecx
lea    0xf1c(%rip),%rdi
mov    %rbx,%rsi
mov    %ecx,%edx
xor    %eax,%eax
call   1030 <execute@plt>
or     %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"tc qdisc del dev %s root\00"
@.str.1 = [50 x i8] c"tc qdisc add dev %s root handle 1: hfsc default 2\00"
@.str.2 = [77 x i8] c"tc class add dev %s parent 1: classid 1:1 hfsc sc rate %dkbit ul rate %dkbit\00"
@.str.3 = [78 x i8] c"tc class add dev %s parent 1:1 classid 1:2 hfsc sc rate %dkbit ul rate %dkbit\00"
define i32 @tc_attach_download_qdisc(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
store i32 0, i32* %7
%8 = load i8*, i8** %4
%9 = call i32 (i8*, i8*, ...) @execute(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = load i8*, i8** %4
%11 = call i32 (i8*, i8*, ...) @execute(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = load i32, i32* %7
%13 = or i32 %12, %11
store i32 %13, i32* %7
%14 = load i8*, i8** %4
%15 = load i32, i32* %6
%16 = load i32, i32* %6
%17 = call i32 (i8*, i8*, ...) @execute(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.2, i64 0, i64 0), i8* %14, i32 %15, i32 %16)
%18 = load i32, i32* %7
%19 = or i32 %18, %17
store i32 %19, i32* %7
%20 = load i8*, i8** %4
%21 = load i32, i32* %6
%22 = sdiv i32 %21, 10
%23 = load i32, i32* %6
%24 = sdiv i32 %23, 10
%25 = call i32 (i8*, i8*, ...) @execute(i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str.3, i64 0, i64 0), i8* %20, i32 %22, i32 %24)
%26 = load i32, i32* %7
%27 = or i32 %26, %25
store i32 %27, i32* %7
%28 = load i32, i32* %7
ret i32 %28
}

LLVM IR (-O2):
@.str = [25 x i8] c"tc qdisc del dev %s root\00"
@.str.1 = [50 x i8] c"tc qdisc add dev %s root handle 1: hfsc default 2\00"
@.str.2 = [77 x i8] c"tc class add dev %s parent 1: classid 1:1 hfsc sc rate %dkbit ul rate %dkbit\00"
@.str.3 = [78 x i8] c"tc class add dev %s parent 1:1 classid 1:2 hfsc sc rate %dkbit ul rate %dkbit\00"
define i32 @tc_attach_download_qdisc(i8* %0, i8* nocapture readnone %1, i32 %2) {
%4 = tail call i32 (i8*, i8*, ...) @execute(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %0)
%5 = tail call i32 (i8*, i8*, ...) @execute(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%6 = tail call i32 (i8*, i8*, ...) @execute(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.2, i64 0, i64 0), i8* %0, i32 %2, i32 %2)
%7 = or i32 %6, %5
%8 = sdiv i32 %2, 10
%9 = tail call i32 (i8*, i8*, ...) @execute(i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str.3, i64 0, i64 0), i8* %0, i32 %8, i32 %8)
%10 = or i32 %7, %9
ret i32 %10
}