#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 /*<<< orphan*/ OK;
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 *);
int /*<<< orphan*/ wtimeout(int /*<<< orphan*/ *, int);
void cmd_wtimeout(int nargs, char **args) {
  WINDOW *win;
  int tval;
  if (check_arg_count(nargs, 2) == 1)
    return;
  if (sscanf(args[0], "%p", &win) == 0) {
    report_count(1);
    report_error("BAD ARGUMENT");
    return;
  }
  if (sscanf(args[1], "%d", &tval) == 0) {
    report_count(1);
    report_error("BAD ARGUMENT");
    return;
  }
  wtimeout(win, tval);
  report_count(1);
  report_return(OK);
}


x86 assembly (clang, -O0):
<cmd_wtimeout>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x2,%esi
call   1050 <check_arg_count@plt>
cmp    $0x1,%eax
jne    118a <cmd_wtimeout+0x2a>
jmp    1227 <cmd_wtimeout+0xc7>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    -0x18(%rbp),%rdx
lea    0xe64(%rip),%rsi
call   1070 <sscanf@plt>
cmp    $0x0,%rax
jne    11c6 <cmd_wtimeout+0x66>
mov    $0x1,%edi
call   1060 <report_count@plt>
lea    0xe47(%rip),%rdi
call   1080 <report_error@plt>
jmp    1227 <cmd_wtimeout+0xc7>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe3b(%rip),%rsi
lea    -0x1c(%rbp),%rdx
call   1070 <sscanf@plt>
cmp    $0x0,%rax
jne    1203 <cmd_wtimeout+0xa3>
mov    $0x1,%edi
call   1060 <report_count@plt>
lea    0xe0a(%rip),%rdi
call   1080 <report_error@plt>
jmp    1227 <cmd_wtimeout+0xc7>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1040 <wtimeout@plt>
mov    $0x1,%edi
call   1060 <report_count@plt>
mov    0x2dc0(%rip),%rax
mov    (%rax),%edi
call   1030 <report_return@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmd_wtimeout>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    $0x2,%esi
call   1050 <check_arg_count@plt>
cmp    $0x1,%eax
je     11e8 <cmd_wtimeout+0x88>
mov    (%rbx),%rdi
lea    0xe7f(%rip),%rsi
lea    0x8(%rsp),%rdx
call   1070 <sscanf@plt>
test   %rax,%rax
je     11d2 <cmd_wtimeout+0x72>
mov    0x8(%rbx),%rdi
lea    0xe75(%rip),%rsi
lea    0x4(%rsp),%rdx
call   1070 <sscanf@plt>
test   %rax,%rax
je     11d2 <cmd_wtimeout+0x72>
mov    0x8(%rsp),%rdi
mov    0x4(%rsp),%esi
call   1040 <wtimeout@plt>
mov    $0x1,%edi
call   1060 <report_count@plt>
mov    0x2e17(%rip),%rax
mov    (%rax),%edi
call   1030 <report_return@plt>
jmp    11e8 <cmd_wtimeout+0x88>
mov    $0x1,%edi
call   1060 <report_count@plt>
lea    0xe20(%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"
@OK = global i32 0
define void @cmd_wtimeout(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32*
%6 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
%7 = load i32, i32* %3
%8 = call i32 @check_arg_count(i32 %7, i32 2)
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %11
10: ; preds = %2
br label %37
11: ; preds = %2
%12 = load i8**, i8*** %4
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = bitcast i32** %5 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 = %11
%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 %37
21: ; preds = %11
%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.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 %37
30: ; preds = %21
%31 = load i32*, i32** %5
%32 = load i32, i32* %6
%33 = call i32 @wtimeout(i32* %31, i32 %32)
%34 = call i32 @report_count(i32 1)
%35 = load i32, i32* @OK
%36 = call i32 @report_return(i32 %35)
br label %37
37: ; preds = %30, %27, %18, %10
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"
@OK = global i32 0
define void @cmd_wtimeout(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 2)
%8 = icmp eq i32 %7, 1
br i1 %8, label %32, label %9
9: ; preds = %2
%10 = load i8*, i8** %1
%11 = bitcast i32** %3 to i32*
%12 = call i64 @sscanf(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %9
%15 = call i32 @report_count(i32 1)
%16 = call i32 @report_error(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %32
17: ; preds = %9
%18 = getelementptr inbounds i8*, i8** %1, i64 1
%19 = load i8*, i8** %18
%20 = call i64 @sscanf(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %4)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %17
%23 = call i32 @report_count(i32 1)
%24 = call i32 @report_error(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %32
25: ; preds = %17
%26 = load i32*, i32** %3
%27 = load i32, i32* %4
%28 = call i32 @wtimeout(i32* %26, i32 %27)
%29 = call i32 @report_count(i32 1)
%30 = load i32, i32* @OK
%31 = call i32 @report_return(i32 %30)
br label %32
32: ; preds = %2, %25, %22, %14
ret void
}