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

/* Variables and functions */
int /*<<< orphan*/ S_IRWXU;
int errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(char *);
char *getPidDir(char const *, int /*<<< orphan*/);
int mkdir(char *, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
char *createPidDir(const char *cg, pid_t pid) {
  char *pid_dir = getPidDir(cg, pid);
  if (mkdir(pid_dir, S_IRWXU) == -1) {
    do {
      if (1) {
        fprintf(stderr, "%s: %d: ",
                "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/CRUx-BPHC/crux-judge/refs/"
                "heads/development/src/resource_limits.c",
                86);
        fprintf(stderr, "mkdir failed: errno: %d", errno);
        fprintf(stderr, "\n");
      }
    } while (0);
    free(pid_dir);
    return NULL;
  }
  return pid_dir;
}


x86 assembly (clang, -O0):
<createPidDir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1060 <getPidDir@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    0x2e7e(%rip),%rax
mov    (%rax),%esi
call   1040 <mkdir@plt>
cmp    $0xffffffff,%eax
jne    11ef <createPidDir+0xaf>
jmp    117f <createPidDir+0x3f>
mov    0x2e52(%rip),%rax
mov    (%rax),%edi
lea    0xe71(%rip),%rsi
lea    0xe73(%rip),%rdx
mov    $0x56,%ecx
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2e2f(%rip),%rax
mov    (%rax),%edi
mov    0x2e1e(%rip),%rax
mov    (%rax),%edx
lea    0xeea(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2e0f(%rip),%rax
mov    (%rax),%edi
lea    0xeeb(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    11f7 <createPidDir+0xb7>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<createPidDir>:
push   %r14
push   %rbx
push   %rax
call   1060 <getPidDir@plt>
mov    %rax,%rbx
mov    0x2e95(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1040 <mkdir@plt>
cmp    $0xffffffff,%eax
jne    11bb <createPidDir+0x7b>
mov    0x2e6f(%rip),%r14
mov    (%r14),%edi
lea    0xe8d(%rip),%rsi
lea    0xe8f(%rip),%rdx
mov    $0x56,%ecx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%r14),%edi
mov    0x2e40(%rip),%rax
mov    (%rax),%edx
lea    0xf0c(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%r14),%edi
lea    0xf13(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@S_IRWXU = global i32 0
@stderr = global i32 0
@.str = [9 x i8] c"%s: %d: \00"
@.str.1 = [156 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/CRUx-BPHC/crux-judge/refs/heads/development/src/resource_limits.c\00"
@.str.2 = [24 x i8] c"mkdir failed: errno: %d\00"
@errno = global i32 0
@.str.3 = [2 x i8] c"\0A\00"
define i8* @createPidDir(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
store i8* %0, i8** %4
store i32 %1, i32* %5
%7 = load i8*, i8** %4
%8 = load i32, i32* %5
%9 = call i8* @getPidDir(i8* %7, i32 %8)
store i8* %9, i8** %6
%10 = load i8*, i8** %6
%11 = load i32, i32* @S_IRWXU
%12 = call i32 @mkdir(i8* %10, i32 %11)
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %26
14: ; preds = %2
br label %15
15: ; preds = %14
%16 = load i32, i32* @stderr
%17 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([156 x i8], [156 x i8]* @.str.1, i64 0, i64 0), i32 86)
%18 = load i32, i32* @stderr
%19 = load i32, i32* @errno
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %19)
%21 = load i32, i32* @stderr
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %23
23: ; preds = %15
%24 = load i8*, i8** %6
%25 = call i32 @free(i8* %24)
store i8* null, i8** %3
br label %28
26: ; preds = %2
%27 = load i8*, i8** %6
store i8* %27, i8** %3
br label %28
28: ; preds = %26, %23
%29 = load i8*, i8** %3
ret i8* %29
}

LLVM IR (-O2):
@S_IRWXU = global i32 0
@stderr = global i32 0
@.str = [9 x i8] c"%s: %d: \00"
@.str.1 = [156 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/CRUx-BPHC/crux-judge/refs/heads/development/src/resource_limits.c\00"
@.str.2 = [24 x i8] c"mkdir failed: errno: %d\00"
@errno = global i32 0
@.str.3 = [2 x i8] c"\0A\00"
define i8* @createPidDir(i8* %0, i32 %1) {
%3 = tail call i8* @getPidDir(i8* %0, i32 %1)
%4 = load i32, i32* @S_IRWXU
%5 = tail call i32 @mkdir(i8* %3, i32 %4)
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %16
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([156 x i8], [156 x i8]* @.str.1, i64 0, i64 0), i32 86)
%10 = load i32, i32* @stderr
%11 = load i32, i32* @errno
%12 = tail call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %11)
%13 = load i32, i32* @stderr
%14 = tail call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%15 = tail call i32 @free(i8* %3)
br label %16
16: ; preds = %2, %7
%17 = phi i8* [ null, %7 ], [ %3, %2 ]
ret i8* %17
}