#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 check_arg_count(int, int);
int /*<<< orphan*/ mvprintw(int, int, char *, char *);
int /*<<< orphan*/ report_count(int);
int /*<<< orphan*/ report_error(char *);
int /*<<< orphan*/ report_return(int /*<<< orphan*/);
scalar_t__ sscanf(char *, char *, int *);
void cmd_mvprintw(int nargs, char **args) {
  int y, x;
  if (check_arg_count(nargs, 4) == 1)
    return;
  if (sscanf(args[0], "%d", &y) == 0) {
    report_count(1);
    report_error("BAD ARGUMENT");
    return;
  }
  if (sscanf(args[1], "%d", &x) == 0) {
    report_count(1);
    report_error("BAD ARGUMENT");
    return;
  }
  report_count(1);
  report_return(mvprintw(y, x, args[2], args[3]));
}


x86 assembly (clang, -O0):
<cmd_mvprintw>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x4,%esi
call   1040 <check_arg_count@plt>
cmp    $0x1,%eax
jne    118a <cmd_mvprintw+0x2a>
jmp    122f <cmd_mvprintw+0xcf>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe68(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1060 <sscanf@plt>
cmp    $0x0,%rax
jne    11c6 <cmd_mvprintw+0x66>
mov    $0x1,%edi
call   1050 <report_count@plt>
lea    0xe47(%rip),%rdi
call   1070 <report_error@plt>
jmp    122f <cmd_mvprintw+0xcf>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe2b(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1060 <sscanf@plt>
cmp    $0x0,%rax
jne    1203 <cmd_mvprintw+0xa3>
mov    $0x1,%edi
call   1050 <report_count@plt>
lea    0xe0a(%rip),%rdi
call   1070 <report_error@plt>
jmp    122f <cmd_mvprintw+0xcf>
mov    $0x1,%edi
call   1050 <report_count@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rcx
call   1080 <mvprintw@plt>
mov    %eax,%edi
call   1030 <report_return@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmd_mvprintw>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    $0x4,%esi
call   1040 <check_arg_count@plt>
cmp    $0x1,%eax
je     11e7 <cmd_mvprintw+0x87>
mov    (%rbx),%rdi
lea    0xe80(%rip),%rsi
lea    0x4(%rsp),%rdx
call   1060 <sscanf@plt>
test   %rax,%rax
je     11d1 <cmd_mvprintw+0x71>
mov    0x8(%rbx),%rdi
lea    0xe66(%rip),%rsi
mov    %rsp,%rdx
call   1060 <sscanf@plt>
mov    %rax,%r14
mov    $0x1,%edi
call   1050 <report_count@plt>
test   %r14,%r14
je     11db <cmd_mvprintw+0x7b>
mov    0x4(%rsp),%edi
mov    (%rsp),%esi
mov    0x10(%rbx),%rdx
mov    0x18(%rbx),%rcx
call   1080 <mvprintw@plt>
mov    %eax,%edi
call   1030 <report_return@plt>
jmp    11e7 <cmd_mvprintw+0x87>
mov    $0x1,%edi
call   1050 <report_count@plt>
lea    0xe21(%rip),%rdi
call   1070 <report_error@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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