#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 findElemInMatrix1(int *, int, int, int);
int /*<<< orphan*/ printf(char *, int, ...);
scalar_t__ scanf(char *, int *);
int main(int argc, char *argv[]) {
  int matrix[5 * 8] = {
      1,  2,  3,  4,  5,  6,  7,  8,  9,  10, 11, 12, 13, 14,
      15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
      29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
  };
  int i, elem;
  while (scanf("%d", &elem) && elem != 0) {
    i = findElemInMatrix1(matrix, 5, 8, elem);
    if (i >= 0) {
      printf("%d is in the matrix(%d,%d)\n", elem, i / 8, i % 8);
    } else {
      printf("%d is not in the matrix\n", elem);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0xb0(%rbp),%rdi
lea    0xe99(%rip),%rsi
mov    $0xa0,%edx
call   1050 <memcpy@plt>
lea    0xf28(%rip),%rdi
lea    -0xb8(%rbp),%rsi
call   1060 <scanf@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0xb9(%rbp)
je     11a9 <main+0x69>
cmpl   $0x0,-0xb8(%rbp)
setne  %al
mov    %al,-0xb9(%rbp)
mov    -0xb9(%rbp),%al
test   $0x1,%al
jne    11bc <main+0x7c>
jmp    1247 <main+0x107>
lea    -0xb0(%rbp),%rdi
mov    -0xb8(%rbp),%ecx
mov    $0x5,%esi
mov    $0x8,%edx
call   1030 <findElemInMatrix1@plt>
mov    %eax,-0xb4(%rbp)
cmpl   $0x0,-0xb4(%rbp)
jl     122e <main+0xee>
mov    -0xb8(%rbp),%esi
mov    -0xb4(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc0(%rbp)
mov    -0xb4(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %edx,%ecx
mov    -0xc0(%rbp),%edx
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1242 <main+0x102>
mov    -0xb8(%rbp),%esi
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1171 <main+0x31>
xor    %eax,%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xb0,%rsp
lea    0xea9(%rip),%rsi
lea    0x10(%rsp),%rdi
mov    $0xa0,%edx
call   1050 <memcpy@plt>
lea    0xf33(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
test   %rax,%rax
je     1202 <main+0xc2>
mov    0xc(%rsp),%ecx
test   %ecx,%ecx
je     1202 <main+0xc2>
lea    0x10(%rsp),%r15
lea    0xf0f(%rip),%r14
lea    0xf05(%rip),%r12
lea    0xc(%rsp),%rbx
lea    0xf18(%rip),%r13
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    $0x5,%esi
mov    $0x8,%edx
call   1030 <findElemInMatrix1@plt>
mov    0xc(%rsp),%esi
test   %eax,%eax
js     11e0 <main+0xa0>
mov    %eax,%edx
shr    $0x3,%edx
and    $0x7,%eax
mov    %r14,%rdi
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11ea <main+0xaa>
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
test   %rax,%rax
je     1202 <main+0xc2>
mov    0xc(%rsp),%ecx
test   %ecx,%ecx
jne    11b0 <main+0x70>
xor    %eax,%eax
add    $0xb0,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.matrix = [40 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31, i32 32, i32 33, i32 34, i32 35, i32 36, i32 37, i32 38, i32 39, i32 40]
@.str = [3 x i8] c"%d\00"
@.str.1 = [28 x i8] c"%d is in the matrix(%d,%d)\0A\00"
@.str.2 = [25 x i8] c"%d is not in the matrix\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [40 x i32]
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = bitcast [40 x i32]* %6 to i8*
br label %10
10: ; preds = %34, %2
%11 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %8)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = load i32, i32* %8
%15 = icmp ne i32 %14, 0
br label %16
16: ; preds = %13, %10
%17 = phi i1 [ false, %10 ], [ %15, %13 ]
br i1 %17, label %18, label %35
18: ; preds = %16
%19 = getelementptr inbounds [40 x i32], [40 x i32]* %6, i64 0, i64 0
%20 = load i32, i32* %8
%21 = call i32 @findElemInMatrix1(i32* %19, i32 5, i32 8, i32 %20)
store i32 %21, i32* %7
%22 = load i32, i32* %7
%23 = icmp sge i32 %22, 0
br i1 %23, label %24, label %31
24: ; preds = %18
%25 = load i32, i32* %8
%26 = load i32, i32* %7
%27 = sdiv i32 %26, 8
%28 = load i32, i32* %7
%29 = srem i32 %28, 8
%30 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %25, i32 %27, i32 %29)
br label %34
31: ; preds = %18
%32 = load i32, i32* %8
%33 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %32)
br label %34
34: ; preds = %31, %24
br label %10
35: ; preds = %16
ret i32 0
}

LLVM IR (-O2):
@__const.main.matrix = [40 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31, i32 32, i32 33, i32 34, i32 35, i32 36, i32 37, i32 38, i32 39, i32 40]
@.str = [3 x i8] c"%d\00"
@.str.1 = [28 x i8] c"%d is in the matrix(%d,%d)\0A\00"
@.str.2 = [25 x i8] c"%d is not in the matrix\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [40 x i32]
%4 = alloca i32
%5 = bitcast [40 x i32]* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%8 = icmp ne i64 %7, 0
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 0
%11 = select i1 %8, i1 %10, i1 false
br i1 %11, label %12, label %31
12: ; preds = %2
%13 = getelementptr inbounds [40 x i32], [40 x i32]* %3, i64 0, i64 0
br label %14
14: ; preds = %12, %25
%15 = phi i32 [ %9, %12 ], [ %28, %25 ]
%16 = call i32 @findElemInMatrix1(i32* %13, i32 5, i32 8, i32 %15)
%17 = icmp sgt i32 %16, -1
%18 = load i32, i32* %4
br i1 %17, label %19, label %23
19: ; preds = %14
%20 = lshr i32 %16, 3
%21 = and i32 %16, 7
%22 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %18, i32 %20, i32 %21)
br label %25
23: ; preds = %14
%24 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %18)
br label %25
25: ; preds = %23, %19
%26 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%27 = icmp ne i64 %26, 0
%28 = load i32, i32* %4
%29 = icmp ne i32 %28, 0
%30 = select i1 %27, i1 %29, i1 false
br i1 %30, label %14, label %31
31: ; preds = %25, %2
ret i32 0
}