#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*/ SYS_gettid;
int /*<<< orphan*/ mkdir(char *, int);
int /*<<< orphan*/ sprintf(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ syscall(int /*<<< orphan*/);
int /*<<< orphan*/ system(char *);
int main(void) {
  char cmd[128];
  mkdir("/sys/fs/cgroup/blkio/zz", 755);
  system("echo '8:0 1048576'  > "
         "/sys/fs/cgroup/blkio/zz/blkio.throttle.read_bps_device");
  sprintf(cmd, "echo %ld >> /sys/fs/cgroup/blkio/zz/tasks ",
          syscall(SYS_gettid));
  system(cmd);
  system("sudo dd if=/dev/sda1 of=/dev/null");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xea7(%rip),%rdi
mov    $0x2f3,%esi
call   1030 <mkdir@plt>
lea    0xeae(%rip),%rdi
call   1040 <system@plt>
lea    -0x90(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    0x2e64(%rip),%rax
mov    (%rax),%edi
call   1050 <syscall@plt>
mov    -0x98(%rbp),%rdi
mov    %eax,%edx
lea    0xeca(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x90(%rbp),%rdi
call   1040 <system@plt>
lea    0xedd(%rip),%rdi
call   1040 <system@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x80,%rsp
lea    0xeb1(%rip),%rdi
mov    $0x2f3,%esi
call   1030 <mkdir@plt>
lea    0xeb8(%rip),%rdi
call   1040 <system@plt>
mov    0x2e7c(%rip),%rax
mov    (%rax),%edi
call   1050 <syscall@plt>
lea    0xeeb(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %eax,%edx
call   1060 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
lea    0xefa(%rip),%rdi
call   1040 <system@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [24 x i8] c"/sys/fs/cgroup/blkio/zz\00"
@.str.1 = [77 x i8] c"echo '8:0 1048576' > /sys/fs/cgroup/blkio/zz/blkio.throttle.read_bps_device\00"
@.str.2 = [43 x i8] c"echo %ld >> /sys/fs/cgroup/blkio/zz/tasks \00"
@SYS_gettid = global i32 0
@.str.3 = [34 x i8] c"sudo dd if=/dev/sda1 of=/dev/null\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [128 x i8]
store i32 0, i32* %1
%3 = call i32 @mkdir(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 755)
%4 = call i32 @system(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.1, i64 0, i64 0))
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%6 = load i32, i32* @SYS_gettid
%7 = call i32 @syscall(i32 %6)
%8 = call i32 @sprintf(i8* %5, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i32 %7)
%9 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%10 = call i32 @system(i8* %9)
%11 = call i32 @system(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [24 x i8] c"/sys/fs/cgroup/blkio/zz\00"
@.str.1 = [77 x i8] c"echo '8:0 1048576' > /sys/fs/cgroup/blkio/zz/blkio.throttle.read_bps_device\00"
@.str.2 = [43 x i8] c"echo %ld >> /sys/fs/cgroup/blkio/zz/tasks \00"
@SYS_gettid = global i32 0
@.str.3 = [34 x i8] c"sudo dd if=/dev/sda1 of=/dev/null\00"
define i32 @main() {
%1 = alloca [128 x i8]
%2 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @mkdir(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 755)
%4 = tail call i32 @system(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.1, i64 0, i64 0))
%5 = load i32, i32* @SYS_gettid
%6 = tail call i32 @syscall(i32 %5)
%7 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i32 %6)
%8 = call i32 @system(i8* %2)
%9 = tail call i32 @system(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}