#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 /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ parse_cmdline(int, char **, int);
int /*<<< orphan*/ printf(char *, char *);
int main(int argc, char **argp, char **envp) {
  int file_desc;
  file_desc = open("/dev/bpctl0", 0);
  if (file_desc < 0) {
    printf("Can't open device file: %s\n", "bpctl");
    exit(-1);
  }
  parse_cmdline(argc, argp, file_desc);
  close(file_desc);
  return 0;
}


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)
mov    %rdx,-0x18(%rbp)
lea    0xe8f(%rip),%rdi
xor    %esi,%esi
call   1050 <open@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    11a2 <main+0x52>
lea    0xe80(%rip),%rdi
lea    0xe95(%rip),%rsi
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1060 <parse_cmdline@plt>
mov    -0x1c(%rbp),%edi
call   1040 <close@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %edi,%ebp
lea    0xea0(%rip),%rdi
xor    %esi,%esi
call   1050 <open@plt>
test   %eax,%eax
js     1187 <main+0x37>
mov    %eax,%ebx
mov    %ebp,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1060 <parse_cmdline@plt>
mov    %ebx,%edi
call   1040 <close@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xe7e(%rip),%rdi
lea    0xe93(%rip),%rsi
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"/dev/bpctl0\00"
@.str.1 = [28 x i8] c"Can't open device file: %s\0A\00"
@.str.2 = [6 x i8] c"bpctl\00"
define i32 @main(i32 %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i32
store i32 0, i32* %4
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
%9 = call i32 @open(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 0)
store i32 %9, i32* %8
%10 = load i32, i32* %8
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %3
%13 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @exit(i32 -1)
unreachable
15: ; preds = %3
%16 = load i32, i32* %5
%17 = load i8**, i8*** %6
%18 = load i32, i32* %8
%19 = call i32 @parse_cmdline(i32 %16, i8** %17, i32 %18)
%20 = load i32, i32* %8
%21 = call i32 @close(i32 %20)
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"/dev/bpctl0\00"
@.str.1 = [28 x i8] c"Can't open device file: %s\0A\00"
@.str.2 = [6 x i8] c"bpctl\00"
define i32 @main(i32 %0, i8** %1, i8** nocapture readnone %2) {
%4 = tail call i32 @open(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 0)
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %3
%7 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%8 = tail call i32 @exit(i32 -1)
unreachable
9: ; preds = %3
%10 = tail call i32 @parse_cmdline(i32 %0, i8** %1, i32 %4)
%11 = tail call i32 @close(i32 %4)
ret i32 0
}