#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*/ printf(char *, ...);
scalar_t__ strcmp(char *, char const *);
int checkurl(char *pszurl, const char (*aaszurl)[128], int urlcnt) {
  int i = 0;
  if (NULL == pszurl) {
    printf("url is NULL\n");
    return 0;
  }
  for (i = 0; i < urlcnt; i++) {
    printf("aaszurl is %s\n", aaszurl[i]);
    if (0 == strcmp(pszurl, aaszurl[i])) {
      return i;
    }
  }
  return 0xFFFFFFFF;
}


x86 assembly (clang, -O0):
<checkurl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
jne    1160 <checkurl+0x40>
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11db <checkurl+0xbb>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11d4 <checkurl+0xb4>
mov    -0x18(%rbp),%rsi
movslq -0x20(%rbp),%rax
shl    $0x7,%rax
add    %rax,%rsi
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
movslq -0x20(%rbp),%rax
shl    $0x7,%rax
add    %rax,%rsi
call   1040 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    11c1 <checkurl+0xa1>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11db <checkurl+0xbb>
jmp    11c6 <checkurl+0xa6>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1167 <checkurl+0x47>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkurl>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rdi,%rdi
je     118c <checkurl+0x5c>
mov    $0xffffffff,%r14d
test   %edx,%edx
jle    11a0 <checkurl+0x70>
mov    %rsi,%rbx
mov    %rdi,%r13
mov    %edx,%r12d
lea    0xea6(%rip),%r15
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     119d <checkurl+0x6d>
add    $0x1,%rbp
sub    $0xffffffffffffff80,%rbx
cmp    %rbp,%r12
jne    1160 <checkurl+0x30>
jmp    11a0 <checkurl+0x70>
lea    0xe7c(%rip),%rdi
call   1030 <puts@plt>
xor    %r14d,%r14d
jmp    11a0 <checkurl+0x70>
mov    %ebp,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"url is NULL\0A\00"
@.str.1 = [15 x i8] c"aaszurl is %s\0A\00"
define i32 @checkurl(i8* %0, [128 x i8]* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca [128 x i8]*
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %5
store [128 x i8]* %1, [128 x i8]** %6
store i32 %2, i32* %7
store i32 0, i32* %8
%9 = load i8*, i8** %5
%10 = icmp eq i8* null, %9
br i1 %10, label %11, label %13
11: ; preds = %3
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %4
br label %40
13: ; preds = %3
store i32 0, i32* %8
br label %14
14: ; preds = %36, %13
%15 = load i32, i32* %8
%16 = load i32, i32* %7
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %39
18: ; preds = %14
%19 = load [128 x i8]*, [128 x i8]** %6
%20 = load i32, i32* %8
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [128 x i8], [128 x i8]* %19, i64 %21
%23 = getelementptr inbounds [128 x i8], [128 x i8]* %22, i64 0, i64 0
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %23)
%25 = load i8*, i8** %5
%26 = load [128 x i8]*, [128 x i8]** %6
%27 = load i32, i32* %8
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [128 x i8], [128 x i8]* %26, i64 %28
%30 = getelementptr inbounds [128 x i8], [128 x i8]* %29, i64 0, i64 0
%31 = call i64 @strcmp(i8* %25, i8* %30)
%32 = icmp eq i64 0, %31
br i1 %32, label %33, label %35
33: ; preds = %18
%34 = load i32, i32* %8
store i32 %34, i32* %4
br label %40
35: ; preds = %18
br label %36
36: ; preds = %35
%37 = load i32, i32* %8
%38 = add nsw i32 %37, 1
store i32 %38, i32* %8
br label %14
39: ; preds = %14
store i32 -1, i32* %4
br label %40
40: ; preds = %39, %33, %11
%41 = load i32, i32* %4
ret i32 %41
}

LLVM IR (-O2):
@.str.1 = [15 x i8] c"aaszurl is %s\0A\00"
@str = [12 x i8] c"url is NULL\00"
define i32 @checkurl(i8* %0, [128 x i8]* %1, i32 %2) {
%4 = icmp eq i8* %0, null
br i1 %4, label %9, label %5
5: ; preds = %3
%6 = icmp sgt i32 %2, 0
br i1 %6, label %7, label %22
7: ; preds = %5
%8 = zext i32 %2 to i64
br label %11
9: ; preds = %3
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
br label %22
11: ; preds = %7, %17
%12 = phi i64 [ 0, %7 ], [ %18, %17 ]
%13 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 %12, i64 0
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%15 = tail call i64 @strcmp(i8* %0, i8* %13)
%16 = icmp eq i64 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %11
%18 = add nuw nsw i64 %12, 1
%19 = icmp eq i64 %18, %8
br i1 %19, label %22, label %11
20: ; preds = %11
%21 = trunc i64 %12 to i32
br label %22
22: ; preds = %17, %20, %5, %9
%23 = phi i32 [ 0, %9 ], [ -1, %5 ], [ %21, %20 ], [ -1, %17 ]
ret i32 %23
}