#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*/ display(int, int *);
int *find_addr(int **, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
void main() {
  int row = 0;
  int num = 4;
  int *pos;
  int score[3][4] = {{76, 87, 85, 81}, {67, 61, 71, 60}, {81, 89, 82, 78}};
  scanf("%d", &row);
  while (row) {
    if (row == 1 || row == 2 || row == 3) {
      printf("no.row student's score:\n");
      pos = find_addr(score, row - 1);
      display(num, pos);
      printf("input (1, 2, or 3), 0 indicates exit\n");
      scanf("%d", &row);
    } else {
      printf("input illegal, input (1, 2, or 3), 0 indicates exit\n");
      scanf("%d", &row);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x4,-0x8(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xe8f(%rip),%rsi
mov    $0x30,%edx
call   1050 <memcpy@plt>
lea    0xeae(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1070 <scanf@plt>
cmpl   $0x0,-0x4(%rbp)
je     1220 <main+0xd0>
cmpl   $0x1,-0x4(%rbp)
je     11b3 <main+0x63>
cmpl   $0x2,-0x4(%rbp)
je     11b3 <main+0x63>
cmpl   $0x3,-0x4(%rbp)
jne    11ff <main+0xaf>
lea    0xe79(%rip),%rdi
call   1040 <printf@plt>
lea    -0x40(%rbp),%rdi
mov    -0x4(%rbp),%esi
sub    $0x1,%esi
call   1060 <find_addr@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <display@plt>
lea    0xe76(%rip),%rdi
call   1040 <printf@plt>
lea    0xe3f(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1070 <scanf@plt>
jmp    121b <main+0xcb>
lea    0xe46(%rip),%rdi
call   1040 <printf@plt>
lea    0xe1e(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1070 <scanf@plt>
jmp    118b <main+0x3b>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
movl   $0x0,0xc(%rsp)
movaps 0xec3(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xea7(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe8b(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0xeaf(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
je     120c <main+0xcc>
lea    0xe99(%rip),%r13
lea    0xec6(%rip),%r14
lea    0x10(%rsp),%r15
lea    0xe95(%rip),%rbp
lea    0xe7c(%rip),%r12
lea    0xc(%rsp),%rbx
jmp    11d8 <main+0x98>
nopl   0x0(%rax,%rax,1)
call   1030 <puts@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
je     120c <main+0xcc>
add    $0xffffffff,%eax
mov    %r13,%rdi
cmp    $0x2,%eax
ja     11c0 <main+0x80>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    0xc(%rsp),%esi
add    $0xffffffff,%esi
mov    %r15,%rdi
call   1050 <find_addr@plt>
mov    $0x4,%edi
mov    %rax,%rsi
call   1040 <display@plt>
mov    %rbp,%rdi
jmp    11c0 <main+0x80>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.score = [3 x [4 x i32]] [[4 x i32] [i32 76, i32 87, i32 85, i32 81], [4 x i32] [i32 67, i32 61, i32 71, i32 60], [4 x i32] [i32 81, i32 89, i32 82, i32 78]]
@.str = [3 x i8] c"%d\00"
@.str.1 = [25 x i8] c"no.row student's score:\0A\00"
@.str.2 = [38 x i8] c"input (1, 2, or 3), 0 indicates exit\0A\00"
@.str.3 = [53 x i8] c"input illegal, input (1, 2, or 3), 0 indicates exit\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = alloca [3 x [4 x i32]]
store i32 0, i32* %1
store i32 4, i32* %2
%5 = bitcast [3 x [4 x i32]]* %4 to i8*
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
br label %7
7: ; preds = %34, %0
%8 = load i32, i32* %1
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %35
10: ; preds = %7
%11 = load i32, i32* %1
%12 = icmp eq i32 %11, 1
br i1 %12, label %19, label %13
13: ; preds = %10
%14 = load i32, i32* %1
%15 = icmp eq i32 %14, 2
br i1 %15, label %19, label %16
16: ; preds = %13
%17 = load i32, i32* %1
%18 = icmp eq i32 %17, 3
br i1 %18, label %19, label %31
19: ; preds = %16, %13, %10
%20 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%21 = getelementptr inbounds [3 x [4 x i32]], [3 x [4 x i32]]* %4, i64 0, i64 0
%22 = bitcast [4 x i32]* %21 to i32**
%23 = load i32, i32* %1
%24 = sub nsw i32 %23, 1
%25 = call i32* @find_addr(i32** %22, i32 %24)
store i32* %25, i32** %3
%26 = load i32, i32* %2
%27 = load i32*, i32** %3
%28 = call i32 @display(i32 %26, i32* %27)
%29 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
%30 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
br label %34
31: ; preds = %16
%32 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.3, i64 0, i64 0))
%33 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
br label %34
34: ; preds = %31, %19
br label %7
35: ; preds = %7
ret void
}

LLVM IR (-O2):
@__const.main.score = [3 x [4 x i32]] [[4 x i32] [i32 76, i32 87, i32 85, i32 81], [4 x i32] [i32 67, i32 61, i32 71, i32 60], [4 x i32] [i32 81, i32 89, i32 82, i32 78]]
@.str = [3 x i8] c"%d\00"
@str = [52 x i8] c"input illegal, input (1, 2, or 3), 0 indicates exit\00"
@str.4 = [24 x i8] c"no.row student's score:\00"
@str.5 = [37 x i8] c"input (1, 2, or 3), 0 indicates exit\00"
define void @main() {
%1 = alloca i32
%2 = alloca [3 x [4 x i32]]
%3 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%4 = bitcast [3 x [4 x i32]]* %2 to i8*
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = icmp eq i32 %6, 0
br i1 %7, label %26, label %8
8: ; preds = %0
%9 = bitcast [3 x [4 x i32]]* %2 to i32**
br label %10
10: ; preds = %8, %20
%11 = phi i32 [ %6, %8 ], [ %24, %20 ]
%12 = add i32 %11, -1
%13 = icmp ult i32 %12, 3
br i1 %13, label %14, label %20
14: ; preds = %10
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.4, i64 0, i64 0))
%16 = load i32, i32* %1
%17 = add nsw i32 %16, -1
%18 = call i32* @find_addr(i32** %9, i32 %17)
%19 = call i32 @display(i32 4, i32* %18)
br label %20
20: ; preds = %10, %14
%21 = phi i8* [ getelementptr inbounds ([37 x i8], [37 x i8]* @str.5, i64 0, i64 0), %14 ], [ getelementptr inbounds ([52 x i8], [52 x i8]* @str, i64 0, i64 0), %10 ]
%22 = call i32 @puts(i8* dereferenceable(1) %21)
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%24 = load i32, i32* %1
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %10
26: ; preds = %20, %0
ret void
}