#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*/ mvaddch(int, int, int /*<<< orphan*/);
int /*<<< orphan*/ report_count(int);
int /*<<< orphan*/ report_error(char *);
int /*<<< orphan*/ report_return(int /*<<< orphan*/);
scalar_t__ sscanf(char *, char *, int *);
void cmd_mvaddch(int nargs, char **args) {
  int y, x;
  chtype *ch;
  if (check_arg_count(nargs, 3) == 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;
  }
  ch = (chtype *)args[2];
  report_count(1);
  report_return(mvaddch(y, x, ch[0]));
}


x86 assembly (clang, -O0):
<cmd_mvaddch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x3,%esi
call   1040 <check_arg_count@plt>
cmp    $0x1,%eax
jne    118a <cmd_mvaddch+0x2a>
jmp    1231 <cmd_mvaddch+0xd1>
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_mvaddch+0x66>
mov    $0x1,%edi
call   1050 <report_count@plt>
lea    0xe47(%rip),%rdi
call   1070 <report_error@plt>
jmp    1231 <cmd_mvaddch+0xd1>
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_mvaddch+0xa3>
mov    $0x1,%edi
call   1050 <report_count@plt>
lea    0xe0a(%rip),%rdi
call   1070 <report_error@plt>
jmp    1231 <cmd_mvaddch+0xd1>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    $0x1,%edi
call   1050 <report_count@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x20(%rbp),%rax
mov    (%rax),%edx
call   1080 <mvaddch@plt>
mov    %eax,%edi
call   1030 <report_return@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmd_mvaddch>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    $0x3,%esi
call   1040 <check_arg_count@plt>
cmp    $0x1,%eax
je     11e6 <cmd_mvaddch+0x86>
mov    (%rbx),%rdi
lea    0xe7f(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1060 <sscanf@plt>
test   %rax,%rax
je     11d0 <cmd_mvaddch+0x70>
mov    0x8(%rbx),%rdi
lea    0xe65(%rip),%rsi
lea    0x8(%rsp),%rdx
call   1060 <sscanf@plt>
test   %rax,%rax
je     11d0 <cmd_mvaddch+0x70>
mov    0x10(%rbx),%rbx
mov    $0x1,%edi
call   1050 <report_count@plt>
mov    0xc(%rsp),%edi
mov    0x8(%rsp),%esi
mov    (%rbx),%edx
call   1080 <mvaddch@plt>
mov    %eax,%edi
call   1030 <report_return@plt>
jmp    11e6 <cmd_mvaddch+0x86>
mov    $0x1,%edi
call   1050 <report_count@plt>
lea    0xe22(%rip),%rdi
call   1070 <report_error@plt>
add    $0x10,%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_mvaddch(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
%7 = alloca 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 3)
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %12
11: ; preds = %2
br label %43
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 %43
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 %43
30: ; preds = %21
%31 = load i8**, i8*** %4
%32 = getelementptr inbounds i8*, i8** %31, i64 2
%33 = load i8*, i8** %32
%34 = bitcast i8* %33 to i32*
store i32* %34, i32** %7
%35 = call i32 @report_count(i32 1)
%36 = load i32, i32* %5
%37 = load i32, i32* %6
%38 = load i32*, i32** %7
%39 = getelementptr inbounds i32, i32* %38, i64 0
%40 = load i32, i32* %39
%41 = call i32 @mvaddch(i32 %36, i32 %37, i32 %40)
%42 = call i32 @report_return(i32 %41)
br label %43
43: ; 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_mvaddch(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 3)
%8 = icmp eq i32 %7, 1
br i1 %8, label %34, 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 %34
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
br i1 %20, label %21, label %24
21: ; preds = %16
%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 %34
24: ; preds = %16
%25 = getelementptr inbounds i8*, i8** %1, i64 2
%26 = bitcast i8** %25 to i32**
%27 = load i32*, i32** %26
%28 = call i32 @report_count(i32 1)
%29 = load i32, i32* %3
%30 = load i32, i32* %4
%31 = load i32, i32* %27
%32 = call i32 @mvaddch(i32 %29, i32 %30, i32 %31)
%33 = call i32 @report_return(i32 %32)
br label %34
34: ; preds = %2, %24, %21, %13
ret void
}