#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 get_highest_sum(int **, int);
int *get_numbers(char *, int);
int /*<<< orphan*/ gets(char *);
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char *argv[]) {
  int *rows[100];
  int i, j;
  char s[100 * 3];
  for (i = 0; i < 100; i++) {
    gets(s);
    rows[i] = get_numbers(s, i + 1);
  }
  printf("The highest sum by bottom-up is %d\n", get_highest_sum(rows, 100));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x470,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x334(%rbp)
cmpl   $0x64,-0x334(%rbp)
jge    11b7 <main+0x77>
lea    -0x470(%rbp),%rdi
call   1050 <gets@plt>
lea    -0x470(%rbp),%rdi
mov    -0x334(%rbp),%esi
add    $0x1,%esi
call   1060 <get_numbers@plt>
mov    %rax,%rcx
movslq -0x334(%rbp),%rax
mov    %rcx,-0x330(%rbp,%rax,8)
ff
mov    -0x334(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x334(%rbp)
jmp    1163 <main+0x23>
lea    -0x330(%rbp),%rdi
mov    $0x64,%esi
call   1030 <get_highest_sum@plt>
mov    %eax,%esi
lea    0xe2f(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x470,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x450,%rsp
xor    %r15d,%r15d
mov    %rsp,%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
call   1050 <gets@plt>
lea    0x1(%r15),%rbx
mov    %r14,%rdi
mov    %ebx,%esi
call   1060 <get_numbers@plt>
mov    %rax,0x130(%rsp,%r15,8)
mov    %rbx,%r15
cmp    $0x64,%rbx
jne    1160 <main+0x20>
lea    0x130(%rsp),%rdi
mov    $0x64,%esi
call   1030 <get_highest_sum@plt>
lea    0xe60(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x450,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [36 x i8] c"The highest sum by bottom-up is %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [100 x i32*]
%7 = alloca i32
%8 = alloca i32
%9 = alloca [300 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
br label %10
10: ; preds = %23, %2
%11 = load i32, i32* %7
%12 = icmp slt i32 %11, 100
br i1 %12, label %13, label %26
13: ; preds = %10
%14 = getelementptr inbounds [300 x i8], [300 x i8]* %9, i64 0, i64 0
%15 = call i32 @gets(i8* %14)
%16 = getelementptr inbounds [300 x i8], [300 x i8]* %9, i64 0, i64 0
%17 = load i32, i32* %7
%18 = add nsw i32 %17, 1
%19 = call i32* @get_numbers(i8* %16, i32 %18)
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [100 x i32*], [100 x i32*]* %6, i64 0, i64 %21
store i32* %19, i32** %22
br label %23
23: ; preds = %13
%24 = load i32, i32* %7
%25 = add nsw i32 %24, 1
store i32 %25, i32* %7
br label %10
26: ; preds = %10
%27 = getelementptr inbounds [100 x i32*], [100 x i32*]* %6, i64 0, i64 0
%28 = call i32 @get_highest_sum(i32** %27, i32 100)
%29 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %28)
ret i32 0
}

LLVM IR (-O2):
@.str = [36 x i8] c"The highest sum by bottom-up is %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [100 x i32*]
%4 = alloca [300 x i8]
%5 = bitcast [100 x i32*]* %3 to i8*
%6 = getelementptr inbounds [300 x i8], [300 x i8]* %4, i64 0, i64 0
br label %7
7: ; preds = %2, %7
%8 = phi i64 [ 0, %2 ], [ %10, %7 ]
%9 = call i32 @gets(i8* %6)
%10 = add nuw nsw i64 %8, 1
%11 = trunc i64 %10 to i32
%12 = call i32* @get_numbers(i8* %6, i32 %11)
%13 = getelementptr inbounds [100 x i32*], [100 x i32*]* %3, i64 0, i64 %8
store i32* %12, i32** %13
%14 = icmp eq i64 %10, 100
br i1 %14, label %15, label %7
15: ; preds = %7
%16 = getelementptr inbounds [100 x i32*], [100 x i32*]* %3, i64 0, i64 0
%17 = call i32 @get_highest_sum(i32** %16, i32 100)
%18 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %17)
ret i32 0
}