#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__ argint(int, int *);
int argstr(int /*<<< orphan*/, char **);
int /*<<< orphan*/ begin_op();
struct inode *create(char *, int, int, int);
int /*<<< orphan*/ end_op();
int /*<<< orphan*/ iunlockput(struct inode *);
int sys_mknod(void) {
  struct inode *ip;
  char *path;
  int len;
  int major, minor;
  begin_op();
  if ((len = argstr(0, &path)) < 0 || argint(1, &major) < 0 ||
      argint(2, &minor) < 0 || (ip = create(path, 3, major, minor)) == 0) {
    end_op();
    return -1;
  }
  iunlockput(ip);
  end_op();
  return 0;
}


x86 assembly (clang, -O0):
<sys_mknod>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    $0x0,%al
call   1060 <begin_op@plt>
xor    %edi,%edi
lea    -0x18(%rbp),%rsi
call   1050 <argstr@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jl     11d8 <sys_mknod+0x78>
mov    $0x1,%edi
lea    -0x20(%rbp),%rsi
call   1070 <argint@plt>
cmp    $0x0,%rax
jl     11d8 <sys_mknod+0x78>
mov    $0x2,%edi
lea    -0x24(%rbp),%rsi
call   1070 <argint@plt>
cmp    $0x0,%rax
jl     11d8 <sys_mknod+0x78>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%edx
mov    -0x24(%rbp),%ecx
mov    $0x3,%esi
call   1040 <create@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    11eb <sys_mknod+0x8b>
mov    $0x0,%al
call   1030 <end_op@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1202 <sys_mknod+0xa2>
mov    -0x10(%rbp),%rdi
call   1080 <iunlockput@plt>
mov    $0x0,%al
call   1030 <end_op@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sys_mknod>:
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1060 <begin_op@plt>
lea    0x8(%rsp),%rsi
xor    %edi,%edi
call   1050 <argstr@plt>
mov    $0xffffffff,%ebx
test   %eax,%eax
js     11cc <sys_mknod+0x6c>
lea    0x4(%rsp),%rsi
mov    $0x1,%edi
call   1070 <argint@plt>
test   %rax,%rax
js     11cc <sys_mknod+0x6c>
mov    %rsp,%rsi
mov    $0x2,%edi
call   1070 <argint@plt>
test   %rax,%rax
js     11cc <sys_mknod+0x6c>
mov    0x8(%rsp),%rdi
mov    0x4(%rsp),%edx
mov    (%rsp),%ecx
mov    $0x3,%esi
call   1040 <create@plt>
test   %rax,%rax
je     11cc <sys_mknod+0x6c>
mov    %rax,%rdi
call   1080 <iunlockput@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <end_op@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.inode = type { i32 }
define i32 @sys_mknod() {
%1 = alloca i32
%2 = alloca %struct.inode*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = call i32 (...) @begin_op()
%8 = call i32 @argstr(i32 0, i8** %3)
store i32 %8, i32* %4
%9 = icmp slt i32 %8, 0
br i1 %9, label %22, label %10
10: ; preds = %0
%11 = call i64 @argint(i32 1, i32* %5)
%12 = icmp slt i64 %11, 0
br i1 %12, label %22, label %13
13: ; preds = %10
%14 = call i64 @argint(i32 2, i32* %6)
%15 = icmp slt i64 %14, 0
br i1 %15, label %22, label %16
16: ; preds = %13
%17 = load i8*, i8** %3
%18 = load i32, i32* %5
%19 = load i32, i32* %6
%20 = call %struct.inode* @create(i8* %17, i32 3, i32 %18, i32 %19)
store %struct.inode* %20, %struct.inode** %2
%21 = icmp eq %struct.inode* %20, null
br i1 %21, label %22, label %24
22: ; preds = %16, %13, %10, %0
%23 = call i32 (...) @end_op()
store i32 -1, i32* %1
br label %28
24: ; preds = %16
%25 = load %struct.inode*, %struct.inode** %2
%26 = call i32 @iunlockput(%struct.inode* %25)
%27 = call i32 (...) @end_op()
store i32 0, i32* %1
br label %28
28: ; preds = %24, %22
%29 = load i32, i32* %1
ret i32 %29
}

LLVM IR (-O2):
%struct.inode = type { i32 }
define i32 @sys_mknod() {
%1 = alloca i8*
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i8** %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 (...) @begin_op()
%8 = call i32 @argstr(i32 0, i8** %1)
%9 = icmp slt i32 %8, 0
br i1 %9, label %24, label %10
10: ; preds = %0
%11 = call i64 @argint(i32 1, i32* %2)
%12 = icmp slt i64 %11, 0
br i1 %12, label %24, label %13
13: ; preds = %10
%14 = call i64 @argint(i32 2, i32* %3)
%15 = icmp slt i64 %14, 0
br i1 %15, label %24, label %16
16: ; preds = %13
%17 = load i8*, i8** %1
%18 = load i32, i32* %2
%19 = load i32, i32* %3
%20 = call %struct.inode* @create(i8* %17, i32 3, i32 %18, i32 %19)
%21 = icmp eq %struct.inode* %20, null
br i1 %21, label %24, label %22
22: ; preds = %16
%23 = call i32 @iunlockput(%struct.inode* %20)
br label %24
24: ; preds = %0, %10, %13, %16, %22
%25 = phi i32 [ 0, %22 ], [ -1, %16 ], [ -1, %13 ], [ -1, %10 ], [ -1, %0 ]
%26 = call i32 (...) @end_op()
ret i32 %25
}