#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 strcmp(char *, char *);
scalar_t__ strncmp(char *, char *, int);
int hostcmp(char *host1, char *host2) {
  char *h[2] = {host1, host2};
  int i;
  for (i = 0; i < 2; ++i)
    if (strncmp(h[i], "http://", 7) == 0)
      h[i] += 7;
    else if (strncmp(h[i], "https://", 8) == 0)
      h[i] += 8;
  return strcmp(h[0], h[1]);
}


x86 assembly (clang, -O0):
<hostcmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x2,-0x24(%rbp)
jge    11da <hostcmp+0xba>
movslq -0x24(%rbp),%rax
mov    -0x20(%rbp,%rax,8),%rdi
lea    0xe9f(%rip),%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    118c <hostcmp+0x6c>
movslq -0x24(%rbp),%rax
mov    -0x20(%rbp,%rax,8),%rcx
add    $0x7,%rcx
mov    %rcx,-0x20(%rbp,%rax,8)
jmp    11c7 <hostcmp+0xa7>
movslq -0x24(%rbp),%rax
mov    -0x20(%rbp,%rax,8),%rdi
lea    0xe6c(%rip),%rsi
mov    $0x8,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11c2 <hostcmp+0xa2>
movslq -0x24(%rbp),%rax
mov    -0x20(%rbp,%rax,8),%rcx
add    $0x8,%rcx
mov    %rcx,-0x20(%rbp,%rax,8)
jmp    11c7 <hostcmp+0xa7>
jmp    11cc <hostcmp+0xac>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1147 <hostcmp+0x27>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcmp@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hostcmp>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xecb(%rip),%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
mov    $0x7,%r12d
mov    $0x7,%ebx
test   %rax,%rax
je     116f <hostcmp+0x4f>
lea    0xeb2(%rip),%rsi
mov    %r15,%rdi
mov    $0x8,%edx
call   1030 <strncmp@plt>
xor    %ebx,%ebx
test   %rax,%rax
sete   %bl
shl    $0x3,%rbx
lea    0xe8a(%rip),%rsi
mov    %r14,%rdi
mov    $0x7,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11aa <hostcmp+0x8a>
lea    0xe79(%rip),%rsi
mov    %r14,%rdi
mov    $0x8,%edx
call   1030 <strncmp@plt>
xor    %r12d,%r12d
test   %rax,%rax
sete   %r12b
shl    $0x3,%r12
add    %rbx,%r15
add    %r12,%r14
mov    %r15,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <strcmp@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"http://\00"
@.str.1 = [9 x i8] c"https://\00"
define i32 @hostcmp(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [2 x i8*]
%6 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = getelementptr inbounds [2 x i8*], [2 x i8*]* %5, i64 0, i64 0
%8 = load i8*, i8** %3
store i8* %8, i8** %7
%9 = getelementptr inbounds i8*, i8** %7, i64 1
%10 = load i8*, i8** %4
store i8* %10, i8** %9
store i32 0, i32* %6
br label %11
11: ; preds = %42, %2
%12 = load i32, i32* %6
%13 = icmp slt i32 %12, 2
br i1 %13, label %14, label %45
14: ; preds = %11
%15 = load i32, i32* %6
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [2 x i8*], [2 x i8*]* %5, i64 0, i64 %16
%18 = load i8*, i8** %17
%19 = call i64 @strncmp(i8* %18, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 7)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %27
21: ; preds = %14
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [2 x i8*], [2 x i8*]* %5, i64 0, i64 %23
%25 = load i8*, i8** %24
%26 = getelementptr inbounds i8, i8* %25, i64 7
store i8* %26, i8** %24
br label %41
27: ; preds = %14
%28 = load i32, i32* %6
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [2 x i8*], [2 x i8*]* %5, i64 0, i64 %29
%31 = load i8*, i8** %30
%32 = call i64 @strncmp(i8* %31, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 8)
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %40
34: ; preds = %27
%35 = load i32, i32* %6
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [2 x i8*], [2 x i8*]* %5, i64 0, i64 %36
%38 = load i8*, i8** %37
%39 = getelementptr inbounds i8, i8* %38, i64 8
store i8* %39, i8** %37
br label %40
40: ; preds = %34, %27
br label %41
41: ; preds = %40, %21
br label %42
42: ; preds = %41
%43 = load i32, i32* %6
%44 = add nsw i32 %43, 1
store i32 %44, i32* %6
br label %11
45: ; preds = %11
%46 = getelementptr inbounds [2 x i8*], [2 x i8*]* %5, i64 0, i64 0
%47 = load i8*, i8** %46
%48 = getelementptr inbounds [2 x i8*], [2 x i8*]* %5, i64 0, i64 1
%49 = load i8*, i8** %48
%50 = call i32 @strcmp(i8* %47, i8* %49)
ret i32 %50
}

LLVM IR (-O2):
@.str = [8 x i8] c"http://\00"
@.str.1 = [9 x i8] c"https://\00"
define i32 @hostcmp(i8* %0, i8* %1) {
%3 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 7)
%4 = icmp eq i64 %3, 0
br i1 %4, label %9, label %5
5: ; preds = %2
%6 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 8)
%7 = icmp eq i64 %6, 0
%8 = select i1 %7, i64 8, i64 0
br label %9
9: ; preds = %2, %5
%10 = phi i64 [ %8, %5 ], [ 7, %2 ]
%11 = tail call i64 @strncmp(i8* %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 7)
%12 = icmp eq i64 %11, 0
br i1 %12, label %17, label %13
13: ; preds = %9
%14 = tail call i64 @strncmp(i8* %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 8)
%15 = icmp eq i64 %14, 0
%16 = select i1 %15, i64 8, i64 0
br label %17
17: ; preds = %9, %13
%18 = phi i64 [ %16, %13 ], [ 7, %9 ]
%19 = getelementptr i8, i8* %0, i64 %10
%20 = getelementptr i8, i8* %1, i64 %18
%21 = tail call i32 @strcmp(i8* dereferenceable(1) %19, i8* dereferenceable(1) %20)
ret i32 %21
}