#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*/ findmax(int **);
scalar_t__ malloc(int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int **input = (int **)malloc(100 * sizeof(int *));
  int i, j;
  for (i = 0; i < 100; i++) {
    input[i] = (int *)malloc((i + 1) * sizeof(int));
  }
  for (i = 0; i < 100; i++) {
    for (j = 0; j <= i; j++) {
      scanf("%d", &input[i][j]);
    }
  }
  findmax(input);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x320,%edi
call   1030 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x64,-0x14(%rbp)
jge    118e <main+0x5e>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1154 <main+0x24>
movl   $0x0,-0x14(%rbp)
cmpl   $0x64,-0x14(%rbp)
jge    11f6 <main+0xc6>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     11e3 <main+0xb3>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
movslq -0x18(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe30(%rip),%rdi
call   1050 <scanf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11a6 <main+0x76>
jmp    11e8 <main+0xb8>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1195 <main+0x65>
mov    -0x10(%rbp),%rdi
call   1040 <findmax@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    $0x320,%edi
call   1030 <malloc@plt>
mov    %rax,%r15
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
lea    0x4(%rbx),%r14
mov    %r14d,%edi
call   1030 <malloc@plt>
mov    %rax,(%r15,%rbx,2)
mov    %r14,%rbx
cmp    $0x190,%r14
jne    1150 <main+0x20>
mov    $0x4,%r12d
xor    %r13d,%r13d
lea    0xe84(%rip),%r14
nopl   0x0(%rax)
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%r15,%r13,8),%rsi
add    %rbx,%rsi
mov    %r14,%rdi
call   1050 <scanf@plt>
add    $0x4,%rbx
cmp    %rbx,%r12
jne    1190 <main+0x60>
add    $0x1,%r13
add    $0x4,%r12
cmp    $0x64,%r13
jne    1180 <main+0x50>
mov    %r15,%rdi
call   1040 <findmax@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32**
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i64 @malloc(i32 800)
%6 = inttoptr i64 %5 to i32**
store i32** %6, i32*** %2
store i32 0, i32* %3
br label %7
7: ; preds = %22, %0
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 100
br i1 %9, label %10, label %25
10: ; preds = %7
%11 = load i32, i32* %3
%12 = add nsw i32 %11, 1
%13 = sext i32 %12 to i64
%14 = mul i64 %13, 4
%15 = trunc i64 %14 to i32
%16 = call i64 @malloc(i32 %15)
%17 = inttoptr i64 %16 to i32*
%18 = load i32**, i32*** %2
%19 = load i32, i32* %3
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32*, i32** %18, i64 %20
store i32* %17, i32** %21
br label %22
22: ; preds = %10
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
br label %7
25: ; preds = %7
store i32 0, i32* %3
br label %26
26: ; preds = %48, %25
%27 = load i32, i32* %3
%28 = icmp slt i32 %27, 100
br i1 %28, label %29, label %51
29: ; preds = %26
store i32 0, i32* %4
br label %30
30: ; preds = %44, %29
%31 = load i32, i32* %4
%32 = load i32, i32* %3
%33 = icmp sle i32 %31, %32
br i1 %33, label %34, label %47
34: ; preds = %30
%35 = load i32**, i32*** %2
%36 = load i32, i32* %3
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i32*, i32** %35, i64 %37
%39 = load i32*, i32** %38
%40 = load i32, i32* %4
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i32, i32* %39, i64 %41
%43 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %42)
br label %44
44: ; preds = %34
%45 = load i32, i32* %4
%46 = add nsw i32 %45, 1
store i32 %46, i32* %4
br label %30
47: ; preds = %30
br label %48
48: ; preds = %47
%49 = load i32, i32* %3
%50 = add nsw i32 %49, 1
store i32 %50, i32* %3
br label %26
51: ; preds = %26
%52 = load i32**, i32*** %2
%53 = call i32 @findmax(i32** %52)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = tail call i64 @malloc(i32 800)
%2 = inttoptr i64 %1 to i32**
br label %3
3: ; preds = %0, %3
%4 = phi i64 [ 0, %0 ], [ %5, %3 ]
%5 = add nuw nsw i64 %4, 1
%6 = trunc i64 %5 to i32
%7 = shl i32 %6, 2
%8 = tail call i64 @malloc(i32 %7)
%9 = inttoptr i64 %8 to i32*
%10 = getelementptr inbounds i32*, i32** %2, i64 %4
store i32* %9, i32** %10
%11 = icmp eq i64 %5, 100
br i1 %11, label %12, label %3
12: ; preds = %3, %23
%13 = phi i64 [ %24, %23 ], [ 0, %3 ]
%14 = phi i64 [ %25, %23 ], [ 1, %3 ]
%15 = getelementptr inbounds i32*, i32** %2, i64 %13
br label %16
16: ; preds = %12, %16
%17 = phi i64 [ 0, %12 ], [ %21, %16 ]
%18 = load i32*, i32** %15
%19 = getelementptr inbounds i32, i32* %18, i64 %17
%20 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %19)
%21 = add nuw nsw i64 %17, 1
%22 = icmp eq i64 %21, %14
br i1 %22, label %23, label %16
23: ; preds = %16
%24 = add nuw nsw i64 %13, 1
%25 = add nuw nsw i64 %14, 1
%26 = icmp eq i64 %24, 100
br i1 %26, label %27, label %12
27: ; preds = %23
%28 = tail call i32 @findmax(i32** %2)
ret i32 0
}