#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 banker(int **, int **, int *, int, int);
int /*<<< orphan*/ input(int **, int **, int **, int *, int *, int *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ res_request(int **, int **, int *, int, int);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int n;
  int m;
  int allocation[10][10];
  int maximum[10][10];
  int need[10][10];
  int available[10];
  input(allocation, need, maximum, available, &n, &m);
  int res = banker(allocation, need, available, n, m);
  if (res != 0) {
    int choice;
    printf("\nMake an additional request? (1/0): ");
    scanf("%d", &choice);
    if (choice == 1) {
      int pid;
      printf("\nWhich process: ");
      scanf("%d", &pid);
      res_request(allocation, need, available, pid - 1, m);
      res = banker(allocation, need, available, n, m);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x500,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x1a0(%rbp),%rdi
lea    -0x4c0(%rbp),%rsi
lea    -0x330(%rbp),%rdx
lea    -0x4f0(%rbp),%rcx
lea    -0x8(%rbp),%r8
lea    -0xc(%rbp),%r9
call   1040 <input@plt>
lea    -0x1a0(%rbp),%rdi
lea    -0x4c0(%rbp),%rsi
lea    -0x4f0(%rbp),%rdx
mov    -0x8(%rbp),%ecx
mov    -0xc(%rbp),%r8d
call   1030 <banker@plt>
mov    %eax,-0x4f4(%rbp)
cmpl   $0x0,-0x4f4(%rbp)
je     125d <main+0x10d>
lea    0xe3a(%rip),%rdi
call   1060 <printf@plt>
lea    0xe53(%rip),%rdi
lea    -0x4f8(%rbp),%rsi
call   1070 <scanf@plt>
cmpl   $0x1,-0x4f8(%rbp)
jne    1258 <main+0x108>
lea    0xe36(%rip),%rdi
call   1060 <printf@plt>
lea    0xe27(%rip),%rdi
lea    -0x4fc(%rbp),%rsi
call   1070 <scanf@plt>
lea    -0x1a0(%rbp),%rdi
lea    -0x4c0(%rbp),%rsi
lea    -0x4f0(%rbp),%rdx
mov    -0x4fc(%rbp),%ecx
sub    $0x1,%ecx
mov    -0xc(%rbp),%r8d
call   1050 <res_request@plt>
lea    -0x1a0(%rbp),%rdi
lea    -0x4c0(%rbp),%rsi
lea    -0x4f0(%rbp),%rdx
mov    -0x8(%rbp),%ecx
mov    -0xc(%rbp),%r8d
call   1030 <banker@plt>
mov    %eax,-0x4f4(%rbp)
jmp    125d <main+0x10d>
xor    %eax,%eax
add    $0x500,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x4f0,%rsp
lea    0x1d0(%rsp),%r15
lea    0x40(%rsp),%r14
lea    0x360(%rsp),%rdx
lea    0x10(%rsp),%rbx
lea    0x4(%rsp),%r8
mov    %rsp,%r9
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rcx
call   1040 <input@plt>
mov    0x4(%rsp),%ecx
mov    (%rsp),%r8d
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1030 <banker@plt>
test   %eax,%eax
je     122c <main+0xdc>
lea    0xe4f(%rip),%rdi
call   1060 <printf@plt>
lea    0xe68(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
cmpl   $0x1,0xc(%rsp)
jne    122c <main+0xdc>
lea    0xe53(%rip),%rdi
call   1060 <printf@plt>
lea    0xe44(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1070 <scanf@plt>
mov    0x8(%rsp),%ecx
add    $0xffffffff,%ecx
mov    (%rsp),%r8d
lea    0x1d0(%rsp),%rbx
lea    0x40(%rsp),%r14
lea    0x10(%rsp),%r15
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1050 <res_request@plt>
mov    0x4(%rsp),%ecx
mov    (%rsp),%r8d
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1030 <banker@plt>
xor    %eax,%eax
add    $0x4f0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [37 x i8] c"\0AMake an additional request? (1/0): \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [17 x i8] c"\0AWhich process: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [10 x [10 x i32]]
%5 = alloca [10 x [10 x i32]]
%6 = alloca [10 x [10 x i32]]
%7 = alloca [10 x i32]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %1
%11 = getelementptr inbounds [10 x [10 x i32]], [10 x [10 x i32]]* %4, i64 0, i64 0
%12 = bitcast [10 x i32]* %11 to i32**
%13 = getelementptr inbounds [10 x [10 x i32]], [10 x [10 x i32]]* %6, i64 0, i64 0
%14 = bitcast [10 x i32]* %13 to i32**
%15 = getelementptr inbounds [10 x [10 x i32]], [10 x [10 x i32]]* %5, i64 0, i64 0
%16 = bitcast [10 x i32]* %15 to i32**
%17 = getelementptr inbounds [10 x i32], [10 x i32]* %7, i64 0, i64 0
%18 = call i32 @input(i32** %12, i32** %14, i32** %16, i32* %17, i32* %2, i32* %3)
%19 = getelementptr inbounds [10 x [10 x i32]], [10 x [10 x i32]]* %4, i64 0, i64 0
%20 = bitcast [10 x i32]* %19 to i32**
%21 = getelementptr inbounds [10 x [10 x i32]], [10 x [10 x i32]]* %6, i64 0, i64 0
%22 = bitcast [10 x i32]* %21 to i32**
%23 = getelementptr inbounds [10 x i32], [10 x i32]* %7, i64 0, i64 0
%24 = load i32, i32* %2
%25 = load i32, i32* %3
%26 = call i32 @banker(i32** %20, i32** %22, i32* %23, i32 %24, i32 %25)
store i32 %26, i32* %8
%27 = load i32, i32* %8
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %55
29: ; preds = %0
%30 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%31 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %9)
%32 = load i32, i32* %9
%33 = icmp eq i32 %32, 1
br i1 %33, label %34, label %54
34: ; preds = %29
%35 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%36 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %10)
%37 = getelementptr inbounds [10 x [10 x i32]], [10 x [10 x i32]]* %4, i64 0, i64 0
%38 = bitcast [10 x i32]* %37 to i32**
%39 = getelementptr inbounds [10 x [10 x i32]], [10 x [10 x i32]]* %6, i64 0, i64 0
%40 = bitcast [10 x i32]* %39 to i32**
%41 = getelementptr inbounds [10 x i32], [10 x i32]* %7, i64 0, i64 0
%42 = load i32, i32* %10
%43 = sub nsw i32 %42, 1
%44 = load i32, i32* %3
%45 = call i32 @res_request(i32** %38, i32** %40, i32* %41, i32 %43, i32 %44)
%46 = getelementptr inbounds [10 x [10 x i32]], [10 x [10 x i32]]* %4, i64 0, i64 0
%47 = bitcast [10 x i32]* %46 to i32**
%48 = getelementptr inbounds [10 x [10 x i32]], [10 x [10 x i32]]* %6, i64 0, i64 0
%49 = bitcast [10 x i32]* %48 to i32**
%50 = getelementptr inbounds [10 x i32], [10 x i32]* %7, i64 0, i64 0
%51 = load i32, i32* %2
%52 = load i32, i32* %3
%53 = call i32 @banker(i32** %47, i32** %49, i32* %50, i32 %51, i32 %52)
store i32 %53, i32* %8
br label %54
54: ; preds = %34, %29
br label %55
55: ; preds = %54, %0
ret i32 0
}

LLVM IR (-O2):
@.str = [37 x i8] c"\0AMake an additional request? (1/0): \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [17 x i8] c"\0AWhich process: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [10 x [10 x i32]]
%4 = alloca [10 x [10 x i32]]
%5 = alloca [10 x [10 x i32]]
%6 = alloca [10 x i32]
%7 = alloca i32
%8 = alloca i32
%9 = bitcast i32* %1 to i8*
%10 = bitcast i32* %2 to i8*
%11 = bitcast [10 x [10 x i32]]* %3 to i8*
%12 = bitcast [10 x [10 x i32]]* %4 to i8*
%13 = bitcast [10 x [10 x i32]]* %5 to i8*
%14 = bitcast [10 x i32]* %6 to i8*
%15 = bitcast [10 x [10 x i32]]* %3 to i32**
%16 = bitcast [10 x [10 x i32]]* %5 to i32**
%17 = bitcast [10 x [10 x i32]]* %4 to i32**
%18 = getelementptr inbounds [10 x i32], [10 x i32]* %6, i64 0, i64 0
%19 = call i32 @input(i32** %15, i32** %16, i32** %17, i32* %18, i32* %1, i32* %2)
%20 = load i32, i32* %1
%21 = load i32, i32* %2
%22 = call i32 @banker(i32** %15, i32** %16, i32* %18, i32 %20, i32 %21)
%23 = icmp eq i32 %22, 0
br i1 %23, label %42, label %24
24: ; preds = %0
%25 = bitcast i32* %7 to i8*
%26 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%27 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
%28 = load i32, i32* %7
%29 = icmp eq i32 %28, 1
br i1 %29, label %30, label %41
30: ; preds = %24
%31 = bitcast i32* %8 to i8*
%32 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%33 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
%34 = load i32, i32* %8
%35 = add nsw i32 %34, -1
%36 = load i32, i32* %2
%37 = call i32 @res_request(i32** %15, i32** %16, i32* %18, i32 %35, i32 %36)
%38 = load i32, i32* %1
%39 = load i32, i32* %2
%40 = call i32 @banker(i32** %15, i32** %16, i32* %18, i32 %38, i32 %39)
br label %41
41: ; preds = %30, %24
br label %42
42: ; preds = %41, %0
ret i32 0
}