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

/* Variables and functions */
int /*<<< orphan*/ free(void *);
void *malloc(unsigned int);
int main(void) {
  struct str *psim;
  void *tmp;
  unsigned int __cil_tmp4;
  void *__cil_tmp5;
  unsigned int __cil_tmp6;
  struct str *__cil_tmp7;
  void *__cil_tmp8;
  void *__cil_tmp9;
  struct str **mem_10;
  struct str **mem_11;
  {
    {
      tmp = malloc(4U);
      psim = (struct str *)tmp;
    }
    {
      __cil_tmp4 = (unsigned int)psim;
      __cil_tmp5 = (void *)0;
      __cil_tmp6 = (unsigned int)__cil_tmp5;
      if (__cil_tmp6 == __cil_tmp4) {
        return (1);
      } else {
      }
    }
    {
      mem_10 = (struct str **)psim;
      *mem_10 = psim;
      mem_11 = (struct str **)psim;
      __cil_tmp7 = *mem_11;
      __cil_tmp8 = (void *)__cil_tmp7;
      free(__cil_tmp8);
      __cil_tmp9 = (void *)psim;
      free(__cil_tmp9);
    }
    return (0);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x4,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %eax,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jne    1173 <main+0x53>
movl   $0x1,-0x4(%rbp)
jmp    11c7 <main+0xa7>
jmp    1178 <main+0x58>
mov    -0x10(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x10(%rbp),%rcx
mov    -0x50(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x4,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
test   %ebx,%ebx
je     1149 <main+0x29>
mov    %rbx,(%rbx)
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
ret
mov    $0x1,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.str = type { i32 }
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.str*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca %struct.str*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca %struct.str**
%11 = alloca %struct.str**
store i32 0, i32* %1
%12 = call i8* @malloc(i32 4)
store i8* %12, i8** %3
%13 = load i8*, i8** %3
%14 = bitcast i8* %13 to %struct.str*
store %struct.str* %14, %struct.str** %2
%15 = load %struct.str*, %struct.str** %2
%16 = ptrtoint %struct.str* %15 to i32
store i32 %16, i32* %4
store i8* null, i8** %5
%17 = load i8*, i8** %5
%18 = ptrtoint i8* %17 to i32
store i32 %18, i32* %6
%19 = load i32, i32* %6
%20 = load i32, i32* %4
%21 = icmp eq i32 %19, %20
br i1 %21, label %22, label %23
22: ; preds = %0
store i32 1, i32* %1
br label %41
23: ; preds = %0
br label %24
24: ; preds = %23
%25 = load %struct.str*, %struct.str** %2
%26 = bitcast %struct.str* %25 to %struct.str**
store %struct.str** %26, %struct.str*** %10
%27 = load %struct.str*, %struct.str** %2
%28 = load %struct.str**, %struct.str*** %10
store %struct.str* %27, %struct.str** %28
%29 = load %struct.str*, %struct.str** %2
%30 = bitcast %struct.str* %29 to %struct.str**
store %struct.str** %30, %struct.str*** %11
%31 = load %struct.str**, %struct.str*** %11
%32 = load %struct.str*, %struct.str** %31
store %struct.str* %32, %struct.str** %7
%33 = load %struct.str*, %struct.str** %7
%34 = bitcast %struct.str* %33 to i8*
store i8* %34, i8** %8
%35 = load i8*, i8** %8
%36 = call i32 @free(i8* %35)
%37 = load %struct.str*, %struct.str** %2
%38 = bitcast %struct.str* %37 to i8*
store i8* %38, i8** %9
%39 = load i8*, i8** %9
%40 = call i32 @free(i8* %39)
store i32 0, i32* %1
br label %41
41: ; preds = %24, %22
%42 = load i32, i32* %1
ret i32 %42
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call dereferenceable_or_null(4) i8* @malloc(i32 4)
%2 = ptrtoint i8* %1 to i64
%3 = trunc i64 %2 to i32
%4 = icmp eq i32 %3, 0
br i1 %4, label %9, label %5
5: ; preds = %0
%6 = bitcast i8* %1 to i8**
store i8* %1, i8** %6
%7 = tail call i32 @free(i8* %1)
%8 = tail call i32 @free(i8* %1)
br label %9
9: ; preds = %0, %5
%10 = phi i32 [ 0, %5 ], [ 1, %0 ]
ret i32 %10
}