#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 biggest_line(unsigned char *, int);
int nb_lines(unsigned char *, int);
int /*<<< orphan*/ remove_alums(unsigned char *, int, int, int);
int ia(unsigned char *rows, int size) {
  int removed;
  removed = rows[biggest_line(rows, size)];
  if (nb_lines(rows, size) <= 3)
    --removed;
  if (removed < 1)
    removed = 1;
  remove_alums(rows, biggest_line(rows, size) + 1, removed, size);
  return (0);
}


x86 assembly (clang, -O0):
<ia>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <biggest_line@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1040 <nb_lines@plt>
cmp    $0x3,%eax
jg     1181 <ia+0x51>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x1,-0x10(%rbp)
jge    1192 <ia+0x62>
movl   $0x1,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <biggest_line@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%esi
add    $0x1,%esi
mov    -0x10(%rbp),%edx
mov    -0xc(%rbp),%ecx
call   1050 <remove_alums@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ia>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %rdi,%r15
call   1030 <biggest_line@plt>
cltq
movzbl (%r15,%rax,1),%ebx
mov    %r15,%rdi
mov    %r14d,%esi
call   1040 <nb_lines@plt>
xor    %ecx,%ecx
cmp    $0x4,%eax
setl   %cl
sub    %ecx,%ebx
test   %ebx,%ebx
mov    $0x1,%ebp
cmovg  %ebx,%ebp
mov    %r15,%rdi
mov    %r14d,%esi
call   1030 <biggest_line@plt>
lea    0x1(%rax),%esi
mov    %r15,%rdi
mov    %ebp,%edx
mov    %r14d,%ecx
call   1050 <remove_alums@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @ia(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = load i8*, i8** %3
%7 = load i8*, i8** %3
%8 = load i32, i32* %4
%9 = call i32 @biggest_line(i8* %7, i32 %8)
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %6, i64 %10
%12 = load i8, i8* %11
%13 = zext i8 %12 to i32
store i32 %13, i32* %5
%14 = load i8*, i8** %3
%15 = load i32, i32* %4
%16 = call i32 @nb_lines(i8* %14, i32 %15)
%17 = icmp sle i32 %16, 3
br i1 %17, label %18, label %21
18: ; preds = %2
%19 = load i32, i32* %5
%20 = add nsw i32 %19, -1
store i32 %20, i32* %5
br label %21
21: ; preds = %18, %2
%22 = load i32, i32* %5
%23 = icmp slt i32 %22, 1
br i1 %23, label %24, label %25
24: ; preds = %21
store i32 1, i32* %5
br label %25
25: ; preds = %24, %21
%26 = load i8*, i8** %3
%27 = load i8*, i8** %3
%28 = load i32, i32* %4
%29 = call i32 @biggest_line(i8* %27, i32 %28)
%30 = add nsw i32 %29, 1
%31 = load i32, i32* %5
%32 = load i32, i32* %4
%33 = call i32 @remove_alums(i8* %26, i32 %30, i32 %31, i32 %32)
ret i32 0
}

LLVM IR (-O2):
define i32 @ia(i8* %0, i32 %1) {
%3 = tail call i32 @biggest_line(i8* %0, i32 %1)
%4 = sext i32 %3 to i64
%5 = getelementptr inbounds i8, i8* %0, i64 %4
%6 = load i8, i8* %5
%7 = zext i8 %6 to i32
%8 = tail call i32 @nb_lines(i8* %0, i32 %1)
%9 = icmp slt i32 %8, 4
%10 = sext i1 %9 to i32
%11 = add nsw i32 %10, %7
%12 = icmp sgt i32 %11, 1
%13 = select i1 %12, i32 %11, i32 1
%14 = tail call i32 @biggest_line(i8* %0, i32 %1)
%15 = add nsw i32 %14, 1
%16 = tail call i32 @remove_alums(i8* %0, i32 %15, i32 %13, i32 %1)
ret i32 0
}