#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*/ report_count(int);
int /*<<< orphan*/ report_error(char *);
int /*<<< orphan*/ report_return(int /*<<< orphan*/);
scalar_t__ sscanf(char *, char *, ...);
int /*<<< orphan*/ wattr_set(int /*<<< orphan*/ *, int, short,
                             int /*<<< orphan*/ *);
void cmd_wattr_set(int nargs, char **args) {
  WINDOW *win;
  int attr;
  short pair;
  if (check_arg_count(nargs, 3) == 1)
    return;
  if (sscanf(args[0], "%p", &win) == 0) {
    report_count(1);
    report_error("BAD ARGUMENT");
    return;
  }
  if (sscanf(args[1], "%d", &attr) == 0) {
    report_count(1);
    report_error("BAD ARGUMENT");
    return;
  }
  if (sscanf(args[2], "%hd", &pair) == 0) {
    report_count(1);
    report_error("BAD ARGUMENT");
    return;
  }
  report_count(1);
  report_return(wattr_set(win, attr, pair, NULL));
}


x86 assembly (clang, -O0):
<cmd_wattr_set>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x3,%esi
call   1050 <check_arg_count@plt>
cmp    $0x1,%eax
jne    118a <cmd_wattr_set+0x2a>
jmp    126b <cmd_wattr_set+0x10b>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe68(%rip),%rsi
lea    -0x18(%rbp),%rdx
mov    $0x0,%al
call   1070 <sscanf@plt>
cmp    $0x0,%rax
jne    11c8 <cmd_wattr_set+0x68>
mov    $0x1,%edi
call   1060 <report_count@plt>
lea    0xe45(%rip),%rdi
call   1080 <report_error@plt>
jmp    126b <cmd_wattr_set+0x10b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe39(%rip),%rsi
lea    -0x1c(%rbp),%rdx
mov    $0x0,%al
call   1070 <sscanf@plt>
cmp    $0x0,%rax
jne    1207 <cmd_wattr_set+0xa7>
mov    $0x1,%edi
call   1060 <report_count@plt>
lea    0xe06(%rip),%rdi
call   1080 <report_error@plt>
jmp    126b <cmd_wattr_set+0x10b>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xdfd(%rip),%rsi
lea    -0x1e(%rbp),%rdx
mov    $0x0,%al
call   1070 <sscanf@plt>
cmp    $0x0,%rax
jne    1246 <cmd_wattr_set+0xe6>
mov    $0x1,%edi
call   1060 <report_count@plt>
lea    0xdc7(%rip),%rdi
call   1080 <report_error@plt>
jmp    126b <cmd_wattr_set+0x10b>
mov    $0x1,%edi
call   1060 <report_count@plt>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
xor    %eax,%eax
mov    %eax,%ecx
movswl -0x1e(%rbp),%edx
call   1030 <wattr_set@plt>
mov    %eax,%edi
call   1040 <report_return@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmd_wattr_set>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    $0x3,%esi
call   1050 <check_arg_count@plt>
cmp    $0x1,%eax
je     120f <cmd_wattr_set+0xaf>
mov    (%rbx),%rdi
lea    0xe7b(%rip),%rsi
lea    0x8(%rsp),%rdx
xor    %eax,%eax
call   1070 <sscanf@plt>
test   %rax,%rax
je     11f9 <cmd_wattr_set+0x99>
mov    0x8(%rbx),%rdi
lea    0xe6f(%rip),%rsi
lea    0x4(%rsp),%rdx
xor    %eax,%eax
call   1070 <sscanf@plt>
test   %rax,%rax
je     11f9 <cmd_wattr_set+0x99>
mov    0x10(%rbx),%rdi
lea    0xe56(%rip),%rsi
lea    0x2(%rsp),%rdx
xor    %eax,%eax
call   1070 <sscanf@plt>
mov    %rax,%rbx
mov    $0x1,%edi
call   1060 <report_count@plt>
test   %rbx,%rbx
je     1203 <cmd_wattr_set+0xa3>
mov    0x8(%rsp),%rdi
mov    0x4(%rsp),%esi
movswl 0x2(%rsp),%edx
xor    %ecx,%ecx
call   1030 <wattr_set@plt>
mov    %eax,%edi
call   1040 <report_return@plt>
jmp    120f <cmd_wattr_set+0xaf>
mov    $0x1,%edi
call   1060 <report_count@plt>
lea    0xdf9(%rip),%rdi
call   1080 <report_error@plt>
add    $0x10,%rsp
pop    %rbx
ret

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 = [4 x i8] c"%hd\00"
define void @cmd_wattr_set(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i16
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 %46
12: ; preds = %2
%13 = load i8**, i8*** %4
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i64 (i8*, i8*, ...) @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 %46
21: ; preds = %12
%22 = load i8**, i8*** %4
%23 = getelementptr inbounds i8*, i8** %22, 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.2, 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 %46
30: ; preds = %21
%31 = load i8**, i8*** %4
%32 = getelementptr inbounds i8*, i8** %31, i64 2
%33 = load i8*, i8** %32
%34 = call i64 (i8*, i8*, ...) @sscanf(i8* %33, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i16* %7)
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %30
%37 = call i32 @report_count(i32 1)
%38 = call i32 @report_error(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %46
39: ; preds = %30
%40 = call i32 @report_count(i32 1)
%41 = load i32*, i32** %5
%42 = load i32, i32* %6
%43 = load i16, i16* %7
%44 = call i32 @wattr_set(i32* %41, i32 %42, i16 signext %43, i32* null)
%45 = call i32 @report_return(i32 %44)
br label %46
46: ; preds = %39, %36, %27, %18, %11
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 = [4 x i8] c"%hd\00"
define void @cmd_wattr_set(i32 %0, i8** nocapture %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i16
%6 = bitcast i32** %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = bitcast i16* %5 to i8*
%9 = tail call i32 @check_arg_count(i32 %0, i32 3)
%10 = icmp eq i32 %9, 1
br i1 %10, label %40, label %11
11: ; preds = %2
%12 = load i8*, i8** %1
%13 = call i64 (i8*, i8*, ...) @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 %40
18: ; preds = %11
%19 = getelementptr inbounds i8*, i8** %1, i64 1
%20 = load i8*, i8** %19
%21 = call i64 (i8*, i8*, ...) @sscanf(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, 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 %40
26: ; preds = %18
%27 = getelementptr inbounds i8*, i8** %1, i64 2
%28 = load i8*, i8** %27
%29 = call i64 (i8*, i8*, ...) @sscanf(i8* %28, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i16* %5)
%30 = icmp eq i64 %29, 0
%31 = call i32 @report_count(i32 1)
br i1 %30, label %32, label %34
32: ; preds = %26
%33 = call i32 @report_error(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %40
34: ; preds = %26
%35 = load i32*, i32** %3
%36 = load i32, i32* %4
%37 = load i16, i16* %5
%38 = call i32 @wattr_set(i32* %35, i32 %36, i16 signext %37, i32* null)
%39 = call i32 @report_return(i32 %38)
br label %40
40: ; preds = %2, %34, %32, %23, %15
ret void
}