#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 */
struct Village {
  int dummy;
};
struct Patient {
  int dummy;
};
struct List {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ addList(struct List *, struct Patient *);
int /*<<< orphan*/ removeList(struct List *, struct Patient *);
void check_patients_inside(struct Village *village, struct List *list) {
  struct Patient *p;
  void *__cil_tmp4;
  unsigned int __cil_tmp5;
  unsigned int __cil_tmp6;
  unsigned int __cil_tmp7;
  unsigned int __cil_tmp8;
  unsigned int __cil_tmp9;
  unsigned int __cil_tmp10;
  int __cil_tmp11;
  unsigned int __cil_tmp12;
  unsigned int __cil_tmp13;
  int __cil_tmp14;
  unsigned int __cil_tmp15;
  unsigned int __cil_tmp16;
  unsigned int __cil_tmp17;
  unsigned int __cil_tmp18;
  unsigned int __cil_tmp19;
  unsigned int __cil_tmp20;
  int __cil_tmp21;
  unsigned int __cil_tmp22;
  unsigned int __cil_tmp23;
  unsigned int __cil_tmp24;
  struct List *__cil_tmp25;
  unsigned int __cil_tmp26;
  unsigned int __cil_tmp27;
  struct List *__cil_tmp28;
  unsigned int __cil_tmp29;
  unsigned int __cil_tmp30;
  struct Patient **mem_31;
  int *mem_32;
  int *mem_33;
  int *mem_34;
  int *mem_35;
  int *mem_36;
  struct List **mem_37;
  {
    {
      while (1) {
      while_3_continue:;
        {
          __cil_tmp4 = (void *)0;
          __cil_tmp5 = (unsigned int)__cil_tmp4;
          __cil_tmp6 = (unsigned int)list;
          if (__cil_tmp6 != __cil_tmp5) {
          } else {
            goto while_3_break;
          }
        }
        mem_31 = (struct Patient **)list;
        p = *mem_31;
        __cil_tmp7 = (unsigned int)p;
        __cil_tmp8 = __cil_tmp7 + 8;
        __cil_tmp9 = (unsigned int)p;
        __cil_tmp10 = __cil_tmp9 + 8;
        mem_32 = (int *)__cil_tmp10;
        __cil_tmp11 = *mem_32;
        mem_33 = (int *)__cil_tmp8;
        *mem_33 = __cil_tmp11 - 1;
        {
          __cil_tmp12 = (unsigned int)p;
          __cil_tmp13 = __cil_tmp12 + 8;
          mem_34 = (int *)__cil_tmp13;
          __cil_tmp14 = *mem_34;
          if (__cil_tmp14 == 0) {
            {
              __cil_tmp15 = 32 + 4;
              __cil_tmp16 = (unsigned int)village;
              __cil_tmp17 = __cil_tmp16 + __cil_tmp15;
              __cil_tmp18 = 32 + 4;
              __cil_tmp19 = (unsigned int)village;
              __cil_tmp20 = __cil_tmp19 + __cil_tmp18;
              mem_35 = (int *)__cil_tmp20;
              __cil_tmp21 = *mem_35;
              mem_36 = (int *)__cil_tmp17;
              *mem_36 = __cil_tmp21 + 1;
              __cil_tmp22 = 32 + 36;
              __cil_tmp23 = (unsigned int)village;
              __cil_tmp24 = __cil_tmp23 + __cil_tmp22;
              __cil_tmp25 = (struct List *)__cil_tmp24;
              removeList(__cil_tmp25, p);
              __cil_tmp26 = (unsigned int)village;
              __cil_tmp27 = __cil_tmp26 + 20;
              __cil_tmp28 = (struct List *)__cil_tmp27;
              addList(__cil_tmp28, p);
            }
          } else {
          }
        }
        __cil_tmp29 = (unsigned int)list;
        __cil_tmp30 = __cil_tmp29 + 8;
        mem_37 = (struct List **)__cil_tmp30;
        list = *mem_37;
      }
    while_3_break:;
    }
    return;
  }
}


x86 assembly (clang, -O0):
<check_patients_inside>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
jmp    1138 <check_patients_inside+0x18>
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
je     115f <check_patients_inside+0x3f>
jmp    1164 <check_patients_inside+0x44>
jmp    12f1 <check_patients_inside+0x1d1>
mov    -0x10(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0x98(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
mov    %rax,-0xa0(%rbp)
mov    -0xa0(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x30(%rbp),%eax
mov    %rax,-0xa8(%rbp)
mov    -0x3c(%rbp),%ecx
sub    $0x1,%ecx
mov    -0xa8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
mov    %rax,-0xb0(%rbp)
mov    -0xb0(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x48(%rbp)
cmpl   $0x0,-0x48(%rbp)
jne    12b3 <check_patients_inside+0x193>
movl   $0x24,-0x4c(%rbp)
mov    -0x8(%rbp),%rax
mov    %eax,-0x50(%rbp)
mov    -0x50(%rbp),%eax
add    -0x4c(%rbp),%eax
mov    %eax,-0x54(%rbp)
movl   $0x24,-0x58(%rbp)
mov    -0x8(%rbp),%rax
mov    %eax,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
add    -0x58(%rbp),%eax
mov    %eax,-0x60(%rbp)
mov    -0x60(%rbp),%eax
mov    %rax,-0xb8(%rbp)
mov    -0xb8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x64(%rbp)
mov    -0x54(%rbp),%eax
mov    %rax,-0xc0(%rbp)
mov    -0x64(%rbp),%ecx
add    $0x1,%ecx
mov    -0xc0(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x44,-0x68(%rbp)
mov    -0x8(%rbp),%rax
mov    %eax,-0x6c(%rbp)
mov    -0x6c(%rbp),%eax
add    -0x68(%rbp),%eax
mov    %eax,-0x70(%rbp)
mov    -0x70(%rbp),%eax
mov    %rax,-0x78(%rbp)
mov    -0x78(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <removeList@plt>
mov    -0x8(%rbp),%rax
mov    %eax,-0x7c(%rbp)
mov    -0x7c(%rbp),%eax
add    $0x14,%eax
mov    %eax,-0x80(%rbp)
mov    -0x80(%rbp),%eax
mov    %rax,-0x88(%rbp)
mov    -0x88(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <addList@plt>
jmp    12b8 <check_patients_inside+0x198>
jmp    12b8 <check_patients_inside+0x198>
mov    -0x10(%rbp),%rax
mov    %eax,-0x8c(%rbp)
mov    -0x8c(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x90(%rbp)
mov    -0x90(%rbp),%eax
mov    %rax,-0xc8(%rbp)
mov    -0xc8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x10(%rbp)
jmp    1133 <check_patients_inside+0x13>
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_patients_inside>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%rbx
test   %ebx,%ebx
je     1184 <check_patients_inside+0x64>
mov    %rdi,%r14
lea    0x24(%rdi),%r13d
lea    0x44(%rdi),%r15d
add    $0x14,%r14d
jmp    115a <check_patients_inside+0x3a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x8,%ebx
mov    (%rbx),%rbx
test   %ebx,%ebx
je     1184 <check_patients_inside+0x64>
mov    (%rbx),%r12
lea    0x8(%r12),%eax
addl   $0xffffffff,(%rax)
jne    1150 <check_patients_inside+0x30>
addl   $0x1,0x0(%r13)
mov    %r15,%rdi
mov    %r12,%rsi
call   1030 <removeList@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1040 <addList@plt>
jmp    1150 <check_patients_inside+0x30>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.Village = type { i32 }
%struct.List = type { i32 }
%struct.Patient = type { i32 }
define void @check_patients_inside(%struct.Village* %0, %struct.List* %1) {
%3 = alloca %struct.Village*
%4 = alloca %struct.List*
%5 = alloca %struct.Patient*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
%26 = alloca i32
%27 = alloca %struct.List*
%28 = alloca i32
%29 = alloca i32
%30 = alloca %struct.List*
%31 = alloca i32
%32 = alloca i32
%33 = alloca %struct.Patient**
%34 = alloca i32*
%35 = alloca i32*
%36 = alloca i32*
%37 = alloca i32*
%38 = alloca i32*
%39 = alloca %struct.List**
store %struct.Village* %0, %struct.Village** %3
store %struct.List* %1, %struct.List** %4
br label %40
40: ; preds = %2, %130
br label %41
41: ; preds = %40
store i8* null, i8** %6
%42 = load i8*, i8** %6
%43 = ptrtoint i8* %42 to i32
store i32 %43, i32* %7
%44 = load %struct.List*, %struct.List** %4
%45 = ptrtoint %struct.List* %44 to i32
store i32 %45, i32* %8
%46 = load i32, i32* %8
%47 = load i32, i32* %7
%48 = icmp ne i32 %46, %47
br i1 %48, label %49, label %50
49: ; preds = %41
br label %51
50: ; preds = %41
br label %140
51: ; preds = %49
%52 = load %struct.List*, %struct.List** %4
%53 = bitcast %struct.List* %52 to %struct.Patient**
store %struct.Patient** %53, %struct.Patient*** %33
%54 = load %struct.Patient**, %struct.Patient*** %33
%55 = load %struct.Patient*, %struct.Patient** %54
store %struct.Patient* %55, %struct.Patient** %5
%56 = load %struct.Patient*, %struct.Patient** %5
%57 = ptrtoint %struct.Patient* %56 to i32
store i32 %57, i32* %9
%58 = load i32, i32* %9
%59 = add i32 %58, 8
store i32 %59, i32* %10
%60 = load %struct.Patient*, %struct.Patient** %5
%61 = ptrtoint %struct.Patient* %60 to i32
store i32 %61, i32* %11
%62 = load i32, i32* %11
%63 = add i32 %62, 8
store i32 %63, i32* %12
%64 = load i32, i32* %12
%65 = zext i32 %64 to i64
%66 = inttoptr i64 %65 to i32*
store i32* %66, i32** %34
%67 = load i32*, i32** %34
%68 = load i32, i32* %67
store i32 %68, i32* %13
%69 = load i32, i32* %10
%70 = zext i32 %69 to i64
%71 = inttoptr i64 %70 to i32*
store i32* %71, i32** %35
%72 = load i32, i32* %13
%73 = sub nsw i32 %72, 1
%74 = load i32*, i32** %35
store i32 %73, i32* %74
%75 = load %struct.Patient*, %struct.Patient** %5
%76 = ptrtoint %struct.Patient* %75 to i32
store i32 %76, i32* %14
%77 = load i32, i32* %14
%78 = add i32 %77, 8
store i32 %78, i32* %15
%79 = load i32, i32* %15
%80 = zext i32 %79 to i64
%81 = inttoptr i64 %80 to i32*
store i32* %81, i32** %36
%82 = load i32*, i32** %36
%83 = load i32, i32* %82
store i32 %83, i32* %16
%84 = load i32, i32* %16
%85 = icmp eq i32 %84, 0
br i1 %85, label %86, label %129
86: ; preds = %51
store i32 36, i32* %17
%87 = load %struct.Village*, %struct.Village** %3
%88 = ptrtoint %struct.Village* %87 to i32
store i32 %88, i32* %18
%89 = load i32, i32* %18
%90 = load i32, i32* %17
%91 = add i32 %89, %90
store i32 %91, i32* %19
store i32 36, i32* %20
%92 = load %struct.Village*, %struct.Village** %3
%93 = ptrtoint %struct.Village* %92 to i32
store i32 %93, i32* %21
%94 = load i32, i32* %21
%95 = load i32, i32* %20
%96 = add i32 %94, %95
store i32 %96, i32* %22
%97 = load i32, i32* %22
%98 = zext i32 %97 to i64
%99 = inttoptr i64 %98 to i32*
store i32* %99, i32** %37
%100 = load i32*, i32** %37
%101 = load i32, i32* %100
store i32 %101, i32* %23
%102 = load i32, i32* %19
%103 = zext i32 %102 to i64
%104 = inttoptr i64 %103 to i32*
store i32* %104, i32** %38
%105 = load i32, i32* %23
%106 = add nsw i32 %105, 1
%107 = load i32*, i32** %38
store i32 %106, i32* %107
store i32 68, i32* %24
%108 = load %struct.Village*, %struct.Village** %3
%109 = ptrtoint %struct.Village* %108 to i32
store i32 %109, i32* %25
%110 = load i32, i32* %25
%111 = load i32, i32* %24
%112 = add i32 %110, %111
store i32 %112, i32* %26
%113 = load i32, i32* %26
%114 = zext i32 %113 to i64
%115 = inttoptr i64 %114 to %struct.List*
store %struct.List* %115, %struct.List** %27
%116 = load %struct.List*, %struct.List** %27
%117 = load %struct.Patient*, %struct.Patient** %5
%118 = call i32 @removeList(%struct.List* %116, %struct.Patient* %117)
%119 = load %struct.Village*, %struct.Village** %3
%120 = ptrtoint %struct.Village* %119 to i32
store i32 %120, i32* %28
%121 = load i32, i32* %28
%122 = add i32 %121, 20
store i32 %122, i32* %29
%123 = load i32, i32* %29
%124 = zext i32 %123 to i64
%125 = inttoptr i64 %124 to %struct.List*
store %struct.List* %125, %struct.List** %30
%126 = load %struct.List*, %struct.List** %30
%127 = load %struct.Patient*, %struct.Patient** %5
%128 = call i32 @addList(%struct.List* %126, %struct.Patient* %127)
br label %130
129: ; preds = %51
br label %130
130: ; preds = %129, %86
%131 = load %struct.List*, %struct.List** %4
%132 = ptrtoint %struct.List* %131 to i32
store i32 %132, i32* %31
%133 = load i32, i32* %31
%134 = add i32 %133, 8
store i32 %134, i32* %32
%135 = load i32, i32* %32
%136 = zext i32 %135 to i64
%137 = inttoptr i64 %136 to %struct.List**
store %struct.List** %137, %struct.List*** %39
%138 = load %struct.List**, %struct.List*** %39
%139 = load %struct.List*, %struct.List** %138
store %struct.List* %139, %struct.List** %4
br label %40
140: ; preds = %50
ret void
}

LLVM IR (-O2):
%struct.Village = type { i32 }
%struct.List = type { i32 }
%struct.Patient = type { i32 }
define void @check_patients_inside(%struct.Village* %0, %struct.List* %1) {
%3 = ptrtoint %struct.List* %1 to i64
%4 = trunc i64 %3 to i32
%5 = icmp eq i32 %4, 0
br i1 %5, label %42, label %6
6: ; preds = %2
%7 = ptrtoint %struct.Village* %0 to i64
%8 = add i64 %7, 36
%9 = and i64 %8, 4294967295
%10 = inttoptr i64 %9 to i32*
%11 = add i64 %7, 68
%12 = and i64 %11, 4294967295
%13 = inttoptr i64 %12 to %struct.List*
%14 = add i64 %7, 20
%15 = and i64 %14, 4294967295
%16 = inttoptr i64 %15 to %struct.List*
br label %17
17: ; preds = %6, %34
%18 = phi i64 [ %3, %6 ], [ %39, %34 ]
%19 = phi %struct.List* [ %1, %6 ], [ %38, %34 ]
%20 = bitcast %struct.List* %19 to %struct.Patient**
%21 = load %struct.Patient*, %struct.Patient** %20
%22 = ptrtoint %struct.Patient* %21 to i64
%23 = add i64 %22, 8
%24 = and i64 %23, 4294967295
%25 = inttoptr i64 %24 to i32*
%26 = load i32, i32* %25
%27 = add nsw i32 %26, -1
store i32 %27, i32* %25
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %34
29: ; preds = %17
%30 = load i32, i32* %10
%31 = add nsw i32 %30, 1
store i32 %31, i32* %10
%32 = tail call i32 @removeList(%struct.List* %13, %struct.Patient* %21)
%33 = tail call i32 @addList(%struct.List* %16, %struct.Patient* %21)
br label %34
34: ; preds = %17, %29
%35 = add i64 %18, 8
%36 = and i64 %35, 4294967295
%37 = inttoptr i64 %36 to %struct.List**
%38 = load %struct.List*, %struct.List** %37
%39 = ptrtoint %struct.List* %38 to i64
%40 = trunc i64 %39 to i32
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %17
42: ; preds = %34, %2
ret void
}