#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*/ WINDOW;

/* Variables and functions */
int check_arg_count(int, int);
int /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ mvwinnstr(int /*<<< orphan*/ *, int, int, char *, int);
int /*<<< orphan*/ report_count(int);
int /*<<< orphan*/ report_error(char *);
int /*<<< orphan*/ report_return(int /*<<< orphan*/);
int /*<<< orphan*/ report_status(char *);
scalar_t__ sscanf(char *, char *, int *);
void cmd_mvwinnstr(int nargs, char **args) {
  int y, x, count;
  char *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)) == NULL) {
    report_count(1);
    report_error("MALLOC_FAILED");
    return;
  }
  report_count(2);
  report_return(mvwinnstr(win, y, x, string, count));
  report_status(string);
  free(string);
}


x86 assembly (clang, -O0):
<cmd_mvwinnstr>:
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_mvwinnstr+0x2a>
jmp    131b <cmd_mvwinnstr+0x18b>
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_mvwinnstr+0x66>
mov    $0x1,%edi
call   1090 <report_count@plt>
lea    0xe17(%rip),%rdi
call   10b0 <report_error@plt>
jmp    131b <cmd_mvwinnstr+0x18b>
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_mvwinnstr+0xa3>
mov    $0x1,%edi
call   1090 <report_count@plt>
lea    0xdda(%rip),%rdi
call   10b0 <report_error@plt>
jmp    131b <cmd_mvwinnstr+0x18b>
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_mvwinnstr+0xe0>
mov    $0x1,%edi
call   1090 <report_count@plt>
lea    0xd9d(%rip),%rdi
call   10b0 <report_error@plt>
jmp    131b <cmd_mvwinnstr+0x18b>
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_mvwinnstr+0x11d>
mov    $0x1,%edi
call   1090 <report_count@plt>
lea    0xd60(%rip),%rdi
call   10b0 <report_error@plt>
jmp    131b <cmd_mvwinnstr+0x18b>
mov    -0x1c(%rbp),%edi
add    $0x1,%edi
call   1080 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    12e1 <cmd_mvwinnstr+0x151>
mov    $0x1,%edi
call   1090 <report_count@plt>
lea    0xd3c(%rip),%rdi
call   10b0 <report_error@plt>
jmp    131b <cmd_mvwinnstr+0x18b>
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 <mvwinnstr@plt>
mov    %eax,%edi
call   1040 <report_return@plt>
mov    -0x28(%rbp),%rdi
call   1050 <report_status@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmd_mvwinnstr>:
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%rbx
mov    $0x4,%esi
call   1070 <check_arg_count@plt>
cmp    $0x1,%eax
je     1281 <cmd_mvwinnstr+0xf1>
mov    (%rbx),%rdi
lea    0xe4b(%rip),%rsi
lea    0x18(%rsp),%rdx
call   10a0 <sscanf@plt>
test   %rax,%rax
je     126b <cmd_mvwinnstr+0xdb>
mov    0x8(%rbx),%rdi
lea    0xe3d(%rip),%rsi
lea    0x14(%rsp),%rdx
call   10a0 <sscanf@plt>
test   %rax,%rax
je     126b <cmd_mvwinnstr+0xdb>
mov    0x10(%rbx),%rdi
lea    0xe1f(%rip),%rsi
lea    0x10(%rsp),%rdx
call   10a0 <sscanf@plt>
test   %rax,%rax
je     126b <cmd_mvwinnstr+0xdb>
mov    0x18(%rbx),%rdi
lea    0xe05(%rip),%rsi
lea    0xc(%rsp),%rdx
call   10a0 <sscanf@plt>
test   %rax,%rax
je     126b <cmd_mvwinnstr+0xdb>
mov    0xc(%rsp),%edi
add    $0x1,%edi
call   1080 <malloc@plt>
test   %rax,%rax
je     1287 <cmd_mvwinnstr+0xf7>
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 <mvwinnstr@plt>
mov    %eax,%edi
call   1040 <report_return@plt>
mov    %rbx,%rdi
call   1050 <report_status@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
jmp    1281 <cmd_mvwinnstr+0xf1>
mov    $0x1,%edi
call   1090 <report_count@plt>
lea    0xd87(%rip),%rdi
call   10b0 <report_error@plt>
add    $0x20,%rsp
pop    %rbx
ret
mov    $0x1,%edi
call   1090 <report_count@plt>
lea    0xd7b(%rip),%rdi
jmp    127c <cmd_mvwinnstr+0xec>

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_mvwinnstr(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%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 %72
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 %72
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 %72
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 %72
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 %72
51: ; preds = %42
%52 = load i32, i32* %7
%53 = add nsw i32 %52, 1
%54 = call i8* @malloc(i32 %53)
store i8* %54, i8** %8
%55 = icmp eq i8* %54, null
br i1 %55, label %56, label %59
56: ; preds = %51
%57 = call i32 @report_count(i32 1)
%58 = call i32 @report_error(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %72
59: ; preds = %51
%60 = call i32 @report_count(i32 2)
%61 = load i32*, i32** %9
%62 = load i32, i32* %5
%63 = load i32, i32* %6
%64 = load i8*, i8** %8
%65 = load i32, i32* %7
%66 = call i32 @mvwinnstr(i32* %61, i32 %62, i32 %63, i8* %64, i32 %65)
%67 = call i32 @report_return(i32 %66)
%68 = load i8*, i8** %8
%69 = call i32 @report_status(i8* %68)
%70 = load i8*, i8** %8
%71 = call i32 @free(i8* %70)
br label %72
72: ; preds = %59, %56, %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_mvwinnstr(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 %63, 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 %63
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 %63
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 %63
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 %63
45: ; preds = %37
%46 = load i32, i32* %5
%47 = add nsw i32 %46, 1
%48 = call i8* @malloc(i32 %47)
%49 = icmp eq i8* %48, null
br i1 %49, label %50, label %53
50: ; preds = %45
%51 = call i32 @report_count(i32 1)
%52 = call i32 @report_error(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %63
53: ; preds = %45
%54 = call i32 @report_count(i32 2)
%55 = load i32*, i32** %6
%56 = load i32, i32* %3
%57 = load i32, i32* %4
%58 = load i32, i32* %5
%59 = call i32 @mvwinnstr(i32* %55, i32 %56, i32 %57, i8* %48, i32 %58)
%60 = call i32 @report_return(i32 %59)
%61 = call i32 @report_status(i8* %48)
%62 = call i32 @free(i8* %48)
br label %63
63: ; preds = %2, %53, %50, %42, %34, %26, %18
ret void
}