#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int check_arg_count(int, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ getwin(int /*<<< orphan*/ *);
int /*<<< orphan*/ report_count(int);
int /*<<< orphan*/ report_error(char *);
int /*<<< orphan*/ report_ptr(int /*<<< orphan*/);
void cmd_getwin(int nargs, char **args) {
  FILE *fp;
  if (check_arg_count(nargs, 1) == 1)
    return;
  if ((fp = fopen(args[0], "r")) == NULL) {
    report_count(1);
    report_error("BAD FILE_ARGUMENT");
    return;
  }
  report_count(1);
  report_ptr(getwin(fp));
  fclose(fp);
}


x86 assembly (clang, -O0):
<cmd_getwin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x1,%esi
call   1060 <check_arg_count@plt>
cmp    $0x1,%eax
jne    119a <cmd_getwin+0x2a>
jmp    11f9 <cmd_getwin+0x89>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe58(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11d6 <cmd_getwin+0x66>
mov    $0x1,%edi
call   1070 <report_count@plt>
lea    0xe36(%rip),%rdi
call   1080 <report_error@plt>
jmp    11f9 <cmd_getwin+0x89>
mov    $0x1,%edi
call   1070 <report_count@plt>
mov    -0x18(%rbp),%rdi
call   1040 <getwin@plt>
mov    %eax,%edi
call   1050 <report_ptr@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmd_getwin>:
push   %rbx
mov    %rsi,%rbx
mov    $0x1,%esi
call   1060 <check_arg_count@plt>
cmp    $0x1,%eax
jne    1185 <cmd_getwin+0x15>
pop    %rbx
ret
mov    (%rbx),%rdi
lea    0xe71(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%rbx
mov    $0x1,%edi
call   1070 <report_count@plt>
test   %rbx,%rbx
je     11be <cmd_getwin+0x4e>
mov    %rbx,%rdi
call   1040 <getwin@plt>
mov    %eax,%edi
call   1050 <report_ptr@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1030 <fclose@plt>
lea    0xe3d(%rip),%rdi
pop    %rbx
jmp    1080 <report_error@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [18 x i8] c"BAD FILE_ARGUMENT\00"
define void @cmd_getwin(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32*
store i32 %0, i32* %3
store i8** %1, i8*** %4
%6 = load i32, i32* %3
%7 = call i32 @check_arg_count(i32 %6, i32 1)
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %10
9: ; preds = %2
br label %26
10: ; preds = %2
%11 = load i8**, i8*** %4
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %14, i32** %5
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %19
16: ; preds = %10
%17 = call i32 @report_count(i32 1)
%18 = call i32 @report_error(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %26
19: ; preds = %10
%20 = call i32 @report_count(i32 1)
%21 = load i32*, i32** %5
%22 = call i32 @getwin(i32* %21)
%23 = call i32 @report_ptr(i32 %22)
%24 = load i32*, i32** %5
%25 = call i32 @fclose(i32* %24)
br label %26
26: ; preds = %19, %16, %9
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [18 x i8] c"BAD FILE_ARGUMENT\00"
define void @cmd_getwin(i32 %0, i8** nocapture %1) {
%3 = tail call i32 @check_arg_count(i32 %0, i32 1)
%4 = icmp eq i32 %3, 1
br i1 %4, label %16, label %5
5: ; preds = %2
%6 = load i8*, i8** %1
%7 = tail call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32* %7, null
%9 = tail call i32 @report_count(i32 1)
br i1 %8, label %10, label %12
10: ; preds = %5
%11 = tail call i32 @report_error(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %16
12: ; preds = %5
%13 = tail call i32 @getwin(i32* %7)
%14 = tail call i32 @report_ptr(i32 %13)
%15 = tail call i32 @fclose(i32* %7)
br label %16
16: ; preds = %2, %12, %10
ret void
}