#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 check_arg_count(int, int);
int /*<<< orphan*/ free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *malloc(int);
int /*<<< orphan*/ mvwinchnstr(int /*<<< orphan*/ *, int, int,
                               int /*<<< orphan*/ *, int);
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_mvwinchnstr(int nargs, char **args) {
  int y, x, count;
  chtype *string;
  WINDOW *win;
  if (check_arg_count(nargs, 4) == 1)
    return;
  if (sscanf(args[0], "%p", &win) == 0) {
    report_count(1);
    report_error("BAD ARGUMENT");
    return;
  }
  if (sscanf(args[1], "%d", &y) == 0) {
    report_count(1);
    report_error("BAD ARGUMENT");
    return;
  }
  if (sscanf(args[2], "%d", &x) == 0) {
    report_count(1);
    report_error("BAD ARGUMENT");
    return;
  }
  if (sscanf(args[3], "%d", &count) == 0) {
    report_count(1);
    report_error("BAD ARGUMENT");
    return;
  }
  if ((string = malloc((count + 1) * sizeof(chtype))) == NULL) {
    report_count(1);
    report_error("MALLOC_FAILED");
    return;
  }
  report_count(2);
  report_return(mvwinchnstr(win, y, x, string, count));
  report_nstr(string);
  free(string);
}


