#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 atoi(char *);
int get_algorithm_type_id(char *);
int /*<<< orphan*/ show_error_algorithm_type();
int /*<<< orphan*/ show_error_command_pattern();
int /*<<< orphan*/ show_error_job_amount();
scalar_t__ validate_algorithm_type(char *);
scalar_t__ validate_int(char *);
int get_terminal_info(int argc, char **argv, int *job_amount,
                      int *algorithm_id) {
  int error = 0;
  if (argc == 3) {
    if (validate_int(argv[1]) == 0) {
      show_error_job_amount();
      error = 1;
    } else if (validate_algorithm_type(argv[2]) == 0) {
      show_error_algorithm_type();
      error = 1;
    } else {
      *job_amount = atoi(argv[1]);
      *algorithm_id = get_algorithm_type_id(argv[2]);
    }
  } else {
    show_error_command_pattern();
    error = 1;
  }
  return error;
}


x86 assembly (clang, -O0):
<get_terminal_info>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x3,-0x4(%rbp)
jne    1220 <get_terminal_info+0xb0>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <validate_int@plt>
cmp    $0x0,%rax
jne    11c2 <get_terminal_info+0x52>
mov    $0x0,%al
call   1090 <show_error_job_amount@plt>
movl   $0x1,-0x24(%rbp)
jmp    121b <get_terminal_info+0xab>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1080 <validate_algorithm_type@plt>
cmp    $0x0,%rax
jne    11ec <get_terminal_info+0x7c>
mov    $0x0,%al
call   1030 <show_error_algorithm_type@plt>
movl   $0x1,-0x24(%rbp)
jmp    1216 <get_terminal_info+0xa6>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1060 <get_algorithm_type_id@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
jmp    121b <get_terminal_info+0xab>
jmp    122e <get_terminal_info+0xbe>
mov    $0x0,%al
call   1040 <show_error_command_pattern@plt>
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_terminal_info>:
push   %r15
push   %r14
push   %rbx
cmp    $0x3,%edi
jne    11bb <get_terminal_info+0x4b>
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1050 <validate_int@plt>
test   %rax,%rax
je     11c4 <get_terminal_info+0x54>
mov    0x10(%rbx),%rdi
call   1080 <validate_algorithm_type@plt>
test   %rax,%rax
je     11cd <get_terminal_info+0x5d>
mov    0x8(%rbx),%rdi
call   1070 <atoi@plt>
mov    %eax,(%r15)
mov    0x10(%rbx),%rdi
call   1060 <get_algorithm_type_id@plt>
mov    %eax,(%r14)
xor    %eax,%eax
jmp    11d9 <get_terminal_info+0x69>
xor    %eax,%eax
call   1040 <show_error_command_pattern@plt>
jmp    11d4 <get_terminal_info+0x64>
xor    %eax,%eax
call   1090 <show_error_job_amount@plt>
jmp    11d4 <get_terminal_info+0x64>
xor    %eax,%eax
call   1030 <show_error_algorithm_type@plt>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @get_terminal_info(i32 %0, i8** %1, i32* %2, i32* %3) {
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i32* %2, i32** %7
store i32* %3, i32** %8
store i32 0, i32* %9
%10 = load i32, i32* %5
%11 = icmp eq i32 %10, 3
br i1 %11, label %12, label %41
12: ; preds = %4
%13 = load i8**, i8*** %6
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i64 @validate_int(i8* %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %12
%19 = call i32 (...) @show_error_job_amount()
store i32 1, i32* %9
br label %40
20: ; preds = %12
%21 = load i8**, i8*** %6
%22 = getelementptr inbounds i8*, i8** %21, i64 2
%23 = load i8*, i8** %22
%24 = call i64 @validate_algorithm_type(i8* %23)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %20
%27 = call i32 (...) @show_error_algorithm_type()
store i32 1, i32* %9
br label %39
28: ; preds = %20
%29 = load i8**, i8*** %6
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = call i32 @atoi(i8* %31)
%33 = load i32*, i32** %7
store i32 %32, i32* %33
%34 = load i8**, i8*** %6
%35 = getelementptr inbounds i8*, i8** %34, i64 2
%36 = load i8*, i8** %35
%37 = call i32 @get_algorithm_type_id(i8* %36)
%38 = load i32*, i32** %8
store i32 %37, i32* %38
br label %39
39: ; preds = %28, %26
br label %40
40: ; preds = %39, %18
br label %43
41: ; preds = %4
%42 = call i32 (...) @show_error_command_pattern()
store i32 1, i32* %9
br label %43
43: ; preds = %41, %40
%44 = load i32, i32* %9
ret i32 %44
}

LLVM IR (-O2):
define i32 @get_terminal_info(i32 %0, i8** nocapture %1, i32* nocapture writeonly %2, i32* nocapture writeonly %3) {
%5 = icmp eq i32 %0, 3
br i1 %5, label %6, label %25
6: ; preds = %4
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i64 @validate_int(i8* %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %6
%12 = tail call i32 (...) @show_error_job_amount()
br label %27
13: ; preds = %6
%14 = getelementptr inbounds i8*, i8** %1, i64 2
%15 = load i8*, i8** %14
%16 = tail call i64 @validate_algorithm_type(i8* %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = tail call i32 (...) @show_error_algorithm_type()
br label %27
20: ; preds = %13
%21 = load i8*, i8** %7
%22 = tail call i32 @atoi(i8* %21)
store i32 %22, i32* %2
%23 = load i8*, i8** %14
%24 = tail call i32 @get_algorithm_type_id(i8* %23)
store i32 %24, i32* %3
br label %27
25: ; preds = %4
%26 = tail call i32 (...) @show_error_command_pattern()
br label %27
27: ; preds = %11, %20, %18, %25
%28 = phi i32 [ 1, %11 ], [ 1, %18 ], [ 0, %20 ], [ 1, %25 ]
ret i32 %28
}