#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*/ print24GameAnswer(int);
int /*<<< orphan*/ printf(char *);
int readArgs(int, char **);
int main(int argc, char *argv[]) {
  int n;
  if (1 == 0)
    printf("\nP8 - 24 Game:\n");
  n = readArgs(argc, argv);
  if (n < 1 || n > 100000) {
    printf("Invalid sequence length. Aborting...\n");
    printf("\n--------------------\n");
    return 1;
  }
  if (1 == 0)
    printf("\nProblem Solution:\n");
  print24GameAnswer(n);
  if (1 == 0)
    printf("\n--------------------\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <readArgs@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jl     116c <main+0x3c>
cmpl   $0x186a0,-0x14(%rbp)
jle    1190 <main+0x60>
lea    0xe8d(%rip),%rdi
call   1040 <printf@plt>
lea    0xea7(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    119f <main+0x6f>
mov    -0x14(%rbp),%edi
call   1030 <print24GameAnswer@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
call   1050 <readArgs@plt>
lea    -0x186a1(%rax),%ecx
cmp    $0xfffe795f,%ecx
ja     1163 <main+0x33>
lea    0xeb5(%rip),%rdi
call   1030 <puts@plt>
lea    0xece(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
pop    %rcx
ret
mov    %eax,%edi
call   1040 <print24GameAnswer@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [38 x i8] c"Invalid sequence length. Aborting...\0A\00"
@.str.1 = [23 x i8] c"\0A--------------------\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = load i8**, i8*** %5
%9 = call i32 @readArgs(i32 %7, i8** %8)
store i32 %9, i32* %6
%10 = load i32, i32* %6
%11 = icmp slt i32 %10, 1
br i1 %11, label %15, label %12
12: ; preds = %2
%13 = load i32, i32* %6
%14 = icmp sgt i32 %13, 100000
br i1 %14, label %15, label %18
15: ; preds = %12, %2
%16 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%17 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %21
18: ; preds = %12
%19 = load i32, i32* %6
%20 = call i32 @print24GameAnswer(i32 %19)
store i32 0, i32* %3
br label %21
21: ; preds = %18, %15
%22 = load i32, i32* %3
ret i32 %22
}

LLVM IR (-O2):
@str = [37 x i8] c"Invalid sequence length. Aborting...\00"
@str.2 = [22 x i8] c"\0A--------------------\00"
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i32 @readArgs(i32 %0, i8** %1)
%4 = add i32 %3, -100001
%5 = icmp ult i32 %4, -100000
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.2, i64 0, i64 0))
br label %11
9: ; preds = %2
%10 = tail call i32 @print24GameAnswer(i32 %3)
br label %11
11: ; preds = %9, %6
%12 = phi i32 [ 1, %6 ], [ 0, %9 ]
ret i32 %12
}