x86 assembly (clang, -O0):
<cmd_mvwinchnstr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x4,%esi
call   1070 <check_arg_count@plt>
cmp    $0x1,%eax
jne    11ba <cmd_mvwinchnstr+0x2a>
jmp    1323 <cmd_mvwinchnstr+0x193>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    -0x30(%rbp),%rdx
lea    0xe34(%rip),%rsi
call   10a0 <sscanf@plt>
cmp    $0x0,%rax
jne    11f6 <cmd_mvwinchnstr+0x66>
mov    $0x1,%edi
call   1090 <report_count@plt>
lea    0xe17(%rip),%rdi
call   10b0 <report_error@plt>
jmp    1323 <cmd_mvwinchnstr+0x193>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe0b(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   10a0 <sscanf@plt>
cmp    $0x0,%rax
jne    1233 <cmd_mvwinchnstr+0xa3>
mov    $0x1,%edi
call   1090 <report_count@plt>
lea    0xdda(%rip),%rdi
call   10b0 <report_error@plt>
jmp    1323 <cmd_mvwinchnstr+0x193>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xdce(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   10a0 <sscanf@plt>
cmp    $0x0,%rax
jne    1270 <cmd_mvwinchnstr+0xe0>
mov    $0x1,%edi
call   1090 <report_count@plt>
lea    0xd9d(%rip),%rdi
call   10b0 <report_error@plt>
jmp    1323 <cmd_mvwinchnstr+0x193>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xd91(%rip),%rsi
lea    -0x1c(%rbp),%rdx
call   10a0 <sscanf@plt>
cmp    $0x0,%rax
jne    12ad <cmd_mvwinchnstr+0x11d>
mov    $0x1,%edi
call   1090 <report_count@plt>
lea    0xd60(%rip),%rdi
call   10b0 <report_error@plt>
jmp    1323 <cmd_mvwinchnstr+0x193>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    12e9 <cmd_mvwinchnstr+0x159>
mov    $0x1,%edi
call   1090 <report_count@plt>
lea    0xd34(%rip),%rdi
call   10b0 <report_error@plt>
jmp    1323 <cmd_mvwinchnstr+0x193>
mov    $0x2,%edi
call   1090 <report_count@plt>
mov    -0x30(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x28(%rbp),%rcx
mov    -0x1c(%rbp),%r8d
call   1060 <mvwinchnstr@plt>
mov    %eax,%edi
call   1050 <report_return@plt>
mov    -0x28(%rbp),%rdi
call   1040 <report_nstr@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmd_mvwinchnstr>:
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%rbx
mov    $0x4,%esi
call   1070 <check_arg_count@plt>
cmp    $0x1,%eax
je     1285 <cmd_mvwinchnstr+0xf5>
mov    (%rbx),%rdi
lea    0xe4b(%rip),%rsi
lea    0x18(%rsp),%rdx
call   10a0 <sscanf@plt>
test   %rax,%rax
je     126f <cmd_mvwinchnstr+0xdf>
mov    0x8(%rbx),%rdi
lea    0xe3d(%rip),%rsi
lea    0x14(%rsp),%rdx
call   10a0 <sscanf@plt>
test   %rax,%rax
je     126f <cmd_mvwinchnstr+0xdf>
mov    0x10(%rbx),%rdi
lea    0xe1f(%rip),%rsi
lea    0x10(%rsp),%rdx
call   10a0 <sscanf@plt>
test   %rax,%rax
je     126f <cmd_mvwinchnstr+0xdf>
mov    0x18(%rbx),%rdi
lea    0xe05(%rip),%rsi
lea    0xc(%rsp),%rdx
call   10a0 <sscanf@plt>
test   %rax,%rax
je     126f <cmd_mvwinchnstr+0xdf>
mov    0xc(%rsp),%eax
lea    0x4(,%rax,4),%edi
call   1080 <malloc@plt>
test   %rax,%rax
je     128b <cmd_mvwinchnstr+0xfb>
mov    %rax,%rbx
mov    $0x2,%edi
call   1090 <report_count@plt>
mov    0x18(%rsp),%rdi
mov    0x14(%rsp),%esi
mov    0x10(%rsp),%edx
mov    0xc(%rsp),%r8d
mov    %rbx,%rcx
call   1060 <mvwinchnstr@plt>
mov    %eax,%edi
call   1050 <report_return@plt>
mov    %rbx,%rdi
call   1040 <report_nstr@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
jmp    1285 <cmd_mvwinchnstr+0xf5>
mov    $0x1,%edi
call   1090 <report_count@plt>
lea    0xd83(%rip),%rdi
call   10b0 <report_error@plt>
add    $0x20,%rsp
pop    %rbx
ret
mov    $0x1,%edi
call   1090 <report_count@plt>
lea    0xd77(%rip),%rdi
jmp    1280 <cmd_mvwinchnstr+0xf0>

LLVM IR (-O0):
@.str = [3 x i8] c"%p\00"
@.str.1 = [13 x i8] c"BAD ARGUMENT\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [14 x i8] c"MALLOC_FAILED\00"
define void @cmd_mvwinchnstr(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32*
store i32 %0, i32* %3
store i8** %1, i8*** %4
%10 = load i32, i32* %3
%11 = call i32 @check_arg_count(i32 %10, i32 4)
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %14
13: ; preds = %2
br label %75
14: ; preds = %2
%15 = load i8**, i8*** %4
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = bitcast i32** %9 to i32*
%19 = call i64 @sscanf(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %14
%22 = call i32 @report_count(i32 1)
%23 = call i32 @report_error(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %75
24: ; preds = %14
%25 = load i8**, i8*** %4
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = call i64 @sscanf(i8* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %5)
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %24
%31 = call i32 @report_count(i32 1)
%32 = call i32 @report_error(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %75
33: ; preds = %24
%34 = load i8**, i8*** %4
%35 = getelementptr inbounds i8*, i8** %34, i64 2
%36 = load i8*, i8** %35
%37 = call i64 @sscanf(i8* %36, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %6)
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %42
39: ; preds = %33
%40 = call i32 @report_count(i32 1)
%41 = call i32 @report_error(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %75
42: ; preds = %33
%43 = load i8**, i8*** %4
%44 = getelementptr inbounds i8*, i8** %43, i64 3
%45 = load i8*, i8** %44
%46 = call i64 @sscanf(i8* %45, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %7)
%47 = icmp eq i64 %46, 0
br i1 %47, label %48, label %51
48: ; preds = %42
%49 = call i32 @report_count(i32 1)
%50 = call i32 @report_error(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %75
51: ; preds = %42
%52 = load i32, i32* %7
%53 = add nsw i32 %52, 1
%54 = sext i32 %53 to i64
%55 = mul i64 %54, 4
%56 = trunc i64 %55 to i32
%57 = call i32* @malloc(i32 %56)
store i32* %57, i32** %8
%58 = icmp eq i32* %57, null
br i1 %58, label %59, label %62
59: ; preds = %51
%60 = call i32 @report_count(i32 1)
%61 = call i32 @report_error(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %75
62: ; preds = %51
%63 = call i32 @report_count(i32 2)
%64 = load i32*, i32** %9
%65 = load i32, i32* %5
%66 = load i32, i32* %6
%67 = load i32*, i32** %8
%68 = load i32, i32* %7
%69 = call i32 @mvwinchnstr(i32* %64, i32 %65, i32 %66, i32* %67, i32 %68)
%70 = call i32 @report_return(i32 %69)
%71 = load i32*, i32** %8
%72 = call i32 @report_nstr(i32* %71)
%73 = load i32*, i32** %8
%74 = call i32 @free(i32* %73)
br label %75
75: ; preds = %62, %59, %48, %39, %30, %21, %13
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%p\00"
@.str.1 = [13 x i8] c"BAD ARGUMENT\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [14 x i8] c"MALLOC_FAILED\00"
define void @cmd_mvwinchnstr(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = bitcast i32* %5 to i8*
%10 = bitcast i32** %6 to i8*
%11 = tail call i32 @check_arg_count(i32 %0, i32 4)
%12 = icmp eq i32 %11, 1
br i1 %12, label %64, label %13
13: ; preds = %2
%14 = load i8*, i8** %1
%15 = bitcast i32** %6 to i32*
%16 = call i64 @sscanf(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %13
%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 %64
21: ; preds = %13
%22 = getelementptr inbounds i8*, i8** %1, i64 1
%23 = load i8*, i8** %22
%24 = call i64 @sscanf(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %21
%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 %64
29: ; preds = %21
%30 = getelementptr inbounds i8*, i8** %1, i64 2
%31 = load i8*, i8** %30
%32 = call i64 @sscanf(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %4)
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %29
%35 = call i32 @report_count(i32 1)
%36 = call i32 @report_error(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %64
37: ; preds = %29
%38 = getelementptr inbounds i8*, i8** %1, i64 3
%39 = load i8*, i8** %38
%40 = call i64 @sscanf(i8* %39, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %5)
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %45
42: ; preds = %37
%43 = call i32 @report_count(i32 1)
%44 = call i32 @report_error(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %64
45: ; preds = %37
%46 = load i32, i32* %5
%47 = shl i32 %46, 2
%48 = add i32 %47, 4
%49 = call i32* @malloc(i32 %48)
%50 = icmp eq i32* %49, null
br i1 %50, label %51, label %54
51: ; preds = %45
%52 = call i32 @report_count(i32 1)
%53 = call i32 @report_error(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %64
54: ; preds = %45
%55 = call i32 @report_count(i32 2)
%56 = load i32*, i32** %6
%57 = load i32, i32* %3
%58 = load i32, i32* %4
%59 = load i32, i32* %5
%60 = call i32 @mvwinchnstr(i32* %56, i32 %57, i32 %58, i32* %49, i32 %59)
%61 = call i32 @report_return(i32 %60)
%62 = call i32 @report_nstr(i32* %49)
%63 = call i32 @free(i32* %49)
br label %64
64: ; preds = %2, %54, %51, %42, %34, %26, %18
ret void
}