#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*/ close(int);
int /*<<< orphan*/ destroy_cpuset(char *, int);
int open_cpuset(char *, char *);
int /*<<< orphan*/ write(int, char *, int);
void teardown(void) {
  int fd;
  fd = open_cpuset("/sys/fs/cgroup"
                   "/cpuset",
                   "cpuset.cpu_exclusive");
  if (fd >= 0) {
    write(fd, "0", 2);
    close(fd);
  }
  fd = open_cpuset("/sys/fs/cgroup"
                   "/cpuset",
                   "cpuset.sched_load_balance");
  if (fd >= 0) {
    write(fd, "1", 2);
    close(fd);
  }
  destroy_cpuset("my_cpuset_all", 0);
  destroy_cpuset("my_cpuset", 1);
}


x86 assembly (clang, -O0):
<teardown>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
lea    0xec0(%rip),%rsi
call   1060 <open_cpuset@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jl     1184 <teardown+0x44>
mov    -0x4(%rbp),%edi
lea    0xeb9(%rip),%rsi
mov    $0x2,%edx
call   1030 <write@plt>
mov    -0x4(%rbp),%edi
call   1040 <close@plt>
lea    0xe75(%rip),%rdi
lea    0xe9b(%rip),%rsi
call   1060 <open_cpuset@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jl     11c0 <teardown+0x80>
mov    -0x4(%rbp),%edi
lea    0xe99(%rip),%rsi
mov    $0x2,%edx
call   1030 <write@plt>
mov    -0x4(%rbp),%edi
call   1040 <close@plt>
lea    0xe82(%rip),%rdi
xor    %esi,%esi
call   1050 <destroy_cpuset@plt>
lea    0xe82(%rip),%rdi
mov    $0x1,%esi
call   1050 <destroy_cpuset@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<teardown>:
push   %rbx
lea    0xeb8(%rip),%rdi
lea    0xec7(%rip),%rsi
call   1060 <open_cpuset@plt>
test   %eax,%eax
js     1174 <teardown+0x34>
mov    %eax,%ebx
lea    0xeca(%rip),%rsi
mov    %eax,%edi
mov    $0x2,%edx
call   1030 <write@plt>
mov    %ebx,%edi
call   1040 <close@plt>
lea    0xe85(%rip),%rdi
lea    0xeab(%rip),%rsi
call   1060 <open_cpuset@plt>
test   %eax,%eax
js     11a7 <teardown+0x67>
mov    %eax,%ebx
lea    0xeb3(%rip),%rsi
mov    %eax,%edi
mov    $0x2,%edx
call   1030 <write@plt>
mov    %ebx,%edi
call   1040 <close@plt>
lea    0xe9b(%rip),%rdi
xor    %esi,%esi
call   1050 <destroy_cpuset@plt>
lea    0xe9b(%rip),%rdi
mov    $0x1,%esi
pop    %rbx
jmp    1050 <destroy_cpuset@plt>

LLVM IR (-O0):
@.str = [22 x i8] c"/sys/fs/cgroup/cpuset\00"
@.str.1 = [21 x i8] c"cpuset.cpu_exclusive\00"
@.str.2 = [2 x i8] c"0\00"
@.str.3 = [26 x i8] c"cpuset.sched_load_balance\00"
@.str.4 = [2 x i8] c"1\00"
@.str.5 = [14 x i8] c"my_cpuset_all\00"
@.str.6 = [10 x i8] c"my_cpuset\00"
define void @teardown() {
%1 = alloca i32
%2 = call i32 @open_cpuset(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
store i32 %2, i32* %1
%3 = load i32, i32* %1
%4 = icmp sge i32 %3, 0
br i1 %4, label %5, label %10
5: ; preds = %0
%6 = load i32, i32* %1
%7 = call i32 @write(i32 %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 2)
%8 = load i32, i32* %1
%9 = call i32 @close(i32 %8)
br label %10
10: ; preds = %5, %0
%11 = call i32 @open_cpuset(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
store i32 %11, i32* %1
%12 = load i32, i32* %1
%13 = icmp sge i32 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %10
%15 = load i32, i32* %1
%16 = call i32 @write(i32 %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 2)
%17 = load i32, i32* %1
%18 = call i32 @close(i32 %17)
br label %19
19: ; preds = %14, %10
%20 = call i32 @destroy_cpuset(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 0)
%21 = call i32 @destroy_cpuset(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32 1)
ret void
}

LLVM IR (-O2):
@.str = [22 x i8] c"/sys/fs/cgroup/cpuset\00"
@.str.1 = [21 x i8] c"cpuset.cpu_exclusive\00"
@.str.2 = [2 x i8] c"0\00"
@.str.3 = [26 x i8] c"cpuset.sched_load_balance\00"
@.str.4 = [2 x i8] c"1\00"
@.str.5 = [14 x i8] c"my_cpuset_all\00"
@.str.6 = [10 x i8] c"my_cpuset\00"
define void @teardown() {
%1 = tail call i32 @open_cpuset(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%2 = icmp sgt i32 %1, -1
br i1 %2, label %3, label %6
3: ; preds = %0
%4 = tail call i32 @write(i32 %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 2)
%5 = tail call i32 @close(i32 %1)
br label %6
6: ; preds = %3, %0
%7 = tail call i32 @open_cpuset(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%8 = icmp sgt i32 %7, -1
br i1 %8, label %9, label %12
9: ; preds = %6
%10 = tail call i32 @write(i32 %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 2)
%11 = tail call i32 @close(i32 %7)
br label %12
12: ; preds = %9, %6
%13 = tail call i32 @destroy_cpuset(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 0)
%14 = tail call i32 @destroy_cpuset(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32 1)
ret void
}