#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*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int my_req(int n, int m, int **need, int *available, int *req) {
  int p_num = 0;
  int *temp_req = req;
  int i = 0;
  printf("下面输入一次资源请求\n");
  printf("请输入资源请求的进程号: ");
  scanf("%d", &p_num);
  printf("请输入资源请求向量: \n");
  for (i = 0; i < m; i++) {
    scanf("%d", &temp_req[i]);
  }
  for (i = 0; i < m; i++) {
    if (temp_req[i] > need[p_num][i]) {
      printf("合理性不符合要求！\n");
      return -1;
    }
  }
  printf("资源请求合理！\n");
  for (i = 0; i < m; i++) {
    if (temp_req[i] > available[i]) {
      printf("可行性不符合要求！\n");
      return -1;
    }
  }
  printf("资源请求可行!\n");
  return p_num;
}


x86 assembly (clang, -O0):
<my_req>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
lea    0xea9(%rip),%rdi
call   1030 <printf@plt>
lea    0xebd(%rip),%rdi
call   1030 <printf@plt>
lea    0xed5(%rip),%rdi
lea    -0x2c(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xec8(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11c0 <my_req+0xa0>
mov    -0x38(%rbp),%rsi
movslq -0x3c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe97(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    118b <my_req+0x6b>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1222 <my_req+0x102>
mov    -0x38(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x18(%rbp),%rcx
movslq -0x2c(%rbp),%rdx
mov    (%rcx,%rdx,8),%rcx
movslq -0x3c(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jle    120f <my_req+0xef>
lea    0xe68(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    129a <my_req+0x17a>
jmp    1214 <my_req+0xf4>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11c7 <my_req+0xa7>
lea    0xe5a(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1288 <my_req+0x168>
mov    -0x38(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x20(%rbp),%rcx
movslq -0x3c(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jle    1275 <my_req+0x155>
lea    0xe36(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    129a <my_req+0x17a>
jmp    127a <my_req+0x15a>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1235 <my_req+0x115>
lea    0xe28(%rip),%rdi
call   1030 <printf@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_req>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8,%r13
mov    %rcx,0x8(%rsp)
mov    %rdx,%rbx
mov    %esi,%r12d
movl   $0x0,0x4(%rsp)
lea    0xecc(%rip),%rdi
call   1030 <puts@plt>
lea    0xe99(%rip),%rdi
call   1040 <printf@plt>
lea    0xeb1(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
lea    0xec2(%rip),%rdi
call   1030 <puts@plt>
test   %r12d,%r12d
jle    1225 <my_req+0xf5>
mov    %rbx,0x10(%rsp)
mov    %r12d,%r14d
lea    0xe83(%rip),%rbp
mov    %r14,%r15
mov    %r13,%rbx
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
add    $0x4,%rbx
add    $0xffffffffffffffff,%r15
jne    11b0 <my_req+0x80>
test   %r12d,%r12d
mov    0x10(%rsp),%rcx
jle    1225 <my_req+0xf5>
movslq 0x4(%rsp),%rax
mov    (%rcx,%rax,8),%rax
xor    %ecx,%ecx
nopw   0x0(%rax,%rax,1)
mov    0x0(%r13,%rcx,4),%edx
cmp    (%rax,%rcx,4),%edx
jg     1243 <my_req+0x113>
add    $0x1,%rcx
cmp    %rcx,%r14
jne    11e0 <my_req+0xb0>
lea    0xe6a(%rip),%rdi
call   1030 <puts@plt>
test   %r12d,%r12d
mov    0x8(%rsp),%rdx
jle    1231 <my_req+0x101>
xor    %eax,%eax
nopl   0x0(%rax,%rax,1)
mov    0x0(%r13,%rax,4),%ecx
cmp    (%rdx,%rax,4),%ecx
jg     124c <my_req+0x11c>
add    $0x1,%rax
cmp    %rax,%r14
jne    1210 <my_req+0xe0>
jmp    1231 <my_req+0x101>
lea    0xe38(%rip),%rdi
call   1030 <puts@plt>
lea    0xe42(%rip),%rdi
call   1030 <puts@plt>
mov    0x4(%rsp),%eax
jmp    125d <my_req+0x12d>
lea    0xe60(%rip),%rdi
jmp    1253 <my_req+0x123>
lea    0xe3b(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"\E4\B8\8B\E9\9D\A2\E8\BE\93\E5\85\A5\E4\B8\80\E6\AC\A1\E8\B5\84\E6\BA\90\E8\AF\B7\E6\B1\82\0A\00"
@.str.1 = [36 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5\E8\B5\84\E6\BA\90\E8\AF\B7\E6\B1\82\E7\9A\84\E8\BF\9B\E7\A8\8B\E5\8F\B7: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [31 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5\E8\B5\84\E6\BA\90\E8\AF\B7\E6\B1\82\E5\90\91\E9\87\8F: \0A\00"
@.str.4 = [29 x i8] c"\E5\90\88\E7\90\86\E6\80\A7\E4\B8\8D\E7\AC\A6\E5\90\88\E8\A6\81\E6\B1\82\EF\BC\81\0A\00"
@.str.5 = [23 x i8] c"\E8\B5\84\E6\BA\90\E8\AF\B7\E6\B1\82\E5\90\88\E7\90\86\EF\BC\81\0A\00"
@.str.6 = [29 x i8] c"\E5\8F\AF\E8\A1\8C\E6\80\A7\E4\B8\8D\E7\AC\A6\E5\90\88\E8\A6\81\E6\B1\82\EF\BC\81\0A\00"
@.str.7 = [21 x i8] c"\E8\B5\84\E6\BA\90\E8\AF\B7\E6\B1\82\E5\8F\AF\E8\A1\8C!\0A\00"
define i32 @my_req(i32 %0, i32 %1, i32** %2, i32* %3, i32* %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32**
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32
%13 = alloca i32*
%14 = alloca i32
store i32 %0, i32* %7
store i32 %1, i32* %8
store i32** %2, i32*** %9
store i32* %3, i32** %10
store i32* %4, i32** %11
store i32 0, i32* %12
%15 = load i32*, i32** %11
store i32* %15, i32** %13
store i32 0, i32* %14
%16 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%17 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %12)
%19 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %14
br label %20
20: ; preds = %30, %5
%21 = load i32, i32* %14
%22 = load i32, i32* %8
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %33
24: ; preds = %20
%25 = load i32*, i32** %13
%26 = load i32, i32* %14
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i32, i32* %25, i64 %27
%29 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %28)
br label %30
30: ; preds = %24
%31 = load i32, i32* %14
%32 = add nsw i32 %31, 1
store i32 %32, i32* %14
br label %20
33: ; preds = %20
store i32 0, i32* %14
br label %34
34: ; preds = %57, %33
%35 = load i32, i32* %14
%36 = load i32, i32* %8
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %60
38: ; preds = %34
%39 = load i32*, i32** %13
%40 = load i32, i32* %14
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i32, i32* %39, i64 %41
%43 = load i32, i32* %42
%44 = load i32**, i32*** %9
%45 = load i32, i32* %12
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i32*, i32** %44, i64 %46
%48 = load i32*, i32** %47
%49 = load i32, i32* %14
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i32, i32* %48, i64 %50
%52 = load i32, i32* %51
%53 = icmp sgt i32 %43, %52
br i1 %53, label %54, label %56
54: ; preds = %38
%55 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %6
br label %87
56: ; preds = %38
br label %57
57: ; preds = %56
%58 = load i32, i32* %14
%59 = add nsw i32 %58, 1
store i32 %59, i32* %14
br label %34
60: ; preds = %34
%61 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %14
br label %62
62: ; preds = %81, %60
%63 = load i32, i32* %14
%64 = load i32, i32* %8
%65 = icmp slt i32 %63, %64
br i1 %65, label %66, label %84
66: ; preds = %62
%67 = load i32*, i32** %13
%68 = load i32, i32* %14
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i32, i32* %67, i64 %69
%71 = load i32, i32* %70
%72 = load i32*, i32** %10
%73 = load i32, i32* %14
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds i32, i32* %72, i64 %74
%76 = load i32, i32* %75
%77 = icmp sgt i32 %71, %76
br i1 %77, label %78, label %80
78: ; preds = %66
%79 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0))
store i32 -1, i32* %6
br label %87
80: ; preds = %66
br label %81
81: ; preds = %80
%82 = load i32, i32* %14
%83 = add nsw i32 %82, 1
store i32 %83, i32* %14
br label %62
84: ; preds = %62
%85 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
%86 = load i32, i32* %12
store i32 %86, i32* %6
br label %87
87: ; preds = %84, %78, %54
%88 = load i32, i32* %6
ret i32 %88
}

LLVM IR (-O2):
@.str.1 = [36 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5\E8\B5\84\E6\BA\90\E8\AF\B7\E6\B1\82\E7\9A\84\E8\BF\9B\E7\A8\8B\E5\8F\B7: \00"
@.str.2 = [3 x i8] c"%d\00"
@str = [31 x i8] c"\E4\B8\8B\E9\9D\A2\E8\BE\93\E5\85\A5\E4\B8\80\E6\AC\A1\E8\B5\84\E6\BA\90\E8\AF\B7\E6\B1\82\00"
@str.8 = [30 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5\E8\B5\84\E6\BA\90\E8\AF\B7\E6\B1\82\E5\90\91\E9\87\8F: \00"
@str.9 = [22 x i8] c"\E8\B5\84\E6\BA\90\E8\AF\B7\E6\B1\82\E5\90\88\E7\90\86\EF\BC\81\00"
@str.10 = [20 x i8] c"\E8\B5\84\E6\BA\90\E8\AF\B7\E6\B1\82\E5\8F\AF\E8\A1\8C!\00"
@str.11 = [28 x i8] c"\E5\8F\AF\E8\A1\8C\E6\80\A7\E4\B8\8D\E7\AC\A6\E5\90\88\E8\A6\81\E6\B1\82\EF\BC\81\00"
@str.12 = [28 x i8] c"\E5\90\88\E7\90\86\E6\80\A7\E4\B8\8D\E7\AC\A6\E5\90\88\E8\A6\81\E6\B1\82\EF\BC\81\00"
define i32 @my_req(i32 %0, i32 %1, i32** nocapture %2, i32* nocapture %3, i32* %4) {
%6 = alloca i32
%7 = bitcast i32* %6 to i8*
store i32 0, i32* %6
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
%9 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %6)
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.8, i64 0, i64 0))
%12 = icmp sgt i32 %1, 0
br i1 %12, label %13, label %40
13: ; preds = %5
%14 = zext i32 %1 to i64
br label %22
15: ; preds = %22
br i1 %12, label %16, label %40
16: ; preds = %15
%17 = load i32, i32* %6
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i32*, i32** %2, i64 %18
%20 = load i32*, i32** %19
%21 = zext i32 %1 to i64
br label %30
22: ; preds = %13, %22
%23 = phi i64 [ 0, %13 ], [ %26, %22 ]
%24 = getelementptr inbounds i32, i32* %4, i64 %23
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %24)
%26 = add nuw nsw i64 %23, 1
%27 = icmp eq i64 %26, %14
br i1 %27, label %15, label %22
28: ; preds = %30
%29 = icmp eq i64 %37, %21
br i1 %29, label %42, label %30
30: ; preds = %16, %28
%31 = phi i64 [ 0, %16 ], [ %37, %28 ]
%32 = getelementptr inbounds i32, i32* %4, i64 %31
%33 = load i32, i32* %32
%34 = getelementptr inbounds i32, i32* %20, i64 %31
%35 = load i32, i32* %34
%36 = icmp sgt i32 %33, %35
%37 = add nuw nsw i64 %31, 1
br i1 %36, label %38, label %28
38: ; preds = %30
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.12, i64 0, i64 0))
br label %61
40: ; preds = %15, %5
%41 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.9, i64 0, i64 0))
br label %58
42: ; preds = %28
%43 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.9, i64 0, i64 0))
br i1 %12, label %44, label %58
44: ; preds = %42
%45 = zext i32 %1 to i64
br label %48
46: ; preds = %48
%47 = icmp eq i64 %55, %45
br i1 %47, label %58, label %48
48: ; preds = %44, %46
%49 = phi i64 [ 0, %44 ], [ %55, %46 ]
%50 = getelementptr inbounds i32, i32* %4, i64 %49
%51 = load i32, i32* %50
%52 = getelementptr inbounds i32, i32* %3, i64 %49
%53 = load i32, i32* %52
%54 = icmp sgt i32 %51, %53
%55 = add nuw nsw i64 %49, 1
br i1 %54, label %56, label %46
56: ; preds = %48
%57 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.11, i64 0, i64 0))
br label %61
58: ; preds = %46, %40, %42
%59 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.10, i64 0, i64 0))
%60 = load i32, i32* %6
br label %61
61: ; preds = %58, %56, %38
%62 = phi i32 [ -1, %38 ], [ -1, %56 ], [ %60, %58 ]
ret i32 %62
}