#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 lengthOfLongestSubstring(char *);
int /*<<< orphan*/ printf(char *, int);
int main() {
  char *strings[] = {"abba", "a", "aa", "ab", "abcadbeb", "bbbb"};
  int i;
  for (i = 0; i < 6; i++) {
    printf("%d\n", lengthOfLongestSubstring(strings[i]));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1040 <memset@plt>
lea    0xeaa(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0xea5(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    0xe99(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xe91(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xe89(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    0xe87(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x44(%rbp)
cmpl   $0x6,-0x44(%rbp)
jge    11cc <main+0x9c>
movslq -0x44(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rdi
call   1050 <lengthOfLongestSubstring@plt>
mov    %eax,%esi
lea    0xe60(%rip),%rdi
call   1030 <printf@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1198 <main+0x68>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xed8(%rip),%rdi
call   1040 <lengthOfLongestSubstring@plt>
lea    0xee5(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
lea    0xec1(%rip),%rdi
call   1040 <lengthOfLongestSubstring@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
lea    0xeaa(%rip),%rdi
call   1040 <lengthOfLongestSubstring@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
lea    0xe97(%rip),%rdi
call   1040 <lengthOfLongestSubstring@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
lea    0xe84(%rip),%rdi
call   1040 <lengthOfLongestSubstring@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
lea    0xe77(%rip),%rdi
call   1040 <lengthOfLongestSubstring@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"abba\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [3 x i8] c"aa\00"
@.str.3 = [3 x i8] c"ab\00"
@.str.4 = [9 x i8] c"abcadbeb\00"
@.str.5 = [5 x i8] c"bbbb\00"
@.str.6 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [6 x i8*]
%3 = alloca i32
store i32 0, i32* %1
%4 = bitcast [6 x i8*]* %2 to i8*
%5 = bitcast i8* %4 to [6 x i8*]*
%6 = getelementptr inbounds [6 x i8*], [6 x i8*]* %5, i32 0, i32 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8** %6
%7 = getelementptr inbounds [6 x i8*], [6 x i8*]* %5, i32 0, i32 1
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i32 0, i32 0), i8** %7
%8 = getelementptr inbounds [6 x i8*], [6 x i8*]* %5, i32 0, i32 2
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0), i8** %8
%9 = getelementptr inbounds [6 x i8*], [6 x i8*]* %5, i32 0, i32 3
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i32 0, i32 0), i8** %9
%10 = getelementptr inbounds [6 x i8*], [6 x i8*]* %5, i32 0, i32 4
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i32 0, i32 0), i8** %10
%11 = getelementptr inbounds [6 x i8*], [6 x i8*]* %5, i32 0, i32 5
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i32 0, i32 0), i8** %11
store i32 0, i32* %3
br label %12
12: ; preds = %22, %0
%13 = load i32, i32* %3
%14 = icmp slt i32 %13, 6
br i1 %14, label %15, label %25
15: ; preds = %12
%16 = load i32, i32* %3
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [6 x i8*], [6 x i8*]* %2, i64 0, i64 %17
%19 = load i8*, i8** %18
%20 = call i32 @lengthOfLongestSubstring(i8* %19)
%21 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %20)
br label %22
22: ; preds = %15
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
br label %12
25: ; preds = %12
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"abba\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [3 x i8] c"aa\00"
@.str.3 = [3 x i8] c"ab\00"
@.str.4 = [9 x i8] c"abcadbeb\00"
@.str.5 = [5 x i8] c"bbbb\00"
@.str.6 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = tail call i32 @lengthOfLongestSubstring(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %1)
%3 = tail call i32 @lengthOfLongestSubstring(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %3)
%5 = tail call i32 @lengthOfLongestSubstring(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%6 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %5)
%7 = tail call i32 @lengthOfLongestSubstring(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%8 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %7)
%9 = tail call i32 @lengthOfLongestSubstring(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%10 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %9)
%11 = tail call i32 @lengthOfLongestSubstring(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%12 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %11)
ret i32 0
}