#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);
scalar_t__ search(int, int, int);
int main(void) {
  int count = 0;
  int i;
  for (i = 0; i < 5 * 4; i++) {
    count += search(i % 5, i / 5, 1);
  }
  printf("%d", count / 2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x14,-0xc(%rbp)
jge    1186 <main+0x66>
mov    -0xc(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
mov    -0xc(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    $0x1,%edx
call   1040 <search@plt>
mov    %rax,%rcx
movslq -0x8(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    113d <main+0x1d>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xe66(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
xor    %ebp,%ebp
mov    $0xcccccccd,%r14d
xor    %ebx,%ebx
xchg   %ax,%ax
mov    %ebp,%eax
imul   %r14,%rax
shr    $0x22,%rax
lea    (%rax,%rax,4),%eax
mov    %ebp,%edi
sub    %eax,%edi
movzbl %bpl,%eax
imul   $0xcd,%eax,%esi
shr    $0xa,%esi
mov    $0x1,%edx
call   1040 <search@plt>
add    %eax,%ebx
add    $0x1,%ebp
cmp    $0x14,%ebp
jne    1130 <main+0x10>
mov    %ebx,%esi
shr    $0x1f,%esi
add    %ebx,%esi
sar    %esi
lea    0xe8e(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
br label %4
4: ; preds = %17, %0
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 20
br i1 %6, label %7, label %20
7: ; preds = %4
%8 = load i32, i32* %3
%9 = srem i32 %8, 5
%10 = load i32, i32* %3
%11 = sdiv i32 %10, 5
%12 = call i64 @search(i32 %9, i32 %11, i32 1)
%13 = load i32, i32* %2
%14 = sext i32 %13 to i64
%15 = add nsw i64 %14, %12
%16 = trunc i64 %15 to i32
store i32 %16, i32* %2
br label %17
17: ; preds = %7
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 1
store i32 %19, i32* %3
br label %4
20: ; preds = %4
%21 = load i32, i32* %2
%22 = sdiv i32 %21, 2
%23 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %22)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
br label %1
1: ; preds = %0, %1
%2 = phi i32 [ 0, %0 ], [ %12, %1 ]
%3 = phi i32 [ 0, %0 ], [ %11, %1 ]
%4 = trunc i32 %2 to i8
%5 = urem i8 %4, 5
%6 = zext i8 %5 to i32
%7 = udiv i8 %4, 5
%8 = zext i8 %7 to i32
%9 = tail call i64 @search(i32 %6, i32 %8, i32 1)
%10 = trunc i64 %9 to i32
%11 = add i32 %3, %10
%12 = add nuw nsw i32 %2, 1
%13 = icmp eq i32 %12, 20
br i1 %13, label %14, label %1
14: ; preds = %1
%15 = sdiv i32 %11, 2
%16 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %15)
ret i32 0
}