#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 */
struct jtree_t {
  int dummy;
};
struct jtnode_t {
  int dummy;
};

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ jtree_beam_search(struct jtree_t *, int);
int /*<<< orphan*/ jtree_branch_and_bound_v2(struct jtnode_t **, short);
struct jtree_t *jtree_create_root(int, struct jtnode_t **, int, int, int, int,
                                  int);
struct jtnode_t **jtree_read_jobs(short);
int /*<<< orphan*/ printf(char *, int, ...);
int /*<<< orphan*/ strcmp(char *, char *);
int main(int argc, char **argv, char **envp) {
  argc--;
  argv++;
  int t, d, p, n, w, z, i;
  n = atoi(argv[0]);
  if (n <= 0) {
    return 0;
  }
  w = n / 2;
  struct jtnode_t **jobs = jtree_read_jobs((short)n);
  struct jtree_t *root = NULL;
  root = jtree_create_root(0x00, jobs, 0x00, 0x00, n, n, 0x00);
  if (!strcmp(argv[1], "bb")) {
    jtree_branch_and_bound_v2(jobs, (short)n);
  }
  if (!strcmp(argv[1], "bs")) {
    if (n < 2) {
      if (t > d) {
        printf("%d: %d\n", p, z);
      } else {
        printf("0: %d\n", z);
      }
      return 0;
    }
    jtree_beam_search(root, w);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jg     11c4 <main+0x54>
movl   $0x0,-0x4(%rbp)
jmp    12b3 <main+0x143>
mov    -0x28(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%eax
movswl %ax,%edi
call   1080 <jtree_read_jobs@plt>
mov    %rax,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
mov    -0x40(%rbp),%rsi
mov    -0x28(%rbp),%r8d
mov    -0x28(%rbp),%r9d
xor    %ecx,%ecx
mov    %ecx,%edi
mov    %ecx,%edx
movl   $0x0,(%rsp)
call   1040 <jtree_create_root@plt>
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xde6(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1237 <main+0xc7>
mov    -0x40(%rbp),%rdi
mov    -0x28(%rbp),%eax
movswl %ax,%esi
call   1030 <jtree_branch_and_bound_v2@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdbd(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    12ac <main+0x13c>
cmpl   $0x2,-0x28(%rbp)
jge    12a0 <main+0x130>
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jle    1283 <main+0x113>
mov    -0x24(%rbp),%esi
mov    -0x30(%rbp),%edx
lea    0xd8f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1294 <main+0x124>
mov    -0x30(%rbp),%esi
lea    0xd81(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12b3 <main+0x143>
mov    -0x48(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   1060 <jtree_beam_search@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    0x8(%rsi),%rdi
call   1090 <atoi@plt>
test   %eax,%eax
jle    1218 <main+0xa8>
mov    %eax,%ebx
movswl %bx,%r12d
mov    %r12d,%edi
call   1080 <jtree_read_jobs@plt>
mov    %rax,%r13
movl   $0x0,(%rsp)
xor    %edi,%edi
mov    %rax,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
mov    %ebx,%r8d
mov    %ebx,%r9d
call   1040 <jtree_create_root@plt>
mov    %rax,%r15
mov    0x10(%r14),%rbp
lea    0xe37(%rip),%rsi
mov    %rbp,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
jne    11e4 <main+0x74>
mov    %r13,%rdi
mov    %r12d,%esi
call   1030 <jtree_branch_and_bound_v2@plt>
mov    0x10(%r14),%rbp
lea    0xe18(%rip),%rsi
mov    %rbp,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
jne    1218 <main+0xa8>
cmp    $0x1,%ebx
ja     120c <main+0x9c>
lea    0xe03(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1218 <main+0xa8>
shr    %ebx
mov    %r15,%rdi
mov    %ebx,%esi
call   1060 <jtree_beam_search@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.jtnode_t = type { i32 }
%struct.jtree_t = type { i32 }
@.str = [3 x i8] c"bb\00"
@.str.1 = [3 x i8] c"bs\00"
@.str.2 = [8 x i8] c"%d: %d\0A\00"
@.str.3 = [7 x i8] c"0: %d\0A\00"
define i32 @main(i32 %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca %struct.jtnode_t**
%16 = alloca %struct.jtree_t*
store i32 0, i32* %4
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
%17 = load i32, i32* %5
%18 = add nsw i32 %17, -1
store i32 %18, i32* %5
%19 = load i8**, i8*** %6
%20 = getelementptr inbounds i8*, i8** %19, i32 1
store i8** %20, i8*** %6
%21 = load i8**, i8*** %6
%22 = getelementptr inbounds i8*, i8** %21, i64 0
%23 = load i8*, i8** %22
%24 = call i32 @atoi(i8* %23)
store i32 %24, i32* %11
%25 = load i32, i32* %11
%26 = icmp sle i32 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %3
store i32 0, i32* %4
br label %74
28: ; preds = %3
%29 = load i32, i32* %11
%30 = sdiv i32 %29, 2
store i32 %30, i32* %12
%31 = load i32, i32* %11
%32 = trunc i32 %31 to i16
%33 = call %struct.jtnode_t** @jtree_read_jobs(i16 signext %32)
store %struct.jtnode_t** %33, %struct.jtnode_t*** %15
store %struct.jtree_t* null, %struct.jtree_t** %16
%34 = load %struct.jtnode_t**, %struct.jtnode_t*** %15
%35 = load i32, i32* %11
%36 = load i32, i32* %11
%37 = call %struct.jtree_t* @jtree_create_root(i32 0, %struct.jtnode_t** %34, i32 0, i32 0, i32 %35, i32 %36, i32 0)
store %struct.jtree_t* %37, %struct.jtree_t** %16
%38 = load i8**, i8*** %6
%39 = getelementptr inbounds i8*, i8** %38, i64 1
%40 = load i8*, i8** %39
%41 = call i32 @strcmp(i8* %40, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%42 = icmp ne i32 %41, 0
br i1 %42, label %48, label %43
43: ; preds = %28
%44 = load %struct.jtnode_t**, %struct.jtnode_t*** %15
%45 = load i32, i32* %11
%46 = trunc i32 %45 to i16
%47 = call i32 @jtree_branch_and_bound_v2(%struct.jtnode_t** %44, i16 signext %46)
br label %48
48: ; preds = %43, %28
%49 = load i8**, i8*** %6
%50 = getelementptr inbounds i8*, i8** %49, i64 1
%51 = load i8*, i8** %50
%52 = call i32 @strcmp(i8* %51, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%53 = icmp ne i32 %52, 0
br i1 %53, label %73, label %54
54: ; preds = %48
%55 = load i32, i32* %11
%56 = icmp slt i32 %55, 2
br i1 %56, label %57, label %69
57: ; preds = %54
%58 = load i32, i32* %8
%59 = load i32, i32* %9
%60 = icmp sgt i32 %58, %59
br i1 %60, label %61, label %65
61: ; preds = %57
%62 = load i32, i32* %10
%63 = load i32, i32* %13
%64 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %62, i32 %63)
br label %68
65: ; preds = %57
%66 = load i32, i32* %13
%67 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %66)
br label %68
68: ; preds = %65, %61
store i32 0, i32* %4
br label %74
69: ; preds = %54
%70 = load %struct.jtree_t*, %struct.jtree_t** %16
%71 = load i32, i32* %12
%72 = call i32 @jtree_beam_search(%struct.jtree_t* %70, i32 %71)
br label %73
73: ; preds = %69, %48
store i32 0, i32* %4
br label %74
74: ; preds = %73, %68, %27
%75 = load i32, i32* %4
ret i32 %75
}

LLVM IR (-O2):
%struct.jtnode_t = type { i32 }
%struct.jtree_t = type { i32 }
@.str = [3 x i8] c"bb\00"
@.str.1 = [3 x i8] c"bs\00"
@.str.3 = [7 x i8] c"0: %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1, i8** nocapture readnone %2) {
%4 = getelementptr inbounds i8*, i8** %1, i64 1
%5 = load i8*, i8** %4
%6 = tail call i32 @atoi(i8* %5)
%7 = icmp slt i32 %6, 1
br i1 %7, label %30, label %8
8: ; preds = %3
%9 = lshr i32 %6, 1
%10 = trunc i32 %6 to i16
%11 = tail call %struct.jtnode_t** @jtree_read_jobs(i16 signext %10)
%12 = tail call %struct.jtree_t* @jtree_create_root(i32 0, %struct.jtnode_t** %11, i32 0, i32 0, i32 %6, i32 %6, i32 0)
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = load i8*, i8** %13
%15 = tail call i32 @strcmp(i8* dereferenceable(1) %14, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %8
%18 = tail call i32 @jtree_branch_and_bound_v2(%struct.jtnode_t** %11, i16 signext %10)
%19 = load i8*, i8** %13
br label %20
20: ; preds = %17, %8
%21 = phi i8* [ %19, %17 ], [ %14, %8 ]
%22 = tail call i32 @strcmp(i8* dereferenceable(1) %21, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %30
24: ; preds = %20
%25 = icmp ult i32 %6, 2
br i1 %25, label %26, label %28
26: ; preds = %24
%27 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 undef)
br label %30
28: ; preds = %24
%29 = tail call i32 @jtree_beam_search(%struct.jtree_t* %12, i32 %9)
br label %30
30: ; preds = %26, %28, %20, %3
ret i32 0
}