#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*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char *, ...);
scalar_t__ system(char *);
int tc_start() {
  char *cmd;
  cmd = malloc(sizeof "/sbin/tc" + sizeof "eth0" + sizeof "10Mbit" + 64 + 1);
  if (cmd == NULL)
    return 1;
  snprintf(
      cmd, (sizeof "/sbin/tc" + sizeof "eth0" + sizeof "10Mbit" + 64 + 1),
      "%s qdisc add dev %s root handle 1:0 cbq bandwidth %s avpkt 1000 mpu 64",
      "/sbin/tc", "eth0", "10Mbit");
  if (system(cmd)) {
    free(cmd);
    return 1;
  }
  cmd = malloc(sizeof "/sbin/tc" + sizeof "eth0" + sizeof "10Mbit" + 128 + 1);
  if (cmd == NULL)
    return 1;
  snprintf(
      cmd, (sizeof "/sbin/tc" + sizeof "eth0" + sizeof "10Mbit" + 128 + 1),
      "%s class add dev %s parent 1:0 classid 1:1 cbq bandwidth %s rate "
      "1.0Mbit weight 100Kbit prio 8 maxburst 20 avpkt 1000 bounded isolated",
      "/sbin/tc", "eth0", "10Mbit");
  if (system(cmd)) {
    free(cmd);
    return 1;
  }
  cmd = malloc(sizeof "/sbin/tc" + sizeof "eth0" + sizeof "10Mbit" +
               sizeof "1Kbit" + sizeof "1Kbit" + 106 + 1);
  if (cmd == NULL)
    return 1;
  snprintf(cmd,
           (sizeof "/sbin/tc" + sizeof "eth0" + sizeof "1Kbit" +
            sizeof "1Kbit" + sizeof "10Mbit" + 106 + 1),
           "%s class add dev %s parent 1:1 classid 1:101 cbq bandwidth %s rate "
           "%s weight %s prio 1 maxburst 1 avpkt 1000 bounded",
           "/sbin/tc", "eth0", "10Mbit", "1Kbit", "1Kbit");
  if (system(cmd)) {
    free(cmd);
    return 1;
  }
  cmd = malloc(sizeof "/sbin/tc" + sizeof "eth0" + 57 + 1);
  if (cmd == NULL)
    return 1;
  snprintf(cmd, (sizeof "/sbin/tc" + sizeof "eth0" + 57 + 1),
           "%s qdisc add dev %s parent 1:101 sfq quantum 1514b perturb 10",
           "/sbin/tc", "eth0");
  if (system(cmd)) {
    free(cmd);
    return 1;
  }
  free(cmd);
  return 0;
}


