#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;
};
struct Hosp {
  int dummy;
};

/* Variables and functions */
struct List *check_patients_assess(struct Village *, struct List *);
int /*<<< orphan*/ check_patients_inside(struct Village *, struct List *);
int /*<<< orphan*/ check_patients_waiting(struct Village *, struct List *);
struct Patient *generate_patient(struct Village *);
int /*<<< orphan*/ put_in_hosp(struct Hosp *, struct Patient *);
int /*<<< orphan*/ removeList(struct List *, struct Patient *);
struct List *sim(struct Village *village) {
  int i;
  struct Patient *patient;
  struct Patient *p;
  struct List *l;
  struct List *vl;
  struct List *up;
  void *__cil_tmp8;
  unsigned int __cil_tmp9;
  unsigned int __cil_tmp10;
  void *__cil_tmp11;
  void *__cil_tmp12;
  unsigned int __cil_tmp13;
  unsigned int __cil_tmp14;
  unsigned int __cil_tmp15;
  unsigned int __cil_tmp16;
  void *__cil_tmp17;
  unsigned int __cil_tmp18;
  unsigned int __cil_tmp19;
  unsigned int __cil_tmp20;
  unsigned int __cil_tmp21;
  struct Hosp *__cil_tmp22;
  unsigned int __cil_tmp23;
  unsigned int __cil_tmp24;
  unsigned int __cil_tmp25;
  unsigned int __cil_tmp26;
  unsigned int __cil_tmp27;
  unsigned int __cil_tmp28;
  struct List *__cil_tmp29;
  unsigned int __cil_tmp30;
  unsigned int __cil_tmp31;
  unsigned int __cil_tmp32;
  unsigned int __cil_tmp33;
  struct List *__cil_tmp34;
  unsigned int __cil_tmp35;
  unsigned int __cil_tmp36;
  unsigned int __cil_tmp37;
  unsigned int __cil_tmp38;
  struct List *__cil_tmp39;
  void *__cil_tmp40;
  unsigned int __cil_tmp41;
  unsigned int __cil_tmp42;
  unsigned int __cil_tmp43;
  unsigned int __cil_tmp44;
  struct Hosp *__cil_tmp45;
  struct List **mem_46;
  struct Patient **mem_47;
  struct List **mem_48;
  struct List **mem_49;
  struct List **mem_50;
  struct List **mem_51;
  {
    {
      __cil_tmp8 = (void *)0;
      __cil_tmp9 = (unsigned int)__cil_tmp8;
      __cil_tmp10 = (unsigned int)village;
      if (__cil_tmp10 == __cil_tmp9) {
        {
          __cil_tmp11 = (void *)0;
          return ((struct List *)__cil_tmp11);
        }
      } else {
      }
    }
    i = 0;
    {
      while (1) {
      while_7_continue:;
        if (i < 4) {
        } else {
          goto while_7_break;
        }
        {
          __cil_tmp12 = (void *)0;
          __cil_tmp13 = (unsigned int)__cil_tmp12;
          __cil_tmp14 = (unsigned int)l;
          if (__cil_tmp14 != __cil_tmp13) {
            __cil_tmp15 = (unsigned int)l;
            __cil_tmp16 = __cil_tmp15 + 8;
            mem_46 = (struct List **)__cil_tmp16;
            l = *mem_46;
            {
              while (1) {
              while_8_continue:;
                {
                  __cil_tmp17 = (void *)0;
                  __cil_tmp18 = (unsigned int)__cil_tmp17;
                  __cil_tmp19 = (unsigned int)l;
                  if (__cil_tmp19 != __cil_tmp18) {
                  } else {
                    goto while_8_break;
                  }
                }
                {
                  mem_47 = (struct Patient **)l;
                  p = *mem_47;
                  __cil_tmp20 = (unsigned int)village;
                  __cil_tmp21 = __cil_tmp20 + 32;
                  __cil_tmp22 = (struct Hosp *)__cil_tmp21;
                  put_in_hosp(__cil_tmp22, p);
                  removeList(vl, p);
                  __cil_tmp23 = (unsigned int)l;
                  __cil_tmp24 = __cil_tmp23 + 8;
                  mem_48 = (struct List **)__cil_tmp24;
                  l = *mem_48;
                }
              }
            while_8_break:;
            }
          } else {
          }
        }
        i = i + 1;
      }
    while_7_break:;
    }
    {
      __cil_tmp25 = 36 + 8;
      __cil_tmp26 = 32 + __cil_tmp25;
      __cil_tmp27 = (unsigned int)village;
      __cil_tmp28 = __cil_tmp27 + __cil_tmp26;
      mem_49 = (struct List **)__cil_tmp28;
      __cil_tmp29 = *mem_49;
      check_patients_inside(village, __cil_tmp29);
      __cil_tmp30 = 24 + 8;
      __cil_tmp31 = 32 + __cil_tmp30;
      __cil_tmp32 = (unsigned int)village;
      __cil_tmp33 = __cil_tmp32 + __cil_tmp31;
      mem_50 = (struct List **)__cil_tmp33;
      __cil_tmp34 = *mem_50;
      up = check_patients_assess(village, __cil_tmp34);
      __cil_tmp35 = 12 + 8;
      __cil_tmp36 = 32 + __cil_tmp35;
      __cil_tmp37 = (unsigned int)village;
      __cil_tmp38 = __cil_tmp37 + __cil_tmp36;
      mem_51 = (struct List **)__cil_tmp38;
      __cil_tmp39 = *mem_51;
      check_patients_waiting(village, __cil_tmp39);
      patient = generate_patient(village);
    }
    {
      __cil_tmp40 = (void *)0;
      __cil_tmp41 = (unsigned int)__cil_tmp40;
      __cil_tmp42 = (unsigned int)patient;
      if (__cil_tmp42 != __cil_tmp41) {
        {
          __cil_tmp43 = (unsigned int)village;
          __cil_tmp44 = __cil_tmp43 + 32;
          __cil_tmp45 = (struct Hosp *)__cil_tmp44;
          put_in_hosp(__cil_tmp45, patient);
        }
      } else {
      }
    }
    return (up);
  }
}


