#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 */
typedef int /*<<< orphan*/ str;

/* Variables and functions */
int max_substr_len(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  int ret = 0;
  char str[] = "abcdefgegcsgcasse";
  ret = max_substr_len(str, sizeof(str) / sizeof(str[0]));
  printf("str: %s\n", str);
  printf("ret: %d\n", ret);
  return ret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    0xebc(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xeb9(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xeb6(%rip),%ax
mov    %ax,-0x20(%rbp)
lea    -0x30(%rbp),%rdi
mov    $0x12,%esi
call   1030 <max_substr_len@plt>
mov    %eax,-0x14(%rbp)
lea    -0x30(%rbp),%rsi
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
movaps 0xed3(%rip),%xmm0
movaps %xmm0,(%rsp)
movw   $0x65,0x10(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x12,%esi
call   1030 <max_substr_len@plt>
mov    %eax,%ebp
lea    0xec1(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb9(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.str = [18 x i8] c"abcdefgegcsgcasse\00"
@.str = [9 x i8] c"str: %s\0A\00"
@.str.1 = [9 x i8] c"ret: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [18 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%8 = bitcast [18 x i8]* %7 to i8*
%9 = getelementptr inbounds [18 x i8], [18 x i8]* %7, i64 0, i64 0
%10 = call i32 @max_substr_len(i8* %9, i32 18)
store i32 %10, i32* %6
%11 = getelementptr inbounds [18 x i8], [18 x i8]* %7, i64 0, i64 0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = load i32, i32* %6
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%15 = load i32, i32* %6
ret i32 %15
}

LLVM IR (-O2):
@__const.main.str = [18 x i8] c"abcdefgegcsgcasse\00"
@.str = [9 x i8] c"str: %s\0A\00"
@.str.1 = [9 x i8] c"ret: %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [18 x i8]
%4 = getelementptr inbounds [18 x i8], [18 x i8]* %3, i64 0, i64 0
%5 = call i32 @max_substr_len(i8* %4, i32 18)
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %4)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %5)
ret i32 %5
}