#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*/ color_content(short, short *, short *, short *);
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 *, short *);
void cmd_color_content(int nargs, char **args) {
  short colour, red, green, blue;
  if (check_arg_count(nargs, 1) == 1)
    return;
  if (sscanf(args[0], "%hd", &colour) == 0) {
    report_count(1);
    report_error("BAD ARGUMENT");
    return;
  }
  report_count(4);
  report_return(color_content(colour, &red, &green, &blue));
  report_int(red);
  report_int(green);
  report_int(blue);
}


x86 assembly (clang, -O0):
<cmd_color_content>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x1,%esi
call   1040 <check_arg_count@plt>
cmp    $0x1,%eax
jne    119a <cmd_color_content+0x2a>
jmp    1217 <cmd_color_content+0xa7>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe58(%rip),%rsi
lea    -0x12(%rbp),%rdx
call   1060 <sscanf@plt>
cmp    $0x0,%rax
jne    11d6 <cmd_color_content+0x66>
mov    $0x1,%edi
call   1050 <report_count@plt>
lea    0xe38(%rip),%rdi
call   1070 <report_error@plt>
jmp    1217 <cmd_color_content+0xa7>
mov    $0x4,%edi
call   1050 <report_count@plt>
lea    -0x14(%rbp),%rsi
lea    -0x16(%rbp),%rdx
lea    -0x18(%rbp),%rcx
movswl -0x12(%rbp),%edi
call   1090 <color_content@plt>
mov    %eax,%edi
call   1030 <report_return@plt>
movswl -0x14(%rbp),%edi
call   1080 <report_int@plt>
movswl -0x16(%rbp),%edi
call   1080 <report_int@plt>
movswl -0x18(%rbp),%edi
call   1080 <report_int@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmd_color_content>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    $0x1,%esi
call   1040 <check_arg_count@plt>
cmp    $0x1,%eax
je     1200 <cmd_color_content+0x90>
mov    (%rbx),%rdi
lea    0xe6f(%rip),%rsi
lea    0xe(%rsp),%rdx
call   1060 <sscanf@plt>
test   %rax,%rax
je     11ea <cmd_color_content+0x7a>
mov    $0x4,%edi
call   1050 <report_count@plt>
movswl 0xe(%rsp),%edi
lea    0xc(%rsp),%rsi
lea    0xa(%rsp),%rdx
lea    0x8(%rsp),%rcx
call   1090 <color_content@plt>
mov    %eax,%edi
call   1030 <report_return@plt>
movswl 0xc(%rsp),%edi
call   1080 <report_int@plt>
movswl 0xa(%rsp),%edi
call   1080 <report_int@plt>
movswl 0x8(%rsp),%edi
call   1080 <report_int@plt>
jmp    1200 <cmd_color_content+0x90>
mov    $0x1,%edi
call   1050 <report_count@plt>
lea    0xe09(%rip),%rdi
call   1070 <report_error@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%hd\00"
@.str.1 = [13 x i8] c"BAD ARGUMENT\00"
define void @cmd_color_content(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i16
%6 = alloca i16
%7 = alloca i16
%8 = alloca i16
store i32 %0, i32* %3
store i8** %1, i8*** %4
%9 = load i32, i32* %3
%10 = call i32 @check_arg_count(i32 %9, i32 1)
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %13
12: ; preds = %2
br label %33
13: ; preds = %2
%14 = load i8**, i8*** %4
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i64 @sscanf(i8* %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i16* %5)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %13
%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 %33
22: ; preds = %13
%23 = call i32 @report_count(i32 4)
%24 = load i16, i16* %5
%25 = call i32 @color_content(i16 signext %24, i16* %6, i16* %7, i16* %8)
%26 = call i32 @report_return(i32 %25)
%27 = load i16, i16* %6
%28 = call i32 @report_int(i16 signext %27)
%29 = load i16, i16* %7
%30 = call i32 @report_int(i16 signext %29)
%31 = load i16, i16* %8
%32 = call i32 @report_int(i16 signext %31)
br label %33
33: ; preds = %22, %19, %12
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%hd\00"
@.str.1 = [13 x i8] c"BAD ARGUMENT\00"
define void @cmd_color_content(i32 %0, i8** nocapture %1) {
%3 = alloca i16
%4 = alloca i16
%5 = alloca i16
%6 = alloca i16
%7 = bitcast i16* %3 to i8*
%8 = bitcast i16* %4 to i8*
%9 = bitcast i16* %5 to i8*
%10 = bitcast i16* %6 to i8*
%11 = tail call i32 @check_arg_count(i32 %0, i32 1)
%12 = icmp eq i32 %11, 1
br i1 %12, label %31, label %13
13: ; preds = %2
%14 = load i8*, i8** %1
%15 = call i64 @sscanf(i8* %14, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i16* %3)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %13
%18 = call i32 @report_count(i32 1)
%19 = call i32 @report_error(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %31
20: ; preds = %13
%21 = call i32 @report_count(i32 4)
%22 = load i16, i16* %3
%23 = call i32 @color_content(i16 signext %22, i16* %4, i16* %5, i16* %6)
%24 = call i32 @report_return(i32 %23)
%25 = load i16, i16* %4
%26 = call i32 @report_int(i16 signext %25)
%27 = load i16, i16* %5
%28 = call i32 @report_int(i16 signext %27)
%29 = load i16, i16* %6
%30 = call i32 @report_int(i16 signext %29)
br label %31
31: ; preds = %2, %20, %17
ret void
}