#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;
};

/* Variables and functions */
float my_rand(long);
int mymalloc(unsigned int);
struct Patient *generate_patient(struct Village *village) {
  struct Patient *patient;
  float rand___0;
  int tmp;
  void *__cil_tmp5;
  unsigned int __cil_tmp6;
  unsigned int __cil_tmp7;
  long __cil_tmp8;
  unsigned int __cil_tmp9;
  unsigned int __cil_tmp10;
  float __cil_tmp11;
  float __cil_tmp12;
  double __cil_tmp13;
  unsigned int __cil_tmp14;
  unsigned int __cil_tmp15;
  unsigned int __cil_tmp16;
  unsigned int __cil_tmp17;
  unsigned int __cil_tmp18;
  unsigned int __cil_tmp19;
  long *mem_20;
  long *mem_21;
  int *mem_22;
  int *mem_23;
  int *mem_24;
  struct Village **mem_25;
  {
    {
      __cil_tmp5 = (void *)0;
      patient = (struct Patient *)__cil_tmp5;
      __cil_tmp6 = (unsigned int)village;
      __cil_tmp7 = __cil_tmp6 + 96;
      mem_20 = (long *)__cil_tmp7;
      __cil_tmp8 = *mem_20;
      rand___0 = my_rand(__cil_tmp8);
      __cil_tmp9 = (unsigned int)village;
      __cil_tmp10 = __cil_tmp9 + 96;
      __cil_tmp11 = (float)2147483647;
      __cil_tmp12 = rand___0 * __cil_tmp11;
      mem_21 = (long *)__cil_tmp10;
      *mem_21 = (long)__cil_tmp12;
    }
    {
      __cil_tmp13 = (double)rand___0;
      if (__cil_tmp13 > 0.666) {
        {
          tmp = mymalloc(16U);
          patient = (struct Patient *)tmp;
          mem_22 = (int *)patient;
          *mem_22 = 0;
          __cil_tmp14 = (unsigned int)patient;
          __cil_tmp15 = __cil_tmp14 + 4;
          mem_23 = (int *)__cil_tmp15;
          *mem_23 = 0;
          __cil_tmp16 = (unsigned int)patient;
          __cil_tmp17 = __cil_tmp16 + 8;
          mem_24 = (int *)__cil_tmp17;
          *mem_24 = 0;
          __cil_tmp18 = (unsigned int)patient;
          __cil_tmp19 = __cil_tmp18 + 12;
          mem_25 = (struct Village **)__cil_tmp19;
          *mem_25 = village;
        }
      } else {
      }
    }
    return (patient);
  }
}


