#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 */
struct inode {
  int dummy;
};

/* Variables and functions */
scalar_t__ argstr(int /*<<< orphan*/, char **);
int /*<<< orphan*/ begin_trans();
int /*<<< orphan*/ commit_trans();
struct inode *create(char *, int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ iunlockput(struct inode *);
int sys_mkdir(void) {
  char *path;
  struct inode *ip;
  begin_trans();
  if (argstr(0, &path) < 0 || (ip = create(path, 1, 0, 0)) == 0) {
    commit_trans();
    return -1;
  }
  iunlockput(ip);
  commit_trans();
  return 0;
}


x86 assembly (clang, -O0):
<sys_mkdir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1040 <begin_trans@plt>
xor    %edi,%edi
lea    -0x10(%rbp),%rsi
call   1050 <argstr@plt>
cmp    $0x0,%rax
jl     1194 <sys_mkdir+0x44>
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
xor    %ecx,%ecx
mov    %ecx,%edx
call   1030 <create@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11a7 <sys_mkdir+0x57>
mov    $0x0,%al
call   1060 <commit_trans@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11be <sys_mkdir+0x6e>
mov    -0x18(%rbp),%rdi
call   1070 <iunlockput@plt>
mov    $0x0,%al
call   1060 <commit_trans@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sys_mkdir>:
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1040 <begin_trans@plt>
lea    0x8(%rsp),%rsi
xor    %edi,%edi
call   1050 <argstr@plt>
mov    $0xffffffff,%ebx
test   %rax,%rax
js     1194 <sys_mkdir+0x44>
mov    0x8(%rsp),%rdi
mov    $0x1,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1030 <create@plt>
test   %rax,%rax
je     1194 <sys_mkdir+0x44>
mov    %rax,%rdi
call   1070 <iunlockput@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <commit_trans@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.inode = type { i32 }
define i32 @sys_mkdir() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca %struct.inode*
%4 = call i32 (...) @begin_trans()
%5 = call i64 @argstr(i32 0, i8** %2)
%6 = icmp slt i64 %5, 0
br i1 %6, label %11, label %7
7: ; preds = %0
%8 = load i8*, i8** %2
%9 = call %struct.inode* @create(i8* %8, i32 1, i32 0, i32 0)
store %struct.inode* %9, %struct.inode** %3
%10 = icmp eq %struct.inode* %9, null
br i1 %10, label %11, label %13
11: ; preds = %7, %0
%12 = call i32 (...) @commit_trans()
store i32 -1, i32* %1
br label %17
13: ; preds = %7
%14 = load %struct.inode*, %struct.inode** %3
%15 = call i32 @iunlockput(%struct.inode* %14)
%16 = call i32 (...) @commit_trans()
store i32 0, i32* %1
br label %17
17: ; preds = %13, %11
%18 = load i32, i32* %1
ret i32 %18
}

LLVM IR (-O2):
%struct.inode = type { i32 }
define i32 @sys_mkdir() {
%1 = alloca i8*
%2 = bitcast i8** %1 to i8*
%3 = tail call i32 (...) @begin_trans()
%4 = call i64 @argstr(i32 0, i8** %1)
%5 = icmp slt i64 %4, 0
br i1 %5, label %12, label %6
6: ; preds = %0
%7 = load i8*, i8** %1
%8 = call %struct.inode* @create(i8* %7, i32 1, i32 0, i32 0)
%9 = icmp eq %struct.inode* %8, null
br i1 %9, label %12, label %10
10: ; preds = %6
%11 = call i32 @iunlockput(%struct.inode* %8)
br label %12
12: ; preds = %0, %6, %10
%13 = phi i32 [ 0, %10 ], [ -1, %6 ], [ -1, %0 ]
%14 = call i32 (...) @commit_trans()
ret i32 %13
}