#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 string_length(char *);
int sum_matrix(int **);
int sum_row_max(int **);
int main() {
  int x[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
  int sum_max = sum_row_max(x);
  printf("Sum of max from each row is: %d\n", sum_max);
  int sum_elements = sum_matrix(x);
  printf("Sum of all elements is: %d\n", sum_elements);
  char *s = "Hello World";
  int length = string_length(s);
  printf("Length of '%s' is %d\n", s, length);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xe96(%rip),%rsi
mov    $0x24,%edx
call   1040 <memcpy@plt>
lea    -0x30(%rbp),%rdi
call   1060 <sum_row_max@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%esi
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x30(%rbp),%rdi
call   1070 <sum_matrix@plt>
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%esi
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeac(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
call   1050 <string_length@plt>
mov    %eax,-0x44(%rbp)
mov    -0x40(%rbp),%rsi
mov    -0x44(%rbp),%edx
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
mov    0xed5(%rip),%eax
mov    %eax,0x20(%rsp)
movaps 0xeba(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe9e(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1050 <sum_row_max@plt>
lea    0xeac(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1060 <sum_matrix@plt>
lea    0xeb5(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xec1(%rip),%rbx
mov    %rbx,%rdi
call   1040 <string_length@plt>
lea    0xebe(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.x = [3 x [3 x i32]] [[3 x i32] [i32 1, i32 2, i32 3], [3 x i32] [i32 4, i32 5, i32 6], [3 x i32] [i32 7, i32 8, i32 9]]
@.str = [33 x i8] c"Sum of max from each row is: %d\0A\00"
@.str.1 = [28 x i8] c"Sum of all elements is: %d\0A\00"
@.str.2 = [12 x i8] c"Hello World\00"
@.str.3 = [22 x i8] c"Length of '%s' is %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [3 x [3 x i32]]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
store i32 0, i32* %1
%7 = bitcast [3 x [3 x i32]]* %2 to i8*
%8 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %2, i64 0, i64 0
%9 = bitcast [3 x i32]* %8 to i32**
%10 = call i32 @sum_row_max(i32** %9)
store i32 %10, i32* %3
%11 = load i32, i32* %3
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %2, i64 0, i64 0
%14 = bitcast [3 x i32]* %13 to i32**
%15 = call i32 @sum_matrix(i32** %14)
store i32 %15, i32* %4
%16 = load i32, i32* %4
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %16)
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8** %5
%18 = load i8*, i8** %5
%19 = call i32 @string_length(i8* %18)
store i32 %19, i32* %6
%20 = load i8*, i8** %5
%21 = load i32, i32* %6
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %20, i32 %21)
ret i32 0
}

LLVM IR (-O2):
@__const.main.x = [3 x [3 x i32]] [[3 x i32] [i32 1, i32 2, i32 3], [3 x i32] [i32 4, i32 5, i32 6], [3 x i32] [i32 7, i32 8, i32 9]]
@.str = [33 x i8] c"Sum of max from each row is: %d\0A\00"
@.str.1 = [28 x i8] c"Sum of all elements is: %d\0A\00"
@.str.2 = [12 x i8] c"Hello World\00"
@.str.3 = [22 x i8] c"Length of '%s' is %d\0A\00"
define i32 @main() {
%1 = alloca [3 x [3 x i32]]
%2 = bitcast [3 x [3 x i32]]* %1 to i8*
%3 = bitcast [3 x [3 x i32]]* %1 to i32**
%4 = call i32 @sum_row_max(i32** %3)
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = call i32 @sum_matrix(i32** %3)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%8 = call i32 @string_length(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %8)
ret i32 0
}