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


x86 assembly (clang, -O0):
<cmd_wattr_get>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x1,%esi
call   1050 <check_arg_count@plt>
cmp    $0x1,%eax
jne    119a <cmd_wattr_get+0x2a>
jmp    1210 <cmd_wattr_get+0xa0>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe58(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1070 <sscanf@plt>
cmp    $0x0,%rax
jne    11d6 <cmd_wattr_get+0x66>
mov    $0x1,%edi
call   1060 <report_count@plt>
lea    0xe37(%rip),%rdi
call   1080 <report_error@plt>
jmp    1210 <cmd_wattr_get+0xa0>
mov    $0x3,%edi
call   1060 <report_count@plt>
mov    -0x18(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
lea    -0x1e(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%ecx
call   1030 <wattr_get@plt>
mov    %eax,%edi
call   1040 <report_return@plt>
mov    -0x1c(%rbp),%eax
movswl %ax,%edi
call   1090 <report_int@plt>
movswl -0x1e(%rbp),%edi
call   1090 <report_int@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmd_wattr_get>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    $0x1,%esi
call   1050 <check_arg_count@plt>
cmp    $0x1,%eax
je     11f3 <cmd_wattr_get+0x83>
mov    (%rbx),%rdi
lea    0xe6f(%rip),%rsi
lea    0x8(%rsp),%rdx
call   1070 <sscanf@plt>
test   %rax,%rax
je     11dd <cmd_wattr_get+0x6d>
mov    $0x3,%edi
call   1060 <report_count@plt>
mov    0x8(%rsp),%rdi
lea    0x4(%rsp),%rsi
lea    0x2(%rsp),%rdx
xor    %ecx,%ecx
call   1030 <wattr_get@plt>
mov    %eax,%edi
call   1040 <report_return@plt>
movswl 0x4(%rsp),%edi
call   1090 <report_int@plt>
movswl 0x2(%rsp),%edi
call   1090 <report_int@plt>
jmp    11f3 <cmd_wattr_get+0x83>
mov    $0x1,%edi
call   1060 <report_count@plt>
lea    0xe15(%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"
define void @cmd_wattr_get(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 1)
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %12
11: ; preds = %2
br label %31
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 %31
21: ; preds = %12
%22 = call i32 @report_count(i32 3)
%23 = load i32*, i32** %5
%24 = call i32 @wattr_get(i32* %23, i32* %6, i16* %7, i32* null)
%25 = call i32 @report_return(i32 %24)
%26 = load i32, i32* %6
%27 = trunc i32 %26 to i16
%28 = call i32 @report_int(i16 signext %27)
%29 = load i16, i16* %7
%30 = call i32 @report_int(i16 signext %29)
br label %31
31: ; preds = %21, %18, %11
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%p\00"
@.str.1 = [13 x i8] c"BAD ARGUMENT\00"
define void @cmd_wattr_get(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 1)
%10 = icmp eq i32 %9, 1
br i1 %10, label %28, label %11
11: ; preds = %2
%12 = load i8*, i8** %1
%13 = call i64 @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 %28
18: ; preds = %11
%19 = call i32 @report_count(i32 3)
%20 = load i32*, i32** %3
%21 = call i32 @wattr_get(i32* %20, i32* %4, i16* %5, i32* null)
%22 = call i32 @report_return(i32 %21)
%23 = load i32, i32* %4
%24 = trunc i32 %23 to i16
%25 = call i32 @report_int(i16 signext %24)
%26 = load i16, i16* %5
%27 = call i32 @report_int(i16 signext %26)
br label %28
28: ; preds = %2, %18, %15
ret void
}