#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 length_of_longest_substr(char *);
int /*<<< orphan*/ printf(char *, char *, int);
int main() {
  char *str_a = "abracadabra";
  char *str_b = "peter";
  char *str_c = "ababababababababa";
  printf("longest non-repeat substring of %s is %d char long\n", str_a,
         length_of_longest_substr(str_a));
  printf("longest non-repeat substring of %s is %d char long\n", str_b,
         length_of_longest_substr(str_b));
  printf("longest non-repeat substring of %s is %d char long\n", str_c,
         length_of_longest_substr(str_c));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xecb(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xec6(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <length_of_longest_substr@plt>
mov    -0x38(%rbp),%rsi
mov    %eax,%edx
lea    0xeb6(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <length_of_longest_substr@plt>
mov    -0x30(%rbp),%rsi
mov    %eax,%edx
lea    0xe93(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <length_of_longest_substr@plt>
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
lea    0xe70(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xed5(%rip),%rbx
mov    %rbx,%rdi
call   1030 <length_of_longest_substr@plt>
lea    0xeea(%rip),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <printf@plt>
lea    0xebe(%rip),%rbx
mov    %rbx,%rdi
call   1030 <length_of_longest_substr@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <printf@plt>
lea    0xea8(%rip),%rbx
mov    %rbx,%rdi
call   1030 <length_of_longest_substr@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [12 x i8] c"abracadabra\00"
@.str.1 = [6 x i8] c"peter\00"
@.str.2 = [18 x i8] c"ababababababababa\00"
@.str.3 = [52 x i8] c"longest non-repeat substring of %s is %d char long\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i32 0, i32* %1
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %2
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8** %3
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8** %4
%5 = load i8*, i8** %2
%6 = load i8*, i8** %2
%7 = call i32 @length_of_longest_substr(i8* %6)
%8 = call i32 @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.3, i64 0, i64 0), i8* %5, i32 %7)
%9 = load i8*, i8** %3
%10 = load i8*, i8** %3
%11 = call i32 @length_of_longest_substr(i8* %10)
%12 = call i32 @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.3, i64 0, i64 0), i8* %9, i32 %11)
%13 = load i8*, i8** %4
%14 = load i8*, i8** %4
%15 = call i32 @length_of_longest_substr(i8* %14)
%16 = call i32 @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.3, i64 0, i64 0), i8* %13, i32 %15)
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"abracadabra\00"
@.str.1 = [6 x i8] c"peter\00"
@.str.2 = [18 x i8] c"ababababababababa\00"
@.str.3 = [52 x i8] c"longest non-repeat substring of %s is %d char long\0A\00"
define i32 @main() {
%1 = tail call i32 @length_of_longest_substr(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %1)
%3 = tail call i32 @length_of_longest_substr(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32 @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %3)
%5 = tail call i32 @length_of_longest_substr(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%6 = tail call i32 @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %5)
ret i32 0
}