x86 assembly (clang, -O0):
<generate_patient>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    $0x60,%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <my_rand@plt>
movss  %xmm0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
add    $0x60,%eax
mov    %eax,-0x38(%rbp)
movss  0xe81(%rip),%xmm0
movss  %xmm0,-0x3c(%rbp)
movss  -0x14(%rbp),%xmm0
mulss  -0x3c(%rbp),%xmm0
movss  %xmm0,-0x40(%rbp)
mov    -0x38(%rbp),%eax
mov    %rax,-0x70(%rbp)
cvttss2si -0x40(%rbp),%rcx
mov    -0x70(%rbp),%rax
mov    %rcx,(%rax)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  0xe36(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1270 <generate_patient+0x150>
mov    $0x10,%edi
call   1040 <mymalloc@plt>
mov    %eax,-0x18(%rbp)
movslq -0x18(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x78(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rax
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x50(%rbp)
mov    -0x50(%rbp),%eax
mov    %rax,-0x80(%rbp)
mov    -0x80(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rax
mov    %eax,-0x54(%rbp)
mov    -0x54(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x58(%rbp)
mov    -0x58(%rbp),%eax
mov    %rax,-0x88(%rbp)
mov    -0x88(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rax
mov    %eax,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
add    $0xc,%eax
mov    %eax,-0x60(%rbp)
mov    -0x60(%rbp),%eax
mov    %rax,-0x90(%rbp)
mov    -0x8(%rbp),%rcx
mov    -0x90(%rbp),%rax
mov    %rcx,(%rax)
jmp    1275 <generate_patient+0x155>
jmp    1275 <generate_patient+0x155>
mov    -0x10(%rbp),%rax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate_patient>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0x60(%rdi),%ebx
mov    (%rbx),%rdi
call   1030 <my_rand@plt>
cvtss2sd %xmm0,%xmm1
mulss  0xec2(%rip),%xmm0
cvttss2si %xmm0,%rax
mov    %rax,(%rbx)
ucomisd 0xeba(%rip),%xmm1
jbe    117c <generate_patient+0x5c>
mov    $0x10,%edi
call   1040 <mymalloc@plt>
cltq
movl   $0x0,(%rax)
lea    0x4(%rax),%ecx
movl   $0x0,(%rcx)
lea    0x8(%rax),%ecx
movl   $0x0,(%rcx)
lea    0xc(%rax),%ecx
mov    %r14,(%rcx)
jmp    117e <generate_patient+0x5e>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.Patient = type { i32 }
%struct.Village = type { i32 }
define %struct.Patient* @generate_patient(%struct.Village* %0) {
%2 = alloca %struct.Village*
%3 = alloca %struct.Patient*
%4 = alloca float
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i64
%10 = alloca i32
%11 = alloca i32
%12 = alloca float
%13 = alloca float
%14 = alloca double
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i64*
%22 = alloca i64*
%23 = alloca i32*
%24 = alloca i32*
%25 = alloca i32*
%26 = alloca %struct.Village**
store %struct.Village* %0, %struct.Village** %2
store i8* null, i8** %6
%27 = load i8*, i8** %6
%28 = bitcast i8* %27 to %struct.Patient*
store %struct.Patient* %28, %struct.Patient** %3
%29 = load %struct.Village*, %struct.Village** %2
%30 = ptrtoint %struct.Village* %29 to i32
store i32 %30, i32* %7
%31 = load i32, i32* %7
%32 = add i32 %31, 96
store i32 %32, i32* %8
%33 = load i32, i32* %8
%34 = zext i32 %33 to i64
%35 = inttoptr i64 %34 to i64*
store i64* %35, i64** %21
%36 = load i64*, i64** %21
%37 = load i64, i64* %36
store i64 %37, i64* %9
%38 = load i64, i64* %9
%39 = call float @my_rand(i64 %38)
store float %39, float* %4
%40 = load %struct.Village*, %struct.Village** %2
%41 = ptrtoint %struct.Village* %40 to i32
store i32 %41, i32* %10
%42 = load i32, i32* %10
%43 = add i32 %42, 96
store i32 %43, i32* %11
store float 0x41E0000000000000, float* %12
%44 = load float, float* %4
%45 = load float, float* %12
%46 = fmul float %44, %45
store float %46, float* %13
%47 = load i32, i32* %11
%48 = zext i32 %47 to i64
%49 = inttoptr i64 %48 to i64*
store i64* %49, i64** %22
%50 = load float, float* %13
%51 = fptosi float %50 to i64
%52 = load i64*, i64** %22
store i64 %51, i64* %52
%53 = load float, float* %4
%54 = fpext float %53 to double
store double %54, double* %14
%55 = load double, double* %14
%56 = fcmp ogt double %55, 6.660000e-01
br i1 %56, label %57, label %90
57: ; preds = %1
%58 = call i32 @mymalloc(i32 16)
store i32 %58, i32* %5
%59 = load i32, i32* %5
%60 = sext i32 %59 to i64
%61 = inttoptr i64 %60 to %struct.Patient*
store %struct.Patient* %61, %struct.Patient** %3
%62 = load %struct.Patient*, %struct.Patient** %3
%63 = bitcast %struct.Patient* %62 to i32*
store i32* %63, i32** %23
%64 = load i32*, i32** %23
store i32 0, i32* %64
%65 = load %struct.Patient*, %struct.Patient** %3
%66 = ptrtoint %struct.Patient* %65 to i32
store i32 %66, i32* %15
%67 = load i32, i32* %15
%68 = add i32 %67, 4
store i32 %68, i32* %16
%69 = load i32, i32* %16
%70 = zext i32 %69 to i64
%71 = inttoptr i64 %70 to i32*
store i32* %71, i32** %24
%72 = load i32*, i32** %24
store i32 0, i32* %72
%73 = load %struct.Patient*, %struct.Patient** %3
%74 = ptrtoint %struct.Patient* %73 to i32
store i32 %74, i32* %17
%75 = load i32, i32* %17
%76 = add i32 %75, 8
store i32 %76, i32* %18
%77 = load i32, i32* %18
%78 = zext i32 %77 to i64
%79 = inttoptr i64 %78 to i32*
store i32* %79, i32** %25
%80 = load i32*, i32** %25
store i32 0, i32* %80
%81 = load %struct.Patient*, %struct.Patient** %3
%82 = ptrtoint %struct.Patient* %81 to i32
store i32 %82, i32* %19
%83 = load i32, i32* %19
%84 = add i32 %83, 12
store i32 %84, i32* %20
%85 = load i32, i32* %20
%86 = zext i32 %85 to i64
%87 = inttoptr i64 %86 to %struct.Village**
store %struct.Village** %87, %struct.Village*** %26
%88 = load %struct.Village*, %struct.Village** %2
%89 = load %struct.Village**, %struct.Village*** %26
store %struct.Village* %88, %struct.Village** %89
br label %91
90: ; preds = %1
br label %91
91: ; preds = %90, %57
%92 = load %struct.Patient*, %struct.Patient** %3
ret %struct.Patient* %92
}

LLVM IR (-O2):
%struct.Patient = type { i32 }
%struct.Village = type { i32 }
define %struct.Patient* @generate_patient(%struct.Village* %0) {
%2 = ptrtoint %struct.Village* %0 to i64
%3 = add i64 %2, 96
%4 = and i64 %3, 4294967295
%5 = inttoptr i64 %4 to i64*
%6 = load i64, i64* %5
%7 = tail call float @my_rand(i64 %6)
%8 = fmul float %7, 0x41E0000000000000
%9 = fptosi float %8 to i64
store i64 %9, i64* %5
%10 = fpext float %7 to double
%11 = fcmp ogt double %10, 6.660000e-01
br i1 %11, label %12, label %26
12: ; preds = %1
%13 = tail call i32 @mymalloc(i32 16)
%14 = sext i32 %13 to i64
%15 = inttoptr i64 %14 to %struct.Patient*
%16 = getelementptr %struct.Patient, %struct.Patient* %15, i64 0, i32 0
store i32 0, i32* %16
%17 = add i32 %13, 4
%18 = zext i32 %17 to i64
%19 = inttoptr i64 %18 to i32*
store i32 0, i32* %19
%20 = add i32 %13, 8
%21 = zext i32 %20 to i64
%22 = inttoptr i64 %21 to i32*
store i32 0, i32* %22
%23 = add i32 %13, 12
%24 = zext i32 %23 to i64
%25 = inttoptr i64 %24 to %struct.Village**
store %struct.Village* %0, %struct.Village** %25
br label %26
26: ; preds = %1, %12
%27 = phi %struct.Patient* [ %15, %12 ], [ null, %1 ]
ret %struct.Patient* %27
}