#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*/ uid_t;
typedef int /*<<< orphan*/ mode_t;
typedef int /*<<< orphan*/ gid_t;

/* Variables and functions */
int /*<<< orphan*/ LOG_WARNING;
int chown(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
scalar_t__ mkdir(char *, int /*<<< orphan*/);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, char *, ...);
void makedir(char *path, mode_t mode, uid_t owner, gid_t group) {
  if (mkdir(path, mode) != 0) {
    syslog(LOG_WARNING, "Can't create directory %s:%s", path, strerror(errno));
    exit(2);
  }
  if ((chown(path, owner, group)) == -1) {
    syslog(LOG_WARNING, "Unable to change ownership of %s", path);
    exit(2);
  }
}


x86 assembly (clang, -O0):
<makedir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <mkdir@plt>
cmp    $0x0,%rax
je     11be <makedir+0x6e>
mov    0x2e66(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    0x2e42(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%rdx
mov    %eax,%ecx
lea    0xe53(%rip),%rsi
mov    $0x0,%al
call   1040 <syslog@plt>
mov    $0x2,%edi
call   1060 <exit@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1050 <chown@plt>
cmp    $0xffffffff,%eax
jne    11fb <makedir+0xab>
mov    0x2e0b(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe33(%rip),%rsi
mov    $0x0,%al
call   1040 <syslog@plt>
mov    $0x2,%edi
call   1060 <exit@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<makedir>:
push   %rbp
push   %r14
push   %rbx
mov    %ecx,%ebp
mov    %edx,%ebx
mov    %rdi,%r14
call   1030 <mkdir@plt>
test   %rax,%rax
jne    117b <makedir+0x2b>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
call   1050 <chown@plt>
cmp    $0xffffffff,%eax
je     11b1 <makedir+0x61>
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2e66(%rip),%rax
mov    (%rax),%ebx
mov    0x2e4d(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
lea    0xe67(%rip),%rsi
mov    %ebx,%edi
mov    %r14,%rdx
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <syslog@plt>
mov    $0x2,%edi
call   1060 <exit@plt>
mov    0x2e30(%rip),%rax
mov    (%rax),%edi
lea    0xe5c(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <syslog@plt>
mov    $0x2,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@LOG_WARNING = global i32 0
@.str = [29 x i8] c"Can't create directory %s:%s\00"
@errno = global i32 0
@.str.1 = [33 x i8] c"Unable to change ownership of %s\00"
define void @makedir(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%9 = load i8*, i8** %5
%10 = load i32, i32* %6
%11 = call i64 @mkdir(i8* %9, i32 %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %20
13: ; preds = %4
%14 = load i32, i32* @LOG_WARNING
%15 = load i8*, i8** %5
%16 = load i32, i32* @errno
%17 = call i32 @strerror(i32 %16)
%18 = call i32 (i32, i8*, i8*, ...) @syslog(i32 %14, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %15, i32 %17)
%19 = call i32 @exit(i32 2)
unreachable
20: ; preds = %4
%21 = load i8*, i8** %5
%22 = load i32, i32* %7
%23 = load i32, i32* %8
%24 = call i32 @chown(i8* %21, i32 %22, i32 %23)
%25 = icmp eq i32 %24, -1
br i1 %25, label %26, label %31
26: ; preds = %20
%27 = load i32, i32* @LOG_WARNING
%28 = load i8*, i8** %5
%29 = call i32 (i32, i8*, i8*, ...) @syslog(i32 %27, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %28)
%30 = call i32 @exit(i32 2)
unreachable
31: ; preds = %20
ret void
}

LLVM IR (-O2):
@LOG_WARNING = global i32 0
@.str = [29 x i8] c"Can't create directory %s:%s\00"
@errno = global i32 0
@.str.1 = [33 x i8] c"Unable to change ownership of %s\00"
define void @makedir(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = tail call i64 @mkdir(i8* %0, i32 %1)
%6 = icmp eq i64 %5, 0
br i1 %6, label %13, label %7
7: ; preds = %4
%8 = load i32, i32* @LOG_WARNING
%9 = load i32, i32* @errno
%10 = tail call i32 @strerror(i32 %9)
%11 = tail call i32 (i32, i8*, i8*, ...) @syslog(i32 %8, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %10)
%12 = tail call i32 @exit(i32 2)
unreachable
13: ; preds = %4
%14 = tail call i32 @chown(i8* %0, i32 %2, i32 %3)
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %20
16: ; preds = %13
%17 = load i32, i32* @LOG_WARNING
%18 = tail call i32 (i32, i8*, i8*, ...) @syslog(i32 %17, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%19 = tail call i32 @exit(i32 2)
unreachable
20: ; preds = %13
ret void
}