#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*/ setcurmax(char *, int, int, char *, int *, int *);
int strlen(char *);
int lengthOfLongestSubstring(char *s) {
  char allc[256] = {0};
  int maxlen = 0;
  int i, his = 0;
  int slen = strlen(s);
  for (i = 0; slen - i > maxlen; i++) {
    setcurmax(s, slen, i, allc, &maxlen, &his);
  }
  return his;
}


x86 assembly (clang, -O0):
<lengthOfLongestSubstring>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1040 <memset@plt>
movl   $0x0,-0x114(%rbp)
movl   $0x0,-0x11c(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x120(%rbp)
movl   $0x0,-0x118(%rbp)
mov    -0x120(%rbp),%eax
sub    -0x118(%rbp),%eax
cmp    -0x114(%rbp),%eax
jle    11d5 <lengthOfLongestSubstring+0xa5>
mov    -0x8(%rbp),%rdi
mov    -0x120(%rbp),%esi
mov    -0x118(%rbp),%edx
lea    -0x110(%rbp),%rcx
lea    -0x114(%rbp),%r8
lea    -0x11c(%rbp),%r9
call   1050 <setcurmax@plt>
mov    -0x118(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x118(%rbp)
jmp    117f <lengthOfLongestSubstring+0x4f>
mov    -0x11c(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lengthOfLongestSubstring>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
mov    %rdi,%r14
xorps  %xmm0,%xmm0
movaps %xmm0,0x100(%rsp)
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
call   1030 <strlen@plt>
test   %eax,%eax
jle    11fa <lengthOfLongestSubstring+0xda>
mov    %eax,%r15d
xor    %ebx,%ebx
lea    0xc(%rsp),%r12
lea    0x8(%rsp),%r13
mov    %eax,%ebp
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r15d,%esi
mov    %ebx,%edx
lea    0x10(%rsp),%rcx
mov    %r12,%r8
mov    %r13,%r9
call   1040 <setcurmax@plt>
add    $0x1,%ebx
add    $0xffffffff,%ebp
cmp    0xc(%rsp),%ebp
jg     11d0 <lengthOfLongestSubstring+0xb0>
mov    0x8(%rsp),%eax
jmp    11fc <lengthOfLongestSubstring+0xdc>
xor    %eax,%eax
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @lengthOfLongestSubstring(i8* %0) {
%2 = alloca i8*
%3 = alloca [256 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %2
%8 = bitcast [256 x i8]* %3 to i8*
store i32 0, i32* %4
store i32 0, i32* %6
%9 = load i8*, i8** %2
%10 = call i32 @strlen(i8* %9)
store i32 %10, i32* %7
store i32 0, i32* %5
br label %11
11: ; preds = %23, %1
%12 = load i32, i32* %7
%13 = load i32, i32* %5
%14 = sub nsw i32 %12, %13
%15 = load i32, i32* %4
%16 = icmp sgt i32 %14, %15
br i1 %16, label %17, label %26
17: ; preds = %11
%18 = load i8*, i8** %2
%19 = load i32, i32* %7
%20 = load i32, i32* %5
%21 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%22 = call i32 @setcurmax(i8* %18, i32 %19, i32 %20, i8* %21, i32* %4, i32* %6)
br label %23
23: ; preds = %17
%24 = load i32, i32* %5
%25 = add nsw i32 %24, 1
store i32 %25, i32* %5
br label %11
26: ; preds = %11
%27 = load i32, i32* %6
ret i32 %27
}

LLVM IR (-O2):
define i32 @lengthOfLongestSubstring(i8* %0) {
%2 = alloca [256 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%6 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%7 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%8 = tail call i32 @strlen(i8* %0)
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %19
10: ; preds = %1, %10
%11 = phi i32 [ %13, %10 ], [ 0, %1 ]
%12 = call i32 @setcurmax(i8* %0, i32 %8, i32 %11, i8* %5, i32* %3, i32* %4)
%13 = add nuw nsw i32 %11, 1
%14 = sub nsw i32 %8, %13
%15 = load i32, i32* %3
%16 = icmp sgt i32 %14, %15
br i1 %16, label %10, label %17
17: ; preds = %10
%18 = load i32, i32* %4
br label %19
19: ; preds = %17, %1
%20 = phi i32 [ %18, %17 ], [ 0, %1 ]
ret i32 %20
}