#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*/ abort();
int aim_callhandler(int sess, int conn, unsigned short family,
                    unsigned short type) {
  static int i = 0;
  if (!conn)
    return 0;
  if (type == 0xffff) {
    return 0;
  }
  if (i >= 1)
    abort();
  i++;
  return aim_callhandler(sess, conn, family, (unsigned short)0xffff);
}


x86 assembly (clang, -O0):
<aim_callhandler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %cx,%ax
mov    %dx,%cx
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %cx,-0xe(%rbp)
mov    %ax,-0x10(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    1152 <aim_callhandler+0x32>
movl   $0x0,-0x4(%rbp)
jmp    11a7 <aim_callhandler+0x87>
movzwl -0x10(%rbp),%eax
cmp    $0xffff,%eax
jne    116d <aim_callhandler+0x4d>
movl   $0x0,-0x4(%rbp)
jmp    11a7 <aim_callhandler+0x87>
cmpl   $0x1,0x2ec0(%rip)
jl     1181 <aim_callhandler+0x61>
mov    $0x0,%al
call   1030 <abort@plt>
mov    0x2ead(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2ea4(%rip)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    $0xffff,%ecx
movzwl -0xe(%rbp),%edx
call   1040 <aim_callhandler@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aim_callhandler>:
push   %rax
test   %esi,%esi
je     112b <aim_callhandler+0x1b>
cmp    $0xffff,%cx
je     112b <aim_callhandler+0x1b>
cmpb   $0x1,0x2f0a(%rip)
je     112f <aim_callhandler+0x1f>
movb   $0x1,0x2f01(%rip)
xor    %eax,%eax
pop    %rcx
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@aim_callhandler.i = internal global i32 0
define i32 @aim_callhandler(i32 %0, i32 %1, i16 zeroext %2, i16 zeroext %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i16
%9 = alloca i16
store i32 %0, i32* %6
store i32 %1, i32* %7
store i16 %2, i16* %8
store i16 %3, i16* %9
%10 = load i32, i32* %7
%11 = icmp ne i32 %10, 0
br i1 %11, label %13, label %12
12: ; preds = %4
store i32 0, i32* %5
br label %30
13: ; preds = %4
%14 = load i16, i16* %9
%15 = zext i16 %14 to i32
%16 = icmp eq i32 %15, 65535
br i1 %16, label %17, label %18
17: ; preds = %13
store i32 0, i32* %5
br label %30
18: ; preds = %13
%19 = load i32, i32* @aim_callhandler.i
%20 = icmp sge i32 %19, 1
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = call i32 (...) @abort()
unreachable
23: ; preds = %18
%24 = load i32, i32* @aim_callhandler.i
%25 = add nsw i32 %24, 1
store i32 %25, i32* @aim_callhandler.i
%26 = load i32, i32* %6
%27 = load i32, i32* %7
%28 = load i16, i16* %8
%29 = call i32 @aim_callhandler(i32 %26, i32 %27, i16 zeroext %28, i16 zeroext -1)
store i32 %29, i32* %5
br label %30
30: ; preds = %23, %17, %12
%31 = load i32, i32* %5
ret i32 %31
}

LLVM IR (-O2):
@aim_callhandler.i = internal unnamed_addr global i1 false
define i32 @aim_callhandler(i32 %0, i32 %1, i16 zeroext %2, i16 zeroext %3) {
%5 = icmp eq i32 %1, 0
%6 = icmp eq i16 %3, -1
%7 = or i1 %5, %6
br i1 %7, label %13, label %8
8: ; preds = %4
%9 = load i1, i1* @aim_callhandler.i
br i1 %9, label %10, label %12
10: ; preds = %8
%11 = tail call i32 (...) @abort()
unreachable
12: ; preds = %8
store i1 true, i1* @aim_callhandler.i
br label %13
13: ; preds = %4, %12
ret i32 0
}