x86 assembly (clang, -O0):
<tc_start>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x56,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    116d <tc_start+0x2d>
movl   $0x1,-0x4(%rbp)
jmp    1345 <tc_start+0x205>
mov    -0x10(%rbp),%rdi
mov    $0x56,%esi
lea    0xe83(%rip),%rdx
lea    0xec3(%rip),%rcx
lea    0xec5(%rip),%r8
lea    0xec3(%rip),%r9
mov    $0x0,%al
call   1050 <snprintf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <system@plt>
cmp    $0x0,%rax
je     11c1 <tc_start+0x81>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
jmp    1345 <tc_start+0x205>
mov    $0x96,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11e6 <tc_start+0xa6>
movl   $0x1,-0x4(%rbp)
jmp    1345 <tc_start+0x205>
mov    -0x10(%rbp),%rdi
mov    $0x96,%esi
lea    0xe66(%rip),%rdx
lea    0xe4a(%rip),%rcx
lea    0xe4c(%rip),%r8
lea    0xe4a(%rip),%r9
mov    $0x0,%al
call   1050 <snprintf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <system@plt>
cmp    $0x0,%rax
je     123a <tc_start+0xfa>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
jmp    1345 <tc_start+0x205>
mov    $0x8c,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    125f <tc_start+0x11f>
movl   $0x1,-0x4(%rbp)
jmp    1345 <tc_start+0x205>
mov    -0x10(%rbp),%rdi
mov    $0x8c,%esi
lea    0xe74(%rip),%rdx
lea    0xdd1(%rip),%rcx
lea    0xdd3(%rip),%r8
lea    0xdd1(%rip),%r9
lea    0xecd(%rip),%rax
mov    %rax,(%rsp)
mov    %rax,0x8(%rsp)
mov    $0x0,%al
call   1050 <snprintf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <system@plt>
cmp    $0x0,%rax
je     12c3 <tc_start+0x183>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
jmp    1345 <tc_start+0x205>
mov    $0x48,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    12e8 <tc_start+0x1a8>
movl   $0x1,-0x4(%rbp)
jmp    1345 <tc_start+0x205>
mov    -0x10(%rbp),%rdi
mov    $0x48,%esi
lea    0xe66(%rip),%rdx
lea    0xd48(%rip),%rcx
lea    0xd4a(%rip),%r8
mov    $0x0,%al
call   1050 <snprintf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <system@plt>
cmp    $0x0,%rax
je     1335 <tc_start+0x1f5>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0x4(%rbp)
jmp    1345 <tc_start+0x205>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tc_start>:
push   %rbp
push   %r14
push   %rbx
mov    $0x56,%edi
call   1060 <malloc@plt>
mov    $0x1,%ebp
test   %rax,%rax
je     119b <tc_start+0x5b>
mov    %rax,%rbx
lea    0xe9e(%rip),%rdx
lea    0xede(%rip),%rcx
lea    0xee0(%rip),%r8
lea    0xede(%rip),%r9
mov    %rax,%rdi
mov    $0x56,%esi
xor    %eax,%eax
call   1050 <snprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
test   %rax,%rax
je     11a2 <tc_start+0x62>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    $0x96,%edi
call   1060 <malloc@plt>
test   %rax,%rax
je     119b <tc_start+0x5b>
mov    %rax,%rbx
lea    0xea1(%rip),%rdx
lea    0xe85(%rip),%rcx
lea    0xe87(%rip),%r8
lea    0xe85(%rip),%r9
mov    %rax,%rdi
mov    $0x96,%esi
xor    %eax,%eax
call   1050 <snprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
test   %rax,%rax
jne    1193 <tc_start+0x53>
mov    $0x8c,%edi
call   1060 <malloc@plt>
test   %rax,%rax
je     119b <tc_start+0x5b>
mov    %rax,%r14
lea    0xf53(%rip),%rbx
lea    0xed7(%rip),%rdx
lea    0xe34(%rip),%rcx
lea    0xe36(%rip),%r8
lea    0xe34(%rip),%r9
mov    %rax,%rdi
mov    $0x8c,%esi
xor    %eax,%eax
push   %rbx
push   %rbx
call   1050 <snprintf@plt>
add    $0x10,%rsp
mov    %r14,%rdi
call   1040 <system@plt>
test   %rax,%rax
je     124b <tc_start+0x10b>
mov    %r14,%rdi
jmp    1196 <tc_start+0x56>
mov    $0x48,%edi
call   1060 <malloc@plt>
test   %rax,%rax
je     119b <tc_start+0x5b>
mov    %rax,%rbx
lea    0xef6(%rip),%rdx
lea    0xdd8(%rip),%rcx
lea    0xdda(%rip),%r8
mov    %rax,%rdi
mov    $0x48,%esi
xor    %eax,%eax
call   1050 <snprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
xor    %ebp,%ebp
test   %rax,%rax
setne  %bpl
jmp    1193 <tc_start+0x53>

