#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*/ mvchgat(int, int, int, int, short, int /*<<< orphan*/ *);
int /*<<< orphan*/ report_count(int);
int /*<<< orphan*/ report_error(char *);
int /*<<< orphan*/ report_return(int /*<<< orphan*/);
scalar_t__ sscanf(char *, char *, ...);
void cmd_mvchgat(int nargs, char **args) {
  int y, x, n, attr;
  short colour;
  if (check_arg_count(nargs, 6) == 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;
  }
  if (sscanf(args[2], "%d", &n) == 0) {
    report_count(1);
    report_error("BAD ARGUMENT");
    return;
  }
  if (sscanf(args[3], "%d", &attr) == 0) {
    report_count(1);
    report_error("BAD ARGUMENT");
    return;
  }
  if (sscanf(args[4], "%hd", &colour) == 0) {
    report_count(1);
    report_error("BAD ARGUMENT");
    return;
  }
  report_count(1);
  report_return(mvchgat(y, x, n, attr, colour, NULL));
}


x86 assembly (clang, -O0):
<cmd_mvchgat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x6,%esi
call   1050 <check_arg_count@plt>
cmp    $0x1,%eax
jne    118a <cmd_mvchgat+0x2a>
jmp    12f0 <cmd_mvchgat+0x190>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe68(%rip),%rsi
lea    -0x14(%rbp),%rdx
mov    $0x0,%al
call   1070 <sscanf@plt>
cmp    $0x0,%rax
jne    11c8 <cmd_mvchgat+0x68>
mov    $0x1,%edi
call   1060 <report_count@plt>
lea    0xe45(%rip),%rdi
call   1080 <report_error@plt>
jmp    12f0 <cmd_mvchgat+0x190>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe29(%rip),%rsi
lea    -0x18(%rbp),%rdx
mov    $0x0,%al
call   1070 <sscanf@plt>
cmp    $0x0,%rax
jne    1207 <cmd_mvchgat+0xa7>
mov    $0x1,%edi
call   1060 <report_count@plt>
lea    0xe06(%rip),%rdi
call   1080 <report_error@plt>
jmp    12f0 <cmd_mvchgat+0x190>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xdea(%rip),%rsi
lea    -0x1c(%rbp),%rdx
mov    $0x0,%al
call   1070 <sscanf@plt>
cmp    $0x0,%rax
jne    1246 <cmd_mvchgat+0xe6>
mov    $0x1,%edi
call   1060 <report_count@plt>
lea    0xdc7(%rip),%rdi
call   1080 <report_error@plt>
jmp    12f0 <cmd_mvchgat+0x190>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xdab(%rip),%rsi
lea    -0x20(%rbp),%rdx
mov    $0x0,%al
call   1070 <sscanf@plt>
cmp    $0x0,%rax
jne    1285 <cmd_mvchgat+0x125>
mov    $0x1,%edi
call   1060 <report_count@plt>
lea    0xd88(%rip),%rdi
call   1080 <report_error@plt>
jmp    12f0 <cmd_mvchgat+0x190>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
lea    0xd7c(%rip),%rsi
lea    -0x22(%rbp),%rdx
mov    $0x0,%al
call   1070 <sscanf@plt>
cmp    $0x0,%rax
jne    12c4 <cmd_mvchgat+0x164>
mov    $0x1,%edi
call   1060 <report_count@plt>
lea    0xd49(%rip),%rdi
call   1080 <report_error@plt>
jmp    12f0 <cmd_mvchgat+0x190>
mov    $0x1,%edi
call   1060 <report_count@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
xor    %eax,%eax
mov    %eax,%r9d
movswl -0x22(%rbp),%r8d
call   1040 <mvchgat@plt>
mov    %eax,%edi
call   1030 <report_return@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmd_mvchgat>:
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%rbx
mov    $0x6,%esi
call   1050 <check_arg_count@plt>
cmp    $0x1,%eax
je     1258 <cmd_mvchgat+0xf8>
mov    (%rbx),%rdi
lea    0xe7b(%rip),%rsi
lea    0x1c(%rsp),%rdx
xor    %eax,%eax
call   1070 <sscanf@plt>
test   %rax,%rax
je     1242 <cmd_mvchgat+0xe2>
mov    0x8(%rbx),%rdi
lea    0xe5b(%rip),%rsi
lea    0x18(%rsp),%rdx
xor    %eax,%eax
call   1070 <sscanf@plt>
test   %rax,%rax
je     1242 <cmd_mvchgat+0xe2>
mov    0x10(%rbx),%rdi
lea    0xe3b(%rip),%rsi
lea    0x14(%rsp),%rdx
xor    %eax,%eax
call   1070 <sscanf@plt>
test   %rax,%rax
je     1242 <cmd_mvchgat+0xe2>
mov    0x18(%rbx),%rdi
lea    0xe1f(%rip),%rsi
lea    0x10(%rsp),%rdx
xor    %eax,%eax
call   1070 <sscanf@plt>
test   %rax,%rax
je     1242 <cmd_mvchgat+0xe2>
mov    0x20(%rbx),%rdi
lea    0xe13(%rip),%rsi
lea    0xe(%rsp),%rdx
xor    %eax,%eax
call   1070 <sscanf@plt>
mov    %rax,%rbx
mov    $0x1,%edi
call   1060 <report_count@plt>
test   %rbx,%rbx
je     124c <cmd_mvchgat+0xec>
mov    0x1c(%rsp),%edi
mov    0x18(%rsp),%esi
mov    0x14(%rsp),%edx
mov    0x10(%rsp),%ecx
movswl 0xe(%rsp),%r8d
xor    %r9d,%r9d
call   1040 <mvchgat@plt>
mov    %eax,%edi
call   1030 <report_return@plt>
jmp    1258 <cmd_mvchgat+0xf8>
mov    $0x1,%edi
call   1060 <report_count@plt>
lea    0xdb0(%rip),%rdi
call   1080 <report_error@plt>
add    $0x20,%rsp
pop    %rbx
ret

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

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