#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 uint64_t;

/* Variables and functions */
int /*<<< orphan*/ algo(char *, int);
int /*<<< orphan*/ check_box(char *, int, char);
int strlen(char *);
int usage(char *);
int main(int argc, char *argv[]) {
  if (argc != 2)
    return usage(argv[0]);
  char *boxes = argv[1];
  uint64_t boxes_sz = strlen(boxes);
  uint64_t N = boxes_sz / 2;
  if (N > 5)
    return usage(argv[0]);
  if (!check_box(boxes, boxes_sz, 'A') || !check_box(boxes, boxes_sz, 'B') ||
      !check_box(boxes, boxes_sz, 'E'))
    return usage(argv[0]);
  algo(boxes, boxes_sz);
  return 1;
}


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)
cmpl   $0x2,-0x8(%rbp)
je     1174 <main+0x34>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <usage@plt>
mov    %eax,-0x4(%rbp)
jmp    122d <main+0xed>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x20(%rbp)
cmpl   $0x5,-0x20(%rbp)
jle    11b8 <main+0x78>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <usage@plt>
mov    %eax,-0x4(%rbp)
jmp    122d <main+0xed>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    $0x41,%edx
call   1030 <check_box@plt>
cmp    $0x0,%eax
je     1206 <main+0xc6>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    $0x42,%edx
call   1030 <check_box@plt>
cmp    $0x0,%eax
je     1206 <main+0xc6>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    $0x45,%edx
call   1030 <check_box@plt>
cmp    $0x0,%eax
jne    121a <main+0xda>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <usage@plt>
mov    %eax,-0x4(%rbp)
jmp    122d <main+0xed>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1050 <algo@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
cmp    $0x2,%edi
jne    11ac <main+0x6c>
mov    0x8(%rbx),%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
cmp    $0xc,%eax
jge    11ac <main+0x6c>
mov    %eax,%ebp
mov    %r14,%rdi
mov    %eax,%esi
mov    $0x41,%edx
call   1030 <check_box@plt>
test   %eax,%eax
je     11ac <main+0x6c>
mov    %r14,%rdi
mov    %ebp,%esi
mov    $0x42,%edx
call   1030 <check_box@plt>
test   %eax,%eax
je     11ac <main+0x6c>
mov    %r14,%rdi
mov    %ebp,%esi
mov    $0x45,%edx
call   1030 <check_box@plt>
test   %eax,%eax
je     11ac <main+0x6c>
mov    %r14,%rdi
mov    %ebp,%esi
call   1050 <algo@plt>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    (%rbx),%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1060 <usage@plt>

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 @usage(i8* %14)
store i32 %15, i32* %3
br label %55
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
store i8* %19, i8** %6
%20 = load i8*, i8** %6
%21 = call i32 @strlen(i8* %20)
store i32 %21, i32* %7
%22 = load i32, i32* %7
%23 = sdiv i32 %22, 2
store i32 %23, i32* %8
%24 = load i32, i32* %8
%25 = icmp sgt i32 %24, 5
br i1 %25, label %26, label %31
26: ; preds = %16
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 0
%29 = load i8*, i8** %28
%30 = call i32 @usage(i8* %29)
store i32 %30, i32* %3
br label %55
31: ; preds = %16
%32 = load i8*, i8** %6
%33 = load i32, i32* %7
%34 = call i32 @check_box(i8* %32, i32 %33, i8 signext 65)
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %46
36: ; preds = %31
%37 = load i8*, i8** %6
%38 = load i32, i32* %7
%39 = call i32 @check_box(i8* %37, i32 %38, i8 signext 66)
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %46
41: ; preds = %36
%42 = load i8*, i8** %6
%43 = load i32, i32* %7
%44 = call i32 @check_box(i8* %42, i32 %43, i8 signext 69)
%45 = icmp ne i32 %44, 0
br i1 %45, label %51, label %46
46: ; preds = %41, %36, %31
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 0
%49 = load i8*, i8** %48
%50 = call i32 @usage(i8* %49)
store i32 %50, i32* %3
br label %55
51: ; preds = %41
%52 = load i8*, i8** %6
%53 = load i32, i32* %7
%54 = call i32 @algo(i8* %52, i32 %53)
store i32 1, i32* %3
br label %55
55: ; preds = %51, %46, %26, %11
%56 = load i32, i32* %3
ret i32 %56
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 @usage(i8* %5)
br label %29
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 @strlen(i8* %9)
%11 = icmp sgt i32 %10, 11
br i1 %11, label %12, label %15
12: ; preds = %7
%13 = load i8*, i8** %1
%14 = tail call i32 @usage(i8* %13)
br label %29
15: ; preds = %7
%16 = tail call i32 @check_box(i8* %9, i32 %10, i8 signext 65)
%17 = icmp eq i32 %16, 0
br i1 %17, label %24, label %18
18: ; preds = %15
%19 = tail call i32 @check_box(i8* %9, i32 %10, i8 signext 66)
%20 = icmp eq i32 %19, 0
br i1 %20, label %24, label %21
21: ; preds = %18
%22 = tail call i32 @check_box(i8* %9, i32 %10, i8 signext 69)
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %21, %18, %15
%25 = load i8*, i8** %1
%26 = tail call i32 @usage(i8* %25)
br label %29
27: ; preds = %21
%28 = tail call i32 @algo(i8* %9, i32 %10)
br label %29
29: ; preds = %12, %24, %27, %4
%30 = phi i32 [ %6, %4 ], [ %14, %12 ], [ 1, %27 ], [ %26, %24 ]
ret i32 %30
}