LLVM IR (-O0):
@.str = [71 x i8] c"%s qdisc add dev %s root handle 1:0 cbq bandwidth %s avpkt 1000 mpu 64\00"
@.str.1 = [9 x i8] c"/sbin/tc\00"
@.str.2 = [5 x i8] c"eth0\00"
@.str.3 = [7 x i8] c"10Mbit\00"
@.str.4 = [135 x i8] c"%s class add dev %s parent 1:0 classid 1:1 cbq bandwidth %s rate 1.0Mbit weight 100Kbit prio 8 maxburst 20 avpkt 1000 bounded isolated\00"
@.str.5 = [117 x i8] c"%s class add dev %s parent 1:1 classid 1:101 cbq bandwidth %s rate %s weight %s prio 1 maxburst 1 avpkt 1000 bounded\00"
@.str.6 = [6 x i8] c"1Kbit\00"
@.str.7 = [62 x i8] c"%s qdisc add dev %s parent 1:101 sfq quantum 1514b perturb 10\00"
define i32 @tc_start() {
%1 = alloca i32
%2 = alloca i8*
%3 = call i8* @malloc(i32 86)
store i8* %3, i8** %2
%4 = load i8*, i8** %2
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %7
6: ; preds = %0
store i32 1, i32* %1
br label %61
7: ; preds = %0
%8 = load i8*, i8** %2
%9 = call i32 (i8*, i32, i8*, i8*, i8*, ...) @snprintf(i8* %8, i32 86, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%10 = load i8*, i8** %2
%11 = call i64 @system(i8* %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %7
%14 = load i8*, i8** %2
%15 = call i32 @free(i8* %14)
store i32 1, i32* %1
br label %61
16: ; preds = %7
%17 = call i8* @malloc(i32 150)
store i8* %17, i8** %2
%18 = load i8*, i8** %2
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %21
20: ; preds = %16
store i32 1, i32* %1
br label %61
21: ; preds = %16
%22 = load i8*, i8** %2
%23 = call i32 (i8*, i32, i8*, i8*, i8*, ...) @snprintf(i8* %22, i32 150, i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%24 = load i8*, i8** %2
%25 = call i64 @system(i8* %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %21
%28 = load i8*, i8** %2
%29 = call i32 @free(i8* %28)
store i32 1, i32* %1
br label %61
30: ; preds = %21
%31 = call i8* @malloc(i32 140)
store i8* %31, i8** %2
%32 = load i8*, i8** %2
%33 = icmp eq i8* %32, null
br i1 %33, label %34, label %35
34: ; preds = %30
store i32 1, i32* %1
br label %61
35: ; preds = %30
%36 = load i8*, i8** %2
%37 = call i32 (i8*, i32, i8*, i8*, i8*, ...) @snprintf(i8* %36, i32 140, i8* getelementptr inbounds ([117 x i8], [117 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%38 = load i8*, i8** %2
%39 = call i64 @system(i8* %38)
%40 = icmp ne i64 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %35
%42 = load i8*, i8** %2
%43 = call i32 @free(i8* %42)
store i32 1, i32* %1
br label %61
44: ; preds = %35
%45 = call i8* @malloc(i32 72)
store i8* %45, i8** %2
%46 = load i8*, i8** %2
%47 = icmp eq i8* %46, null
br i1 %47, label %48, label %49
48: ; preds = %44
store i32 1, i32* %1
br label %61
49: ; preds = %44
%50 = load i8*, i8** %2
%51 = call i32 (i8*, i32, i8*, i8*, i8*, ...) @snprintf(i8* %50, i32 72, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%52 = load i8*, i8** %2
%53 = call i64 @system(i8* %52)
%54 = icmp ne i64 %53, 0
br i1 %54, label %55, label %58
55: ; preds = %49
%56 = load i8*, i8** %2
%57 = call i32 @free(i8* %56)
store i32 1, i32* %1
br label %61
58: ; preds = %49
%59 = load i8*, i8** %2
%60 = call i32 @free(i8* %59)
store i32 0, i32* %1
br label %61
61: ; preds = %58, %55, %48, %41, %34, %27, %20, %13, %6
%62 = load i32, i32* %1
ret i32 %62
}

LLVM IR (-O2):
@.str = [71 x i8] c"%s qdisc add dev %s root handle 1:0 cbq bandwidth %s avpkt 1000 mpu 64\00"
@.str.1 = [9 x i8] c"/sbin/tc\00"
@.str.2 = [5 x i8] c"eth0\00"
@.str.3 = [7 x i8] c"10Mbit\00"
@.str.4 = [135 x i8] c"%s class add dev %s parent 1:0 classid 1:1 cbq bandwidth %s rate 1.0Mbit weight 100Kbit prio 8 maxburst 20 avpkt 1000 bounded isolated\00"
@.str.5 = [117 x i8] c"%s class add dev %s parent 1:1 classid 1:101 cbq bandwidth %s rate %s weight %s prio 1 maxburst 1 avpkt 1000 bounded\00"
@.str.6 = [6 x i8] c"1Kbit\00"
@.str.7 = [62 x i8] c"%s qdisc add dev %s parent 1:101 sfq quantum 1514b perturb 10\00"
define i32 @tc_start() {
%1 = tail call dereferenceable_or_null(86) i8* @malloc(i32 86)
%2 = icmp eq i8* %1, null
br i1 %2, label %36, label %3
3: ; preds = %0
%4 = tail call i32 (i8*, i32, i8*, i8*, i8*, ...) @snprintf(i8* %1, i32 86, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%5 = tail call i64 @system(i8* %1)
%6 = icmp eq i64 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %3
%8 = tail call i32 @free(i8* %1)
br label %36
9: ; preds = %3
%10 = tail call dereferenceable_or_null(150) i8* @malloc(i32 150)
%11 = icmp eq i8* %10, null
br i1 %11, label %36, label %12
12: ; preds = %9
%13 = tail call i32 (i8*, i32, i8*, i8*, i8*, ...) @snprintf(i8* %10, i32 150, i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%14 = tail call i64 @system(i8* %10)
%15 = icmp eq i64 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %12
%17 = tail call i32 @free(i8* %10)
br label %36
18: ; preds = %12
%19 = tail call dereferenceable_or_null(140) i8* @malloc(i32 140)
%20 = icmp eq i8* %19, null
br i1 %20, label %36, label %21
21: ; preds = %18
%22 = tail call i32 (i8*, i32, i8*, i8*, i8*, ...) @snprintf(i8* %19, i32 140, i8* getelementptr inbounds ([117 x i8], [117 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%23 = tail call i64 @system(i8* %19)
%24 = icmp eq i64 %23, 0
br i1 %24, label %27, label %25
25: ; preds = %21
%26 = tail call i32 @free(i8* %19)
br label %36
27: ; preds = %21
%28 = tail call dereferenceable_or_null(72) i8* @malloc(i32 72)
%29 = icmp eq i8* %28, null
br i1 %29, label %36, label %30
30: ; preds = %27
%31 = tail call i32 (i8*, i32, i8*, i8*, i8*, ...) @snprintf(i8* %28, i32 72, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%32 = tail call i64 @system(i8* %28)
%33 = icmp ne i64 %32, 0
%34 = tail call i32 @free(i8* %28)
%35 = zext i1 %33 to i32
br label %36
36: ; preds = %30, %27, %18, %9, %0, %25, %16, %7
%37 = phi i32 [ 1, %7 ], [ 1, %16 ], [ 1, %25 ], [ 1, %0 ], [ 1, %9 ], [ 1, %18 ], [ 1, %27 ], [ %35, %30 ]
ret i32 %37
}