#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int count_open_fds();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ parse_count(char *, int *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  int expected;
  if (argc != 2)
    goto help_out;
  if (parse_count(argv[1], &expected) < 0)
    goto help_out;
  if (count_open_fds() == expected)
    return EXIT_SUCCESS;
  else
    return EXIT_FAILURE;
help_out:
  fprintf(stderr,
          "Usage: %s N\n"
          "where N is the expected number of open file descriptors.\n"
          "This program exits with a failure if the number "
          "does not match exactly.\n",
          argv[0]);
  return EXIT_FAILURE;
}


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)
je     1155 <main+0x25>
jmp    11a7 <main+0x77>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <parse_count@plt>
cmp    $0x0,%rax
jge    1175 <main+0x45>
jmp    11a7 <main+0x77>
mov    $0x0,%al
call   1030 <count_open_fds@plt>
cmp    -0x14(%rbp),%eax
jne    1196 <main+0x66>
mov    0x2e44(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11cf <main+0x9f>
mov    0x2e3b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11cf <main+0x9f>
mov    0x2e32(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe42(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e0e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jne    1166 <main+0x36>
mov    0x8(%rbx),%rdi
lea    0xc(%rsp),%rsi
call   1050 <parse_count@plt>
test   %rax,%rax
js     1166 <main+0x36>
xor    %eax,%eax
call   1030 <count_open_fds@plt>
cmp    0xc(%rsp),%eax
jne    117e <main+0x4e>
mov    0x2e6c(%rip),%rax
jmp    1185 <main+0x55>
mov    0x2e73(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe87(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e53(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@EXIT_SUCCESS = global i32 0
@EXIT_FAILURE = global i32 0
@stderr = global i32 0
@.str = [142 x i8] c"Usage: %s N\0Awhere N is the expected number of open file descriptors.\0AThis program exits with a failure if the number does not match exactly.\0A\00"
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 ne i32 %7, 2
br i1 %8, label %9, label %10
9: ; preds = %2
br label %25
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i64 @parse_count(i8* %13, i32* %6)
%15 = icmp slt i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %10
br label %25
17: ; preds = %10
%18 = call i32 (...) @count_open_fds()
%19 = load i32, i32* %6
%20 = icmp eq i32 %18, %19
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = load i32, i32* @EXIT_SUCCESS
store i32 %22, i32* %3
br label %32
23: ; preds = %17
%24 = load i32, i32* @EXIT_FAILURE
store i32 %24, i32* %3
br label %32
25: ; preds = %16, %9
%26 = load i32, i32* @stderr
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 0
%29 = load i8*, i8** %28
%30 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([142 x i8], [142 x i8]* @.str, i64 0, i64 0), i8* %29)
%31 = load i32, i32* @EXIT_FAILURE
store i32 %31, i32* %3
br label %32
32: ; preds = %25, %23, %21
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
@EXIT_SUCCESS = global i32 0
@EXIT_FAILURE = global i32 0
@stderr = global i32 0
@.str = [142 x i8] c"Usage: %s N\0Awhere N is the expected number of open file descriptors.\0AThis program exits with a failure if the number does not match exactly.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = icmp eq i32 %0, 2
br i1 %5, label %6, label %16
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = call i64 @parse_count(i8* %8, i32* %3)
%10 = icmp slt i64 %9, 0
br i1 %10, label %16, label %11
11: ; preds = %6
%12 = call i32 (...) @count_open_fds()
%13 = load i32, i32* %3
%14 = icmp eq i32 %12, %13
%15 = select i1 %14, i32* @EXIT_SUCCESS, i32* @EXIT_FAILURE
br label %20
16: ; preds = %6, %2
%17 = load i32, i32* @stderr
%18 = load i8*, i8** %1
%19 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([142 x i8], [142 x i8]* @.str, i64 0, i64 0), i8* %18)
br label %20
20: ; preds = %11, %16
%21 = phi i32* [ @EXIT_FAILURE, %16 ], [ %15, %11 ]
%22 = load i32, i32* %21
ret i32 %22
}