#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 /*<<< orphan*/ EXIT_FAILURE;
int atoi(char *);
int /*<<< orphan*/ check_square(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ print_usage();
int /*<<< orphan*/ printf(char *);
int parse_number_threads(int argc, char **argv) {
  if (argc != 2) {
    printf("You didn't enter the correct number of arguments\n");
    print_usage();
    exit(EXIT_FAILURE);
  }
  int threads = atoi(argv[1]);
  if (threads < 1 || !check_square(threads)) {
    printf("You entered an invalid number of threads\n");
    printf("Please select a square integer greater than 1\n");
    print_usage();
    exit(EXIT_FAILURE);
  }
  return threads;
}


x86 assembly (clang, -O0):
<parse_number_threads>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x4(%rbp)
je     118a <parse_number_threads+0x3a>
lea    0xe90(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1070 <print_usage@plt>
mov    0x2e5d(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jl     11b5 <parse_number_threads+0x65>
mov    -0x14(%rbp),%edi
call   1030 <check_square@plt>
cmp    $0x0,%eax
jne    11e2 <parse_number_threads+0x92>
lea    0xe76(%rip),%rdi
call   1040 <printf@plt>
lea    0xe94(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1070 <print_usage@plt>
mov    0x2e05(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_number_threads>:
push   %rbx
cmp    $0x2,%edi
jne    1189 <parse_number_threads+0x39>
mov    0x8(%rsi),%rdi
call   1050 <atoi@plt>
test   %eax,%eax
jle    1174 <parse_number_threads+0x24>
mov    %eax,%ebx
mov    %eax,%edi
call   1040 <check_square@plt>
test   %eax,%eax
je     1174 <parse_number_threads+0x24>
mov    %ebx,%eax
pop    %rbx
ret
lea    0xe85(%rip),%rdi
call   1030 <puts@plt>
lea    0xea2(%rip),%rdi
jmp    1190 <parse_number_threads+0x40>
lea    0xec7(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1070 <print_usage@plt>
mov    0x2e3d(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [50 x i8] c"You didn't enter the correct number of arguments\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [42 x i8] c"You entered an invalid number of threads\0A\00"
@.str.2 = [47 x i8] c"Please select a square integer greater than 1\0A\00"
define i32 @parse_number_threads(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
%6 = load i32, i32* %3
%7 = icmp ne i32 %6, 2
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (...) @print_usage()
%11 = load i32, i32* @EXIT_FAILURE
%12 = call i32 @exit(i32 %11)
unreachable
13: ; preds = %2
%14 = load i8**, i8*** %4
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @atoi(i8* %16)
store i32 %17, i32* %5
%18 = load i32, i32* %5
%19 = icmp slt i32 %18, 1
br i1 %19, label %24, label %20
20: ; preds = %13
%21 = load i32, i32* %5
%22 = call i32 @check_square(i32 %21)
%23 = icmp ne i32 %22, 0
br i1 %23, label %30, label %24
24: ; preds = %20, %13
%25 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
%26 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0))
%27 = call i32 (...) @print_usage()
%28 = load i32, i32* @EXIT_FAILURE
%29 = call i32 @exit(i32 %28)
unreachable
30: ; preds = %20
%31 = load i32, i32* %5
ret i32 %31
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@str = [41 x i8] c"You entered an invalid number of threads\00"
@str.3 = [46 x i8] c"Please select a square integer greater than 1\00"
@str.4 = [49 x i8] c"You didn't enter the correct number of arguments\00"
define i32 @parse_number_threads(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %9, label %4
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str.4, i64 0, i64 0))
%6 = tail call i32 (...) @print_usage()
%7 = load i32, i32* @EXIT_FAILURE
%8 = tail call i32 @exit(i32 %7)
unreachable
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32 @atoi(i8* %11)
%13 = icmp slt i32 %12, 1
br i1 %13, label %17, label %14
14: ; preds = %9
%15 = tail call i32 @check_square(i32 %12)
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %23
17: ; preds = %14, %9
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str, i64 0, i64 0))
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.3, i64 0, i64 0))
%20 = tail call i32 (...) @print_usage()
%21 = load i32, i32* @EXIT_FAILURE
%22 = tail call i32 @exit(i32 %21)
unreachable
23: ; preds = %14
ret i32 %12
}