#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 */
unsigned int tolower(unsigned char);
unsigned int str_to_int_l(unsigned char *s) {
  unsigned int temp = 0;
  int loop = 4;
  while (loop--) {
    temp = (temp << 8) | (tolower(*s));
    if (*s)
      s++;
  }
  while (*s) {
    temp = (temp << 8) | (tolower(*s));
    s++;
  }
  return (temp);
}


x86 assembly (clang, -O0):
<str_to_int_l>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x4,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x10(%rbp)
cmp    $0x0,%eax
je     117b <str_to_int_l+0x6b>
mov    -0xc(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movzbl (%rax),%edi
call   1030 <tolower@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
or     %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     1176 <str_to_int_l+0x66>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    112a <str_to_int_l+0x1a>
jmp    1180 <str_to_int_l+0x70>
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     11bd <str_to_int_l+0xad>
mov    -0xc(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movzbl (%rax),%edi
call   1030 <tolower@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
or     %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1180 <str_to_int_l+0x70>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_to_int_l>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
movzbl (%rdi),%edi
call   1030 <tolower@plt>
xor    %r15d,%r15d
cmpb   $0x0,(%rbx)
mov    %eax,%r14d
setne  %r15b
lea    (%rbx,%r15,1),%r13
movzbl (%rbx,%r15,1),%edi
call   1030 <tolower@plt>
mov    %eax,%ebp
xor    %r12d,%r12d
mov    %rbx,(%rsp)
cmpb   $0x0,(%rbx,%r15,1)
setne  %r12b
lea    (%r12,%r13,1),%rax
mov    %rax,0x10(%rsp)
shl    $0x10,%r14d
shl    $0x8,%ebp
or     %r14d,%ebp
movzbl (%r12,%r13,1),%edi
call   1030 <tolower@plt>
mov    %eax,%ebx
or     %ebp,%ebx
xor    %r14d,%r14d
cmpb   $0x0,(%r12,%r13,1)
setne  %r14b
mov    0x10(%rsp),%r13
lea    (%r14,%r13,1),%rcx
mov    %rcx,0x8(%rsp)
shl    $0x8,%ebx
movzbl (%r14,%r13,1),%edi
call   1030 <tolower@plt>
mov    %eax,%ebp
or     %ebx,%ebp
xor    %ecx,%ecx
cmpb   $0x0,(%r14,%r13,1)
setne  %cl
mov    0x8(%rsp),%rax
mov    (%rcx,%rax,1),%al
test   %al,%al
je     11e8 <str_to_int_l+0xd8>
add    %r14,%rcx
add    %r12,%rcx
add    %r15,%rcx
mov    (%rsp),%rdx
lea    (%rdx,%rcx,1),%rbx
add    $0x1,%rbx
nopl   (%rax)
shl    $0x8,%ebp
movzbl %al,%edi
call   1030 <tolower@plt>
or     %eax,%ebp
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    11d0 <str_to_int_l+0xc0>
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @str_to_int_l(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
store i32 4, i32* %4
br label %5
5: ; preds = %22, %1
%6 = load i32, i32* %4
%7 = add nsw i32 %6, -1
store i32 %7, i32* %4
%8 = icmp ne i32 %6, 0
br i1 %8, label %9, label %23
9: ; preds = %5
%10 = load i32, i32* %3
%11 = shl i32 %10, 8
%12 = load i8*, i8** %2
%13 = load i8, i8* %12
%14 = call i32 @tolower(i8 zeroext %13)
%15 = or i32 %11, %14
store i32 %15, i32* %3
%16 = load i8*, i8** %2
%17 = load i8, i8* %16
%18 = icmp ne i8 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %9
%20 = load i8*, i8** %2
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %2
br label %22
22: ; preds = %19, %9
br label %5
23: ; preds = %5
br label %24
24: ; preds = %28, %23
%25 = load i8*, i8** %2
%26 = load i8, i8* %25
%27 = icmp ne i8 %26, 0
br i1 %27, label %28, label %37
28: ; preds = %24
%29 = load i32, i32* %3
%30 = shl i32 %29, 8
%31 = load i8*, i8** %2
%32 = load i8, i8* %31
%33 = call i32 @tolower(i8 zeroext %32)
%34 = or i32 %30, %33
store i32 %34, i32* %3
%35 = load i8*, i8** %2
%36 = getelementptr inbounds i8, i8* %35, i32 1
store i8* %36, i8** %2
br label %24
37: ; preds = %24
%38 = load i32, i32* %3
ret i32 %38
}

LLVM IR (-O2):
define i32 @str_to_int_l(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = tail call i32 @tolower(i8 zeroext %2)
%4 = load i8, i8* %0
%5 = icmp ne i8 %4, 0
%6 = zext i1 %5 to i64
%7 = getelementptr i8, i8* %0, i64 %6
%8 = load i8, i8* %7
%9 = tail call i32 @tolower(i8 zeroext %8)
%10 = load i8, i8* %7
%11 = icmp ne i8 %10, 0
%12 = zext i1 %11 to i64
%13 = getelementptr i8, i8* %7, i64 %12
%14 = shl i32 %3, 16
%15 = shl i32 %9, 8
%16 = or i32 %14, %15
%17 = load i8, i8* %13
%18 = tail call i32 @tolower(i8 zeroext %17)
%19 = or i32 %18, %16
%20 = load i8, i8* %13
%21 = icmp ne i8 %20, 0
%22 = zext i1 %21 to i64
%23 = getelementptr i8, i8* %13, i64 %22
%24 = shl i32 %19, 8
%25 = load i8, i8* %23
%26 = tail call i32 @tolower(i8 zeroext %25)
%27 = or i32 %26, %24
%28 = load i8, i8* %23
%29 = icmp ne i8 %28, 0
%30 = zext i1 %29 to i64
%31 = getelementptr i8, i8* %23, i64 %30
%32 = load i8, i8* %31
%33 = icmp eq i8 %32, 0
br i1 %33, label %44, label %34
34: ; preds = %1, %34
%35 = phi i8 [ %42, %34 ], [ %32, %1 ]
%36 = phi i32 [ %40, %34 ], [ %27, %1 ]
%37 = phi i8* [ %41, %34 ], [ %31, %1 ]
%38 = shl i32 %36, 8
%39 = tail call i32 @tolower(i8 zeroext %35)
%40 = or i32 %39, %38
%41 = getelementptr inbounds i8, i8* %37, i64 1
%42 = load i8, i8* %41
%43 = icmp eq i8 %42, 0
br i1 %43, label %44, label %34
44: ; preds = %34, %1
%45 = phi i32 [ %27, %1 ], [ %40, %34 ]
ret i32 %45
}