x86 assembly (clang, -O0):
<sim>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x48(%rbp)
mov    -0x48(%rbp),%rax
mov    %eax,-0x4c(%rbp)
mov    -0x10(%rbp),%rax
mov    %eax,-0x50(%rbp)
mov    -0x50(%rbp),%eax
cmp    -0x4c(%rbp),%eax
jne    11a6 <sim+0x46>
movq   $0x0,-0x58(%rbp)
mov    -0x58(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    14a9 <sim+0x349>
jmp    11ab <sim+0x4b>
movl   $0x0,-0x14(%rbp)
jmp    11b7 <sim+0x57>
cmpl   $0x4,-0x14(%rbp)
jge    11c6 <sim+0x66>
jmp    11cb <sim+0x6b>
jmp    12f3 <sim+0x193>
movq   $0x0,-0x60(%rbp)
mov    -0x60(%rbp),%rax
mov    %eax,-0x64(%rbp)
mov    -0x30(%rbp),%rax
mov    %eax,-0x68(%rbp)
mov    -0x68(%rbp),%eax
cmp    -0x64(%rbp),%eax
je     12e0 <sim+0x180>
mov    -0x30(%rbp),%rax
mov    %eax,-0x6c(%rbp)
mov    -0x6c(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x70(%rbp)
mov    -0x70(%rbp),%eax
mov    %rax,-0x108(%rbp)
mov    -0x108(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
jmp    121a <sim+0xba>
movq   $0x0,-0x78(%rbp)
mov    -0x78(%rbp),%rax
mov    %eax,-0x7c(%rbp)
mov    -0x30(%rbp),%rax
mov    %eax,-0x80(%rbp)
mov    -0x80(%rbp),%eax
cmp    -0x7c(%rbp),%eax
je     1241 <sim+0xe1>
jmp    1246 <sim+0xe6>
jmp    12db <sim+0x17b>
mov    -0x30(%rbp),%rax
mov    %rax,-0x110(%rbp)
mov    -0x110(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    %eax,-0x84(%rbp)
mov    -0x84(%rbp),%eax
add    $0x20,%eax
mov    %eax,-0x88(%rbp)
mov    -0x88(%rbp),%eax
mov    %rax,-0x90(%rbp)
mov    -0x90(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1080 <put_in_hosp@plt>
mov    -0x38(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1060 <removeList@plt>
mov    -0x30(%rbp),%rax
mov    %eax,-0x94(%rbp)
mov    -0x94(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x98(%rbp)
mov    -0x98(%rbp),%eax
mov    %rax,-0x118(%rbp)
mov    -0x118(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
jmp    1215 <sim+0xb5>
jmp    12e5 <sim+0x185>
jmp    12e5 <sim+0x185>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b2 <sim+0x52>
movl   $0x2c,-0x9c(%rbp)
mov    -0x9c(%rbp),%eax
add    $0x20,%eax
mov    %eax,-0xa0(%rbp)
mov    -0x10(%rbp),%rax
mov    %eax,-0xa4(%rbp)
mov    -0xa4(%rbp),%eax
add    -0xa0(%rbp),%eax
mov    %eax,-0xa8(%rbp)
mov    -0xa8(%rbp),%eax
mov    %rax,-0x120(%rbp)
mov    -0x120(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0xb0(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0xb0(%rbp),%rsi
call   1030 <check_patients_inside@plt>
movl   $0x20,-0xb4(%rbp)
mov    -0xb4(%rbp),%eax
add    $0x20,%eax
mov    %eax,-0xb8(%rbp)
mov    -0x10(%rbp),%rax
mov    %eax,-0xbc(%rbp)
mov    -0xbc(%rbp),%eax
add    -0xb8(%rbp),%eax
mov    %eax,-0xc0(%rbp)
mov    -0xc0(%rbp),%eax
mov    %rax,-0x128(%rbp)
mov    -0x128(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0xc8(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0xc8(%rbp),%rsi
call   1050 <check_patients_assess@plt>
mov    %rax,-0x40(%rbp)
movl   $0x14,-0xcc(%rbp)
mov    -0xcc(%rbp),%eax
add    $0x20,%eax
mov    %eax,-0xd0(%rbp)
mov    -0x10(%rbp),%rax
mov    %eax,-0xd4(%rbp)
mov    -0xd4(%rbp),%eax
add    -0xd0(%rbp),%eax
mov    %eax,-0xd8(%rbp)
mov    -0xd8(%rbp),%eax
mov    %rax,-0x130(%rbp)
mov    -0x130(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0xe0(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0xe0(%rbp),%rsi
call   1040 <check_patients_waiting@plt>
mov    -0x10(%rbp),%rdi
call   1070 <generate_patient@plt>
mov    %rax,-0x20(%rbp)
movq   $0x0,-0xe8(%rbp)
mov    -0xe8(%rbp),%rax
mov    %eax,-0xec(%rbp)
mov    -0x20(%rbp),%rax
mov    %eax,-0xf0(%rbp)
mov    -0xf0(%rbp),%eax
cmp    -0xec(%rbp),%eax
je     149c <sim+0x33c>
mov    -0x10(%rbp),%rax
mov    %eax,-0xf4(%rbp)
mov    -0xf4(%rbp),%eax
add    $0x20,%eax
mov    %eax,-0xf8(%rbp)
mov    -0xf8(%rbp),%eax
mov    %rax,-0x100(%rbp)
mov    -0x100(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1080 <put_in_hosp@plt>
jmp    14a1 <sim+0x341>
jmp    14a1 <sim+0x341>
mov    -0x40(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sim>:
xor    %eax,%eax
ret

LLVM IR (-O0):
%struct.List = type { i32 }
%struct.Village = type { i32 }
%struct.Patient = type { i32 }
%struct.Hosp = type { i32 }
define %struct.List* @sim(%struct.Village* %0) {
%2 = alloca %struct.List*
%3 = alloca %struct.Village*
%4 = alloca i32
%5 = alloca %struct.Patient*
%6 = alloca %struct.Patient*
%7 = alloca %struct.List*
%8 = alloca %struct.List*
%9 = alloca %struct.List*
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i8*
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca %struct.Hosp*
%25 = alloca i32
%26 = alloca i32
%27 = alloca i32
%28 = alloca i32
%29 = alloca i32
%30 = alloca i32
%31 = alloca %struct.List*
%32 = alloca i32
%33 = alloca i32
%34 = alloca i32
%35 = alloca i32
%36 = alloca %struct.List*
%37 = alloca i32
%38 = alloca i32
%39 = alloca i32
%40 = alloca i32
%41 = alloca %struct.List*
%42 = alloca i8*
%43 = alloca i32
%44 = alloca i32
%45 = alloca i32
%46 = alloca i32
%47 = alloca %struct.Hosp*
%48 = alloca %struct.List**
%49 = alloca %struct.Patient**
%50 = alloca %struct.List**
%51 = alloca %struct.List**
%52 = alloca %struct.List**
%53 = alloca %struct.List**
store %struct.Village* %0, %struct.Village** %3
store i8* null, i8** %10
%54 = load i8*, i8** %10
%55 = ptrtoint i8* %54 to i32
store i32 %55, i32* %11
%56 = load %struct.Village*, %struct.Village** %3
%57 = ptrtoint %struct.Village* %56 to i32
store i32 %57, i32* %12
%58 = load i32, i32* %12
%59 = load i32, i32* %11
%60 = icmp eq i32 %58, %59
br i1 %60, label %61, label %64
61: ; preds = %1
store i8* null, i8** %13
%62 = load i8*, i8** %13
%63 = bitcast i8* %62 to %struct.List*
store %struct.List* %63, %struct.List** %2
br label %202
64: ; preds = %1
br label %65
65: ; preds = %64
store i32 0, i32* %4
br label %66
66: ; preds = %65, %130
br label %67
67: ; preds = %66
%68 = load i32, i32* %4
%69 = icmp slt i32 %68, 4
br i1 %69, label %70, label %71
70: ; preds = %67
br label %72
71: ; preds = %67
br label %133
72: ; preds = %70
store i8* null, i8** %14
%73 = load i8*, i8** %14
%74 = ptrtoint i8* %73 to i32
store i32 %74, i32* %15
%75 = load %struct.List*, %struct.List** %7
%76 = ptrtoint %struct.List* %75 to i32
store i32 %76, i32* %16
%77 = load i32, i32* %16
%78 = load i32, i32* %15
%79 = icmp ne i32 %77, %78
br i1 %79, label %80, label %129
80: ; preds = %72
%81 = load %struct.List*, %struct.List** %7
%82 = ptrtoint %struct.List* %81 to i32
store i32 %82, i32* %17
%83 = load i32, i32* %17
%84 = add i32 %83, 8
store i32 %84, i32* %18
%85 = load i32, i32* %18
%86 = zext i32 %85 to i64
%87 = inttoptr i64 %86 to %struct.List**
store %struct.List** %87, %struct.List*** %48
%88 = load %struct.List**, %struct.List*** %48
%89 = load %struct.List*, %struct.List** %88
store %struct.List* %89, %struct.List** %7
br label %90
90: ; preds = %80, %101
br label %91
91: ; preds = %90
store i8* null, i8** %19
%92 = load i8*, i8** %19
%93 = ptrtoint i8* %92 to i32
store i32 %93, i32* %20
%94 = load %struct.List*, %struct.List** %7
%95 = ptrtoint %struct.List* %94 to i32
store i32 %95, i32* %21
%96 = load i32, i32* %21
%97 = load i32, i32* %20
%98 = icmp ne i32 %96, %97
br i1 %98, label %99, label %100
99: ; preds = %91
br label %101
100: ; preds = %91
br label %128
101: ; preds = %99
%102 = load %struct.List*, %struct.List** %7
%103 = bitcast %struct.List* %102 to %struct.Patient**
store %struct.Patient** %103, %struct.Patient*** %49
%104 = load %struct.Patient**, %struct.Patient*** %49
%105 = load %struct.Patient*, %struct.Patient** %104
store %struct.Patient* %105, %struct.Patient** %6
%106 = load %struct.Village*, %struct.Village** %3
%107 = ptrtoint %struct.Village* %106 to i32
store i32 %107, i32* %22
%108 = load i32, i32* %22
%109 = add i32 %108, 32
store i32 %109, i32* %23
%110 = load i32, i32* %23
%111 = zext i32 %110 to i64
%112 = inttoptr i64 %111 to %struct.Hosp*
store %struct.Hosp* %112, %struct.Hosp** %24
%113 = load %struct.Hosp*, %struct.Hosp** %24
%114 = load %struct.Patient*, %struct.Patient** %6
%115 = call i32 @put_in_hosp(%struct.Hosp* %113, %struct.Patient* %114)
%116 = load %struct.List*, %struct.List** %8
%117 = load %struct.Patient*, %struct.Patient** %6
%118 = call i32 @removeList(%struct.List* %116, %struct.Patient* %117)
%119 = load %struct.List*, %struct.List** %7
%120 = ptrtoint %struct.List* %119 to i32
store i32 %120, i32* %25
%121 = load i32, i32* %25
%122 = add i32 %121, 8
store i32 %122, i32* %26
%123 = load i32, i32* %26
%124 = zext i32 %123 to i64
%125 = inttoptr i64 %124 to %struct.List**
store %struct.List** %125, %struct.List*** %50
%126 = load %struct.List**, %struct.List*** %50
%127 = load %struct.List*, %struct.List** %126
store %struct.List* %127, %struct.List** %7
br label %90
128: ; preds = %100
br label %130
129: ; preds = %72
br label %130
130: ; preds = %129, %128
%131 = load i32, i32* %4
%132 = add nsw i32 %131, 1
store i32 %132, i32* %4
br label %66
133: ; preds = %71
store i32 44, i32* %27
%134 = load i32, i32* %27
%135 = add i32 32, %134
store i32 %135, i32* %28
%136 = load %struct.Village*, %struct.Village** %3
%137 = ptrtoint %struct.Village* %136 to i32
store i32 %137, i32* %29
%138 = load i32, i32* %29
%139 = load i32, i32* %28
%140 = add i32 %138, %139
store i32 %140, i32* %30
%141 = load i32, i32* %30
%142 = zext i32 %141 to i64
%143 = inttoptr i64 %142 to %struct.List**
store %struct.List** %143, %struct.List*** %51
%144 = load %struct.List**, %struct.List*** %51
%145 = load %struct.List*, %struct.List** %144
store %struct.List* %145, %struct.List** %31
%146 = load %struct.Village*, %struct.Village** %3
%147 = load %struct.List*, %struct.List** %31
%148 = call i32 @check_patients_inside(%struct.Village* %146, %struct.List* %147)
store i32 32, i32* %32
%149 = load i32, i32* %32
%150 = add i32 32, %149
store i32 %150, i32* %33
%151 = load %struct.Village*, %struct.Village** %3
%152 = ptrtoint %struct.Village* %151 to i32
store i32 %152, i32* %34
%153 = load i32, i32* %34
%154 = load i32, i32* %33
%155 = add i32 %153, %154
store i32 %155, i32* %35
%156 = load i32, i32* %35
%157 = zext i32 %156 to i64
%158 = inttoptr i64 %157 to %struct.List**
store %struct.List** %158, %struct.List*** %52
%159 = load %struct.List**, %struct.List*** %52
%160 = load %struct.List*, %struct.List** %159
store %struct.List* %160, %struct.List** %36
%161 = load %struct.Village*, %struct.Village** %3
%162 = load %struct.List*, %struct.List** %36
%163 = call %struct.List* @check_patients_assess(%struct.Village* %161, %struct.List* %162)
store %struct.List* %163, %struct.List** %9
store i32 20, i32* %37
%164 = load i32, i32* %37
%165 = add i32 32, %164
store i32 %165, i32* %38
%166 = load %struct.Village*, %struct.Village** %3
%167 = ptrtoint %struct.Village* %166 to i32
store i32 %167, i32* %39
%168 = load i32, i32* %39
%169 = load i32, i32* %38
%170 = add i32 %168, %169
store i32 %170, i32* %40
%171 = load i32, i32* %40
%172 = zext i32 %171 to i64
%173 = inttoptr i64 %172 to %struct.List**
store %struct.List** %173, %struct.List*** %53
%174 = load %struct.List**, %struct.List*** %53
%175 = load %struct.List*, %struct.List** %174
store %struct.List* %175, %struct.List** %41
%176 = load %struct.Village*, %struct.Village** %3
%177 = load %struct.List*, %struct.List** %41
%178 = call i32 @check_patients_waiting(%struct.Village* %176, %struct.List* %177)
%179 = load %struct.Village*, %struct.Village** %3
%180 = call %struct.Patient* @generate_patient(%struct.Village* %179)
store %struct.Patient* %180, %struct.Patient** %5
store i8* null, i8** %42
%181 = load i8*, i8** %42
%182 = ptrtoint i8* %181 to i32
store i32 %182, i32* %43
%183 = load %struct.Patient*, %struct.Patient** %5
%184 = ptrtoint %struct.Patient* %183 to i32
store i32 %184, i32* %44
%185 = load i32, i32* %44
%186 = load i32, i32* %43
%187 = icmp ne i32 %185, %186
br i1 %187, label %188, label %199
188: ; preds = %133
%189 = load %struct.Village*, %struct.Village** %3
%190 = ptrtoint %struct.Village* %189 to i32
store i32 %190, i32* %45
%191 = load i32, i32* %45
%192 = add i32 %191, 32
store i32 %192, i32* %46
%193 = load i32, i32* %46
%194 = zext i32 %193 to i64
%195 = inttoptr i64 %194 to %struct.Hosp*
store %struct.Hosp* %195, %struct.Hosp** %47
%196 = load %struct.Hosp*, %struct.Hosp** %47
%197 = load %struct.Patient*, %struct.Patient** %5
%198 = call i32 @put_in_hosp(%struct.Hosp* %196, %struct.Patient* %197)
br label %200
199: ; preds = %133
br label %200
200: ; preds = %199, %188
%201 = load %struct.List*, %struct.List** %9
store %struct.List* %201, %struct.List** %2
br label %202
202: ; preds = %200, %61
%203 = load %struct.List*, %struct.List** %2
ret %struct.List* %203
}

LLVM IR (-O2):
%struct.List = type { i32 }
%struct.Village = type { i32 }
define %struct.List* @sim(%struct.Village* %0) {
%2 = ptrtoint %struct.Village* %0 to i64
%3 = trunc i64 %2 to i32
%4 = icmp eq i32 %3, 0
ret %struct.List* null
}