#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*/ logadds(int, char *, char *, int /*<<< orphan*/ *);
scalar_t__ strcmp(char *, char *);
void check_iloop(char *args[], char *test) {
  int i = 0;
  while (args[i] != NULL) {
    if ((strcmp(args[i], test) == 0) || (strcmp(args[i], ".") == 0)) {
      logadds(-1, "Warning: possible infinite loop (%s)", args[i], NULL);
    }
    i++;
  }
  return;
}


x86 assembly (clang, -O0):
<check_iloop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     11ba <check_iloop+0x9a>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     118b <check_iloop+0x6b>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe84(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11ac <check_iloop+0x8c>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    $0xffffffff,%edi
lea    0xe5f(%rip),%rsi
xor    %eax,%eax
mov    %eax,%ecx
call   1040 <logadds@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1137 <check_iloop+0x17>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_iloop>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    (%rdi),%rdi
test   %rdi,%rdi
je     118e <check_iloop+0x6e>
mov    %rsi,%r14
lea    0xec5(%rip),%r15
lea    0xebc(%rip),%r12
jmp    116f <check_iloop+0x4f>
cs nopw 0x0(%rax,%rax,1)
mov    (%rbx),%rdx
mov    $0xffffffff,%edi
mov    %r15,%rsi
xor    %ecx,%ecx
call   1040 <logadds@plt>
mov    0x8(%rbx),%rdi
add    $0x8,%rbx
test   %rdi,%rdi
je     118e <check_iloop+0x6e>
mov    %r14,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1150 <check_iloop+0x30>
mov    (%rbx),%rdi
mov    %r12,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
jne    1162 <check_iloop+0x42>
jmp    1150 <check_iloop+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c".\00"
@.str.1 = [37 x i8] c"Warning: possible infinite loop (%s)\00"
define void @check_iloop(i8** nocapture %0, i8* %1) {
%3 = load i8*, i8** %0
%4 = icmp eq i8* %3, null
br i1 %4, label %23, label %5
5: ; preds = %2, %18
%6 = phi i64 [ %19, %18 ], [ 0, %2 ]
%7 = phi i8* [ %21, %18 ], [ %3, %2 ]
%8 = phi i8** [ %20, %18 ], [ %0, %2 ]
%9 = tail call i64 @strcmp(i8* %7, i8* %1)
%10 = icmp eq i64 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %5
%12 = load i8*, i8** %8
%13 = tail call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %11, %5
%16 = load i8*, i8** %8
%17 = tail call i32 @logadds(i32 -1, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %16, i32* null)
br label %18
18: ; preds = %15, %11
%19 = add nuw i64 %6, 1
%20 = getelementptr inbounds i8*, i8** %0, i64 %19
%21 = load i8*, i8** %20
%22 = icmp eq i8* %21, null
br i1 %22, label %23, label %5
23: ; preds = %18, %2
ret void
}