#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 max_sublist(int *, int, int *);
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  int list[] = {-6, -2, -4, -4, -2, -3, -5, -1, -3};
  int len = 9;
  int max = 0;
  int result = max_sublist(list, len, &max);
  if (result) {
    printf("error\n");
    return 0;
  }
  printf("%d\n", max);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xeb6(%rip),%rsi
mov    $0x24,%edx
call   1050 <memcpy@plt>
movl   $0x9,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%esi
lea    -0x38(%rbp),%rdx
call   1030 <max_sublist@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
je     1199 <main+0x69>
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11b1 <main+0x81>
mov    -0x38(%rbp),%esi
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x38,%rsp
mov    0xee6(%rip),%eax
mov    %eax,0x30(%rsp)
movaps 0xecb(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xeaf(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movl   $0x0,0xc(%rsp)
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rdx
mov    $0x9,%esi
call   1040 <max_sublist@plt>
test   %eax,%eax
je     1184 <main+0x54>
lea    0xeab(%rip),%rdi
call   1030 <puts@plt>
jmp    1196 <main+0x66>
mov    0xc(%rsp),%esi
lea    0xe95(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x38,%rsp
ret

LLVM IR (-O0):
@__const.main.list = [9 x i32] [i32 -6, i32 -2, i32 -4, i32 -4, i32 -2, i32 -3, i32 -5, i32 -1, i32 -3]
@.str = [7 x i8] c"error\0A\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [9 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = bitcast [9 x i32]* %2 to i8*
store i32 9, i32* %3
store i32 0, i32* %4
%7 = getelementptr inbounds [9 x i32], [9 x i32]* %2, i64 0, i64 0
%8 = load i32, i32* %3
%9 = call i32 @max_sublist(i32* %7, i32 %8, i32* %4)
store i32 %9, i32* %5
%10 = load i32, i32* %5
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %1
br label %17
14: ; preds = %0
%15 = load i32, i32* %4
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %15)
store i32 0, i32* %1
br label %17
17: ; preds = %14, %12
%18 = load i32, i32* %1
ret i32 %18
}

LLVM IR (-O2):
@__const.main.list = [9 x i32] [i32 -6, i32 -2, i32 -4, i32 -4, i32 -2, i32 -3, i32 -5, i32 -1, i32 -3]
@.str.1 = [4 x i8] c"%d\0A\00"
@str = [6 x i8] c"error\00"
define i32 @main() {
%1 = alloca [9 x i32]
%2 = alloca i32
%3 = bitcast [9 x i32]* %1 to i8*
%4 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%5 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 0, i64 0
%6 = call i32 @max_sublist(i32* %5, i32 9, i32* %2)
%7 = icmp eq i32 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %0
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
br label %13
10: ; preds = %0
%11 = load i32, i32* %2
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %11)
br label %13
13: ; preds = %10, %8
ret i32 0
}