#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;

/* Variables and functions */
int check_arg_count(int, int);
int /*<<< orphan*/ mvinchstr(int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ report_count(int);
int /*<<< orphan*/ report_error(char *);
int /*<<< orphan*/ report_nstr(int /*<<< orphan*/ *);
int /*<<< orphan*/ report_return(int /*<<< orphan*/);
scalar_t__ sscanf(char *, char *, int *);
void cmd_mvinchstr(int nargs, char **args) {
  int y, x;
  chtype string[256];
  if (check_arg_count(nargs, 2) == 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(2);
  report_return(mvinchstr(y, x, string));
  report_nstr(string);
}


x86 assembly (clang, -O0):
<cmd_mvinchstr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x2,%esi
call   1060 <check_arg_count@plt>
cmp    $0x1,%eax
jne    119d <cmd_mvinchstr+0x2d>
jmp    1245 <cmd_mvinchstr+0xd5>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe55(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1080 <sscanf@plt>
cmp    $0x0,%rax
jne    11d9 <cmd_mvinchstr+0x69>
mov    $0x1,%edi
call   1070 <report_count@plt>
lea    0xe34(%rip),%rdi
call   1090 <report_error@plt>
jmp    1245 <cmd_mvinchstr+0xd5>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe18(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1080 <sscanf@plt>
cmp    $0x0,%rax
jne    1216 <cmd_mvinchstr+0xa6>
mov    $0x1,%edi
call   1070 <report_count@plt>
lea    0xdf7(%rip),%rdi
call   1090 <report_error@plt>
jmp    1245 <cmd_mvinchstr+0xd5>
mov    $0x2,%edi
call   1070 <report_count@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
lea    -0x420(%rbp),%rdx
call   1030 <mvinchstr@plt>
mov    %eax,%edi
call   1050 <report_return@plt>
lea    -0x420(%rbp),%rdi
call   1040 <report_nstr@plt>
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmd_mvinchstr>:
push   %rbx
sub    $0x410,%rsp
mov    %rsi,%rbx
mov    $0x2,%esi
call   1060 <check_arg_count@plt>
cmp    $0x1,%eax
je     1203 <cmd_mvinchstr+0x93>
mov    (%rbx),%rdi
lea    0xe6c(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1080 <sscanf@plt>
test   %rax,%rax
je     11ed <cmd_mvinchstr+0x7d>
mov    0x8(%rbx),%rdi
lea    0xe52(%rip),%rsi
lea    0x8(%rsp),%rdx
call   1080 <sscanf@plt>
test   %rax,%rax
je     11ed <cmd_mvinchstr+0x7d>
mov    $0x2,%edi
call   1070 <report_count@plt>
mov    0xc(%rsp),%edi
mov    0x8(%rsp),%esi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdx
call   1030 <mvinchstr@plt>
mov    %eax,%edi
call   1050 <report_return@plt>
mov    %rbx,%rdi
call   1040 <report_nstr@plt>
jmp    1203 <cmd_mvinchstr+0x93>
mov    $0x1,%edi
call   1070 <report_count@plt>
lea    0xe05(%rip),%rdi
call   1090 <report_error@plt>
add    $0x410,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [13 x i8] c"BAD ARGUMENT\00"
define void @cmd_mvinchstr(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
%7 = alloca [256 x 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 2)
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %12
11: ; preds = %2
br label %39
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 %39
21: ; preds = %12
%22 = load i8**, i8*** %4
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i64 @sscanf(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %21
%28 = call i32 @report_count(i32 1)
%29 = call i32 @report_error(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %39
30: ; preds = %21
%31 = call i32 @report_count(i32 2)
%32 = load i32, i32* %5
%33 = load i32, i32* %6
%34 = getelementptr inbounds [256 x i32], [256 x i32]* %7, i64 0, i64 0
%35 = call i32 @mvinchstr(i32 %32, i32 %33, i32* %34)
%36 = call i32 @report_return(i32 %35)
%37 = getelementptr inbounds [256 x i32], [256 x i32]* %7, i64 0, i64 0
%38 = call i32 @report_nstr(i32* %37)
br label %39
39: ; preds = %30, %27, %18, %11
ret void
}

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