#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 *address(int **, int);
int /*<<< orphan*/ display(int *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
void main() {
  int score[3][4] = {{76, 87, 56, 89}, {34, 983, 12, 382}, {37, 83, 24, 82}};
  int row;
  int *ptr;
  int num = 4;
  printf("(1, 2, 3)?");
  scanf("%d", &row);
  while (row) {
    if (row == 1 || row == 2 || row == 3) {
      printf("student %d\n", row);
      ptr = address(score, row - 1);
      display(ptr, num);
      printf("(1, 2, 3)?");
      scanf("%d", &row);
    } else {
      printf("error row, input again\n");
      printf("(1, 2, 3)?");
      scanf("%d", &row);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
lea    -0x30(%rbp),%rdi
lea    0xe9d(%rip),%rsi
mov    $0x30,%edx
call   1060 <memcpy@plt>
movl   $0x4,-0x44(%rbp)
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb2(%rip),%rdi
lea    -0x34(%rbp),%rsi
call   1070 <scanf@plt>
cmpl   $0x0,-0x34(%rbp)
je     123e <main+0xee>
cmpl   $0x1,-0x34(%rbp)
je     11ba <main+0x6a>
cmpl   $0x2,-0x34(%rbp)
je     11ba <main+0x6a>
cmpl   $0x3,-0x34(%rbp)
jne    120d <main+0xbd>
mov    -0x34(%rbp),%esi
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%esi
sub    $0x1,%esi
call   1050 <address@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x44(%rbp),%esi
call   1030 <display@plt>
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe3c(%rip),%rdi
lea    -0x34(%rbp),%rsi
call   1070 <scanf@plt>
jmp    1239 <main+0xe9>
lea    0xe36(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe0e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe0b(%rip),%rdi
lea    -0x34(%rbp),%rsi
call   1070 <scanf@plt>
jmp    1192 <main+0x42>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
movaps 0xebb(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xe9f(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe83(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0xea7(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xea4(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
mov    0xc(%rsp),%esi
test   %esi,%esi
je     1235 <main+0xe5>
lea    0xe8a(%rip),%r14
lea    0x10(%rsp),%r15
lea    0xe70(%rip),%r12
lea    0xe74(%rip),%r13
lea    0xc(%rsp),%rbx
lea    0xe77(%rip),%rbp
jmp    1205 <main+0xb5>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbp,%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
mov    0xc(%rsp),%esi
test   %esi,%esi
je     1235 <main+0xe5>
lea    -0x1(%rsi),%eax
cmp    $0x2,%eax
ja     11e0 <main+0x90>
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rsp),%esi
add    $0xffffffff,%esi
mov    %r15,%rdi
call   1060 <address@plt>
mov    %rax,%rdi
mov    $0x4,%esi
call   1040 <display@plt>
jmp    11e8 <main+0x98>
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 56, i32 89], [4 x i32] [i32 34, i32 983, i32 12, i32 382], [4 x i32] [i32 37, i32 83, i32 24, i32 82]]
@.str = [11 x i8] c"(1, 2, 3)?\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [12 x i8] c"student %d\0A\00"
@.str.3 = [24 x i8] c"error row, input again\0A\00"
define void @main() {
%1 = alloca [3 x [4 x i32]]
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = bitcast [3 x [4 x i32]]* %1 to i8*
store i32 4, i32* %4
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %8
8: ; preds = %37, %0
%9 = load i32, i32* %2
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %38
11: ; preds = %8
%12 = load i32, i32* %2
%13 = icmp eq i32 %12, 1
br i1 %13, label %20, label %14
14: ; preds = %11
%15 = load i32, i32* %2
%16 = icmp eq i32 %15, 2
br i1 %16, label %20, label %17
17: ; preds = %14
%18 = load i32, i32* %2
%19 = icmp eq i32 %18, 3
br i1 %19, label %20, label %33
20: ; preds = %17, %14, %11
%21 = load i32, i32* %2
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %21)
%23 = getelementptr inbounds [3 x [4 x i32]], [3 x [4 x i32]]* %1, i64 0, i64 0
%24 = bitcast [4 x i32]* %23 to i32**
%25 = load i32, i32* %2
%26 = sub nsw i32 %25, 1
%27 = call i32* @address(i32** %24, i32 %26)
store i32* %27, i32** %3
%28 = load i32*, i32** %3
%29 = load i32, i32* %4
%30 = call i32 @display(i32* %28, i32 %29)
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%32 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %37
33: ; preds = %17
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%36 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %37
37: ; preds = %33, %20
br label %8
38: ; preds = %8
ret void
}

LLVM IR (-O2):
@__const.main.score = [3 x [4 x i32]] [[4 x i32] [i32 76, i32 87, i32 56, i32 89], [4 x i32] [i32 34, i32 983, i32 12, i32 382], [4 x i32] [i32 37, i32 83, i32 24, i32 82]]
@.str = [11 x i8] c"(1, 2, 3)?\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [12 x i8] c"student %d\0A\00"
@str = [23 x i8] c"error row, input again\00"
define void @main() {
%1 = alloca [3 x [4 x i32]]
%2 = alloca i32
%3 = bitcast [3 x [4 x i32]]* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = load i32, i32* %2
%8 = icmp eq i32 %7, 0
br i1 %8, label %28, label %9
9: ; preds = %0
%10 = bitcast [3 x [4 x i32]]* %1 to i32**
br label %11
11: ; preds = %9, %23
%12 = phi i32 [ %7, %9 ], [ %26, %23 ]
%13 = add i32 %12, -1
%14 = icmp ult i32 %13, 3
br i1 %14, label %15, label %21
15: ; preds = %11
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%17 = load i32, i32* %2
%18 = add nsw i32 %17, -1
%19 = call i32* @address(i32** %10, i32 %18)
%20 = call i32 @display(i32* %19, i32 4)
br label %23
21: ; preds = %11
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
br label %23
23: ; preds = %21, %15
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%26 = load i32, i32* %2
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %11
28: ; preds = %23, %0
ret void
}