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

/* Variables and functions */
int /*<<< orphan*/ PATH_MAX;
int join_cgroup_from_top(char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char *);
int join_classid(void) {
  char cgroup_workdir[PATH_MAX + 1];
  snprintf(cgroup_workdir, sizeof(cgroup_workdir), "%s%s",
           "/sys/fs/cgroup"
           "/net_cls",
           "/cgroup-test-work-dir");
  return join_cgroup_from_top(cgroup_workdir);
}


x86 assembly (clang, -O0):
<join_classid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0x2ec1(%rip),%rax
mov    (%rax),%eax
add    $0x1,%eax
mov    %rsp,%rcx
mov    %rcx,-0x8(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x18(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x10(%rbp)
mov    %eax,%esi
lea    0xea0(%rip),%rdx
lea    0xe9e(%rip),%rcx
lea    0xeae(%rip),%r8
call   1030 <snprintf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <join_cgroup_from_top@plt>
mov    -0x8(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<join_classid>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
push   %rax
mov    0x2ec3(%rip),%rax
mov    (%rax),%esi
add    $0x1,%esi
mov    %rsp,%rbx
lea    0xf(%rsi),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xeb6(%rip),%rdx
lea    0xeb4(%rip),%rcx
lea    0xec4(%rip),%r8
mov    %rbx,%rdi
call   1030 <snprintf@plt>
mov    %rbx,%rdi
call   1040 <join_cgroup_from_top@plt>
lea    -0x8(%rbp),%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@PATH_MAX = global i32 0
@.str = [5 x i8] c"%s%s\00"
@.str.1 = [23 x i8] c"/sys/fs/cgroup/net_cls\00"
@.str.2 = [22 x i8] c"/cgroup-test-work-dir\00"
define i32 @join_classid() {
%1 = alloca i8*
%2 = alloca i64
%3 = load i32, i32* @PATH_MAX
%4 = add nsw i32 %3, 1
%5 = zext i32 %4 to i64
%6 = call i8* @llvm.stacksave()
store i8* %6, i8** %1
%7 = alloca i8, i64 %5
store i64 %5, i64* %2
%8 = trunc i64 %5 to i32
%9 = call i32 @snprintf(i8* %7, i32 %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @join_cgroup_from_top(i8* %7)
%11 = load i8*, i8** %1
ret i32 %10
}

LLVM IR (-O2):
@PATH_MAX = global i32 0
@.str = [5 x i8] c"%s%s\00"
@.str.1 = [23 x i8] c"/sys/fs/cgroup/net_cls\00"
@.str.2 = [22 x i8] c"/cgroup-test-work-dir\00"
define i32 @join_classid() {
%1 = load i32, i32* @PATH_MAX
%2 = add nsw i32 %1, 1
%3 = zext i32 %2 to i64
%4 = alloca i8, i64 %3
%5 = call i32 @snprintf(i8* %4, i32 %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%6 = call i32 @join_cgroup_from_top(i8* %4)
ret i32 %6
}