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

/* Variables and functions */
int /*<<< orphan*/ box(int /*<<< orphan*/ *, int /*<<< orphan*/,
                       int /*<<< orphan*/);
int check_arg_count(int, int);
int /*<<< orphan*/ report_count(int);
int /*<<< orphan*/ report_error(char *);
int /*<<< orphan*/ report_return(int /*<<< orphan*/);
scalar_t__ sscanf(char *, char *, int /*<<< orphan*/ **);
void cmd_box(int nargs, char **args) {
  WINDOW *win;
  chtype *vertical, *horizontal;
  if (check_arg_count(nargs, 3) == 1)
    return;
  if (sscanf(args[0], "%p", &win) == 0) {
    report_count(1);
    report_error("BAD ARGUMENT");
    return;
  }
  vertical = (chtype *)args[1];
  horizontal = (chtype *)args[2];
  report_count(1);
  report_return(box(win, vertical[0], horizontal[0]));
}


x86 assembly (clang, -O0):
<cmd_box>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x3,%esi
call   1050 <check_arg_count@plt>
cmp    $0x1,%eax
jne    118a <cmd_box+0x2a>
jmp    1204 <cmd_box+0xa4>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe68(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1070 <sscanf@plt>
cmp    $0x0,%rax
jne    11c6 <cmd_box+0x66>
mov    $0x1,%edi
call   1060 <report_count@plt>
lea    0xe47(%rip),%rdi
call   1080 <report_error@plt>
jmp    1204 <cmd_box+0xa4>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    $0x1,%edi
call   1060 <report_count@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    (%rax),%esi
mov    -0x28(%rbp),%rax
mov    (%rax),%edx
call   1040 <box@plt>
mov    %eax,%edi
call   1030 <report_return@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmd_box>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    $0x3,%esi
call   1050 <check_arg_count@plt>
cmp    $0x1,%eax
je     11cc <cmd_box+0x6c>
mov    (%rbx),%rdi
lea    0xe80(%rip),%rsi
mov    %rsp,%rdx
call   1070 <sscanf@plt>
test   %rax,%rax
je     11b6 <cmd_box+0x56>
mov    0x8(%rbx),%r14
mov    0x10(%rbx),%rbx
mov    $0x1,%edi
call   1060 <report_count@plt>
mov    (%rsp),%rdi
mov    (%r14),%esi
mov    (%rbx),%edx
call   1040 <box@plt>
mov    %eax,%edi
call   1030 <report_return@plt>
jmp    11cc <cmd_box+0x6c>
mov    $0x1,%edi
call   1060 <report_count@plt>
lea    0xe3c(%rip),%rdi
call   1080 <report_error@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%p\00"
@.str.1 = [13 x i8] c"BAD ARGUMENT\00"
define void @cmd_box(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
store i32 %0, i32* %3
store i8** %1, i8*** %4
%8 = load i32, i32* %3
%9 = call i32 @check_arg_count(i32 %8, i32 3)
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %12
11: ; preds = %2
br label %40
12: ; preds = %2
%13 = load i8**, i8*** %4
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i64 @sscanf(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32** %5)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %12
%19 = call i32 @report_count(i32 1)
%20 = call i32 @report_error(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %40
21: ; preds = %12
%22 = load i8**, i8*** %4
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = bitcast i8* %24 to i32*
store i32* %25, i32** %6
%26 = load i8**, i8*** %4
%27 = getelementptr inbounds i8*, i8** %26, i64 2
%28 = load i8*, i8** %27
%29 = bitcast i8* %28 to i32*
store i32* %29, i32** %7
%30 = call i32 @report_count(i32 1)
%31 = load i32*, i32** %5
%32 = load i32*, i32** %6
%33 = getelementptr inbounds i32, i32* %32, i64 0
%34 = load i32, i32* %33
%35 = load i32*, i32** %7
%36 = getelementptr inbounds i32, i32* %35, i64 0
%37 = load i32, i32* %36
%38 = call i32 @box(i32* %31, i32 %34, i32 %37)
%39 = call i32 @report_return(i32 %38)
br label %40
40: ; preds = %21, %18, %11
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%p\00"
@.str.1 = [13 x i8] c"BAD ARGUMENT\00"
define void @cmd_box(i32 %0, i8** nocapture %1) {
%3 = alloca i32*
%4 = bitcast i32** %3 to i8*
%5 = tail call i32 @check_arg_count(i32 %0, i32 3)
%6 = icmp eq i32 %5, 1
br i1 %6, label %27, label %7
7: ; preds = %2
%8 = load i8*, i8** %1
%9 = call i64 @sscanf(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32** %3)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %7
%12 = call i32 @report_count(i32 1)
%13 = call i32 @report_error(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %27
14: ; preds = %7
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = bitcast i8** %15 to i32**
%17 = load i32*, i32** %16
%18 = getelementptr inbounds i8*, i8** %1, i64 2
%19 = bitcast i8** %18 to i32**
%20 = load i32*, i32** %19
%21 = call i32 @report_count(i32 1)
%22 = load i32*, i32** %3
%23 = load i32, i32* %17
%24 = load i32, i32* %20
%25 = call i32 @box(i32* %22, i32 %23, i32 %24)
%26 = call i32 @report_return(i32 %25)
br label %27
27: ; preds = %2, %14, %11
ret void
}