#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_path;

/* Variables and functions */
int /*<<< orphan*/ PATH_MAX;
int join_cgroup_from_top(char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char *, char *);
int join_cgroup(char *path) {
  char cgroup_path[PATH_MAX + 1];
  snprintf(cgroup_path, sizeof(cgroup_path), "%s%s%s", "/mnt",
           "/cgroup-test-work-dir", path);
  return join_cgroup_from_top(cgroup_path);
}


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

x86 assembly (clang, -O2):
<join_cgroup>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
push   %rax
mov    %rdi,%r9
mov    0x2ec0(%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    0xeb3(%rip),%rdx
lea    0xeb3(%rip),%rcx
lea    0xeb1(%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 = [7 x i8] c"%s%s%s\00"
@.str.1 = [5 x i8] c"/mnt\00"
@.str.2 = [22 x i8] c"/cgroup-test-work-dir\00"
define i32 @join_cgroup(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i64
store i8* %0, i8** %2
%5 = load i32, i32* @PATH_MAX
%6 = add nsw i32 %5, 1
%7 = zext i32 %6 to i64
%8 = call i8* @llvm.stacksave()
store i8* %8, i8** %3
%9 = alloca i8, i64 %7
store i64 %7, i64* %4
%10 = trunc i64 %7 to i32
%11 = load i8*, i8** %2
%12 = call i32 @snprintf(i8* %9, i32 %10, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %11)
%13 = call i32 @join_cgroup_from_top(i8* %9)
%14 = load i8*, i8** %3
ret i32 %13
}

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