#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_cp_info(int);
int ioctl_cp_info(int);
int open_cp_info();
int /*<<< orphan*/ read_cp_info(int);
int main(int argc, char **argv) {
  int fd = open_cp_info();
  if (fd <= 2)
    return -1;
  int ret = ioctl_cp_info(fd);
  if (ret < 0)
    return -1;
  read_cp_info(fd);
  close_cp_info(fd);
  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    $0x0,%al
call   1060 <open_cp_info@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x2,-0x14(%rbp)
jg     1176 <main+0x36>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ae <main+0x6e>
mov    -0x14(%rbp),%edi
call   1050 <ioctl_cp_info@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    1197 <main+0x57>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ae <main+0x6e>
mov    -0x14(%rbp),%edi
call   1040 <read_cp_info@plt>
mov    -0x14(%rbp),%edi
call   1030 <close_cp_info@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1060 <open_cp_info@plt>
mov    $0xffffffff,%ebp
cmp    $0x3,%eax
jl     1171 <main+0x31>
mov    %eax,%ebx
mov    %eax,%edi
call   1050 <ioctl_cp_info@plt>
test   %eax,%eax
js     1171 <main+0x31>
mov    %ebx,%edi
call   1040 <read_cp_info@plt>
mov    %ebx,%edi
call   1030 <close_cp_info@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 (...) @open_cp_info()
store i32 %8, i32* %6
%9 = load i32, i32* %6
%10 = icmp sle i32 %9, 2
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 -1, i32* %3
br label %23
12: ; preds = %2
%13 = load i32, i32* %6
%14 = call i32 @ioctl_cp_info(i32 %13)
store i32 %14, i32* %7
%15 = load i32, i32* %7
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %12
store i32 -1, i32* %3
br label %23
18: ; preds = %12
%19 = load i32, i32* %6
%20 = call i32 @read_cp_info(i32 %19)
%21 = load i32, i32* %6
%22 = call i32 @close_cp_info(i32 %21)
store i32 0, i32* %3
br label %23
23: ; preds = %18, %17, %11
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @open_cp_info()
%4 = icmp slt i32 %3, 3
br i1 %4, label %11, label %5
5: ; preds = %2
%6 = tail call i32 @ioctl_cp_info(i32 %3)
%7 = icmp slt i32 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %5
%9 = tail call i32 @read_cp_info(i32 %3)
%10 = tail call i32 @close_cp_info(i32 %3)
br label %11
11: ; preds = %8, %5, %2
%12 = phi i32 [ -1, %2 ], [ 0, %8 ], [ -1, %5 ]
ret i32 %12
}