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

/* Variables and functions */
int S_IFREG;
int /*<<< orphan*/ errno;
int mknod(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *, ...);
char *strerror(int /*<<< orphan*/);
int main(int argc, char **argv) {
  int rc;
  if (argc < 2) {
    printf("Usage %s filename\n", argv[0]);
    return 1;
  }
  rc = mknod(argv[1], S_IFREG | 0644, 0);
  if (rc) {
    printf("mknod(%s) error: %s\n", argv[1], strerror(errno));
  }
  return rc;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1171 <main+0x41>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11d1 <main+0xa1>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e68(%rip),%rax
mov    (%rax),%esi
or     $0x1a4,%esi
xor    %edx,%edx
call   1040 <mknod@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11cb <main+0x9b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    0x2e29(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    -0x20(%rbp),%rsi
mov    %rax,%rdx
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
cmp    $0x1,%edi
jg     1154 <main+0x24>
mov    (%rbx),%rsi
lea    0xeba(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%ebp
jmp    119f <main+0x6f>
mov    0x8(%rbx),%rdi
mov    0x2e89(%rip),%rax
mov    $0x1a4,%esi
or     (%rax),%esi
xor    %ebp,%ebp
xor    %edx,%edx
call   1040 <mknod@plt>
test   %eax,%eax
je     119f <main+0x6f>
mov    %eax,%r14d
mov    0x8(%rbx),%rbx
mov    0x2e57(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
lea    0xe84(%rip),%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r14d,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Usage %s filename\0A\00"
@S_IFREG = global i32 0
@.str.1 = [21 x i8] c"mknod(%s) error: %s\0A\00"
@errno = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 2
br i1 %8, label %9, label %14
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 0
%12 = load i8*, i8** %11
%13 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %12)
store i32 1, i32* %3
br label %32
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = load i32, i32* @S_IFREG
%19 = or i32 %18, 420
%20 = call i32 @mknod(i8* %17, i32 %19, i32 0)
store i32 %20, i32* %6
%21 = load i32, i32* %6
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %30
23: ; preds = %14
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = load i32, i32* @errno
%28 = call i8* @strerror(i32 %27)
%29 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %26, i8* %28)
br label %30
30: ; preds = %23, %14
%31 = load i32, i32* %6
store i32 %31, i32* %3
br label %32
32: ; preds = %30, %9
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
@.str = [19 x i8] c"Usage %s filename\0A\00"
@S_IFREG = global i32 0
@.str.1 = [21 x i8] c"mknod(%s) error: %s\0A\00"
@errno = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %5)
br label %19
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = load i32, i32* @S_IFREG
%11 = or i32 %10, 420
%12 = tail call i32 @mknod(i8* %9, i32 %11, i32 0)
%13 = icmp eq i32 %12, 0
br i1 %13, label %19, label %14
14: ; preds = %7
%15 = load i8*, i8** %8
%16 = load i32, i32* @errno
%17 = tail call i8* @strerror(i32 %16)
%18 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %15, i8* %17)
br label %19
19: ; preds = %7, %14, %4
%20 = phi i32 [ 1, %4 ], [ %12, %14 ], [ 0, %7 ]
ret i32 %20
}